Как сделать тип stage необязательным?
как мне сделать тип stage необязательным пропсом в ReturnType<typeof useView>
?
const MainView = ({ form, functions }: ReturnType<typeof useView> ) => {}
export const useView = () => {
const navigate = useNavigate()
const [stage, setStage] = useState<'email' | 'password' | 'about'>('email')
const signUpForm = useForm<EmailFormScheme | PasswordFormScheme>({
mode: 'onChange',
defaultValues: {
email: '',
password: ''
},
resolver: zodResolver(stage === 'email' ? emailFormScheme : stage === 'password' ? passwordFormScheme : emailFormScheme)
})
const onSubmit = signUpForm.handleSubmit(value => {
if(stage === 'email' && 'email' in value) {
navigate('stage=1')
setStage('password')
}
})
return {
form: signUpForm,
stage,
functions: { onSubmit }
}
}