refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-25 23:14:27 +08:00
parent 17984a385e
commit 396a296c0b
21 changed files with 73 additions and 95 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ import Tooltip from "./Tooltip";
import IssuerList from "./IssuerList";
import useGoogleAuthConfig from "../../../common/hook/useGoogleAuthConfig";
import useGithubAuthConfig from "../../../common/hook/useGithubAuthConfig";
import { LoginConfig } from "../../../types/server";
export default function Logins() {
const {
@@ -25,7 +26,7 @@ export default function Logins() {
} = useGithubAuthConfig();
const { values, updateConfig, setValues, reset, changed } = useConfig("login");
const handleUpdate = async () => {
const { google } = values;
const { google } = values as LoginConfig;
if (changed) {
updateConfig(values);
}
+2 -1
View File
@@ -16,6 +16,7 @@ import Toggle from "../../../common/component/styled/Toggle";
import Label from "../../../common/component/styled/Label";
import SaveTip from "../../../common/component/SaveTip";
import toast from "react-hot-toast";
import { SMTPConfig } from "../../../types/server";
export default function ConfigSMTP() {
const [testEmail, setTestEmail] = useState("");
@@ -24,7 +25,7 @@ export default function ConfigSMTP() {
const handleUpdate = () => {
// const { token_url, description } = values;
updateConfig({ ...values, port: Number(values.port ?? 0) });
updateConfig({ ...values, port: Number((values as SMTPConfig)?.port ?? 0) });
};
const handleChange = (evt) => {
const newValue = evt.target.value;