Skip to content

Commit

Permalink
πŸ› fix: μ‹œκΈ‰ μž…λ ₯ ν›„ μœ νš¨μ„± 검사 및 μ‹œκ°μ  ν‘œμ‹œ 정상화 #127
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMirror21 committed Jan 20, 2025
1 parent 73443d0 commit 13a6b50
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 36 deletions.
9 changes: 6 additions & 3 deletions src/components/Common/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type InputProps = {
placeholder: string; // ν”Œλ ˆμ΄μŠ€ν™€λ” ν…μŠ€νŠΈ
value: string | null; // μž…λ ₯ ν•„λ“œμ˜ ν˜„μž¬ κ°’
onChange: (value: string) => void; // μž…λ ₯κ°’ λ³€κ²½ μ‹œ 호좜될 ν•¨μˆ˜
onBlur?: (value: string) => void; // μž…λ ₯ ν•„λ“œμ—μ„œ ν¬μ»€μŠ€κ°€ λΉ μ Έλ‚˜κ°ˆ λ•Œ 호좜될 ν•¨μˆ˜ (선택적)
onBlur?: (value: string) => boolean; // μž…λ ₯ ν•„λ“œμ—μ„œ ν¬μ»€μŠ€κ°€ λΉ μ Έλ‚˜κ°ˆ λ•Œ 호좜될 ν•¨μˆ˜ (선택적)
canDelete: boolean; // μ‚­μ œ λ²„νŠΌ ν‘œμ‹œ μ—¬λΆ€
clearInvalid?: () => void; // ν† κΈ€ μ‹œ invalid μƒνƒœλ₯Ό ν•΄μ œν•  ν•¨μˆ˜ (선택적)
isInvalid?: boolean; // μœ νš¨ν•˜μ§€ μ•Šμ€ μž…λ ₯ μƒνƒœ μ—¬λΆ€ (선택적)
Expand Down Expand Up @@ -86,8 +86,11 @@ const Input = ({
};

const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
if (onBlur) onBlur(e.target.value);
handleFocus('blur');
if (onBlur && onBlur(e.target.value) === true) {
setCurrentStatus(INPUT_STATUS.INVALID);
return;
}
setCurrentStatus(INPUT_STATUS.DISABLED);
};

return (
Expand Down
8 changes: 1 addition & 7 deletions src/components/Employer/PostCreate/Step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ const Step1 = ({
}) => {
// ν˜„μž¬ stepλ‚΄μ—μ„œ μž…λ ₯λ°›λŠ” 정보λ₯Ό λ”°λ‘œ 관리할 state, μΆ”ν›„ λ‹€μŒ step으둜 λ„˜μ–΄κ°ˆ λ•Œ funnel 관리 νŽ˜μ΄μ§€μ˜ state둜 ν†΅ν•©λœλ‹€.
const [newPostInfo, setNewPostInfo] = useState<JobPostingForm>(postInfo);
// μ‹œκΈ‰μ΄ 10030원 미만일 경우 κ²½κ³  λ©”μ‹œμ§€λ₯Ό ν‘œμ‹œ
const [warning, setWarning] = useState(false);
// λ²„νŠΌ ν™œμ„±ν™” μ—¬λΆ€λ₯Ό μœ„ν•œ ν”Œλž˜κ·Έ
const [isInvalid, setIsInvalid] = useState(true);
// 근무 μ‹œκ°„ λͺ¨λ‹¬ ν™œμ„±ν™” μ—¬λΆ€ μœ„ν•œ ν”Œλž˜κ·Έ
Expand Down Expand Up @@ -140,12 +138,8 @@ const Step1 = ({
})
}
onBlur={() =>
handleHourlyRateBlur({
value: String(newPostInfo.body.hourly_rate),
setWarning,
})
handleHourlyRateBlur(String(newPostInfo.body.hourly_rate))
}
isInvalid={warning}
canDelete={false}
isUnit
unit="원"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ const EmployerLaborContractForm = ({

const [isLoading, setIsLoading] = useState(false);
const [isInvalid, setIsInvalid] = useState(false);
// μ‹œκΈ‰ 10030원 미만일 경우 κ²½κ³  ν‘œμ‹œ
const [warning, setWarning] = useState(false);
// κ·Όλ¬΄μ‹œκ°„, μš”μΌ 선택 λͺ¨λ‹¬ ν™œμ„±ν™” ν”Œλž˜κ·Έ
const [isModal, setIsModal] = useState(false);
// μž…λ ₯ μ™„λ£Œ μ‹œ 제좜
Expand Down Expand Up @@ -436,12 +434,8 @@ const EmployerLaborContractForm = ({
})
}
onBlur={() =>
handleHourlyRateBlur({
value: String(newDocumentData.hourly_rate),
setWarning,
})
handleHourlyRateBlur(String(newDocumentData.hourly_rate))
}
isInvalid={warning}
canDelete={false}
isUnit
unit="원"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ const EmployerPartTimePermitForm = ({
} = useAddressSearch();
const [isLoading, setIsLoading] = useState(false);
const [isInvalid, setIsInvalid] = useState(false);
// μ‹œκΈ‰ 10030원 미만일 경우 κ²½κ³  ν‘œμ‹œ
const [warning, setWarning] = useState(false);
// μž…λ ₯ μ™„λ£Œ μ‹œ 제좜
const { mutate: putDocument } = usePutPartTimeEmployPermitEmployer(
Number(id),
Expand Down Expand Up @@ -356,12 +354,8 @@ const EmployerPartTimePermitForm = ({
})
}
onBlur={() =>
handleHourlyRateBlur({
value: String(newDocumentData.hourly_rate),
setWarning,
})
handleHourlyRateBlur(String(newDocumentData.hourly_rate))
}
isInvalid={warning}
canDelete={false}
isUnit
unit="원"
Expand Down
14 changes: 2 additions & 12 deletions src/utils/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,9 @@ export const parseStringToSafeNumber = (value: string): number => {
};

// μ‹œκΈ‰ ν•„λ“œ onBlur 이벀트 ν•Έλ“€λŸ¬
export const handleHourlyRateBlur = ({
value,
setWarning,
}: {
value: string;
setWarning: React.Dispatch<React.SetStateAction<boolean>>;
}) => {
export const handleHourlyRateBlur = (value: string) => {
const parsedValue = parseStringToSafeNumber(value);
if (parsedValue < MINIMUM_HOURLY_RATE) {
setWarning(true);
} else {
setWarning(false);
}
return parsedValue < MINIMUM_HOURLY_RATE;
};

// base64 데이터λ₯Ό λ””μ½”λ”©ν•΄ 이미지 νƒ€μž…μ„ μΆ”λ‘ ν•˜λŠ” ν•¨μˆ˜
Expand Down

0 comments on commit 13a6b50

Please sign in to comment.