Skip to content

Commit 4c7cfee

Browse files
authored
Merge pull request #452 from besscroft/fix/signup-success-i18n
fix: correct auth success i18n toast messages
2 parents 933f050 + 006fa06 commit 4c7cfee

5 files changed

Lines changed: 40 additions & 16 deletions

File tree

components/sign-up/sign-up-from.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const SignUpForm = ({
1717
...props
1818
}: React.ComponentPropsWithoutRef<'form'>) => {
1919
const router = useRouter()
20-
const t = useTranslations()
20+
const t = useTranslations('Login')
2121

2222
const [isLoading, setIsLoading] = useState<boolean>(false)
2323

@@ -60,7 +60,7 @@ export const SignUpForm = ({
6060
try {
6161
const parsedCredentials = zHandle()
6262
if (!parsedCredentials.success) {
63-
toast.error(t('Login.invalidCredentials', { defaultValue: 'Please check your email and password format' }))
63+
toast.error(t('invalidCredentials'))
6464
return
6565
}
6666

@@ -76,10 +76,10 @@ export const SignUpForm = ({
7676
//show loading
7777
console.log(ctx)
7878
},
79-
onSuccess: (ctx) => {
80-
toast.success(t('Login.signUpSuccess', { defaultValue: 'Sign up successful' }))
79+
onSuccess: () => {
80+
toast.success(t('signUpSuccess'))
8181
setTimeout(() => {
82-
location.replace('/admin')
82+
router.replace('/admin')
8383
}, 1000)
8484
},
8585
onError: (ctx) => {
@@ -89,7 +89,7 @@ export const SignUpForm = ({
8989

9090
} catch (e) {
9191
console.error(e)
92-
toast.error(t('Login.error', { defaultValue: 'An error occurred, please try again' }))
92+
toast.error(t('error'))
9393
} finally {
9494
setIsLoading(false)
9595
}
@@ -103,7 +103,7 @@ export const SignUpForm = ({
103103
return (
104104
<form onSubmit={handleSubmit} className={cn('space-y-4', className)} {...props}>
105105
<div className="space-y-2">
106-
<Label htmlFor="email" className="select-none">{t('Login.email')}</Label>
106+
<Label htmlFor="email" className="select-none">{t('email')}</Label>
107107
<Input
108108
id="email"
109109
type="email"
@@ -116,7 +116,7 @@ export const SignUpForm = ({
116116
/>
117117
</div>
118118
<div className="space-y-2">
119-
<Label htmlFor="password" className="select-none">{t('Login.password')}</Label>
119+
<Label htmlFor="password" className="select-none">{t('password')}</Label>
120120
<Input
121121
id="password"
122122
type="password"
@@ -132,17 +132,17 @@ export const SignUpForm = ({
132132
type="submit"
133133
className="w-full h-12 select-none cursor-pointer"
134134
disabled={email.length === 0 || password.length < 8}
135-
aria-label={t('Login.signUp')}
135+
aria-label={t('signUp')}
136136
>
137-
{isLoading && <ReloadIcon className="mr-2 h-4 w-4 animate-spin"/>}{t('Login.signUp')}
137+
{isLoading && <ReloadIcon className="mr-2 h-4 w-4 animate-spin"/>}{t('signUp')}
138138
</Button>
139139
<Button
140140
variant="ghost"
141141
className="w-full select-none cursor-pointer"
142142
onClick={() => router.push('/')}
143-
aria-label={t('Login.goHome')}
143+
aria-label={t('goHome')}
144144
>
145-
{t('Login.goHome')}
145+
{t('goHome')}
146146
</Button>
147147
</form>
148148
)

messages/en.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
"signInDescription": "Sign in to continue",
2626
"signUpDescription": "Create your account to get started",
2727
"passkeyLogin": "Sign in with Passkey",
28-
"or": "or"
28+
"or": "or",
29+
"success": "Login successful",
30+
"signUpSuccess": "Sign up successful",
31+
"twoFactorFailed": "Two-factor verification failed",
32+
"invalidCredentials": "Please check your email and password format",
33+
"wrongCredentials": "Incorrect email or password",
34+
"error": "An error occurred, please try again"
2935
},
3036
"Link": {
3137
"home": "Home",

messages/ja.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
"signInDescription": "続行するにはログインしてください",
2626
"signUpDescription": "アカウントを作成して始めましょう",
2727
"passkeyLogin": "Passkey でログイン",
28-
"or": "または"
28+
"or": "または",
29+
"success": "ログインに成功しました",
30+
"signUpSuccess": "登録に成功しました",
31+
"twoFactorFailed": "二要素認証に失敗しました",
32+
"invalidCredentials": "メールアドレスとパスワードの形式を確認してください",
33+
"wrongCredentials": "メールアドレスまたはパスワードが正しくありません",
34+
"error": "エラーが発生しました。もう一度お試しください"
2935
},
3036
"Link": {
3137
"home": "ホーム",

messages/zh-TW.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
"signInDescription": "登入後繼續",
2626
"signUpDescription": "建立你的帳戶以開始使用",
2727
"passkeyLogin": "使用 Passkey 登入",
28-
"or": "或者"
28+
"or": "或者",
29+
"success": "登入成功",
30+
"signUpSuccess": "註冊成功",
31+
"twoFactorFailed": "雙重驗證失敗",
32+
"invalidCredentials": "請檢查電子郵件和密碼格式",
33+
"wrongCredentials": "電子郵件或密碼錯誤",
34+
"error": "發生錯誤,請重試"
2935
},
3036
"Link": {
3137
"home": "首頁",

messages/zh.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
"signInDescription": "登录后继续",
2626
"signUpDescription": "创建你的账户以开始使用",
2727
"passkeyLogin": "使用 Passkey 登录",
28-
"or": "或者"
28+
"or": "或者",
29+
"success": "登录成功",
30+
"signUpSuccess": "注册成功",
31+
"twoFactorFailed": "双重验证失败",
32+
"invalidCredentials": "请检查邮箱和密码格式",
33+
"wrongCredentials": "邮箱或密码错误",
34+
"error": "发生错误,请重试"
2935
},
3036
"Link": {
3137
"home": "首页",

0 commit comments

Comments
 (0)