Skip to content

Commit 69faa1e

Browse files
committed
✨ Feat: 구현 의류 삭제 알림
- 옷장 의류 삭제 시, 삭제 메세지 알림 - 로그아웃 시 로그아웃이 되지 않는 오류 해결
1 parent bfa5a43 commit 69faa1e

File tree

8 files changed

+65
-10
lines changed

8 files changed

+65
-10
lines changed

Diff for: src/routes/ClothSize.js

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ router.post('/cloth_size', async (req, res) => {
3434
)
3535

3636
const recommendedSize = aiApiResponse.data.size
37-
3837
res.json({ size: recommendedSize })
3938
} catch (error) {
4039
console.error(error)

Diff for: src/routes/Clothes.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ router.delete('/api/delete/:id', async (req, res) => {
5858
}
5959

6060
await Clothes.findByIdAndDelete(clothId)
61-
res.status(200).json({ message: 'Cloth deleted successfully' })
61+
res
62+
.status(200)
63+
.json({ message: 'Cloth deleted successfully', code: 'DELETE_DONE' })
6264
} catch (error) {
6365
res.status(400).json({ error: 'Error while deleting the cloth' })
6466
}

Diff for: style/src/api/apiConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
//export const API_URL = 'http://localhost:3000'
1+
export const API_URL = 'http://localhost:3000'
22
// 배포 시, 위 코드 주석처리 후 다음 코드로 변경
3-
export const API_URL = 'http://model-fit.kro.kr'
3+
//export const API_URL = 'http://model-fit.kro.kr'

Diff for: style/src/components/FittingPage/ButtonBar.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,19 @@ function ButtonBar({ setErrorCode, showAlert, setIsDefaultPage }) {
124124
setSelected(index)
125125
}
126126

127+
// 이미지 저장
128+
127129
return (
128130
<div className={styles.buttonContainer}>
129131
<CardButton
130-
src={saveImage}
132+
src={uploadImage}
131133
alt="upload"
132134
text="옷 링크 업로드"
133135
onClick={handleModalOpen}
134136
/>
135137
<CardButton
136-
src={uploadImage}
137-
alt="upload"
138+
src={saveImage}
139+
alt="save"
138140
text="이미지 저장"
139141
onClick={() => {}}
140142
/>

Diff for: style/src/components/FittingPage/FittingPage.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ function FittingPage() {
4343
isDefaultPage={isDefaultPage}
4444
setErrorCode={setErrorCode}
4545
showAlert={showAlert}
46-
setIsDefaultPage={setIsDefaultPage}
46+
setIsDefaultPage={setIsDefaultPage}
4747
/>
4848
<div className="empty-space" />
4949
<RightFitContainer
5050
setFittingImage={setFittingImage}
5151
setIsDefaultPage={setIsDefaultPage}
52+
setErrorCode={setErrorCode}
53+
showAlert={showAlert}
5254
/>
5355
<div className="empty-space" />
5456
</div>

Diff for: style/src/components/FittingPage/FittingPageAlert.js

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ function FittingPageAlert({ errorCode, isShowAlert, setIsShowAlert }) {
3535
setShow={setIsShowAlert}
3636
/>
3737
)}
38+
{errorCode === 'DELETE_DONE' && (
39+
<AlertMessage
40+
variant={errorCode === 'DELETE_DONE' ? 'success' : 'danger'}
41+
message={'삭제를 완료했습니다.'}
42+
show={isShowAlert}
43+
setShow={setIsShowAlert}
44+
/>
45+
)}
3846
</>
3947
)
4048
}

Diff for: style/src/components/FittingPage/RightFitContainer.js

+43-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import axios from 'axios'
1212

1313
import LoadingIndicator from '../LoadingIndicator'
1414

15-
function RightFitContainer({ setFittingImage, setIsDefaultPage }) {
15+
function RightFitContainer({
16+
setFittingImage,
17+
setIsDefaultPage,
18+
setErrorCode,
19+
showAlert,
20+
}) {
1621
const [mainMenu, setMainMenu] = useState('closet')
1722
const [subMenu1, setSubMenu1] = useState('all')
1823
const [subMenu2, setSubMenu2] = useState('all')
@@ -109,11 +114,39 @@ function RightFitContainer({ setFittingImage, setIsDefaultPage }) {
109114
`${API_URL}/cloth/api/delete/${clothId}`
110115
)
111116
fetchClothesImages()
117+
setErrorCode(response.data.code)
118+
showAlert()
112119
} catch (error) {
113120
console.error('Error deleting cloth:', error)
114121
}
115122
}
116123

124+
//사이즈 추천
125+
const handleRecommendSize = async (clothId) => {
126+
const user = JSON.parse(localStorage.getItem('user'))
127+
if (!user || !user._id) {
128+
console.error('User ID not found')
129+
return
130+
}
131+
const userId = user._id
132+
133+
try {
134+
const response = await axios.post(`${API_URL}/cloth/cloth_size`, {
135+
userId,
136+
clothId,
137+
})
138+
139+
if (response.status === 200) {
140+
const recommendedSize = response.data.size
141+
alert(`Recommended size: ${recommendedSize}`)
142+
} else {
143+
alert(`Error: ${response.statusText}`)
144+
}
145+
} catch (error) {
146+
console.error('Size Recommendation Error:', error)
147+
}
148+
}
149+
117150
return (
118151
<div className={styles.rightFitContainer}>
119152
<div className={styles.closetContainer}>
@@ -277,6 +310,7 @@ function RightFitContainer({ setFittingImage, setIsDefaultPage }) {
277310
consolea={clothes}
278311
handleFittingCloth={handleFittingCloth}
279312
handleDeleteCloth={handleDeleteCloth}
313+
handleRecommendSize={handleRecommendSize}
280314
/>
281315
))}
282316
</div>
@@ -295,6 +329,7 @@ function ClothesElement({
295329
consolea,
296330
handleFittingCloth,
297331
handleDeleteCloth,
332+
handleRecommendSize,
298333
}) {
299334
return (
300335
<div className={styles.clothesElement}>
@@ -320,9 +355,15 @@ function ClothesElement({
320355
>
321356
<FontAwesomeIcon icon={solid('shirt')} />
322357
</button>
323-
<button className={styles.sizeBtn} onClick={() => {}}>
358+
<button
359+
className={styles.sizeBtn}
360+
onClick={() => {
361+
handleRecommendSize(id)
362+
}}
363+
>
324364
<FontAwesomeIcon icon={solid('ruler-combined')} />
325365
</button>
366+
326367
<button
327368
className={styles.removeBtn}
328369
onClick={() => handleDeleteCloth(id)}

Diff for: style/src/components/User/Logout.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function Logout() {
88
const dispatch = useDispatch()
99
const handleLogout = () => {
1010
dispatch(logout())
11+
localStorage.removeItem('user')
1112
localStorage.removeItem('token')
1213
alert('정상적으로 로그아웃 되었습니다.')
1314
}

0 commit comments

Comments
 (0)