File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"use client" ;
22
3+ import { useRouter } from "next/navigation" ;
34import { useState } from "react" ;
45import { FormProvider , useForm } from "react-hook-form" ;
56
@@ -17,6 +18,7 @@ import { toast } from "@/lib/zustand/useToastStore";
1718import { zodResolver } from "@hookform/resolvers/zod" ;
1819
1920const ApplyMentorPage = ( ) => {
21+ const router = useRouter ( ) ;
2022 const [ step , setStep ] = useState < number > ( 1 ) ;
2123
2224 const methods = useForm < MentorApplicationFormData > ( {
@@ -34,7 +36,12 @@ const ApplyMentorPage = () => {
3436 const { mutate : postMentorApplication } = usePostMentorApplication ( ) ;
3537
3638 const goNextStep = ( ) => setStep ( ( prev ) => prev + 1 ) ;
37- const goPrevStep = ( ) => setStep ( ( prev ) => Math . max ( 1 , prev - 1 ) ) ;
39+ const goPrevStep = ( ) => {
40+ if ( step === 1 ) {
41+ router . back ( ) ;
42+ }
43+ setStep ( ( prev ) => Math . max ( 1 , prev - 1 ) ) ;
44+ } ;
3845
3946 const progress = ( ( step - 1 ) / 3 ) * 100 ;
4047
You can’t perform that action at this time.
0 commit comments