Skip to content

Commit 8b1853c

Browse files
committed
refactor(app-signin): use constant for email field name
1 parent 1975cd6 commit 8b1853c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/app/(uc)/signin/page.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import VerifyCodeLogin from './VerifyCodeLogin';
3636
export function NavButtonStyle() {
3737
return 'h-12 relative rounded-t-xl text-gray-100 px-6 [&.active]:bg-gray-1400 [&.active]:!text-gray';
3838
}
39+
const EMAIL_FIELD_NAME = 'Email'
3940
const SigninAfterStyle = 'after:content-[\'\'] after:absolute after:right-[-12px] after:bottom-0 after:w-3 after:h-3 after:bg-signin-gradient';
4041

4142
export default function Login() {
@@ -60,9 +61,9 @@ export default function Login() {
6061
setLoginType(prevLoginType => {
6162
const loginType = prevLoginType === 'verifyCode' ? 'password' : 'verifyCode';
6263
clearErrors();
63-
const email = getValues('Email')
64+
const email = getValues(EMAIL_FIELD_NAME)
6465
reset();
65-
setValue('Email', email)
66+
setValue(EMAIL_FIELD_NAME, email)
6667
return loginType;
6768
});
6869
};
@@ -103,7 +104,7 @@ export default function Login() {
103104
}
104105
};
105106

106-
const emailField = register('Email', { required: true, pattern: /^\S+@\S+$/i });
107+
const emailField = register(EMAIL_FIELD_NAME, { required: true, pattern: /^\S+@\S+$/i });
107108
emailField.onChange = wrapOnChange(emailField.onChange);
108109

109110
const pwdField = register('Password', {

0 commit comments

Comments
 (0)