feat: add back btn in login
This commit is contained in:
@@ -12,10 +12,15 @@ import Divider from "@/components/Divider";
|
|||||||
import Button from "@/components/styled/Button";
|
import Button from "@/components/styled/Button";
|
||||||
import Input from "@/components/styled/Input";
|
import Input from "@/components/styled/Input";
|
||||||
import StyledLabel from "@/components/styled/Label";
|
import StyledLabel from "@/components/styled/Label";
|
||||||
|
import IconBack from "@/assets/icons/arrow.left.svg";
|
||||||
import MagicLinkLogin from "./MagicLinkLogin";
|
import MagicLinkLogin from "./MagicLinkLogin";
|
||||||
import SignUpLink from "./SignUpLink";
|
import SignUpLink from "./SignUpLink";
|
||||||
import SocialLoginButtons from "./SocialLoginButtons";
|
import SocialLoginButtons from "./SocialLoginButtons";
|
||||||
|
|
||||||
|
const defaultInput = {
|
||||||
|
email: "",
|
||||||
|
password: ""
|
||||||
|
};
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const serverName = useAppSelector((store) => store.server.name);
|
const serverName = useAppSelector((store) => store.server.name);
|
||||||
const { t } = useTranslation("auth");
|
const { t } = useTranslation("auth");
|
||||||
@@ -24,10 +29,7 @@ export default function LoginPage() {
|
|||||||
const [login, { isSuccess, isLoading, error }] = useLoginMutation();
|
const [login, { isSuccess, isLoading, error }] = useLoginMutation();
|
||||||
const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery();
|
const { data: loginConfig, isSuccess: loginConfigSuccess } = useGetLoginConfigQuery();
|
||||||
const [emailInputted, setEmailInputted] = useState(false);
|
const [emailInputted, setEmailInputted] = useState(false);
|
||||||
const [input, setInput] = useState({
|
const [input, setInput] = useState(defaultInput);
|
||||||
email: "",
|
|
||||||
password: ""
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const query = new URLSearchParams(location.search);
|
const query = new URLSearchParams(location.search);
|
||||||
@@ -112,6 +114,10 @@ export default function LoginPage() {
|
|||||||
return { ...prev };
|
return { ...prev };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const handleBack = () => {
|
||||||
|
setInput(defaultInput);
|
||||||
|
setEmailInputted(false);
|
||||||
|
};
|
||||||
const { email, password } = input;
|
const { email, password } = input;
|
||||||
if (!loginConfigSuccess) return null;
|
if (!loginConfigSuccess) return null;
|
||||||
|
|
||||||
@@ -123,7 +129,14 @@ export default function LoginPage() {
|
|||||||
if (loadingSMTPStatus) return null;
|
if (loadingSMTPStatus) return null;
|
||||||
return (
|
return (
|
||||||
<div className="flex-center h-screen dark:bg-gray-700">
|
<div className="flex-center h-screen dark:bg-gray-700">
|
||||||
<div className="py-8 px-10 shadow-md rounded-xl">
|
<div className="relative py-8 px-10 shadow-md rounded-xl">
|
||||||
|
{emailInputted && (
|
||||||
|
<IconBack
|
||||||
|
role="button"
|
||||||
|
className="absolute left-5 top-8 w-10 h-10 stroke-gray-500"
|
||||||
|
onClick={handleBack}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="flex-center flex-col pb-6">
|
<div className="flex-center flex-col pb-6">
|
||||||
<img
|
<img
|
||||||
src={`${BASE_URL}/resource/organization/logo`}
|
src={`${BASE_URL}/resource/organization/logo`}
|
||||||
@@ -178,7 +191,7 @@ export default function LoginPage() {
|
|||||||
{emailInputted && <MagicLinkLogin email={input.email} />}
|
{emailInputted && <MagicLinkLogin email={input.email} />}
|
||||||
{!hideSocials && <SocialLoginButtons />}
|
{!hideSocials && <SocialLoginButtons />}
|
||||||
</div>
|
</div>
|
||||||
{whoCanSignUp === "EveryOne" && !hideSocials && <SignUpLink />}
|
{whoCanSignUp === "EveryOne" && <SignUpLink />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user