-
Notifications
You must be signed in to change notification settings - Fork 1
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: 지원현황/면접기록 목록페이지에서 합불상태를 조회할 수 있다. #213
Changes from 12 commits
015211b
cd6cc15
567072e
4940ef7
9bf04a1
e1f8890
a478b41
95d84eb
a0b90a1
6ddf78d
2115e1b
40930e1
8781867
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,50 @@ | ||
"use client"; | ||
|
||
import { PropsWithChildren, useState } from "react"; | ||
import BoardCell from "./BoardCell.component"; | ||
import Modal from "react-modal"; | ||
import Image from "next/image"; | ||
import CloseImage from "/public/icons/ellipsis.multiply.svg"; | ||
import { cn } from "@/src/utils/cn"; | ||
import Txt from "../Txt.component"; | ||
import { type PropsWithChildren } from "react"; | ||
import useModalState from "../../../src/hooks/useModalState"; | ||
import BoardModal from "./BoardModal"; | ||
import BoardTable from "./BoardTable"; | ||
import { type ApplicantPassState } from "../../../src/apis/kanban"; | ||
|
||
interface BoardData { | ||
export interface BoardData { | ||
id: string; | ||
title: string; | ||
subElements: string[]; | ||
time?: Date; | ||
passState?: ApplicantPassState; | ||
} | ||
|
||
interface BoardProps extends PropsWithChildren { | ||
onClick?: (id: string) => void; | ||
wapperClassname?: string; | ||
wrapperClassname?: string; | ||
boardData: BoardData[]; | ||
} | ||
|
||
const Board = ({ | ||
children, | ||
onClick, | ||
wapperClassname, | ||
wrapperClassname, | ||
boardData, | ||
}: BoardProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const { isOpen, openModal, closeModal } = useModalState(); | ||
|
||
const openModel = (id: string) => { | ||
setIsOpen(true); | ||
const handleModalOpen = (id: string) => () => { | ||
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. 오...! 커링으로 작성한 것은 처음 보네요..! 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. 일단은 현재 커링을 쓴 이유는 컴포넌트를 분리함에 따라 이벤트 핸들러를 넘겨줘야 하는데, 마찬가지로 특정 이벤트 핸들러를 상위 컴포넌트에서 전달해주는데 각 요소 별로 전달해야할 값들이 있을 때 유용하다고 생각합니다^^ 말이 장황할 수 있는데 현재 PR 코드 보시는 느낌 그대로라고 생각하시면 될 거 같습니다 ! |
||
openModal(); | ||
onClick && onClick(id); | ||
}; | ||
const closeModel = () => setIsOpen(false); | ||
|
||
return ( | ||
<section className="flex flex-col"> | ||
{boardData.length === 0 ? ( | ||
<Txt>검색결과가 없습니다.</Txt> | ||
) : ( | ||
<> | ||
{boardData.map((item) => ( | ||
<BoardCell | ||
key={item.id} | ||
title={item.title} | ||
subElements={item.subElements} | ||
onClick={() => openModel(item.id)} | ||
/> | ||
))} | ||
</> | ||
)} | ||
<Modal | ||
style={{ | ||
content: { | ||
width: "calc(100% - 12rem)", | ||
zIndex: "9999", | ||
height: "calc(100%)", | ||
margin: "3rem 6rem 0 6rem", | ||
minWidth: "1280px", | ||
boxShadow: "0px 0px 6px 1px rgba(0, 0, 0, 0.14)", | ||
border: "none", | ||
position: "relative", | ||
inset: "0", | ||
padding: "2.5rem 3rem", | ||
}, | ||
overlay: { | ||
padding: "0", | ||
position: "absolute", | ||
}, | ||
}} | ||
<> | ||
<BoardTable boardRows={boardData} handleModalOpen={handleModalOpen} /> | ||
<BoardModal | ||
isOpen={isOpen} | ||
onRequestClose={closeModel} | ||
onRequestClose={closeModal} | ||
ariaHideApp={false} | ||
wrapperClassname={wrapperClassname} | ||
> | ||
<button className="absolute z-10" onClick={closeModel}> | ||
<Image src={CloseImage} alt="close" /> | ||
</button> | ||
<div | ||
className={cn( | ||
"flex pt-8 absolute h-[calc(100%-6rem)] w-[calc(100%-6rem)]", | ||
wapperClassname | ||
)} | ||
> | ||
{children} | ||
</div> | ||
</Modal> | ||
</section> | ||
{children} | ||
</BoardModal> | ||
</> | ||
); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Modal from "react-modal"; | ||
import CloseImage from "/public/icons/ellipsis.multiply.svg"; | ||
import Image from "next/image"; | ||
import { cn } from "@/src/utils/cn"; | ||
|
||
const modalStyle = { | ||
content: { | ||
width: "calc(100% - 12rem)", | ||
zIndex: "9999", | ||
height: "calc(100%)", | ||
margin: "3rem 6rem 0 6rem", | ||
minWidth: "1280px", | ||
boxShadow: "0px 0px 6px 1px rgba(0, 0, 0, 0.14)", | ||
border: "none", | ||
position: "relative", | ||
inset: "0", | ||
padding: "2.5rem 3rem", | ||
}, | ||
overlay: { | ||
padding: "0", | ||
position: "absolute", | ||
}, | ||
} as const; | ||
|
||
interface BoardModalProps extends Modal.Props { | ||
wrapperClassname?: string; | ||
} | ||
|
||
const BoardModal = ({ | ||
wrapperClassname, | ||
style, | ||
children, | ||
...props | ||
}: BoardModalProps) => { | ||
return ( | ||
<Modal style={{ ...modalStyle, ...style }} {...props}> | ||
<button className="absolute z-10" onClick={props.onRequestClose}> | ||
<Image src={CloseImage} alt="close" /> | ||
</button> | ||
<div | ||
className={cn( | ||
"flex pt-8 absolute h-[calc(100%-6rem)] w-[calc(100%-6rem)]", | ||
wrapperClassname | ||
)} | ||
> | ||
{children} | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default BoardModal; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Txt from "../Txt.component"; | ||
import { BoardData } from "./Board"; | ||
import BoardCell from "./BoardCell.component"; | ||
|
||
interface BoardTableProps { | ||
boardRows: BoardData[]; | ||
handleModalOpen: (id: string) => () => void; | ||
} | ||
const BoardTable = ({ boardRows, handleModalOpen }: BoardTableProps) => { | ||
return ( | ||
<section className="flex flex-col"> | ||
{boardRows.length === 0 ? ( | ||
<Txt>검색결과가 없습니다.</Txt> | ||
) : ( | ||
<> | ||
{boardRows.map(({ id, title, subElements, passState }) => ( | ||
<BoardCell | ||
key={id} | ||
title={title} | ||
subElements={subElements} | ||
passState={passState} | ||
onClick={handleModalOpen(id)} | ||
/> | ||
))} | ||
</> | ||
)} | ||
</section> | ||
); | ||
}; | ||
|
||
export default BoardTable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,9 @@ import { useAtom } from "jotai"; | |
import { interViewApplicantIdState } from "@/src/stores/interview/Interview.atom"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { getInterviewRecordByPageWithOrder } from "@/src/apis/interview"; | ||
import { ORDER_MENU } from "@/src/constants"; | ||
import { CHARACTERS, ORDER_MENU } from "@/src/constants"; | ||
import { useSearchQuery } from "@/src/hooks/useSearchQuery"; | ||
import { removeAll } from "@/src/functions/replacer"; | ||
|
||
interface InterviewBoardProps { | ||
generation: string; | ||
|
@@ -34,7 +35,7 @@ const InterviewBoard = ({ generation }: InterviewBoardProps) => { | |
}); | ||
}; | ||
|
||
const { data, isLoading } = useQuery({ | ||
const { data, status } = useQuery({ | ||
queryKey: ["allInterviewRecord", pageIndex, order, generation], | ||
queryFn: () => | ||
getInterviewRecordByPageWithOrder({ | ||
|
@@ -44,29 +45,35 @@ const InterviewBoard = ({ generation }: InterviewBoardProps) => { | |
}), | ||
}); | ||
|
||
if (!data || isLoading) { | ||
if (status === "loading") { | ||
return <div>loading...</div>; | ||
} | ||
|
||
const { records } = data; | ||
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. 구조 분해를 하나의 데이터만 하는 것은 좋은 코드가 아니여서 이렇게 하신건가요? 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. 음, 꼭 그런건 아니구요 |
||
if (status === "error") { | ||
return <div>에러가 발생하였습니다. 잠시 후 다시 시도해보세요.</div>; | ||
} | ||
2yunseong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const boardData = records.map((value) => { | ||
const boardData = data.records.map((value) => { | ||
return { | ||
id: value.applicantId, | ||
title: value.name, | ||
subElements: [ | ||
value.field1.split('"').join(""), | ||
value.field2.split('"').join(""), | ||
`${value.grade.split('"').join("")} ${value.semester | ||
.split('"') | ||
.join("")}`, | ||
removeAll(value.field1, CHARACTERS.DOUBLE_QUOTE).concat( | ||
CHARACTERS.SLASH, | ||
removeAll(value.field2, CHARACTERS.DOUBLE_QUOTE) | ||
), | ||
2yunseong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
removeAll(value.grade, CHARACTERS.DOUBLE_QUOTE).concat( | ||
CHARACTERS.SPACE, | ||
removeAll(value.semester, CHARACTERS.DOUBLE_QUOTE) | ||
), | ||
], | ||
passState: value.state.passState, | ||
}; | ||
}); | ||
|
||
return ( | ||
<Board | ||
wapperClassname="divide-x" | ||
wrapperClassname="divide-x" | ||
boardData={createSearchData() ?? boardData} | ||
onClick={(id) => onClick(id)} | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ApplicantPassState } from "../../src/apis/kanban"; | ||
import { getApplicantPassState } from "../../src/functions/formatter"; | ||
import Txt from "../common/Txt.component"; | ||
|
||
interface PassStateLabelProps { | ||
passState: ApplicantPassState; | ||
} | ||
|
||
// TODO: if you want more reusable component, it's should get addtional prop that custom css style. | ||
const PassStateLabel = ({ passState }: PassStateLabelProps) => { | ||
2yunseong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<Txt | ||
className="w-full flex-1 last:text-right truncate" | ||
color={ | ||
passState === "non-passed" | ||
? "red" | ||
: passState === "final-passed" | ||
? "blue" | ||
: "black" | ||
} | ||
> | ||
{getApplicantPassState(passState)} | ||
</Txt> | ||
); | ||
}; | ||
|
||
export default PassStateLabel; |
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.
wrapperClassName으로 작성하는게 좋아보입니다.
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.
오타 제보 감사용
.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.
8781867