Skip to content

Commit 274b9f8

Browse files
authored
Update index.tsx
1 parent 8eac884 commit 274b9f8

File tree

1 file changed

+5
-5
lines changed
  • src/app/(crew)/crew/_components/create-crew-form

1 file changed

+5
-5
lines changed

src/app/(crew)/crew/_components/create-crew-form/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ export default function CreateCrewForm({
3131
control,
3232
handleSubmit,
3333
setValue,
34+
getValues,
3435
clearErrors,
35-
formState: { errors },
36+
formState: { errors, isValid },
3637
} = useForm<CreateCrewRequestTypes>({
3738
defaultValues: data,
3839
mode: 'onBlur',
3940
});
4041

41-
const isFormValid = Object.keys(errors).length === 0 && Object.values(data).every(Boolean);
42-
4342
const [categoryIndex, setCategoryIndex] = useState(0);
4443
const [regionIndex, setRegionIndex] = useState(0);
4544

45+
const title = useWatch({ control, name: 'title' });
4646
// mainCategory와 mainLocation 값의 변화를 감지하여 인덱스를 설정
4747
const mainCategory = useWatch({ control, name: 'mainCategory' });
4848
const mainLocation = useWatch({ control, name: 'mainLocation' });
@@ -75,7 +75,7 @@ export default function CreateCrewForm({
7575
크루명을 입력해주세요.
7676
</label>
7777
<span>
78-
<span className="text-blue-500">{data.title.length}</span>/20
78+
<span className="text-blue-500">{title.length}</span>/20
7979
</span>
8080
</div>
8181
<Controller
@@ -244,7 +244,7 @@ export default function CreateCrewForm({
244244
<div className="flex justify-between gap-4 pt-18">
245245
<Button
246246
type="submit"
247-
disabled={!isFormValid}
247+
disabled={!isValid}
248248
className="btn-filled h-11 flex-1 text-base font-medium disabled:bg-gray-200"
249249
>
250250
{isEdit ? '수정' : '확인'}

0 commit comments

Comments
 (0)