NCFRONT-81 #5

Merged
frontdev merged 4 commits from NCFRONT-81 into main 2026-01-29 22:34:35 +08:00
2 changed files with 16 additions and 15 deletions
Showing only changes of commit fc81d471ff - Show all commits
+6 -5
View File
@@ -146,9 +146,9 @@ export async function registration(
state: FormState | undefined, state: FormState | undefined,
formData: FormData, formData: FormData,
): Promise<FormState> { ): Promise<FormState> {
const registrationType = formData.get('accoutType') as string || ''; const accountType = formData.get('accountType') as string || '';
console.log(registrationType); console.log(accountType);
const fullName = formData.get('fullName') as string || ''; const fullName = formData.get('fullName') as string || '';
const email = formData.get('email') as string || ''; const email = formData.get('email') as string || '';
@@ -167,7 +167,7 @@ export async function registration(
password, password,
confirm_password, confirm_password,
agree, agree,
...(registrationType === 'btb' && { companyName }) ...(accountType === 'btb' && { companyName })
}; };
const validatedFields = SignupFormSchema.safeParse(dataToValidate); const validatedFields = SignupFormSchema.safeParse(dataToValidate);
@@ -193,7 +193,7 @@ export async function registration(
confirm_password, confirm_password,
phone, phone,
agree, agree,
...(registrationType === 'btb' && { companyName }) ...(accountType === 'btb' && { companyName })
}, },
error: errors error: errors
}; };
@@ -211,7 +211,8 @@ export async function registration(
email, email,
phone: phone, phone: phone,
password, password,
...(registrationType === 'btb' && { companyName: companyName }) accountType,
...(accountType === 'btb' && { companyName: companyName })
} }
}), }),
headers: { headers: {
+10 -10
View File
@@ -27,7 +27,7 @@ export default function RegisterForm() {
const [formState, setFormState] = useState<FormState | undefined>(undefined); const [formState, setFormState] = useState<FormState | undefined>(undefined);
const [showMailConfirmWindow, setShowMailConfirmWindow] = useState(false); const [showMailConfirmWindow, setShowMailConfirmWindow] = useState(false);
const passwordRef = useRef<HTMLInputElement>(null); const passwordRef = useRef<HTMLInputElement>(null);
const [accountType, setAccountType] = useState<'btc' | 'btb'>('btc'); const [accountType, setAccountType] = useState<'b2c' | 'b2b'>('b2c');
useEffect(() => { useEffect(() => {
setFormState(state); setFormState(state);
@@ -114,10 +114,10 @@ export default function RegisterForm() {
} }
} }
function switchRegistrationTypeHandler(e: React.MouseEvent<HTMLButtonElement>, type: 'btc' | 'btb') { function switchRegistrationTypeHandler(e: React.MouseEvent<HTMLButtonElement>, type: 'b2c' | 'b2b') {
e.preventDefault(); e.preventDefault();
setAccountType(type); setAccountType(type);
if (formState && type === 'btc') { if (formState && type === 'b2c') {
setFormState({ setFormState({
...formState, ...formState,
previousState: { previousState: {
@@ -184,25 +184,25 @@ export default function RegisterForm() {
}}> }}>
<div className={`${styles['form-switcher']}`}> <div className={`${styles['form-switcher']}`}>
<button <button
className={`${styles['form-switcher-button']} ${accountType === 'btc' ? styles['active'] : ''}`} className={`${styles['form-switcher-button']} ${accountType === 'b2c' ? styles['active'] : ''}`}
onClick={(e) => { onClick={(e) => {
switchRegistrationTypeHandler(e, 'btc'); switchRegistrationTypeHandler(e, 'b2c');
}} }}
> >
{t('personal')} {t('personal')}
</button> </button>
<button <button
className={`${styles['form-switcher-button']} ${accountType === 'btb' ? styles['active'] : ''}`} className={`${styles['form-switcher-button']} ${accountType === 'b2b' ? styles['active'] : ''}`}
onClick={(e) => { onClick={(e) => {
switchRegistrationTypeHandler(e, 'btb'); switchRegistrationTypeHandler(e, 'b2b');
}} }}
> >
{t('company')} {t('company')}
</button> </button>
<input <input
type="hiden" type="hiden"
id="accoutType" id="accountType"
name="accoutType" name="accountType"
className={`${styles['form-input-hidden']}`} className={`${styles['form-input-hidden']}`}
defaultValue={accountType} defaultValue={accountType}
/> />
@@ -239,7 +239,7 @@ export default function RegisterForm() {
)} )}
</div> </div>
{accountType === 'btb' && ( {accountType === 'b2b' && (
<div className={`${styles['form-group']}`}> <div className={`${styles['form-group']}`}>
<label <label
className={`${styles['form-label']} ${styles['required']}`} className={`${styles['form-label']} ${styles['required']}`}