-
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: 면접기록/지원현황 페이지 검색 기능 #240
Changes from all commits
a358a54
874c441
47f7d97
60b4b1b
0893937
8487785
8c606bf
690e82a
6908690
bb4936e
3cc4da1
91e8130
ad29ca5
74b9a0d
03a7dba
8bbc391
3e5c91e
8d5cd5e
97c9e85
d33a357
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"use client"; | ||
|
||
import { useQuery } from "@tanstack/react-query"; | ||
import useApplicantPaginationParams from "../../src/hooks/applicant/useApplicantPaginationParams"; | ||
import { getApplicantByPageWithGeneration } from "../../src/apis/applicant"; | ||
import LoadingSpinner from "../common/LoadingSpinner"; | ||
import ApplicantBoard from "./Board"; | ||
import ApplicantPageNavbar from "./PageNavbar"; | ||
|
||
interface ApplicantListProps { | ||
generation: string; | ||
} | ||
|
||
const ApplicantList = ({ generation }: ApplicantListProps) => { | ||
const { pageIndex, order, searchKeyword } = useApplicantPaginationParams(); | ||
const { data: applicants, status } = useQuery( | ||
["allApplicant", { generation, order, pageIndex, searchKeyword }], | ||
() => | ||
getApplicantByPageWithGeneration( | ||
+pageIndex, | ||
generation, | ||
order, | ||
searchKeyword | ||
), | ||
{ | ||
enabled: !!generation, | ||
} | ||
); | ||
Comment on lines
+16
to
+28
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. tanstack query의 v3 문법을 사용하는 곳이 있고 v4 문법을 사용하는 곳이 있는데 통일성있게 가져가는 게 좋다고 생각해서 다 같이 이야기해보면 좋을 것 같네요 ! 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 === "loading") { | ||
return <LoadingSpinner size="s" />; | ||
} | ||
if (status === "error") { | ||
return <div>에러 발생</div>; | ||
} | ||
|
||
return ( | ||
<> | ||
<ApplicantBoard | ||
generation={generation} | ||
applicants={applicants.applicants} | ||
/> | ||
<ApplicantPageNavbar | ||
generation={generation} | ||
maxPage={applicants.maxPage} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default ApplicantList; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,26 @@ | ||
"use client"; | ||
|
||
import Board from "@/components/common/board/Board"; | ||
import { getApplicantByPageWithGeneration } from "@/src/apis/applicant"; | ||
import ApplicantDetailRight from "./DetailRight.component"; | ||
import { useState } from "react"; | ||
import { ApplicantReq } from "@/src/apis/application"; | ||
import { applicantDataFinder } from "@/src/functions/finder"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { ORDER_MENU } from "@/src/constants"; | ||
import { useSearchQuery } from "@/src/hooks/useSearchQuery"; | ||
import { type ApplicantPassState } from "../../src/apis/kanban"; | ||
import ApplicantDetailLeft from "./_applicant/ApplicantDetailLeft"; | ||
import { findApplicantState } from "@/src/utils/applicant"; | ||
import BoardTable from "../common/board/BoardTable"; | ||
import useModalState from "../../src/hooks/useModalState"; | ||
import BoardModal from "../common/board/BoardModal"; | ||
|
||
interface ApplicantBoardProps { | ||
generation: string; | ||
applicants: ApplicantReq[][]; | ||
} | ||
|
||
const ApplicantBoard = ({ generation }: ApplicantBoardProps) => { | ||
const [data, setData] = useState<ApplicantReq[]>([]); | ||
const searchParams = useSearchParams(); | ||
const pageIndex = searchParams.get("page") || "1"; | ||
const order = searchParams.get("order") || ORDER_MENU.APPLICANT[0].type; | ||
const { createSearchData } = useSearchQuery(pageIndex); | ||
|
||
const onClick = (id: string) => { | ||
if (!allData) return; | ||
setData( | ||
applicants?.filter((value) => applicantDataFinder(value, "id") === id)[0] | ||
); | ||
}; | ||
|
||
const { | ||
data: allData, | ||
isLoading, | ||
isError, | ||
} = useQuery( | ||
["allApplicant", pageIndex, order], | ||
() => getApplicantByPageWithGeneration(+pageIndex, generation, order), | ||
{ | ||
enabled: !!generation, | ||
} | ||
const ApplicantBoard = ({ generation, applicants }: ApplicantBoardProps) => { | ||
const [selectedApplicant, setSelectedApplicant] = useState<ApplicantReq[]>( | ||
[] | ||
); | ||
|
||
if (!allData || isLoading) { | ||
return <div>로딩중...</div>; | ||
} | ||
|
||
if (isError) { | ||
return <div>에러 발생</div>; | ||
} | ||
|
||
const { applicants } = allData; | ||
const { isOpen, openModal, closeModal } = useModalState(); | ||
|
||
const boardData = applicants.map((value) => ({ | ||
id: applicantDataFinder(value, "id"), | ||
|
@@ -81,27 +49,38 @@ const ApplicantBoard = ({ generation }: ApplicantBoardProps) => { | |
)}` as ApplicantPassState, | ||
})); | ||
|
||
const handleModalOpen = (id: string) => () => { | ||
openModal(); | ||
setSelectedApplicant( | ||
applicants.filter((value) => applicantDataFinder(value, "id") === id)[0] | ||
); | ||
}; | ||
|
||
return ( | ||
<Board | ||
wrapperClassName="divide-x" | ||
boardData={createSearchData(true) ?? boardData} | ||
onClick={onClick} | ||
> | ||
<div className="flex flex-1"> | ||
<div className="flex-1 overflow-auto px-12 min-w-[40rem]"> | ||
<ApplicantDetailLeft | ||
cardId={-1} | ||
data={data} | ||
generation={generation} | ||
/> | ||
<> | ||
<BoardTable boardRows={boardData} handleModalOpen={handleModalOpen} /> | ||
<BoardModal | ||
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. 네이밍 변경 좋네요!👍 |
||
isOpen={isOpen} | ||
onRequestClose={closeModal} | ||
ariaHideApp={false} | ||
wrapperClassName="divide-x" | ||
> | ||
<div className="flex flex-1"> | ||
<div className="flex-1 overflow-auto px-12 min-w-[40rem]"> | ||
<ApplicantDetailLeft | ||
cardId={-1} | ||
data={selectedApplicant} | ||
generation={generation} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="flex flex-1 min-h-0"> | ||
<div className="flex-1 overflow-auto px-12"> | ||
<ApplicantDetailRight data={data} /> | ||
<div className="flex flex-1 min-h-0"> | ||
<div className="flex-1 overflow-auto px-12"> | ||
<ApplicantDetailRight data={selectedApplicant} /> | ||
</div> | ||
</div> | ||
</div> | ||
</Board> | ||
</BoardModal> | ||
</> | ||
); | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { cn } from "../../src/utils/cn"; | ||
|
||
interface LoadingSpinnerProps { | ||
size?: "s" | "m" | "l" | "xl"; | ||
} | ||
|
||
const getSize = (size: "s" | "m" | "l" | "xl") => { | ||
switch (size) { | ||
case "s": | ||
return cn("w-6", "h-6"); | ||
case "m": | ||
return cn("w-12", "h-12"); | ||
case "l": | ||
return cn("w-18", "h-18"); | ||
case "xl": | ||
return cn("w-24 h-24"); | ||
default: | ||
throw new Error( | ||
"Error: Loading Spinner의 `size` Props는 s, m, l, xl 중 하나 입니다." | ||
); | ||
} | ||
}; | ||
|
||
const LoadingSpinner = ({ size = "s" }: LoadingSpinnerProps) => { | ||
return ( | ||
<div className={getSize(size)}> | ||
<svg | ||
className="mr-3 -ml-1 size-5 animate-spin text-black" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
> | ||
<circle | ||
className="opacity-25" | ||
cx="12" | ||
cy="12" | ||
r="10" | ||
stroke="currentColor" | ||
stroke-width="4" | ||
></circle> | ||
<path | ||
className="opacity-75" | ||
fill="currentColor" | ||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" | ||
></path> | ||
</svg> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LoadingSpinner; |
This file was deleted.
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.
nit. 점진적으로 query 업그레이드 + suspense query, hook으로 바꾸는것도 좋을 수 있겠네요!
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.
너무 좋은 아이디어 입니다 채승님 !! 항상 감사드립니다 :)