Skip to content

Commit

Permalink
fix(web): fix only display either phone or email login (#1888)
Browse files Browse the repository at this point in the history
* fix(web): fix only display either phone or email login

* delete comment
  • Loading branch information
newfish-cmyk committed Mar 4, 2024
1 parent a9bc541 commit 896386d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
6 changes: 3 additions & 3 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
"ToRegister": "去注册",
"ToLogin": "去登录",
"PasswordLogin": "密码登录",
"PhoneLogin": "验证码登录",
"PhoneLogin": "手机号登录",
"Account": "用户名",
"AccountPlaceholder": "请输入用户名",
"Password": "密码",
Expand All @@ -422,7 +422,7 @@
"PleaseBindUser": "请绑定对应用户",
"Email": "邮箱",
"EmailPlaceholder": "请输入你的邮箱",
"EmailLogin": "验证码登录"
"EmailLogin": "邮箱登录"
},
"Time": "时间",
"CreateTime": "创建时间",
Expand Down Expand Up @@ -758,4 +758,4 @@
"Title": "Laf 新版本已经准备好了!",
"Description": "点击立即更新"
}
}
}
6 changes: 3 additions & 3 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
"ToRegister": "去注册",
"ToLogin": "去登录",
"PasswordLogin": "密码登录",
"PhoneLogin": "验证码登录",
"PhoneLogin": "手机号登录",
"Account": "用户名",
"AccountPlaceholder": "请输入用户名",
"Password": "密码",
Expand All @@ -422,7 +422,7 @@
"PleaseBindUser": "请绑定对应用户",
"Email": "邮箱",
"EmailPlaceholder": "请输入你的邮箱",
"EmailLogin": "验证码登录"
"EmailLogin": "邮箱登录"
},
"Time": "时间",
"CreateTime": "创建时间",
Expand Down Expand Up @@ -758,4 +758,4 @@
"Title": "Laf 新版本已经准备好了!",
"Description": "点击立即更新"
}
}
}
12 changes: 4 additions & 8 deletions web/src/pages/auth/signin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import LoginByPhonePanel from "./mods/LoginByPhonePanel";
import useAuthStore from "@/pages/auth/store";
import useGlobalStore from "@/pages/globalStore";

type providersTypes =
export type providersTypes =
| PROVIDER_NAME.EMAIL
| PROVIDER_NAME.GITHUB
| PROVIDER_NAME.PHONE
Expand Down Expand Up @@ -78,13 +78,9 @@ export default function SignIn() {
) : currentProvider === PROVIDER_NAME.PASSWORD ? (
<LoginByPasswordPanel
showSignupBtn={!!passwordProvider?.register}
showPhoneSigninBtn={defaultProvider.name === PROVIDER_NAME.PHONE}
showEmailSigninBtn={defaultProvider.name === PROVIDER_NAME.EMAIL}
switchLoginType={() =>
defaultProvider.name === PROVIDER_NAME.PHONE
? setCurrentProvider(PROVIDER_NAME.PHONE)
: setCurrentProvider(PROVIDER_NAME.EMAIL)
}
showPhoneSigninBtn={!!phoneProvider}
showEmailSigninBtn={!!emailProvider}
setCurrentProvider={setCurrentProvider}
isDarkMode={darkMode}
/>
) : null}
Expand Down
38 changes: 31 additions & 7 deletions web/src/pages/auth/signin/mods/LoginByPasswordPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import {
import { t } from "i18next";

import { OutlineViewOffIcon, OutlineViewOnIcon } from "@/components/CommonIcon";
import { Routes } from "@/constants";
import { PROVIDER_NAME, Routes } from "@/constants";

import { providersTypes } from "../..";

import { useGroupMemberAddMutation } from "@/pages/app/collaboration/service";
import {
Expand All @@ -27,13 +29,13 @@ type FormData = {
};

export default function LoginByPasswordPanel({
switchLoginType,
setCurrentProvider,
showSignupBtn,
showPhoneSigninBtn,
showEmailSigninBtn,
isDarkMode,
}: {
switchLoginType: () => void;
setCurrentProvider: (provider: providersTypes) => void;
showSignupBtn: boolean;
showPhoneSigninBtn: boolean;
showEmailSigninBtn: boolean;
Expand Down Expand Up @@ -159,12 +161,34 @@ export default function LoginByPasswordPanel({
<div></div>
)}
<div className="flex">
{(showPhoneSigninBtn || showEmailSigninBtn) && (
<Button className="!px-2 text-lg" variant={"text"} onClick={switchLoginType}>
{showPhoneSigninBtn ? t("AuthPanel.PhoneLogin") : t("AuthPanel.EmailLogin")}
{showPhoneSigninBtn && (
<Button
className="!px-2 text-lg"
variant={"text"}
onClick={() => {
setCurrentProvider(PROVIDER_NAME.PHONE);
}}
>
{t("AuthPanel.PhoneLogin")}
</Button>
)}
{showSignupBtn && showPhoneSigninBtn && (
<div className="mx-3 flex items-center">
<span className="h-3 w-[1px] bg-primary-500 text-primary-500"></span>
</div>
)}
{showEmailSigninBtn && (
<Button
className="!px-2 text-lg"
variant={"text"}
onClick={() => {
setCurrentProvider(PROVIDER_NAME.EMAIL);
}}
>
{t("AuthPanel.EmailLogin")}
</Button>
)}
{showSignupBtn && (showPhoneSigninBtn || showEmailSigninBtn) && (
{showSignupBtn && showEmailSigninBtn && (
<div className="mx-3 flex items-center">
<span className="h-3 w-[1px] bg-primary-500 text-primary-500"></span>
</div>
Expand Down

0 comments on commit 896386d

Please sign in to comment.