refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-29 22:59:22 +08:00
parent 6bb7af46a0
commit 33c24baecb
52 changed files with 232 additions and 273 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
// import { useState, useEffect } from "react";
import { ChangeEvent } from "react";
import StyledContainer from "./StyledContainer";
import Input from "../../../common/component/styled/Input";
import Textarea from "../../../common/component/styled/Textarea";
@@ -14,7 +14,7 @@ export default function ConfigFirebase() {
// const { token_url, description } = values;
updateConfig(values);
};
const handleChange = (evt) => {
const handleChange = (evt: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const newValue = evt.target.value;
const { type } = evt.target.dataset;
setValues((prev) => {
-8
View File
@@ -54,14 +54,6 @@ export default function Logins() {
updateGithubAuthConfig({ [key]: evt.target.value });
}
};
// const handleChange = (evt) => {
// const newValue = evt.target.value;
// const { type } = evt.target.dataset;
// const items = newValue ? newValue.split("\n") : [];
// setValues((prev) => {
// return { ...prev, [type]: items };
// });
// };
const handleToggle = (val) => {
setValues((prev) => {
return { ...prev, ...val };
+7 -6
View File
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import { useState, useEffect, ChangeEvent } from "react";
import styled from "styled-components";
const StyledTest = styled.div`
display: flex;
@@ -27,14 +27,15 @@ export default function ConfigSMTP() {
// const { token_url, description } = values;
updateConfig({ ...values, port: Number((values as SMTPConfig)?.port ?? 0) });
};
const handleChange = (evt) => {
const handleChange = (evt: ChangeEvent<HTMLInputElement>) => {
const newValue = evt.target.value;
const { type } = evt.target.dataset;
const { type = "" } = evt.target.dataset;
setValues((prev) => {
if (!prev) return prev;
return { ...prev, [type]: newValue };
});
};
const handleTestEmailChange = (evt) => {
const handleTestEmailChange = (evt: ChangeEvent<HTMLInputElement>) => {
const newValue = evt.target.value;
setTestEmail(newValue);
};
@@ -55,8 +56,8 @@ export default function ConfigSMTP() {
}
}, [isSuccess, isError]);
// if (!values) return null;
const { host, port, from, username, password, enabled = false } = values ?? {};
if (!values) return null;
const { host, port, from, username, password, enabled = false } = values as SMTPConfig;
console.log("values", values);
return (
<StyledContainer>