Skip to content

Commit

Permalink
[FEATURE] 에러 상태 빠진 곳 UI 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
eonseok-jeon authored Dec 31, 2024
2 parents 0580ee8 + a3fdb6d commit d9892c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/components/org/OrgAdmin/AboutSection/Curriculum/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ const Curriculum = ({
required: true && VALIDATION_CHECK.required.errorText,
})}
isError={
(errors as any).partCurriculum?.selectedPart?.idx?.message !==
undefined
(errors as any).partCurriculum?.[selectedPart]?.[idx]
?.message !== undefined
}
errorMessage={
(errors as any).partCurriculum?.selectedPart?.idx
(errors as any).partCurriculum?.[selectedPart]?.[idx]
?.message as string
}
id={`${selectedPart} week${idx}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const ExecInfo = ({ selectedExec }: ExecInfoProps) => {
required: true && VALIDATION_CHECK.required.errorText,
})}
isError={
(errors as any).member?.selectedExec?.name?.message !== undefined
(errors as any).member?.[selectedExec]?.name?.message !== undefined
}
errorMessage={
(errors as any).member?.selectedExec?.name?.message as string
(errors as any).member?.[selectedExec]?.name?.message as string
}
labelText="이름"
placeholder="ex. 김솝트"
Expand All @@ -65,11 +65,12 @@ const ExecInfo = ({ selectedExec }: ExecInfoProps) => {
required: true && VALIDATION_CHECK.required.errorText,
})}
isError={
(errors as any).member?.selectedExec?.introduction?.message !==
(errors as any).member?.[selectedExec]?.introduction?.message !==
undefined
}
errorMessage={
(errors as any).member?.selectedExec?.introduction?.message as string
(errors as any).member?.[selectedExec]?.introduction
?.message as string
}
labelText="한 줄 소개"
placeholder="ex. 새로운 도전을 위해 과감히 용기내는 사람"
Expand Down
14 changes: 11 additions & 3 deletions src/components/org/OrgAdmin/MyDropzone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ const MyDropzone = ({
formState: { errors },
} = method;

const errorMsg = label.includes('.')
? label.split('.').length === 2
? (errors as any)?.[label.split('.')[0]]?.[label.split('.')[1]]?.message
: (errors as any)?.[label.split('.')[0]]?.[label.split('.')[1]]?.[
label.split('.')[2]
]?.message
: errors[label]?.message;

const onDrop = useCallback(
(acceptedFiles: File[]) => {
const file = acceptedFiles[0];
Expand Down Expand Up @@ -81,7 +89,7 @@ const MyDropzone = ({
width={width}
height={height}
shape={shape}
isError={errors[label]?.message != undefined}>
isError={errorMsg}>
<input
{...register(label, {
required: true && VALIDATION_CHECK.required.errorText,
Expand All @@ -96,9 +104,9 @@ const MyDropzone = ({
<StImgIcon />
)}
</StImgButton>
{errors[label] && (
{errorMsg && (
<StErrorMessage>
<>{errors[label].message}</>
<>{errorMsg}</>
</StErrorMessage>
)}
</StImgButtonWrapper>
Expand Down

0 comments on commit d9892c1

Please sign in to comment.