diff --git a/.vscode/settings.json b/.vscode/settings.json index 8ec9748c0..0365c8bae 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,5 +25,6 @@ "emmet.triggerExpansionOnTab": true, "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - } + }, + "cSpell.words": ["btns"] } diff --git a/src/common/component/Manifest/index.js b/src/common/component/Manifest/index.js index e4b188b02..c38577d99 100644 --- a/src/common/component/Manifest/index.js +++ b/src/common/component/Manifest/index.js @@ -5,7 +5,7 @@ import Prompt from "./Prompt"; import usePrompt from "./usePrompt"; export default function Manifest() { - const { setCanneled, prompted } = usePrompt(); + const { setCanceled: setCanceled, prompted } = usePrompt(); const deferredPromptRef = useRef(null); const [popup, setPopup] = useState(false); // const { data, isSuccess } = useGetServerQuery(); @@ -59,7 +59,7 @@ export default function Manifest() { deferredPromptRef.current = null; }; const handleClose = async () => { - setCanneled(); + setCanceled(); setPopup(false); }; if (!popup || prompted) return null; diff --git a/src/common/component/Manifest/usePrompt.js b/src/common/component/Manifest/usePrompt.js index 90ec78e1d..a2a6fbd07 100644 --- a/src/common/component/Manifest/usePrompt.js +++ b/src/common/component/Manifest/usePrompt.js @@ -9,7 +9,7 @@ export default function usePrompt() { }; return { - setCanneled: setPrompt, + setCanceled: setPrompt, prompted: !!localStorage.getItem(KEY_PWA_INSTALLED), resetPrompt }; diff --git a/src/routes/reg/Register.js b/src/routes/reg/Register.js index e8285d9b2..eccc297f2 100644 --- a/src/routes/reg/Register.js +++ b/src/routes/reg/Register.js @@ -1,12 +1,17 @@ import { useState, useEffect } from "react"; -// import { useDispatch } from "react-redux"; +import toast from "react-hot-toast"; import { useNavigate } from "react-router-dom"; -// import toast from "react-hot-toast"; +import BASE_URL from "../../app/config"; import Input from "../../common/component/styled/Input"; import Button from "../../common/component/styled/Button"; import { useSendRegMagicLinkMutation } from "../../app/services/auth"; import EmailNextTip from "./EmailNextStepTip"; -// import { useSendLoginMagicLinkMutation } from "../../app/services/auth"; +import SignInLink from "./SignInLink"; +import { useGetLoginConfigQuery } from "../../app/services/server"; +import useGithubAuthConfig from "../../common/hook/useGithubAuthConfig"; +import useGoogleAuthConfig from "../../common/hook/useGoogleAuthConfig"; +import GoogleLoginButton from "../../common/component/GoogleLoginButton"; +import GithubLoginButton from "../../common/component/GithubLoginButton"; export default function Reg() { const [sendRegMagicLink, { isLoading, data, isSuccess }] = useSendRegMagicLinkMutation(); @@ -45,7 +50,12 @@ export default function Reg() { }); // sendMagicLink(email); }; - + const handleCompare = () => { + const { password, confirmPassword } = input; + if (password !== confirmPassword) { + toast.error("Not Same Password!"); + } + }; const handleInput = (evt) => { const { type } = evt.target.dataset; const { value } = evt.target; @@ -55,32 +65,65 @@ export default function Reg() { return { ...prev }; }); }; - const { email, password } = input; + const { clientId } = useGoogleAuthConfig(); + const { config: githubAuthConfig } = useGithubAuthConfig(); + const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery(); + if (!loginConfigSuccess) return null; + const { + github: enableGithubLogin, + google: enableGoogleLogin, + who_can_sign_up: whoCanSignUp + } = loginConfig; + const googleLogin = enableGoogleLogin && clientId; + // 没有开放注册 + if (whoCanSignUp !== "EveryOne") return `Open Register is Closed!`; + const { email, password, confirmPassword } = input; if (data?.mail_is_sent) return ; return ( -
- - - -
+ <> +
+ logo +

Sign Up to Rustchat

+ Please enter your details. +
+ +
+ + + + +
+
+ {googleLogin && } + {enableGithubLogin && } + + ); } diff --git a/src/routes/reg/index.js b/src/routes/reg/index.js index 2e80dcfe6..e7f7bf373 100644 --- a/src/routes/reg/index.js +++ b/src/routes/reg/index.js @@ -1,49 +1,15 @@ import { Outlet } from "react-router-dom"; -import { useMatch } from "react-router-dom"; -import BASE_URL from "../../app/config"; -import SignInLink from "./SignInLink"; -import { useGetLoginConfigQuery } from "../../app/services/server"; -import useGithubAuthConfig from "../../common/hook/useGithubAuthConfig"; -import useGoogleAuthConfig from "../../common/hook/useGoogleAuthConfig"; -import GoogleLoginButton from "../../common/component/GoogleLoginButton"; -import GithubLoginButton from "../../common/component/GithubLoginButton"; +// import { useMatch } from "react-router-dom"; + import StyledWrapper from "./styled"; -export default function Reg() { - const isRegHome = useMatch(`/register`); - const { clientId } = useGoogleAuthConfig(); - const { config: githubAuthConfig } = useGithubAuthConfig(); - const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery(); - if (!loginConfigSuccess) return null; - const { - github: enableGithubLogin, - google: enableGoogleLogin, - who_can_sign_up: whoCanSignUp - } = loginConfig; - const googleLogin = enableGoogleLogin && clientId; - // 没有开放注册 - if (whoCanSignUp !== "EveryOne") return `Open Register is Closed!`; +export default function RegContainer() { + // const isRegHome = useMatch(`/register`); + return (
- {isRegHome && ( - <> -
- logo -

Sign Up to Rustchat

- Please enter your details. -
- - )} - {isRegHome && ( - <> -
- {googleLogin && } - {enableGithubLogin && } - - - )}
);