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

213

parent 39c07bff
......@@ -97,7 +97,7 @@ function Account() {
<Col md={5} className="d-flex align-content-center justify-content-center">
<Button variant="outline-light" onClick={handleShow}>
{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" }} />
) : (
<Image src="/icon/person.svg" className="img-thumbnail"
......
......@@ -29,7 +29,7 @@ function Product({ match, location }) {
preCart.push(cart)
selected.sizes = false
selected.colors = false
setPrice(product.price+price)
setPrice(product.price + price)
}
function handleChange(e) {
const { name, value } = e.target
......@@ -98,7 +98,7 @@ function Product({ match, location }) {
return (
<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">
{`
.btn {
......@@ -114,7 +114,7 @@ function Product({ match, location }) {
</style>
<Row className="justify-content-center mt-5 mx-0">
<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 sm={11} md={4} className="align-middle mt-4">
<h3 className="mb-4">{product.name}</h3>
......
......@@ -3,7 +3,7 @@ import Category from "../schemas/Category.js";
const getCategory = async (req, res) => {
console.log("dsadd=")
try {
const category = await Category.find({}, {_id: 0})
const category = await Category.find({}, { _id: 0 })
res.json(category)
} catch (error) {
console.log(error)
......@@ -11,16 +11,17 @@ const getCategory = async (req, res) => {
}
}
const getSubCategory=(req,res)=>{
const getSubCategory = (req, res) => {
}
const getsubId=(req,res,next,sub)=>{
const subcategory = await category.find({"Dress"})
console.log('sub=',sub)
const getsubId = (req, res, next, sub) => {
// const subcategory = await category.find({"Dress"})
console.log('sub=', sub)
next()
}
export default { getCategory , getsubId, getSubCategory}
\ No newline at end of file
export default { getCategory, getsubId, getSubCategory }
\ No newline at end of file
......@@ -6,10 +6,10 @@ const upload = multer({ dest: 'uploads/' })
const imageUpload = upload.fields([
{ name: 'main_image' },
{ name: 'detail_image' }
])
])
const regist = async (req, res) => {
console.log("req.body=",req.body)
console.log("req.body=", req.body)
try {
const { pro_name, price, stock, main_category, sub_category, description, colors, sizes } = req.body
const main_img = req.files['main_image'][0]
......@@ -33,15 +33,15 @@ const getToHome = async (res, req) => {
try {
const bestProduct = await Product.find({}).sort({ purchase: 1 }).limit(6)
const newProduct = await Product.find({}).sort({ createdAt: -1 }).limit(6)
console.log("best=",bestProduct)
console.log("new=",newProduct)
console.log("best=", bestProduct)
console.log("new=", newProduct)
res.json(bestProduct, newProduct)
} catch {
res.status(500).send('상품을 불러오지 못했습니다.')
}
}
const getlist=(req,res)=>{
const getlist = (req, res) => {
try {
res.json(req.productslist)
} catch (error) {
......@@ -52,7 +52,7 @@ const getlist=(req,res)=>{
const categoryId = async (req, res, next, category) => {
try {
const productslist = await Product.find({main_category: category})
const productslist = await Product.find({ main_category: category })
if (!productslist) {
res.status(404).send('상품을 찾을 수 없습니다.')
}
......@@ -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)
}catch(error){
} catch (error) {
res.status(500).send('상품을 불러오지 못했습니다.')
}
}
const subcategoryId = async (req, res, next, subcategory) => {
try {
const subproductslist = await Product.find({sub_category:subcategory})
const subproductslist = await Product.find({ sub_category: subcategory })
if (!subproductslist) {
res.status(404).send('상품을 찾을 수 없습니다.')
}
......@@ -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