-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 사서 대출권수 변경 #620
base: develop
Are you sure you want to change the base?
The head ref may contain hidden characters: "619-\uC0AC\uC11C-\uB300\uCD9C\uAD8C\uC218-4\uAD8C\uC73C\uB85C-\uBCC0\uACBD"
feat: 사서 대출권수 변경 #620
Changes from 13 commits
2a1079f
6655d5e
426c95f
1c10729
6ea9ec7
afbbcbe
b612710
0b344a3
a24613f
8e0e2ee
db632ed
e56f1ff
5de1deb
314ccc3
ed99a11
702403f
c53f6fe
bd2e37b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { useModal } from "../../hook/useModal"; | ||
import { dateFormat } from "../../util/date"; | ||
import { User } from "../../type"; | ||
import { useRecoilValue } from "recoil"; | ||
import { userAtom } from "~/atom/userAtom"; | ||
import RentModalUser from "./RentModalUser"; | ||
import Image from "../utils/Image"; | ||
import DeleteButton from "../../asset/img/x_button.svg"; | ||
|
@@ -14,6 +16,8 @@ type Props = { | |
const InquireBoxUser = ({ selectedUser, setSelectedUser }: Props) => { | ||
const { setOpen, setClose, Modal } = useModal(); | ||
|
||
const librarian = useRecoilValue(userAtom); | ||
|
||
const deleteUser = () => { | ||
if (setSelectedUser) { | ||
setSelectedUser(null); | ||
|
@@ -22,18 +26,19 @@ const InquireBoxUser = ({ selectedUser, setSelectedUser }: Props) => { | |
|
||
const displayPenalty = () => { | ||
if (!selectedUser) return ""; | ||
|
||
let penalty = ""; | ||
if ( | ||
new Date(selectedUser.penaltyEndDate).setHours(0, 0, 0, 0) >= | ||
new Date().setHours(0, 0, 0, 0) || | ||
selectedUser.overDueDay > 0 | ||
) | ||
penalty += "대출제한 (연체"; | ||
if (selectedUser.lendings.length >= 2) { | ||
if (penalty !== "") penalty += ", 2권 이상 대출"; | ||
else penalty += "대출제한 (2권 이상 대출"; | ||
selectedUser.isPenalty && (penalty += "대출제한 (연체"); | ||
|
||
// 제한 권수 판단 | ||
const lendingLimit = librarian && librarian.id === selectedUser.id ? 4 : 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 34번 라인같은 코드가 많이 보이는데 함수도 빼면 가독성이 더 좋을거 같아요. util함수 같은 느낌으로다가 constant 폴더에 넣으면 적합하다고 생각합니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. constant의 status.js에 함수화 시켜서 넣어봤습니다. 해당 함수에 객체를 인자로 넘기는데, 객체의 요소(isAdmin이나 id)가 undefined 같은 빈 값으로 들어오는 것도 고려해야 좋은지 고민이 됩니다. |
||
|
||
if (selectedUser.lendings.length >= lendingLimit) { | ||
if (selectedUser.isPenalty)penalty += `, ${lendingLimit}권 이상 대출`; | ||
else penalty += `대출제한 (${lendingLimit}권 이상 대출`; | ||
} | ||
if (penalty !== "") penalty += ")"; | ||
if (selectedUser.isPenalty || selectedUser.lendings.length >= lendingLimit) | ||
penalty += ")"; | ||
return penalty; | ||
}; | ||
|
||
|
@@ -47,7 +52,8 @@ const InquireBoxUser = ({ selectedUser, setSelectedUser }: Props) => { | |
? selectedUser.nickname | ||
: selectedUser.email} | ||
</div> | ||
<div className="font-16 color-red"> {displayPenalty()} </div> | ||
{selectedUser.role === 2 ? <div className="rent__inquire-box-user__role color-ff font-16-bold">사서</div> : null} | ||
<div className="font-16 color-red">{displayPenalty()}</div> | ||
<button | ||
className="rent__inquire-box-user__undo-button color-a4" | ||
type="button" | ||
|
@@ -84,9 +90,8 @@ const InquireBoxUser = ({ selectedUser, setSelectedUser }: Props) => { | |
{`${index + 1}. ${item.title}`} | ||
</div> | ||
<div className="user__book-info__description color-54"> | ||
<span>{`예약순위 : ${ | ||
item.ranking ? `${item.ranking}순위` : "-" | ||
}`}</span> | ||
<span>{`예약순위 : ${item.ranking ? `${item.ranking}순위` : "-" | ||
}`}</span> | ||
{item.endAt ? ( | ||
<span className="user__reservations-info"> | ||
예약 혜택 종료일 : {item.endAt} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,7 @@ | ||||||
import { User } from "../../type"; | ||||||
import "../../asset/css/RentModalUserList.css"; | ||||||
import { useRecoilValue } from "recoil"; | ||||||
import { userAtom } from "~/atom/userAtom"; | ||||||
|
||||||
type Props = { | ||||||
setSelectedUser: (user: User) => void; | ||||||
|
@@ -8,24 +10,38 @@ type Props = { | |||||
}; | ||||||
|
||||||
const UserList = ({ user, setSelectedUser, closeModal }: Props) => { | ||||||
|
||||||
const librarian = useRecoilValue(userAtom); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
const isOverDue = (selectedUser: User) => { | ||||||
if ( | ||||||
new Date(selectedUser.penaltyEndDate).setHours(0, 0, 0, 0) >= | ||||||
new Date().setHours(0, 0, 0, 0) || | ||||||
selectedUser.overDueDay > 0 | ||||||
) return true; | ||||||
else return false; | ||||||
} | ||||||
|
||||||
const seletUser = () => { | ||||||
user.isPenalty = isOverDue(user) ? true : false; | ||||||
setSelectedUser(user); | ||||||
closeModal(); | ||||||
}; | ||||||
|
||||||
const displayPenalty = () => { | ||||||
let penalty = ""; | ||||||
if ( | ||||||
new Date(user.penaltyEndDate).setHours(0, 0, 0, 0) >= | ||||||
new Date().setHours(0, 0, 0, 0) || | ||||||
user.overDueDay > 0 | ||||||
) | ||||||
penalty += "대출 불가 (연체"; | ||||||
if (user.lendings.length >= 2) { | ||||||
if (penalty !== "") penalty += ", 2권 이상 대출"; | ||||||
else penalty += "대출 불가 (2권 이상 대출"; | ||||||
user.isPenalty && (penalty += "대출 불가 (연체"); | ||||||
|
||||||
const lendingLimit = librarian.id === user.id ? 4 : 2; | ||||||
|
||||||
if (user.lendings.length >= lendingLimit) { | ||||||
if (user.isPenalty) penalty += `, ${lendingLimit}권 이상 대출`; | ||||||
else penalty += `대출 불가 (${lendingLimit}권 이상 대출`; | ||||||
} | ||||||
if (penalty !== "") penalty += ")"; | ||||||
|
||||||
if (user.isPenalty || user.lendings.length >= lendingLimit) | ||||||
penalty += ")"; | ||||||
|
||||||
return penalty; | ||||||
}; | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSDoc을 통해 다른 파일에서도 비지니스 로직(사서만 4권)을 확인할 수 있도록 수정하면 유지보수하기 용이할 듯 합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영했습니다!