File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,9 @@ const ListContainer = styled.div`
15
15
16
16
function ShoppingList ( { hideButtons } ) {
17
17
const navigate = useNavigate ( ) ;
18
+ const { token } = useUser ( ) ;
18
19
const [ items , setItems ] = useState ( [ ] ) ;
19
20
const [ isLoading , setIsLoading ] = useState ( true ) ;
20
- const token = useUser ( ) ;
21
21
22
22
useEffect ( ( ) => {
23
23
const fetchShoppingList = async ( ) => {
@@ -30,6 +30,7 @@ function ShoppingList({ hideButtons }) {
30
30
"Content-Type" : "application/json" ,
31
31
Authorization : `Bearer ${ token } ` ,
32
32
} ,
33
+ credentials : "include" ,
33
34
}
34
35
) ;
35
36
@@ -46,7 +47,9 @@ function ShoppingList({ hideButtons }) {
46
47
}
47
48
} ;
48
49
49
- fetchShoppingList ( ) ;
50
+ if ( token ) {
51
+ fetchShoppingList ( ) ;
52
+ }
50
53
} , [ token ] ) ;
51
54
52
55
const handleDragEnd = ( result ) => {
@@ -90,7 +93,7 @@ function ShoppingList({ hideButtons }) {
90
93
alert ( "장바구니가 저장되었습니다." ) ;
91
94
} catch ( error ) {
92
95
console . error ( "저장 실패:" , error ) ;
93
- alert ( "저장에 실패했습니다. 다시 시도해주세요 ." ) ;
96
+ alert ( "저장에 실패했습니다. 다시 시도해주��요 ." ) ;
94
97
}
95
98
} ;
96
99
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ const MyPageForm = styled.form`
27
27
` ;
28
28
29
29
function MyPage ( ) {
30
- const { logout, token, user, setUser } = useUser ( ) ;
30
+ const { logout, token, user } = useUser ( ) ;
31
31
const navigate = useNavigate ( ) ;
32
32
const [ name , setName ] = useState ( user ?. name || "" ) ;
33
33
@@ -52,10 +52,9 @@ function MyPage() {
52
52
if ( response . ok ) {
53
53
const updatedUser = { ...user , name : name } ;
54
54
localStorage . setItem ( "user" , JSON . stringify ( updatedUser ) ) ;
55
- setUser ( updatedUser ) ;
56
55
57
56
alert ( "닉네임이 성공적으로 변경되었습니다." ) ;
58
- navigate ( "/" ) ;
57
+ window . location . href = "/" ;
59
58
} else {
60
59
const errorData = await response . json ( ) ;
61
60
throw new Error ( errorData . message ) ;
You can’t perform that action at this time.
0 commit comments