@@ -5,14 +5,14 @@ import clsx from "clsx";
55import Link from "next/link" ;
66import { useRouter } from "next/navigation" ;
77import { type ReactNode , useEffect , useMemo , useState } from "react" ;
8- import { useGetApplicationsList , useGetCompetitors } from "@/apis/applications" ;
8+ import { useGetApplicationsList } from "@/apis/applications" ;
99import CloudSpinnerPage from "@/components/ui/CloudSpinnerPage" ;
1010import { DEFAULT_MAX_CHOICE_COUNT , getHomeUniversityById , REGIONS_KO } from "@/constants/university" ;
1111import { SKIP_GLOBAL_ERROR_TOAST_META } from "@/lib/react-query/errorToastMeta" ;
1212import useAuthStore from "@/lib/zustand/useAuthStore" ;
1313import { IconExpandMoreFilled } from "@/public/svgs/community" ;
1414import type { Applicant , ScoreSheet as ScoreSheetType } from "@/types/application" ;
15- import { type RegionKo , regionMapping } from "@/types/university" ;
15+ import type { RegionKo } from "@/types/university" ;
1616import { getApplicationDetailHref , MobileScoreSheet , ScoreSheetLogo } from "../ScoreSheet" ;
1717
1818type ApplicationAccessErrorCode = "APPLICATION_NOT_FOUND" | "APPLICATION_NOT_APPROVED" ;
@@ -46,7 +46,7 @@ type ScorePageViewProps = {
4646 displayedScoreSheets : ScoreSheetType [ ] ;
4747 totalUniversityCount : number ;
4848 applicantUniversityCount : number ;
49- participantCount : number | null ;
49+ participantCount : number ;
5050 scope : ApplicantScope ;
5151 regionFilter : RegionKo | "" ;
5252 sortMode : ScoreSort ;
@@ -68,20 +68,19 @@ const ApprovedApplicationStatusPage = () => {
6868 ( ) => Array . from ( { length : maxChoiceCount } , ( ) => [ ] as ScoreSheetType [ ] ) ,
6969 [ maxChoiceCount ] ,
7070 ) ;
71- const applicantSearchParams = useMemo (
72- ( ) => ( { region : regionFilter ? ( regionMapping [ regionFilter ] ?? undefined ) : undefined } ) ,
73- [ regionFilter ] ,
74- ) ;
71+ /**
72+ * 모의지원 기간에는 내가 지원한 대학의 경쟁자만(useGetCompetitors ),
73+ * 기간이 끝나면 소속 대학의 전체 지원자 현황(useGetApplicationsList)을 보여준다.
74+ */
7575 const {
7676 data : scoreResponseData ,
7777 isError,
7878 isLoading,
7979 error,
8080 refetch,
81- } = useGetCompetitors ( {
81+ } = useGetApplicationsList ( undefined , {
8282 meta : SKIP_GLOBAL_ERROR_TOAST_META ,
8383 } ) ;
84- const { data : applicantResponseData } = useGetApplicationsList ( applicantSearchParams ) ;
8584 const scoreChoices = scoreResponseData ?. choices ?? emptyChoices ;
8685 const isApplicationMissingOrUnapproved = isApplicationAccessError ( error ) ;
8786
@@ -92,23 +91,24 @@ const ApprovedApplicationStatusPage = () => {
9291 ) ;
9392 const totalUniversityCount = allScoreSheets . length ;
9493 const applicantUniversityCount = allScoreSheets . filter ( ( scoreSheet ) => scoreSheet . applicants . length > 0 ) . length ;
95- const participantCount = useMemo (
96- ( ) => ( applicantResponseData ? getParticipantCount ( applicantResponseData . choices . flat ( ) ) : null ) ,
97- [ applicantResponseData ] ,
94+ /**
95+ * 지역 칩은 서버 파라미터 대신 클라이언트에서 건다.
96+ * GET /applications 에 region 을 넘기면 choices 자체가 걸러져서 "지원한 대학" 목록까지 해당 권역만 남는다.
97+ */
98+ const regionScopedScoreSheets = useMemo (
99+ ( ) => ( regionFilter ? allScoreSheets . filter ( ( scoreSheet ) => scoreSheet . region === regionFilter ) : allScoreSheets ) ,
100+ [ allScoreSheets , regionFilter ] ,
98101 ) ;
102+ const participantCount = useMemo ( ( ) => getParticipantCount ( regionScopedScoreSheets ) , [ regionScopedScoreSheets ] ) ;
99103
100104 const displayedScoreSheets = useMemo ( ( ) => {
101- let result =
105+ const result =
102106 scope === "withApplicants"
103- ? allScoreSheets . filter ( ( scoreSheet ) => scoreSheet . applicants . length > 0 )
104- : allScoreSheets ;
105-
106- if ( regionFilter ) {
107- result = result . filter ( ( scoreSheet ) => scoreSheet . region === regionFilter ) ;
108- }
107+ ? regionScopedScoreSheets . filter ( ( scoreSheet ) => scoreSheet . applicants . length > 0 )
108+ : regionScopedScoreSheets ;
109109
110110 return sortScoreSheets ( result , sortMode ) ;
111- } , [ allScoreSheets , regionFilter , scope , sortMode ] ) ;
111+ } , [ regionScopedScoreSheets , scope , sortMode ] ) ;
112112
113113 useEffect (
114114 function redirectToApplyWhenApplicationMissing ( ) {
@@ -251,19 +251,15 @@ const AppliedUniversityRow = ({ preference, scoreSheet }: AppliedUniversity) =>
251251 ) ;
252252} ;
253253
254- const ParticipantBanner = ( { participantCount } : { participantCount : number | null } ) => (
254+ const ParticipantBanner = ( { participantCount } : { participantCount : number } ) => (
255255 < section className = "mt-6 rounded-lg bg-secondary-100 px-5 py-3" >
256256 < div className = "flex items-center gap-4" >
257257 < div className = "flex size-10 items-center justify-center text-[34px]" aria-hidden >
258258 🔥
259259 </ div >
260260 < div className = "min-w-0 text-k-800" >
261261 < p className = "typo-regular-4" > 솔리드 커넥션과 함께하고 있어요</ p >
262- < p className = "mt-0.5 typo-sb-9" >
263- { participantCount === null
264- ? "지원자 수를 불러오는 중이에요."
265- : `총 ${ participantCount } 명이 성적 공유 참여중!` }
266- </ p >
262+ < p className = "mt-0.5 typo-sb-9" > 총 { participantCount } 명이 성적 공유 참여중!</ p >
267263 </ div >
268264 </ div >
269265 </ section >
0 commit comments