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

발표전

parent 647d9d36
......@@ -15,8 +15,8 @@ function SubNav() {
Object.keys(response.data[0]).forEach((ele) => {
const url = ele.toLowerCase()
list.push(
<Nav.Link as={Link} to={`/categories/${url}`}>{ele}</Nav.Link>
//categories/${SubNav.url}/&{url}
<Nav.Link href={`/categories/${url}`}>{ele}
</Nav.Link>
)
})
setCategoriesDiv(list)
......
......@@ -14,7 +14,13 @@ function Product({ match, location }) {
const [selected, setSelected] = useState({ sizes: false, colors: false })
const [count, setCount] = useState(1)
const [price, setPrice] = useState(0)
// let price = 0
const replace = product.description.replaceAll('\n', '<br />')
// const replace = product.description.replaceAll('\n', '<br />')
// const replace = product.description.replaceAll(/\n/, '<br />')
console.log("objectasdasd", replace)
useEffect(() => {
if (size && color) {
......@@ -173,7 +179,7 @@ function Product({ match, location }) {
</>
<Card className='m-3 d-flex justify-content-center'>
<Card.Body className='text-center'>
{product.description}
{replace}
</Card.Body>
</Card>
<>
......
......@@ -40,7 +40,6 @@ function ProductsList({ match }) {
}
async function getProductlist() {
console.log("tlfgpd")
try {
const response = await axios.get(`/api/product/getproduct/main/${mainCategory}`)
console.log("response.data=main", response.data)
......@@ -51,23 +50,19 @@ function ProductsList({ match }) {
}
}
async function handleSubname(e) {
const subname = e.target.name
console.log("subname=", subname)
try {
console.log("first test!!!!!!!!")
const response = await axios.get(`/api/product/getproduct/sub/${subname}`)
const response = await axios.get(`/api/product/getproduct/sub?subname=${subname}`)
console.log("subname response data=", response.data)
setProductlist(response.data)
} catch (error) {
console.log("오류입니다.")
}
}
// async function readygoods(event) {
// const
// window.location.href='/'
// }
return (
......@@ -103,7 +98,7 @@ function ProductsList({ match }) {
</Row>
<Row className="justify-content-end mx-0 my-5">
<Dropdown>
<Dropdown.Toggle className="mx-2">정렬</Dropdown.Toggle>
<Dropdown.Toggle variant="secondary" className="mx-2">정렬</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item>인기상품</Dropdown.Item>
<Dropdown.Item>신상품</Dropdown.Item>
......@@ -113,7 +108,7 @@ function ProductsList({ match }) {
</Dropdown>
<Form as={Row} onSubmit={handleSearch} className="justify-content-end mx-0">
<FormControl type="text" placeholder="Search" style={{ width: "13rem" }} />
<Button type="submit" className="search px-2">
<Button type="submit" className="search px-2" variant="secondary">
<img src="/icon/search.svg" width="20" height="20" />
</Button>
</Form>
......@@ -134,7 +129,6 @@ function ProductsList({ match }) {
main_img: pro.main_imgUrl,
detail_imgs: pro.detail_imgUrls
}
// onClick={readygoods}
}}>
<ListCard id={pro._id} name={pro.pro_name} price={pro.price} main_img={pro.main_imgUrl}
/>
......
......@@ -74,18 +74,9 @@ const categoryId = async (req, res, next, category) => {
}
const subname = async (req, res) => {
console.log("req.query", req.query)
try {
console.log("last subname::: LET ME SEE")
res.json(req.findsubname)
} catch (error) {
res.status(500).send('상품을 불러오지 못했습니다.')
}
}
const subcategoryId = async (req, res, next, subname) => {
try {
console.log("Please===>>>", subname)
const findSubname = await Product.find({ sub_category: subname })
const findSubname = await Product.find({ sub_category: req.query.subname })
console.log("findSubname111=", findSubname)
res.send(findSubname)
} catch (error) {
......@@ -115,4 +106,4 @@ const plusPurchase = async (req, res) => {
}
}
export default { imageUpload, regist, getToHome, getAll, categoryId, getlist, subcategoryId, subname, plusPurchase }
\ No newline at end of file
export default { imageUpload, regist, getToHome, getAll, categoryId, getlist, subname, plusPurchase }
\ No newline at end of file
......@@ -16,13 +16,13 @@ router.route('/getproduct/all')
router.route('/getproduct/main/:category')
.get(productCtrl.getlist)
router.route('/getproduct/sub/:subname')
router.route('/getproduct/sub')
.get(productCtrl.subname)
router.route('/pluspurchase')
.post(productCtrl.plusPurchase)
router.param('category', productCtrl.categoryId)
router.param('subname',productCtrl.subcategoryId)
// router.param('subname',productCtrl.subcategoryId)
export default router
\ No newline at end of file
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