Skip to content

Commit 0e86467

Browse files
committed
Merge branch 'develop' of 2github.com:AIVLE-School-Third-Big-Project/AI_5_20
2 parents 264b8e5 + e11a600 commit 0e86467

File tree

12 files changed

+200
-52
lines changed

12 files changed

+200
-52
lines changed

src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const aiAPI = process.env.AI_API
1818

1919
const allowedOrigins = [
2020
'http://localhost:3000',
21-
'http://localhost:3001',
2221
'http://www.model-fit.kro.kr',
2322
aiAPI,
2423
]
@@ -73,6 +72,9 @@ app.use('/users', logoutRouter)
7372
const infoRouter = require('./routes/UserInfo')
7473
app.use('/userInfo', infoRouter)
7574

75+
const clothRouter = require('./routes/Clothes')
76+
app.use('/cloth', clothRouter)
77+
7678
app.get('*', (req, res) => {
7779
res.sendFile(path.join(__dirname, '../style/build/index.html'))
7880
})

src/models/Closet.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const mongoose = require('mongoose')
2+
const { Schema } = mongoose
3+
4+
const closetSchema = new Schema({
5+
userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },
6+
clothesImageLink: { type: String, required: true },
7+
fittingImageLink: { type: String, required: true },
8+
})
9+
10+
module.exports = mongoose.model('Closet', closetSchema)

src/models/User.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const userSchema = new Schema({
1616
fit: { type: String, default: '정핏' },
1717
},
1818
sizeProfile: { type: Schema.Types.ObjectId, ref: 'SizeProfile' },
19+
clothes: [{ type: Schema.Types.ObjectId, ref: 'Clothes' }],
1920
})
2021

2122
module.exports = mongoose.model('User', userSchema)

src/routes/Clothes.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const express = require('express')
2+
const router = express.Router()
3+
const Clothes = require('../models/Closet')
4+
const User = require('../models/User')
5+
6+
router.get('/api/clothes', async (req, res) => {
7+
const { userId } = req.query
8+
try {
9+
const user = await User.findById(userId)
10+
if (!user) {
11+
return res
12+
.status(404)
13+
.json({ success: false, message: 'The user was not found.' })
14+
}
15+
const clothes = await Clothes.find({ userId: userId })
16+
res.json(clothes.map((cloth) => cloth.clothesImageLink))
17+
} catch (err) {
18+
console.error(err.message)
19+
res.status(500).send('Server Error')
20+
}
21+
})
22+
23+
module.exports = router

src/routes/FittingImage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fittingApiUrl = process.env.AI_FITTING_API_URL
66

