Skip to content

Commit

Permalink
fix: 청구기호 카테고리가 올바르게 해석되지 않음 (#504)
Browse files Browse the repository at this point in the history
* fix: 청구기호 카테고리가 올바르게 해석되지 않음

* refactor: boolean 느낌 변수명으로 변경
  • Loading branch information
scarf005 authored Jul 17, 2023
1 parent 7812565 commit 9dbf65f
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/component/bookManagement/BookManagementModalDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,24 @@ const BookManagementModalDetail = ({ book, closeModal }: Props) => {
const callSignRegex = /^[A-Za-z][0-9]{1,3}\.[0-9]{2}\.v[1-9]\.c[1-9]$/;
const isbnRegex = /^\d{13}$/;

const validateDate =
const categoryToChange = change.callSign[0];
const isValidDate =
change.publishedAt && dateRegex.test(change.publishedAt);
const validateCallSign = callSignRegex.test(change.callSign);
const validateCategory =
change.callSign[0] ===
category.find(item => parseInt(item.id, 10) === change.categoryId)?.code;
const validateISBN = change.isbn && isbnRegex.test(change.isbn);
const isValidCallSign = callSignRegex.test(change.callSign);
const isValidCategory = category.find(x => x.code === categoryToChange) !== undefined;
const isValidISBN = change.isbn && isbnRegex.test(change.isbn);

let errorMessage = "";
if (validateDate && validateCallSign && validateCategory && validateISBN)
if (isValidDate && isValidCallSign && isValidCategory && isValidISBN)
return errorMessage;

if (!validateDate)
if (!isValidDate)
errorMessage += "출판일자 날짜형식 yyyddmm에 맞지 않습니다.\n";
if (!validateCallSign) errorMessage += "청구기호 형식이 맞지 않습니다.\n";
if (!validateCategory) {
if (!isValidCallSign) errorMessage += "청구기호 형식이 맞지 않습니다.\n";
if (!isValidCategory) {
errorMessage += "카테고리와 청구기호가 맞지 않습니다.\n";
}
if (!validateISBN) errorMessage += "13자리 ISBN를 입력해주세요";
if (!isValidISBN) errorMessage += "13자리 ISBN를 입력해주세요";
return errorMessage;
};

Expand Down

0 comments on commit 9dbf65f

Please sign in to comment.