-
Notifications
You must be signed in to change notification settings - Fork 5
feat: 내 알바폼 > 지원자 페이지 추가 #118
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
df65918
refactor: 폼 만들기 FloatingBtn 으로 교체
cccwon2 6e0a88c
feat: 내 알바폼 > 지원자 추가
cccwon2 2e41111
chore: 자잘한 UI 수정 등
cccwon2 b7561c4
chore: chomatic 최신 버전 업데이트
cccwon2 51fe71b
chore: 모달 confirm 문구 수정
cccwon2 9379b85
design: 하단 상태 표시 영역 수정
cccwon2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/app/(pages)/myAlbaform/(role)/applicant/components/ApplicantSortSection.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| "use client"; | ||
|
|
||
| import React from "react"; | ||
| import FilterDropdown from "@/app/components/button/dropdown/FilterDropdown"; | ||
| import { formStatusOptions } from "@/constants/formOptions"; | ||
| import { useRouter } from "next/navigation"; | ||
|
|
||
| const APPLICANT_SORT_OPTIONS = [ | ||
| { label: "전체", value: "" }, | ||
| { label: "최신순", value: formStatusOptions.INTERVIEW_PENDING }, | ||
| { label: "시급높은순", value: formStatusOptions.INTERVIEW_COMPLETED }, | ||
| { label: "지원자 많은순", value: formStatusOptions.HIRED }, | ||
| { label: "스크랩 많은순", value: formStatusOptions.REJECTED }, | ||
| ]; | ||
|
|
||
| interface ApplicantSortSectionProps { | ||
| pathname: string; | ||
| searchParams: URLSearchParams; | ||
| } | ||
|
|
||
| export default function ApplicantSortSection({ pathname, searchParams }: ApplicantSortSectionProps) { | ||
| const router = useRouter(); | ||
| const currentOrderBy = searchParams.get("orderBy") || ""; | ||
|
|
||
| const currentLabel = | ||
| APPLICANT_SORT_OPTIONS.find((opt) => opt.value === currentOrderBy)?.label || APPLICANT_SORT_OPTIONS[0].label; | ||
|
|
||
| const handleSortChange = (selected: string) => { | ||
| const option = APPLICANT_SORT_OPTIONS.find((opt) => opt.label === selected); | ||
| if (option) { | ||
| const params = new URLSearchParams(searchParams); | ||
| params.set("orderBy", option.value); | ||
| router.push(`${pathname}?${params.toString()}`); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <FilterDropdown | ||
| options={APPLICANT_SORT_OPTIONS.map((option) => option.label)} | ||
| className="!w-28 md:!w-40" | ||
| initialValue={currentLabel} | ||
| onChange={handleSortChange} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,141 @@ | ||
| "use client"; | ||
|
|
||
| import React from "react"; | ||
| import { useEffect } from "react"; | ||
| import { useRouter } from "next/navigation"; | ||
| import { usePathname, useRouter, useSearchParams } from "next/navigation"; | ||
| import { useInView } from "react-intersection-observer"; | ||
| import { useUser } from "@/hooks/queries/user/me/useUser"; | ||
| import { userRoles } from "@/constants/userRoles"; | ||
| import ApplicantSortSection from "./components/ApplicantSortSection"; | ||
| import SearchSection from "@/app/components/layout/forms/SearchSection"; | ||
| import MyApplicationListItem from "@/app/components/card/cardList/MyApplicationListItem"; | ||
| import { useMyApplications } from "@/hooks/queries/user/me/useMyApplications"; | ||
|
|
||
| const APPLICATIONS_PER_PAGE = 10; | ||
|
|
||
| export default function ApplicantPage() { | ||
| const router = useRouter(); | ||
| const { user, isLoading } = useUser(); | ||
| const pathname = usePathname(); | ||
| const searchParams = useSearchParams(); | ||
| const { user, isLoading: isUserLoading } = useUser(); | ||
|
|
||
| // 무한 스크롤을 위한 Intersection Observer 설정 | ||
| const { ref, inView } = useInView({ | ||
| threshold: 0.1, | ||
| triggerOnce: false, | ||
| rootMargin: "100px", | ||
| }); | ||
|
|
||
| // 검색 및 정렬 상태 관리 | ||
| const status = searchParams.get("status") || undefined; | ||
| const keyword = searchParams.get("keyword") || undefined; | ||
|
|
||
| const { | ||
| data, | ||
| fetchNextPage, | ||
| hasNextPage, | ||
| isFetchingNextPage, | ||
| isLoading: isLoadingData, | ||
| error, | ||
| } = useMyApplications({ | ||
| limit: APPLICATIONS_PER_PAGE, | ||
| status, | ||
| keyword, | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| if (!isLoading) { | ||
| if (!isUserLoading) { | ||
| if (!user) { | ||
| router.push("/login"); | ||
| } else if (user.role === userRoles.OWNER) { | ||
| router.push("/myAlbaform/owner"); | ||
| } | ||
| } | ||
| }, [user, isLoading, router]); | ||
| }, [user, isUserLoading, router]); | ||
|
|
||
| // 스크롤이 하단에 도달하면 다음 페이지 로드 | ||
| useEffect(() => { | ||
| if (inView && hasNextPage && !isFetchingNextPage) { | ||
| fetchNextPage(); | ||
| } | ||
| }, [inView, hasNextPage, isFetchingNextPage, fetchNextPage]); | ||
|
|
||
| // 에러 상태 처리 | ||
| if (error) { | ||
| return ( | ||
| <div className="flex h-[calc(100vh-200px)] items-center justify-center"> | ||
| <p className="text-red-500">지원 내역을 불러오는데 실패했습니다.</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (isLoading) { | ||
| // 로딩 상태 처리 | ||
| if (isUserLoading || isLoadingData) { | ||
| return ( | ||
| <div className="flex h-[calc(100vh-200px)] items-center justify-center"> | ||
| <div>로딩 중...</div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| // 지원자용 페이지 컨텐츠 | ||
| return ( | ||
| <div> | ||
| <h1>지원자 페이지</h1> | ||
| {/* 지원자용 컨텐츠 */} | ||
| <div className="flex min-h-screen flex-col items-center"> | ||
| {/* 검색 섹션과 필터를 고정 위치로 설정 */} | ||
| <div className="fixed left-0 right-0 top-16 z-40 bg-white shadow-sm"> | ||
| {/* 검색 섹션 */} | ||
| <div className="w-full border-b border-grayscale-100"> | ||
| <div className="mx-auto flex max-w-screen-2xl flex-col gap-4 px-4 py-4 md:px-6 lg:px-8"> | ||
| <SearchSection /> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* 필터 섹션 */} | ||
| <div className="w-full border-b border-grayscale-100"> | ||
| <div className="mx-auto flex max-w-screen-2xl items-center justify-between gap-2 px-4 py-4 md:px-6 lg:px-8"> | ||
| <ApplicantSortSection pathname={pathname} searchParams={searchParams} /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* 메인 콘텐츠 영역 */} | ||
| <div className="w-full pt-[132px]"> | ||
| {!data?.pages?.[0]?.data?.length ? ( | ||
| <div className="flex h-[calc(100vh-200px)] flex-col items-center justify-center"> | ||
| <p className="text-grayscale-500">지원 내역이 없습니다.</p> | ||
| </div> | ||
| ) : ( | ||
| <div className="mx-auto mt-4 w-full max-w-screen-xl px-3"> | ||
| <div className="flex flex-wrap justify-start gap-6"> | ||
| {data?.pages.map((page) => ( | ||
| <React.Fragment key={page.nextCursor}> | ||
| {page.data.map((application) => ( | ||
| <div key={application.id}> | ||
| <MyApplicationListItem | ||
| id={application.id} | ||
| createdAt={application.createdAt} | ||
| updatedAt={application.updatedAt} | ||
| status={application.status} | ||
| resumeId={application.resumeId} | ||
| resumeName={application.resumeName} | ||
| form={application.form} | ||
| /> | ||
| </div> | ||
| ))} | ||
| </React.Fragment> | ||
| ))} | ||
| </div> | ||
|
|
||
| {/* 무한 스크롤 트리거 영역 */} | ||
| <div ref={ref} className="h-4 w-full"> | ||
| {isFetchingNextPage && ( | ||
| <div className="flex justify-center py-4"> | ||
| <div className="h-6 w-6 animate-spin rounded-full border-2 border-primary-orange-300 border-t-transparent" /> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
넵