77
// 피팅 이미지 요청을 보내는 함수
88
async function sendFittingRequest(userId, clothingImageUrl) {
9-
const callbackUrl = `${webApiUrl}/api/fitting-image`
9+
const callbackUrl = `${webApiUrl}/api/fitting`
1010

1111
try {
1212
const response = await axios.post(fittingApiUrl, {

src/routes/UserInfo.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ router.get('/api/info', async (req, res) => {
3939
.status(404)
4040
.json({ success: false, message: 'The user was not found.' })
4141
}
42-
4342
res.status(201).json({ success: true, user })
4443
} catch (error) {
4544
console.error('User lookup errors :', error)

style/src/components/FittingPage.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

style/src/components/FittingPage/ButtonBar.js

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { useState } from 'react'
22

33
import CardButton from './CardButton'
44

@@ -13,13 +13,34 @@ import resetImage from '../../images/reset.png'
1313
// 각 버튼 누르면 모달창 띄워서 업로드/배경 변경 창 띄우면 좋을듯?
1414
// 원본 디자인에서 공유 버튼 필요 없을 것 같아 제외 함
1515
function ButtonBar() {
16+
// URL 입력 저장을 위한 state 생성
17+
const [imageUrl, setImageUrl] = useState('')
18+
const [isModalOpen, setIsModalOpen] = useState(false)
19+
20+
const handleInputUrl = (e) => {
21+
setImageUrl(e.target.value)
22+
}
23+
24+
// URL 업로드 버튼 클릭 이벤트 핸들러
25+
const handleUrlUploadClick = () => {
26+
// URL 크롤링 하는 함수 작성
27+
}
28+
29+
const handleModalOpen = () => {
30+
setIsModalOpen(true)
31+
}
32+
33+
const handleModalClose = () => {
34+
setIsModalOpen(false)
35+
}
36+
1637
return (
1738
<div className={styles.buttonContainer}>
1839
<CardButton
1940
src={saveImage}
20-
alt="save"
21-
text="이미지 업로드"
22-
onClick={() => {}}
41+
alt="upload"
42+
text="옷 링크 업로드"
43+
onClick={handleModalOpen}
2344
/>
2445
<CardButton
2546
src={uploadImage}
@@ -37,10 +58,32 @@ function ButtonBar() {
3758
src={resetImage}
3859
alt="reset"
3960
text="되돌리기"
40-
onClick={() => {}}
61+
onClick={getUserImage}
4162
/>
63+
{isModalOpen && (
64+
<div className={styles.modal}>
65+
<div className={styles.modalContent}>
66+
<h2>의류 올리기</h2>
67+
<input
68+
type="text"
69+
placeholder="옷 링크 입력"
70+
value={imageUrl}
71+
onChange={handleInputUrl}
72+
/>
73+
<button onClick={handleUrlUploadClick}>Upload</button>
74+
<button onClick={handleModalClose}>Close</button>
75+
</div>
76+
</div>
77+
)}
4278
</div>
4379
)
4480
}
4581

82+
async function getUserImage() {
83+
// 데이터베이스에서 유저의 이미지를 불러오는 함수를 호출
84+
//const userImage = await fetchUserImageFromDB();
85+
// 상태를 업데이트하여 이미지가 표시되는 곳에 사용자 이미지를 표시합니다.
86+
//setImageUrl(userImage);
87+
}
88+
4689
export default ButtonBar

style/src/components/FittingPage/FittingPage.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ import { useSelector } from 'react-redux'
1010

1111
import shoppingImage from '../../images/shopping-mall.png'
1212

13-
{
14-
/* {user && (
15-
<div>
16-
<h2>환영합니다, {user.email}님!</h2>
17-
</div>
18-
)} */
19-
}
2013
function FittingPage() {
2114
const user = useSelector((state) => state.auth.user)
2215

style/src/components/FittingPage/FittingPage.module.css

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,54 @@
337337
font-family: 'NanumSquare';
338338
font-size: 18px;
339339
font-weight: 600;
340-
}
340+
}
341+
342+
.modal {
343+
position: fixed;
344+
top: 0;
345+
left: 0;
346+
right: 0;
347+
bottom: 0;
348+
background-color: rgba(0, 0, 0, 0.5);
349+
display: flex;
350+
justify-content: center;
351+
align-items: center;
352+
z-index: 1000;
353+
}
354+
355+
.modalContent {
356+
background-color: white;
357+
padding: 24px;
358+
width: 100%;
359+
max-width: 400px;
360+
border-radius: 4px;
361+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
362+
}
363+
364+
.modalContent input {
365+
width: 100%;
366+
padding: 8px;
367+
display: block;
368+
border: 1px solid #ccc;
369+
border-radius: 4px;
370+
margin-bottom: 16px;
371+
}
372+
373+
.modalContent button {
374+
background-color: #007bff;
375+
border: none;
376+
color: white;
377+
padding: 8px 16px;
378+
text-align: center;
379+
text-decoration: none;
380+
display: inline-block;
381+
font-size: 14px;
382+
border-radius: 4px;
383+
cursor: pointer;
384+
margin-right: 8px;
385+
}
386+
387+
.modalContent button:last-child {
388+
background-color: #ccc;
389+
}
390+

0 commit comments

Comments
 (0)