-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from UMC-FITple/feat/#141
Feat/#141 옷장 삭제 구현하기
- Loading branch information
Showing
9 changed files
with
90 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,37 @@ | ||
const API_BASE_URL = 'http://localhost:3000'; | ||
const API_BASE_URL = "http://localhost:3000"; | ||
|
||
export const submitUserInfo = async (data, imageFile) => { | ||
const formData = new FormData(); | ||
formData.append('data', JSON.stringify(data)); | ||
|
||
if (imageFile) { | ||
formData.append('image', imageFile); | ||
const formData = new FormData(); | ||
formData.append("data", JSON.stringify(data)); | ||
|
||
if (imageFile) { | ||
formData.append("image", imageFile); | ||
} | ||
|
||
try { | ||
const response = await fetch(`${API_BASE_URL}/FITple/myprofile`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "multipart/form-data", | ||
}, | ||
body: formData, | ||
credentials: "include", | ||
}); | ||
|
||
if (!response.status === 200) { | ||
if (response.status === 407) { | ||
console.error("이미 존재하는 닉네임입니다."); | ||
} | ||
throw new Error(`Network response was not ok: ${response.status}`); | ||
} | ||
|
||
try { | ||
const response = await fetch(`${API_BASE_URL}/FITple/myprofile`, { | ||
method: 'POST', | ||
headers: { | ||
"Content-Type": "multipart/form-data", | ||
}, | ||
body: formData, | ||
credentials: 'include', | ||
}); | ||
|
||
if (!response.status === 200) { | ||
if (response.status === 407) { | ||
console.error('이미 존재하는 닉네임입니다.'); | ||
} | ||
throw new Error(`Network response was not ok: ${response.status}`); | ||
} | ||
const responseData = await response.json(); | ||
console.log("submit User Info!"); | ||
console.log(responseData); | ||
|
||
const responseData = await response.json(); | ||
console.log('submit User Info!'); | ||
console.log(responseData); | ||
|
||
return response; | ||
} catch (error) { | ||
console.error('Error:', error); | ||
throw error; | ||
} | ||
return response; | ||
} catch (error) { | ||
console.error("Error:", error); | ||
throw error; | ||
} | ||
}; | ||
|
||
|
||
// // 임시 토큰 발급 함수 | ||
// const fetchToken = async () => { | ||
// try { | ||
// const response = await fetch(`${API_BASE_URL}/temp-token`, { | ||
// method: 'POST', | ||
// headers: { | ||
// 'Content-Type': 'application/json', | ||
// }, | ||
// credentials: "include", | ||
// body: JSON.stringify({ | ||
// // 필요한 경우 바디 데이터를 추가 | ||
// }), | ||
// }); | ||
|
||
// if (!response.ok) { | ||
// throw new Error('Failed to fetch token'); | ||
// } | ||
|
||
// const data = await response.json(); | ||
// return data.token; | ||
// } catch (error) { | ||
// console.error('Error fetching token:', error); | ||
// throw error; | ||
// } | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
import { create } from "zustand"; | ||
import { persist } from "zustand/middleware"; | ||
|
||
const useAuthStore = create((set) => ({ | ||
token: localStorage.getItem("token") || null, // Rehydrate token from localStorage | ||
authenticate: false, | ||
setToken: (newToken) => { | ||
localStorage.setItem("token", newToken); | ||
set({ token: newToken }); | ||
}, | ||
setAuthenticate: (state) => { | ||
set({ authenticate: state }); | ||
}, | ||
// const useAuthStore = create((set) => ({ | ||
// authenticate: false, | ||
// setAuthenticate: (state) => { | ||
// set({ authenticate: state }); | ||
// }, | ||
|
||
clearToken: () => { | ||
localStorage.removeItem("token"); | ||
set({ token: null }); | ||
}, | ||
})); | ||
// clearToken: () => { | ||
// localStorage.removeItem("token"); | ||
// set({ token: null }); | ||
// }, | ||
// })); | ||
|
||
export default useAuthStore; | ||
// zustand persist을 이용해서 로그인 상태를 로컬 스토리지 같은 공간에 저장한다. | ||
const userAuthStore = create( | ||
persist( | ||
(set, get) => ({ | ||
authenticate: false, | ||
setAuthenticate: (state) => { | ||
set({ authenticate: state }); | ||
}, | ||
|
||
clearToken: () => { | ||
localStorage.removeItem("token"); | ||
set({ token: null }); | ||
}, | ||
}), | ||
{ | ||
name: "useAuthStorage", | ||
} | ||
) | ||
); | ||
|
||
export default userAuthStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters