@@ -13,9 +13,9 @@ import AdminDashboard from '@/components/admin/AdminDashboard';
1313import { useAuthenticatedApi } from '@/hooks/useAuthenticatedApi' ;
1414
1515const columns = [
16- { name : 'NAME' , uid : 'name' } ,
17- { name : 'MAJOR / ID' , uid : 'major' } ,
18- { name : 'PAYMENT' , uid : 'isPayed' } ,
16+ { name : 'NAME' , uid : 'name' , sortable : true } ,
17+ { name : 'MAJOR / ID' , uid : 'major' , sortable : true } ,
18+ { name : 'PAYMENT' , uid : 'isPayed' , sortable : true } ,
1919 { name : 'TOGGLE' , uid : 'togglePay' } ,
2020] ;
2121
@@ -42,6 +42,10 @@ export default function Page() {
4242 const [ statsTotal , setStatsTotal ] = React . useState ( 0 ) ;
4343 const [ statsLoading , setStatsLoading ] = React . useState ( false ) ;
4444 const [ statsError , setStatsError ] = React . useState ( '' ) ;
45+ const [ sortDescriptor , setSortDescriptor ] = React . useState ( {
46+ column : 'createdAt' ,
47+ direction : 'descending' ,
48+ } ) ;
4549
4650 const rowsPerPage = 10 ; //한 페이지당 표시될 유저 수
4751
@@ -50,11 +54,22 @@ export default function Page() {
5054 setLoading ( true ) ;
5155 setError ( '' ) ;
5256 try {
57+ // 정렬 컬럼 매핑 (프론트엔드 컬럼명 -> API 파라미터명)
58+ const sortColumnMap = {
59+ 'isPayed' : 'isPayed' ,
60+ 'name' : 'name' ,
61+ 'major' : 'major' ,
62+ 'createdAt' : 'createdAt' ,
63+ } ;
64+
65+ const apiSortColumn = sortColumnMap [ sortDescriptor . column ] || 'createdAt' ;
66+ const apiSortDirection = sortDescriptor . direction === 'ascending' ? 'ASC' : 'DESC' ;
67+
5368 const params = {
5469 page : page - 1 ,
5570 size : rowsPerPage ,
56- sort : 'createdAt' ,
57- dir : 'DESC' ,
71+ sort : apiSortColumn ,
72+ dir : apiSortDirection ,
5873 question : query || undefined ,
5974 } ;
6075 const res = await apiClient . get ( '/recruit/members' , { params } ) ;
@@ -72,7 +87,7 @@ export default function Page() {
7287 } finally {
7388 setLoading ( false ) ;
7489 }
75- } , [ apiClient , page , rowsPerPage , query ] ) ;
90+ } , [ apiClient , page , rowsPerPage , query , sortDescriptor ] ) ;
7691
7792 // 통계용 전체 멤버 데이터 조회 (페이지네이션 병렬 수집)
7893 const fetchAllUsersForStats = useCallback ( async ( ) => {
@@ -215,6 +230,8 @@ export default function Page() {
215230 < Table
216231 className = 'dark text-white py-[30px] px-[96px] mobile:px-[10px]'
217232 aria-label = 'Example table with custom cells'
233+ sortDescriptor = { sortDescriptor }
234+ onSortChange = { setSortDescriptor }
218235 bottomContent = {
219236 < div className = 'relative' >
220237 < AdminTableBottomContent
@@ -235,6 +252,7 @@ export default function Page() {
235252 key = { column . uid }
236253 align = { [ 'actions' , 'togglePay' ] . includes ( column . uid ) ? 'center' : 'start' }
237254 className = { column . uid === 'togglePay' ? 'text-center' : '' }
255+ allowsSorting = { column . sortable }
238256 >
239257 { column . name }
240258 </ TableColumn >
0 commit comments