File tree Expand file tree Collapse file tree 3 files changed +29
-21
lines changed
Expand file tree Collapse file tree 3 files changed +29
-21
lines changed Original file line number Diff line number Diff line change 77 "dev" : " vite" ,
88 "build" : " tsc -b && vite build" ,
99 "lint" : " eslint ." ,
10- "preview" : " vite preview"
10+ "preview" : " vite preview" ,
11+ "type-check" : " tsc --noEmit"
1112 },
1213 "dependencies" : {
1314 "@react-oauth/google" : " ^0.12.1" ,
Original file line number Diff line number Diff line change @@ -9,30 +9,32 @@ interface Apply {
99 updatedAt : string ;
1010}
1111
12-
1312export const useApplyList = ( track : string | null ) => {
1413 const [ applyList , setApplyList ] = useState < Apply [ ] > ( [ ] ) ;
1514 const [ loading , setLoading ] = useState ( false ) ;
1615 const [ error , setError ] = useState < string | null > ( null ) ;
1716 const accessToken = useAuthStore ( ( state ) => state . accessToken ) ;
1817
19- useEffect ( ( ) => {
20- const fetchList = async ( ) => {
21- setLoading ( true ) ;
22- setError ( null ) ;
18+ useEffect ( ( ) => {
19+ const fetchList = async ( ) => {
20+ if ( ! accessToken || ! track ) return ;
21+
22+ setLoading ( true ) ;
23+ setError ( null ) ;
24+
25+ try {
26+ const data = await fetchApplyList ( accessToken , track ) ;
27+ setApplyList ( data ) ;
28+ } catch ( err ) {
29+ setError ( "지원서 목록을 조회하는 중 오류가 발생했습니다." ) ;
30+ } finally {
31+ setLoading ( false ) ;
32+ }
33+ } ;
2334
24- try {
25- const data = await fetchApplyList ( accessToken , track ) ;
26- setApplyList ( data ) ;
27- } catch ( err ) {
28- setError ( "지원서 목록을 조회하는 중 오류가 발생했습니다." ) ;
29- } finally {
30- setLoading ( false ) ;
31- }
32- } ;
35+ fetchList ( ) ;
36+ } , [ track , accessToken ] ) ;
3337
34- fetchList ( ) ;
35- } , [ track , accessToken ] ) ;
3638
3739 return { applyList, loading, error } ;
38- } ;
40+ } ;
Original file line number Diff line number Diff line change 11import apiConfig from "../config/apiConfig" ;
22import { Application } from "../types/application" ;
33
4+ interface ApiResponse < T > {
5+ status : number ;
6+ message : string ;
7+ data : T ;
8+ }
9+
410export const fetchApplications = async ( track ?: string ) : Promise < Application [ ] > => {
511 try {
6- const response = await apiConfig . get < Application [ ] > ( "/admin/apply" , {
12+ const response = await apiConfig . get < ApiResponse < Application [ ] > > ( "/admin/apply" , {
713 headers : {
814 Authorization : `Bearer ${ localStorage . getItem ( "accessToken" ) } ` ,
915 Accept : "application/json" ,
1016 } ,
1117 params : track ? { track } : { } ,
1218 } ) ;
1319
14- return response . data . data ; // data 속성 내부 배열만 반환하는 것으로 수정했는데 'Application[]' 형식에 'data' 속성이 없다는 오류 발생.
20+ return response . data . data ;
1521 } catch ( error : any ) {
1622 throw new Error ( error . response ?. data ?. message || "지원서 목록 조회 실패" ) ;
1723 }
1824} ;
19-
You can’t perform that action at this time.
0 commit comments