Skip to content

Commit e61e0b5

Browse files
committed
feat : 뒤로가기 구현하다
1 parent acc017c commit e61e0b5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/app/my/apply-mentor/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22

3+
import { useRouter } from "next/navigation";
34
import { useState } from "react";
45
import { FormProvider, useForm } from "react-hook-form";
56

@@ -17,6 +18,7 @@ import { toast } from "@/lib/zustand/useToastStore";
1718
import { zodResolver } from "@hookform/resolvers/zod";
1819

1920
const 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

0 commit comments

Comments
 (0)