Commit abc50ef9 authored by 박상호's avatar 박상호 🎼
Browse files

213

parent 39c07bff
...@@ -97,7 +97,7 @@ function Account() { ...@@ -97,7 +97,7 @@ function Account() {
<Col md={5} className="d-flex align-content-center justify-content-center"> <Col md={5} className="d-flex align-content-center justify-content-center">
<Button variant="outline-light" onClick={handleShow}> <Button variant="outline-light" onClick={handleShow}>
{account.avatarUrl ? ( {account.avatarUrl ? (
<Image src={account.avatarUrl && `/image/${account.avatarUrl}`} className="img-thumbnail" <Image src={account.avatarUrl && `/images/${account.avatarUrl}`} className="img-thumbnail"
roundedCircle style={{ objectFit: "cover", width: "10rem", height: "10rem" }} /> roundedCircle style={{ objectFit: "cover", width: "10rem", height: "10rem" }} />
) : ( ) : (
<Image src="/icon/person.svg" className="img-thumbnail" <Image src="/icon/person.svg" className="img-thumbnail"
......
...@@ -29,7 +29,7 @@ function Product({ match, location }) { ...@@ -29,7 +29,7 @@ function Product({ match, location }) {
preCart.push(cart) preCart.push(cart)
selected.sizes = false selected.sizes = false
selected.colors = false selected.colors = false
setPrice(product.price+price) setPrice(product.price + price)
} }
function handleChange(e) { function handleChange(e) {
const { name, value } = e.target const { name, value } = e.target
...@@ -98,7 +98,7 @@ function Product({ match, location }) { ...@@ -98,7 +98,7 @@ function Product({ match, location }) {
return ( return (
<div> <div>
{console.log("match=",match.params, "location=",location.state, "product=",product)} {console.log("match=", match.params, "location=", location.state, "product=", product)}
<style type="text/css"> <style type="text/css">
{` {`
.btn { .btn {
...@@ -114,7 +114,7 @@ function Product({ match, location }) { ...@@ -114,7 +114,7 @@ function Product({ match, location }) {
</style> </style>
<Row className="justify-content-center mt-5 mx-0"> <Row className="justify-content-center mt-5 mx-0">
<Col sm={11} md={4}> <Col sm={11} md={4}>
<img src={product.main_img} style={{ objectFit: "contain", width: "100%" }} /> <img src={`/images/${product.main_img}`} style={{ objectFit: "contain", width: "100%" }} />
</Col> </Col>
<Col sm={11} md={4} className="align-middle mt-4"> <Col sm={11} md={4} className="align-middle mt-4">
<h3 className="mb-4">{product.name}</h3> <h3 className="mb-4">{product.name}</h3>
......
...@@ -3,7 +3,7 @@ import Category from "../schemas/Category.js"; ...@@ -3,7 +3,7 @@ import Category from "../schemas/Category.js";
const getCategory = async (req, res) => { const getCategory = async (req, res) => {
console.log("dsadd=") console.log("dsadd=")
try { try {
const category = await Category.find({}, {_id: 0}) const category = await Category.find({}, { _id: 0 })
res.json(category) res.json(category)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
...@@ -11,16 +11,17 @@ const getCategory = async (req, res) => { ...@@ -11,16 +11,17 @@ const getCategory = async (req, res) => {
} }
} }
const getSubCategory=(req,res)=>{ const getSubCategory = (req, res) => {
} }
const getsubId=(req,res,next,sub)=>{ const getsubId = (req, res, next, sub) => {
const subcategory = await category.find({"Dress"}) // const subcategory = await category.find({"Dress"})
console.log('sub=',sub) console.log('sub=', sub)
next() next()
} }
export default { getCategory , getsubId, getSubCategory} export default { getCategory, getsubId, getSubCategory }
\ No newline at end of file \ No newline at end of file
...@@ -6,10 +6,10 @@ const upload = multer({ dest: 'uploads/' }) ...@@ -6,10 +6,10 @@ const upload = multer({ dest: 'uploads/' })
const imageUpload = upload.fields([ const imageUpload = upload.fields([
{ name: 'main_image' }, { name: 'main_image' },
{ name: 'detail_image' } { name: 'detail_image' }
]) ])
const regist = async (req, res) => { const regist = async (req, res) => {
console.log("req.body=",req.body) console.log("req.body=", req.body)
try { try {
const { pro_name, price, stock, main_category, sub_category, description, colors, sizes } = req.body const { pro_name, price, stock, main_category, sub_category, description, colors, sizes } = req.body
const main_img = req.files['main_image'][0] const main_img = req.files['main_image'][0]
...@@ -33,15 +33,15 @@ const getToHome = async (res, req) => { ...@@ -33,15 +33,15 @@ const getToHome = async (res, req) => {
try { try {
const bestProduct = await Product.find({}).sort({ purchase: 1 }).limit(6) const bestProduct = await Product.find({}).sort({ purchase: 1 }).limit(6)
const newProduct = await Product.find({}).sort({ createdAt: -1 }).limit(6) const newProduct = await Product.find({}).sort({ createdAt: -1 }).limit(6)
console.log("best=",bestProduct) console.log("best=", bestProduct)
console.log("new=",newProduct) console.log("new=", newProduct)
res.json(bestProduct, newProduct) res.json(bestProduct, newProduct)
} catch { } catch {
res.status(500).send('상품을 불러오지 못했습니다.') res.status(500).send('상품을 불러오지 못했습니다.')
} }
} }
const getlist=(req,res)=>{ const getlist = (req, res) => {
try { try {
res.json(req.productslist) res.json(req.productslist)
} catch (error) { } catch (error) {
...@@ -52,7 +52,7 @@ const getlist=(req,res)=>{ ...@@ -52,7 +52,7 @@ const getlist=(req,res)=>{
const categoryId = async (req, res, next, category) => { const categoryId = async (req, res, next, category) => {
try { try {
const productslist = await Product.find({main_category: category}) const productslist = await Product.find({ main_category: category })
if (!productslist) { if (!productslist) {
res.status(404).send('상품을 찾을 수 없습니다.') res.status(404).send('상품을 찾을 수 없습니다.')
} }
...@@ -63,16 +63,17 @@ const categoryId = async (req, res, next, category) => { ...@@ -63,16 +63,17 @@ const categoryId = async (req, res, next, category) => {
} }
} }
const subgetlist=(req,res)=>{
try{ const subgetlist = (req, res) => {
try {
res.json(req.subproductslist) res.json(req.subproductslist)
}catch(error){ } catch (error) {
res.status(500).send('상품을 불러오지 못했습니다.') res.status(500).send('상품을 불러오지 못했습니다.')
} }
} }
const subcategoryId = async (req, res, next, subcategory) => { const subcategoryId = async (req, res, next, subcategory) => {
try { try {
const subproductslist = await Product.find({sub_category:subcategory}) const subproductslist = await Product.find({ sub_category: subcategory })
if (!subproductslist) { if (!subproductslist) {
res.status(404).send('상품을 찾을 수 없습니다.') res.status(404).send('상품을 찾을 수 없습니다.')
} }
...@@ -83,4 +84,4 @@ const subcategoryId = async (req, res, next, subcategory) => { ...@@ -83,4 +84,4 @@ const subcategoryId = async (req, res, next, subcategory) => {
} }
} }
export default { imageUpload, regist, categoryId, getlist, subcategoryId, subgetlist } export default { imageUpload, regist, categoryId, getlist, subcategoryId, subgetlist, getToHome }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment