diff --git a/src/components/org/OrgAdmin/index.tsx b/src/components/org/OrgAdmin/index.tsx index 4950681..98b69fb 100644 --- a/src/components/org/OrgAdmin/index.tsx +++ b/src/components/org/OrgAdmin/index.tsx @@ -22,6 +22,7 @@ import type { Group } from './types'; import { validationAboutInputs, validationCommonInputs, + validationHomeInputs, validationRecruitInputs, } from './utils'; @@ -74,9 +75,14 @@ function OrgAdmin() { setIntroPart(part); }; + const handleValidateHomeInputs = () => + validationHomeInputs(getValues, setError, onChangeIntroPart); + const onSubmit: SubmitHandler = (data) => { const handleValidateCommonInputs = () => validationCommonInputs(getValues, setError, setGroup); + const handleValidateHomeInputs = () => + validationHomeInputs(getValues, setError, onChangeIntroPart); const handleValidationAboutInputs = () => validationAboutInputs( getValues, @@ -94,19 +100,27 @@ function OrgAdmin() { const validationFlow = { 공통: [ + handleValidateCommonInputs, + handleValidateHomeInputs, + handleValidationAboutInputs, + handleValidationRecruitInputs, + ], + 홈: [ + handleValidateHomeInputs, handleValidateCommonInputs, handleValidationAboutInputs, handleValidationRecruitInputs, ], - 홈: [], 소개: [ handleValidationAboutInputs, handleValidateCommonInputs, + handleValidateHomeInputs, handleValidationRecruitInputs, ], 지원하기: [ handleValidationRecruitInputs, handleValidateCommonInputs, + handleValidateHomeInputs, handleValidationAboutInputs, ], }; @@ -117,6 +131,7 @@ function OrgAdmin() { if (validateFn === handleValidateCommonInputs) return '공통'; if (validateFn === handleValidationAboutInputs) return '소개'; if (validateFn === handleValidationRecruitInputs) return '지원하기'; + if (validateFn === handleValidateHomeInputs) return '홈'; return '공통'; }; diff --git a/src/components/org/OrgAdmin/utils.ts b/src/components/org/OrgAdmin/utils.ts index 8b11332..ef76331 100644 --- a/src/components/org/OrgAdmin/utils.ts +++ b/src/components/org/OrgAdmin/utils.ts @@ -56,6 +56,27 @@ export const validationCommonInputs = ( return true; }; +export const validationHomeInputs = ( + getValues: (payload?: string | string[]) => FieldValues, + setError: (name: string, error: { type: string; message: string }) => void, + onChangeIntroPart: (part: PART_KO) => void, +) => { + for (const part of PART_LIST) { + const name = `partIntroduction${part}`; + const data = getValues(name); + if (!data) { + console.log(part, data); + setError(name, { + type: 'required', + message: VALIDATION_CHECK.required.errorText, + }); + onChangeIntroPart(part); + return false; + } + } + return true; +}; + export const validationAboutInputs = ( getValues: (payload?: string | string[]) => FieldValues, setError: (name: string, error: { type: string; message: string }) => void,