Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
shopping-mall
Commits
58d63a89
Commit
58d63a89
authored
Jan 15, 2021
by
kusang96
Browse files
Merge remote-tracking branch 'origin/jaeyeon' into ourMaster
parents
c932e6d2
1dca5038
Changes
7
Show whitespace changes
Inline
Side-by-side
client/src/Components/ListCard.js
View file @
58d63a89
...
...
@@ -12,6 +12,8 @@ function ListCard({ id, name, price, main_img }) {
<
/Card.Body
>
<
/Card
>
)
}
}
export
default
ListCard
\ No newline at end of file
client/src/Pages/Home.js
View file @
58d63a89
...
...
@@ -43,42 +43,42 @@ function Home() {
<
h2
style
=
{{
marginRight
:
"
5rem
"
,
marginLeft
:
"
3rem
"
,
marginBottom
:
"
2rem
"
,
marginTop
:
"
2rem
"
}}
><
u
>
New
Arrival
<
/u></
h2
>
<
Row
className
=
"
justify-content-center mx-0
"
>
<
Card
className
=
"
mx-1 my-2
"
style
=
{{
width
:
'
18rem
'
}}
>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
icon/asd.jpg
"
/>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
/
icon/asd.jpg
"
/>
<
Card
.
Body
>
<
Card
.
Title
className
=
"
font-weight-bold
"
>
제품명
<
/Card.Title
>
<
Card
.
Text
>
가격
<
/Card.Text
>
<
/Card.Body
>
<
/Card
>
<
Card
className
=
"
mx-1 my-2
"
style
=
{{
width
:
'
18rem
'
}}
>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
icon/asd.jpg
"
/>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
/
icon/asd.jpg
"
/>
<
Card
.
Body
>
<
Card
.
Title
className
=
"
font-weight-bold
"
>
제품명
<
/Card.Title
>
<
Card
.
Text
>
가격
<
/Card.Text
>
<
/Card.Body
>
<
/Card
>
<
Card
className
=
"
mx-1 my-2
"
style
=
{{
width
:
'
18rem
'
}}
>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
icon/asd.jpg
"
/>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
/
icon/asd.jpg
"
/>
<
Card
.
Body
>
<
Card
.
Title
className
=
"
font-weight-bold
"
>
제품명
<
/Card.Title
>
<
Card
.
Text
>
가격
<
/Card.Text
>
<
/Card.Body
>
<
/Card
>
<
Card
className
=
"
mx-1 my-2
"
style
=
{{
width
:
'
18rem
'
}}
>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
icon/asd.jpg
"
/>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
/
icon/asd.jpg
"
/>
<
Card
.
Body
>
<
Card
.
Title
className
=
"
font-weight-bold
"
>
제품명
<
/Card.Title
>
<
Card
.
Text
>
가격
<
/Card.Text
>
<
/Card.Body
>
<
/Card
>
<
Card
className
=
"
mx-1 my-2
"
style
=
{{
width
:
'
18rem
'
}}
>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
icon/asd.jpg
"
/>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
/
icon/asd.jpg
"
/>
<
Card
.
Body
>
<
Card
.
Title
className
=
"
font-weight-bold
"
>
제품명
<
/Card.Title
>
<
Card
.
Text
>
가격
<
/Card.Text
>
<
/Card.Body
>
<
/Card
>
<
Card
className
=
"
mx-1 my-2
"
style
=
{{
width
:
'
18rem
'
}}
>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
icon/asd.jpg
"
/>
<
Card
.
Img
className
=
"
img-fluid
"
variant
=
"
top
"
src
=
"
/
icon/asd.jpg
"
/>
<
Card
.
Body
>
<
Card
.
Title
className
=
"
font-weight-bold
"
>
제품명
<
/Card.Title
>
<
Card
.
Text
>
가격
<
/Card.Text
>
...
...
client/src/Pages/ProductRegist.js
View file @
58d63a89
...
...
@@ -33,7 +33,7 @@ function ProductsRegist() {
useEffect
(
async
()
=>
{
try
{
const
response
=
await
axios
.
get
(
'
/api/categories
'
)
const
response
=
await
axios
.
get
(
'
/api/categories
/main
'
)
const
data
=
response
.
data
[
0
]
setCategories
([
Object
.
keys
(
data
),
Object
.
values
(
data
)])
}
catch
(
error
)
{
...
...
@@ -122,7 +122,7 @@ function ProductsRegist() {
product
[
"
sizes
"
]
=
sizes
const
formData
=
new
FormData
();
for
(
let
key
in
product
)
{
if
(
key
===
"
main_image
"
||
key
===
"
detail_image
"
)
{
if
(
key
===
"
main_image
"
||
key
===
"
detail_image
"
)
{
console
.
log
(
product
[
key
][
0
])
formData
.
append
(
key
,
product
[
key
][
0
])
}
else
{
...
...
client/src/Pages/ProductsList.js
View file @
58d63a89
...
...
@@ -6,40 +6,57 @@ import axios from 'axios';
import
catchError
from
'
../utils/catchErrors
'
;
import
{
isAuthenticated
}
from
'
../utils/auth
'
;
import
{
Container
,
Row
,
Col
,
Form
,
FormControl
,
Button
,
Dropdown
}
from
'
react-bootstrap
'
;
import
catchErrors
from
'
../utils/catchErrors
'
;
function
ProductsList
({
match
})
{
const
[
mainCategory
,
setMainCategory
]
=
useState
(
match
.
params
.
main
)
const
[
sub
,
setSub
]
=
useState
([
'
PADDED JACKET
'
,
'
JACKET
'
,
'
JUMPER
'
,
'
COAT
'
,
'
FLEECE
'
,
'
CARDIGAN / VEST
'
])
const
[
mainCategory
,
setMainCategory
]
=
useState
(
match
.
params
.
main
.
toUpperCase
()
)
const
[
sub
category
,
setSubcategory
]
=
useState
([
])
const
[
productlist
,
setProductlist
]
=
useState
([])
const
[
sub
,
setSub
]
=
useState
([])
const
[
error
,
setError
]
=
useState
(
''
)
// const user=isAuthenticated()
useEffect
(()
=>
{
getSubsCategories
()
getProductlist
()
},
[
mainCategory
])
useEffect
(()
=>
{
setMainCategory
(
match
.
params
.
main
.
toUpperCase
())
},
[
match
.
params
.
main
])
useEffect
(()
=>
{
getProductlist
()
},
[
mainCategory
])
function
handleSearch
()
{
// async function getProfile(user){
// console.log(user)
}
// async function handleClick(subCategory) {
// try {
// const response = await axios.get(`/api/users/profile/${user}`)
// setProfile(response.data)
// const response = await axios.get(`/api/product/getproduct/${subCategory}`)
// console.log("response.data=", response.data)
// setProductlist(response.data)
// } catch (error) {
// catchErrors(error, setError)
// }
// }
function
handleSearch
()
{
// function handleSubmit(e) {
// e.preventDefault()
// }
async
function
getSubsCategories
()
{
try
{
const
response
=
await
axios
.
get
(
`/api/categories/sub/
${
mainCategory
}
`
)
console
.
log
(
"
sub
"
,
response
.
data
)
setSubcategory
(
response
.
data
)
}
catch
(
error
)
{
catchError
(
error
,
setError
)
}
}
async
function
handleClick
(
subCategory
)
{
async
function
getProductlist
(
)
{
try
{
const
response
=
await
axios
.
get
(
`/api/product/getproduct/
${
sub
Category
}
`
)
const
response
=
await
axios
.
get
(
`/api/product/getproduct/
${
main
Category
}
`
)
console
.
log
(
"
response.data=
"
,
response
.
data
)
setProductlist
(
response
.
data
)
}
catch
(
error
)
{
...
...
@@ -47,22 +64,24 @@ function ProductsList({ match }) {
}
}
function
handle
Submit
(
e
)
{
function
handle
Click
(
e
){
e
.
preventDefault
()
return
getsubproductlist
()
}
async
function
get
P
roductlist
()
{
async
function
get
subp
roductlist
(){
try
{
const
response
=
await
axios
.
get
(
`/api/product/getproduct/
${
mainC
ategory
}
`
)
console
.
log
(
"
response.data=
"
,
response
.
data
)
const
response
=
await
axios
.
get
(
`/api/product/getproduct/
${
subc
ategory
}
`
)
console
.
log
(
"
response.data
sub
=
"
,
response
.
data
)
setProductlist
(
response
.
data
)
}
catch
(
error
)
{
catchError
(
error
,
setError
)
catchError
s
(
error
,
setError
)
}
}
return
(
<
div
>
{
console
.
log
(
"
main=
"
,
mainCategory
)}
<
style
type
=
"
text/css
"
>
{
`
a, a:hover, a:active {
...
...
@@ -85,7 +104,7 @@ function ProductsList({ match }) {
<
Row
className
=
"
justify-content-center
"
>
<
Col
sm
=
{
10
}
xs
=
{
12
}
>
<
h1
style
=
{{
fontSize
:
"
3rem
"
}}
className
=
"
text-center
"
>
{
mainCategory
}
<
/h1
>
<
div
className
=
"
text-center
"
>
{
sub
.
map
((
ele
)
=>
(
<
div
className
=
"
text-center
"
>
{
sub
category
.
map
((
ele
)
=>
(
<
Button
className
=
"
m-1
"
onClick
=
{(
ele
)
=>
handleClick
(
ele
)}
>
{
ele
}
<
/Button
>
))}
<
/div
>
<
/Col
>
...
...
client/src/Pages/Signup.js
View file @
58d63a89
...
...
@@ -44,8 +44,6 @@ function Signup() {
}
}
function
checkPassword
(
event
)
{
const
p1
=
user
.
password
const
p2
=
user
.
password2
...
...
server/controllers/product.controller.js
View file @
58d63a89
...
...
@@ -49,16 +49,40 @@ const getlist=(req,res)=>{
}
}
const
categoryId
=
async
(
req
,
res
,
next
,
category
)
=>
{
try
{
const
productslist
=
await
Product
.
find
({
main_category
:
category
})
console
.
log
(
category
)
const
productslist
=
await
Product
.
find
({
"
main_category
"
:
`
${
category
}
`
})
if
(
!
productslist
)
{
res
.
status
(
404
).
send
(
'
상품을 찾을 수 없습니다.
'
)
}
console
.
log
(
"
list=
"
,
productslist
)
req
.
productslist
=
productslist
next
()
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
}
}
export
default
{
imageUpload
,
regist
,
categoryId
,
getlist
,
getToHome
}
\ No newline at end of file
const
subgetlist
=
(
req
,
res
)
=>
{
try
{
res
.
json
(
req
.
subproductslist
)
}
catch
(
error
){
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
}
}
const
subcategoryId
=
async
(
req
,
res
,
next
,
subcategory
)
=>
{
try
{
const
subproductslist
=
await
Product
.
find
({
"
sub_category
"
:
`
${
subcategory
}
`
})
if
(
!
subproductslist
)
{
res
.
status
(
404
).
send
(
'
상품을 찾을 수 없습니다.
'
)
}
req
.
subproductslist
=
subproductslist
next
()
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
}
}
export
default
{
imageUpload
,
regist
,
categoryId
,
getlist
,
subcategoryId
,
subgetlist
}
server/routes/product.routes.js
View file @
58d63a89
...
...
@@ -13,6 +13,11 @@ router.route('/getproduct')
router
.
route
(
'
/getproduct/:category
'
)
.
get
(
productCtrl
.
getlist
)
router
.
route
(
'
/getproduct/:subcategory
'
)
.
get
(
productCtrl
.
subgetlist
)
router
.
param
(
'
category
'
,
productCtrl
.
categoryId
)
router
.
param
(
'
subcategory
'
,
productCtrl
.
subcategoryId
)
export
default
router
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment