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

발표전

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