From 73824a28d7b8e146a7f56331b31b2fc05478f5d5 Mon Sep 17 00:00:00 2001 From: pwc2002 Date: Fri, 12 Sep 2025 16:59:37 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=97=90=20=ED=85=8C=EC=9D=B4=EB=B8=94=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20API=20=ED=98=B8=EC=B6=9C=20=EC=8B=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=A7=A4?= =?UTF-8?q?=ED=95=91=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/page.jsx | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/app/admin/page.jsx b/src/app/admin/page.jsx index d9b708a..8b7903e 100644 --- a/src/app/admin/page.jsx +++ b/src/app/admin/page.jsx @@ -13,9 +13,9 @@ import AdminDashboard from '@/components/admin/AdminDashboard'; import { useAuthenticatedApi } from '@/hooks/useAuthenticatedApi'; const columns = [ - { name: 'NAME', uid: 'name' }, - { name: 'MAJOR / ID', uid: 'major' }, - { name: 'PAYMENT', uid: 'isPayed' }, + { name: 'NAME', uid: 'name', sortable: true }, + { name: 'MAJOR / ID', uid: 'major', sortable: true }, + { name: 'PAYMENT', uid: 'isPayed', sortable: true }, { name: 'TOGGLE', uid: 'togglePay' }, ]; @@ -42,6 +42,10 @@ export default function Page() { const [statsTotal, setStatsTotal] = React.useState(0); const [statsLoading, setStatsLoading] = React.useState(false); const [statsError, setStatsError] = React.useState(''); + const [sortDescriptor, setSortDescriptor] = React.useState({ + column: 'createdAt', + direction: 'descending', + }); const rowsPerPage = 10; //한 페이지당 표시될 유저 수 @@ -50,11 +54,22 @@ export default function Page() { setLoading(true); setError(''); try { + // 정렬 컬럼 매핑 (프론트엔드 컬럼명 -> API 파라미터명) + const sortColumnMap = { + 'isPayed': 'isPayed', + 'name': 'name', + 'major': 'major', + 'createdAt': 'createdAt', + }; + + const apiSortColumn = sortColumnMap[sortDescriptor.column] || 'createdAt'; + const apiSortDirection = sortDescriptor.direction === 'ascending' ? 'ASC' : 'DESC'; + const params = { page: page - 1, size: rowsPerPage, - sort: 'createdAt', - dir: 'DESC', + sort: apiSortColumn, + dir: apiSortDirection, question: query || undefined, }; const res = await apiClient.get('/recruit/members', { params }); @@ -72,7 +87,7 @@ export default function Page() { } finally { setLoading(false); } - }, [apiClient, page, rowsPerPage, query]); + }, [apiClient, page, rowsPerPage, query, sortDescriptor]); // 통계용 전체 멤버 데이터 조회 (페이지네이션 병렬 수집) const fetchAllUsersForStats = useCallback(async () => { @@ -215,6 +230,8 @@ export default function Page() { {column.name}