diff --git a/src/pages/employer/shops/[shopId]/notices/[noticeId]/index.tsx b/src/pages/employer/shops/[shopId]/notices/[noticeId]/index.tsx index b290953..ffee448 100644 --- a/src/pages/employer/shops/[shopId]/notices/[noticeId]/index.tsx +++ b/src/pages/employer/shops/[shopId]/notices/[noticeId]/index.tsx @@ -88,9 +88,7 @@ export const getServerSideProps: GetServerSideProps<{ notice: NoticeCard }> = as const noticeRes = await axiosInstance.get(`shops/${shopId}/notices/${noticeId}`); return { props: { notice: toNoticeCard(noticeRes.data) } }; } catch { - return { - notFound: true, - }; + return { notFound: true }; } }; @@ -98,6 +96,7 @@ const EmployerNoticeDetailPage = ({ notice }: { notice: NoticeCard }) => { const headers = ['신청자', '소개', '전화번호', '상태']; const [data, setData] = useState([]); const [offset, setOffset] = useState(0); + const [total, setTotal] = useState(0); // ✅ 전체 개수 const limit = 5; const { role, isLogin, user } = useAuth(); @@ -109,7 +108,6 @@ const EmployerNoticeDetailPage = ({ notice }: { notice: NoticeCard }) => { const isOwner = user?.shop?.item.id === notice.shopId; const canEdit = useMemo(() => status === 'open' && isOwner, [status, isOwner]); - // 공고 편집하기 const handleEditClick = useCallback(() => { if (!canEdit) return; @@ -149,14 +147,17 @@ const EmployerNoticeDetailPage = ({ notice }: { notice: NoticeCard }) => { router.push(`/employer/shops/${notice.shopId}/notices/${notice.id}/edit`); }, [canEdit, isLogin, role, user, notice, router]); - // 신청자 불러오기 - + // 신청자 불러오기 (페이지네이션) useEffect(() => { const fetchApplications = async () => { - const res = await axiosInstance.get<{ items: ApplicationTableApiResponse[] }>( - `/shops/${notice.shopId}/notices/${notice.id}/applications`, - { params: { offset, limit } } - ); + const res = await axiosInstance.get<{ + items: ApplicationTableApiResponse[]; + total?: number; + count?: number; + hasNext?: boolean; + }>(`/shops/${notice.shopId}/notices/${notice.id}/applications`, { + params: { offset, limit }, + }); const tableData: TableRowProps[] = res.data.items.map(app => { const userItem = app.item.user?.item; @@ -180,11 +181,24 @@ const EmployerNoticeDetailPage = ({ notice }: { notice: NoticeCard }) => { }); setData(tableData); + + // total 적용 + const apiTotal = res.data.total ?? res.data.count; + if (typeof apiTotal === 'number') { + setTotal(apiTotal); + } else { + const hasNext = res.data.hasNext ?? tableData.length === limit; + const guessed = offset + tableData.length + (hasNext ? 1 : 0); + setTotal(guessed); + } }; fetchApplications(); }, [notice.shopId, notice.id, offset, limit]); + // 첫 페이지에서도 페이지네이션 보이도록 표시용 offset + const displayOffset = total > limit ? (offset === 0 ? 2 : offset) : offset; + return ( <> @@ -209,14 +223,15 @@ const EmployerNoticeDetailPage = ({ notice }: { notice: NoticeCard }) => { onSecondary={modal?.onSecondary} /> + setData(prev => prev.map(row => (row.id === id ? { ...row, status: newStatus } : row))) diff --git a/src/pages/my-profile/index.tsx b/src/pages/my-profile/index.tsx index 9f34141..60b531b 100644 --- a/src/pages/my-profile/index.tsx +++ b/src/pages/my-profile/index.tsx @@ -80,7 +80,7 @@ export default function MyProfileDetailPage() { const currentTotal = rows.length > 0 ? applications.length : stableTotal; const pagedRows = useMemo(() => currentRows.slice(offset, offset + limit), [currentRows, offset]); - + const displayOffset = currentTotal > limit ? (offset === 0 ? 2 : offset) : offset; return ( <> {/* ───────────────── 상단 영역 ───────────────── */} @@ -197,7 +197,7 @@ export default function MyProfileDetailPage() { userRole={userType} total={currentTotal} limit={limit} - offset={offset} + offset={displayOffset} onPageChange={setOffset} onStatusUpdate={() => {}} // ✅ 이 페이지에서는 상태 변경 없음(필수 prop 무해한 no-op) /> diff --git a/src/pages/my-profile/register.tsx b/src/pages/my-profile/register.tsx index 4e5db9a..ad5f6f3 100644 --- a/src/pages/my-profile/register.tsx +++ b/src/pages/my-profile/register.tsx @@ -153,7 +153,7 @@ export default function MyProfileRegisterPage() { {/* 선호 지역 */}
name='region'