1
- import styled from "styled-components"
2
- import { VolunteerHeader } from "../../components/Volunteer/Header" ;
3
- import { ApplicationHistory } from "../../components/Volunteer/ApplicationHistory" ;
4
- import { useEffect , useState } from "react" ;
5
- import { Explain , Text } from "./Application" ;
6
- import { getMyVolunteers } from "../../apis/volunteers" ;
7
- import { useLocation } from "react-router-dom" ;
1
+ import styled from 'styled-components' ;
2
+ import { VolunteerHeader } from '../../components/Volunteer/Header' ;
3
+ import { ApplicationHistory } from '../../components/Volunteer/ApplicationHistory' ;
4
+ import { useEffect , useState } from 'react' ;
5
+ import { Explain , Text } from './Application' ;
6
+ import { getMyVolunteers } from '../../apis/volunteers' ;
7
+ import { useLocation } from 'react-router-dom' ;
8
+ import axios from 'axios' ;
8
9
9
10
enum THEME {
10
- 'LIGHT' = 'LIGHT' ,
11
- 'DARK' = 'DARK' ,
11
+ 'LIGHT' = 'LIGHT' ,
12
+ 'DARK' = 'DARK' ,
12
13
}
13
14
14
15
export const VolunteerHistory = ( ) => {
15
- const [ histories , setHistories ] = useState < any [ ] > ( [ ] ) ;
16
- const location = useLocation ( ) ;
17
- const initTheme = new URLSearchParams ( location . search ) ;
18
- const [ userTheme ] = useState < THEME > (
19
- initTheme . get ( 'theme' ) === 'dark' ? THEME . DARK : THEME . LIGHT ,
20
- )
16
+ const [ histories , setHistories ] = useState < any [ ] > ( [ ] ) ;
17
+ const location = useLocation ( ) ;
18
+ const initTheme = new URLSearchParams ( location . search ) ;
19
+ const [ userTheme ] = useState < THEME > (
20
+ initTheme . get ( 'theme' ) === 'dark' ? THEME . DARK : THEME . LIGHT ,
21
+ ) ;
21
22
22
- useEffect ( ( ) => {
23
- getMyVolunteers ( )
24
- . then ( response => {
25
- setHistories ( response . volunteer_applications || [ ] ) ;
26
- } )
27
- . catch ( error => {
28
- console . error ( '봉사 신청 내역을 가져오는 중 오류가 발생했습니다:' , error ) ;
29
- } )
30
- } , [ ] )
23
+ useEffect ( ( ) => {
24
+ getMyVolunteers ( )
25
+ . then ( ( response ) => {
26
+ setHistories ( response . volunteer_applications || [ ] ) ;
27
+ } )
28
+ . catch ( ( error ) => {
29
+ if ( axios . isAxiosError ( error ) ) {
30
+ console . error ( '에러 메시지:' , error . message ) ;
31
+ console . error ( '응답 데이터:' , error . response ?. data ) ;
32
+ console . error ( '상태 코드:' , error . response ?. status ) ;
33
+ } else {
34
+ console . error ( '알 수 없는 에러:' , error ) ;
35
+ }
36
+ } ) ;
37
+ } , [ ] ) ;
31
38
32
- return (
33
- < Wrapper >
34
- < VolunteerHeader />
35
- < ContentWrapper Theme = { userTheme } >
36
- { histories . length > 0 ? (
37
- < ContentContainer >
38
- { histories . map ( ( history ) => (
39
- < ApplicationHistory
40
- key = { history . id }
41
- name = { history . name }
42
- status = { history . status }
43
- volunteerId = { history . volunteer_id }
44
- />
45
- ) ) }
46
- </ ContentContainer >
47
- ) : (
48
- < TextWrapper >
49
- < Text Theme = { userTheme } > 신청 내역이 없습니다.</ Text >
50
- < Explain Theme = { userTheme } > 신청 내역은 이곳에서 확인할 수 있어요.</ Explain >
51
- </ TextWrapper >
52
- ) }
53
- </ ContentWrapper >
54
- </ Wrapper >
55
- )
56
- }
39
+ return (
40
+ < Wrapper >
41
+ < VolunteerHeader />
42
+ < ContentWrapper Theme = { userTheme } >
43
+ { histories . length > 0 ? (
44
+ < ContentContainer >
45
+ { histories . map ( ( history ) => (
46
+ < ApplicationHistory
47
+ key = { history . id }
48
+ name = { history . name }
49
+ status = { history . status }
50
+ volunteerId = { history . volunteer_id }
51
+ />
52
+ ) ) }
53
+ </ ContentContainer >
54
+ ) : (
55
+ < TextWrapper >
56
+ < Text Theme = { userTheme } > 신청 내역이 없습니다.</ Text >
57
+ < Explain Theme = { userTheme } >
58
+ 신청 내역은 이곳에서 확인할 수 있어요.
59
+ </ Explain >
60
+ </ TextWrapper >
61
+ ) }
62
+ </ ContentWrapper >
63
+ </ Wrapper >
64
+ ) ;
65
+ } ;
57
66
58
67
const Wrapper = styled . div `
59
- width: 100vw;
60
- display: flex;
61
- flex-direction: column;
62
- align-items: center;
63
-
68
+ width: 100vw;
69
+ display: flex;
70
+ flex-direction: column;
71
+ align-items: center;
64
72
` ;
65
73
66
- const ContentWrapper = styled . div < { Theme : THEME } > `
67
- width: 100%;
68
- min-height: 100vh;
69
- background-color: ${ ( { Theme} ) => Theme === THEME . LIGHT ? '#F2F2F7' : '#242424' } ;
74
+ const ContentWrapper = styled . div < { Theme : THEME } > `
75
+ width: 100%;
76
+ min-height: 100vh;
77
+ background-color: ${ ( { Theme } ) =>
78
+ Theme === THEME . LIGHT ? '#F2F2F7' : '#242424' } ;
70
79
` ;
71
80
72
81
const ContentContainer = styled . div `
73
- margin-top: 119px;
74
- gap: 12px;
75
- display: flex;
76
- flex-direction: column;
77
- align-items: center;
78
- margin-bottom: 24px;
79
- padding-left: 20px;
80
- padding-right: 20px;
81
- width: 100%;
82
+ margin-top: 119px;
83
+ gap: 12px;
84
+ display: flex;
85
+ flex-direction: column;
86
+ align-items: center;
87
+ margin-bottom: 24px;
88
+ padding-left: 20px;
89
+ padding-right: 20px;
90
+ width: 100%;
82
91
` ;
83
92
84
93
const TextWrapper = styled . div `
85
- display: flex;
86
- align-items: center;
87
- flex-direction: column;
88
- gap: 7px;
89
- margin-top: 400px;
90
- ` ;
94
+ display: flex;
95
+ align-items: center;
96
+ flex-direction: column;
97
+ gap: 7px;
98
+ margin-top: 400px;
99
+ ` ;
0 commit comments