Skip to content

Commit

Permalink
style: Posting 함수 가독성 높이기 위한 함수 처리
Browse files Browse the repository at this point in the history
- Payload 생성, 필드 유효성 검증, 주소 분리, 일하는 요일 convertDays함수를 /util/postin/ 하위에 함수 파일로 처리
- phoneInput의 체크박스 값이 읽어지지 않는 버그 디버깅

ref : #18
  • Loading branch information
minseoKim-11 committed Nov 12, 2024
1 parent 3fb1fa0 commit a7ade43
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 205 deletions.
7 changes: 3 additions & 4 deletions src/api/postingAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ export const postJobPosting = async (accessToken, payload) => {
if (result.status === 200) {
response.isSuccess = true;
response.message = result.data.message;
response.data = result.data.data; // 필요에 따라 데이터 할당
response.data = result.data.data;
}
} catch (err) {
response.isSuccess = false;
response.message = err.response?.data?.message || err.message;

if (err.response?.status === 401) {
alert("인증이 필요합니다. 다시 로그인해주세요.");
// 여기서 로그아웃 및 재로그인 프로세스를 트리거할 수 있음
}

}
Expand All @@ -40,8 +39,8 @@ export const updateJobPosting = async (accessToken, postId, postData) => {

try {
const body = {
postId, // 백엔드에서 postId가 필요하지 않다고 명시했으나, 요청 형식에 포함
userId: 0, // 사용하지 않음
postId,
userId,
storeName: "", // 수정 불가
workPlaceAddress: "", // 수정 불가
postData, // 수정 가능한 postData만 포함
Expand Down
23 changes: 17 additions & 6 deletions src/components/posting/PhoneInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,26 @@ const PhoneInput = ({ label, onChange, onValidityChange }) => {
setPhone(value);

const valid = /^\d{3}-\d{4}-\d{4}$/.test(value); // 올바른 형식인지 확인
setIsValid(valid);
onValidityChange && onValidityChange(valid); // 유효성 상태 부모 전달
onChange && onChange({ phone: value, noCalls });
};

setIsValid(valid);
onValidityChange && onValidityChange(valid);

if (onChange) {
setTimeout(() => {
onChange({ phone: value, noCalls });
}, 0);
}
};

const handleCheckboxChange = () => {
setNoCalls((prev) => {
const updatedNoCalls = !prev;
onChange && onChange({ phone, noCalls: updatedNoCalls });

if (onChange) {
setTimeout(() => {
onChange({ phone, noCalls: updatedNoCalls });
}, 0);
}

return updatedNoCalls;
});
};
Expand Down
Loading

0 comments on commit a7ade43

Please sign in to comment.