|
1 | 1 | "use client"; |
2 | 2 | // μν¬νΌ μμ νμ΄μ§ (μ¬μ₯λ) |
3 | 3 |
|
4 | | -import { useEffect, useState } from "react"; |
| 4 | +import { useEffect, useMemo, useState } from "react"; |
5 | 5 | import { useParams, useRouter, useSearchParams } from "next/navigation"; |
6 | 6 | import { FormProvider, useForm } from "react-hook-form"; |
7 | 7 | import axios from "axios"; |
@@ -33,7 +33,7 @@ export default function EditFormPage() { |
33 | 33 | const { |
34 | 34 | reset, |
35 | 35 | handleSubmit, |
36 | | - formState: { isDirty, isValid }, |
| 36 | + formState: { isDirty }, |
37 | 37 | } = methods; |
38 | 38 |
|
39 | 39 | const queryClient = useQueryClient(); |
@@ -72,6 +72,29 @@ export default function EditFormPage() { |
72 | 72 | } |
73 | 73 | }, [albaFormDetailData, reset]); |
74 | 74 |
|
| 75 | + const isComplete = useMemo(() => { |
| 76 | + // μμ±μ΄ μλ£λ νλλ€: κΈ°λ³Έκ°μμ λ³κ²½λ κ²½μ°λ₯Ό νμΈ |
| 77 | + return ( |
| 78 | + currentValues.title && |
| 79 | + currentValues.description && |
| 80 | + currentValues.location && |
| 81 | + currentValues.workStartDate && |
| 82 | + currentValues.workEndDate && |
| 83 | + currentValues.recruitmentStartDate && |
| 84 | + currentValues.recruitmentEndDate && |
| 85 | + currentValues.workStartTime && |
| 86 | + currentValues.workEndTime && |
| 87 | + currentValues.age && |
| 88 | + currentValues.preferred && |
| 89 | + currentValues.education && |
| 90 | + currentValues.gender && |
| 91 | + currentValues.numberOfPositions >= 0 && |
| 92 | + currentValues.imageUrls.length > 0 && |
| 93 | + currentValues.hourlyWage >= 10_030 && |
| 94 | + (currentValues.workDays.length > 0 || currentValues.isNegotiableWorkDays) |
| 95 | + ); |
| 96 | + }, [currentValues]); |
| 97 | + |
75 | 98 | // μμ λ νΌ μ μΆ λ¦¬μ‘νΈμΏΌλ¦¬ |
76 | 99 | const mutation = useMutation({ |
77 | 100 | mutationFn: async () => { |
@@ -170,7 +193,7 @@ export default function EditFormPage() { |
170 | 193 | width="md" |
171 | 194 | color="orange" |
172 | 195 | className="h-[58px] w-full lg:h-[72px] lg:text-xl lg:leading-8" |
173 | | - disabled={!isDirty || !isValid} |
| 196 | + disabled={!isDirty || !isComplete} |
174 | 197 | onClick={handleSubmit(() => mutation.mutate())} |
175 | 198 | > |
176 | 199 | {mutation.isPending ? <DotLoadingSpinner /> : "μμ νκΈ°"} |
|
0 commit comments