|
@@ -9,31 +9,42 @@ type FormState = {
|
|
|
phone: string;
|
|
|
idCardImage: string;
|
|
|
licenseImage: string;
|
|
|
+ email: string;
|
|
|
+ name: string;
|
|
|
};
|
|
|
|
|
|
+const validate = object({
|
|
|
+ enterprise: string(formatValidateError('register.errors.enterprise'))
|
|
|
+ .min(1, 'register.errors.enterprise'),
|
|
|
+ phone: string(formatValidateError('register.errors.phone'))
|
|
|
+ .min(1, 'register.errors.phone'),
|
|
|
+ idCardImage: string(formatValidateError('register.errors.idcard'))
|
|
|
+ .min(1, 'register.errors.idcard'),
|
|
|
+ licenseImage: string(formatValidateError('register.errors.licenseImage'))
|
|
|
+ .min(1, 'register.errors.licenseImage'),
|
|
|
+ email: string(formatValidateError('register.errors.email'))
|
|
|
+ .min(1, 'register.errors.email')
|
|
|
+ .email('register.errors.emailType'),
|
|
|
+ name: string(formatValidateError('register.errors.name'))
|
|
|
+ .min(1, 'register.errors.name'),
|
|
|
+});
|
|
|
+
|
|
|
export function useFormState(isSuccess: Ref<boolean>) {
|
|
|
- const {handleSubmit, handleReset} = useForm<FormState>({
|
|
|
+ const {handleSubmit, handleReset, values} = useForm<FormState>({
|
|
|
initialValues: {
|
|
|
enterprise: '',
|
|
|
phone: '',
|
|
|
idCardImage: '',
|
|
|
licenseImage: '',
|
|
|
+ email: '',
|
|
|
+ name: '',
|
|
|
},
|
|
|
- validationSchema: toTypedSchema(object({
|
|
|
- enterprise: string(formatValidateError('register.errors.enterprise'))
|
|
|
- .min(1, 'register.errors.enterprise'),
|
|
|
- phone: string(formatValidateError('register.errors.phone'))
|
|
|
- .min(1, 'register.errors.phone'),
|
|
|
- idCardImage: string(formatValidateError('register.errors.idcard'))
|
|
|
- .min(1, 'register.errors.idcard'),
|
|
|
- licenseImage: string(formatValidateError('register.errors.licenseImage'))
|
|
|
- .min(1, 'register.errors.licenseImage'),
|
|
|
- })),
|
|
|
+ validationSchema: toTypedSchema(validate),
|
|
|
});
|
|
|
|
|
|
const onSubmit = handleSubmit(function(value) {
|
|
|
isSuccess.value = true;
|
|
|
});
|
|
|
|
|
|
- return {onSubmit, handleReset};
|
|
|
+ return [{values}, {onSubmit, handleReset}] as const;
|
|
|
}
|