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

good

parent bbd71444
......@@ -9,11 +9,13 @@ function MainNav() {
return (
<Navbar sticky="top" style={{ background: "#CDC5C2" }}>
<Navbar.Brand href="/home" className="text-light">
<img alt="로고" src="/icon/footprint.svg" width="24" height="24" />
<img alt="로고" src="/icon/footprint.svg" width="18" height="18" />
{' '}KU#
</Navbar.Brand>
<Nav className="ml-auto">
{user ? <> <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link>
<Nav className="ml-auto d-flex align-items-center">
{user ?
<>
<Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link>
<Nav.Link className="text-light" href="/account"> Mypage </Nav.Link>
<Nav.Link href="/shoppingcart">
<img alt="카트" src="/icon/cart.svg" width="30" height="30" />
......
......@@ -18,6 +18,7 @@ function Account() {
const userId = isAuthenticated()
const [ordered, setOrdered] = useState('')
async function getUsername(user) {
// console.log("tlg")
try {
......@@ -94,6 +95,7 @@ function Account() {
}
}
return (
<Container className="px-3">
<style type="text/css">
......
......@@ -185,15 +185,15 @@ function ProductsRegist() {
<Form.Group>
<Form.Label>분류</Form.Label>
<Row>
<Col md={4}>
<Form.Control as="select" name="main_category" onChange={handleCategory} disabled={product["sub_category"].length > 0}>
<Col md={4} className="mb-1">
<Form.Control as="select" name="main_category" onChange={handleCategory} disabled={product["sub_category"].length > 0} >
<option value="" >상위분류</option>
{categories[0].map((main) => (
<option value={main}>{main}</option>
))}
</Form.Control>
</Col>
<Col md={6}>
<Col md={6} className="mb-2">
<Form.Control as="select" ref={selectRef} name="sub_category" onChange={handleCategory}>
<option value="" >하위분류</option>
{(categoryNum === '') ? '' : (categories[1][categoryNum].map((sub) => (
......@@ -209,7 +209,7 @@ function ProductsRegist() {
</Form.Group>
<Form.Group>
<Form.Label>사이즈</Form.Label>
<Row>
<Row className="px-3">
<Col>
<Form.Check type="checkbox" name="sizes" label="210" value="210" onChange={handleCheckBox} />
<Form.Check type="checkbox" name="sizes" label="215" value="215" onChange={handleCheckBox} />
......@@ -238,10 +238,10 @@ function ProductsRegist() {
<Form.Group>
<Form.Label>색상</Form.Label>
<Row>
<Col md={10}>
<Col md={9} xs={9} className="pr-1">
<Form.Control as="input" ref={colorRef} name="colors" placeholder="색상" onChange={handleColor} />
</Col>
<Col>
<Col className="pl-1">
<Button className="float-right" style={{ background: '#91877F', borderColor: '#91877F' }} onClick={addColor}>추가</Button>
</Col>
</Row>
......
......@@ -58,38 +58,11 @@ function ProductsList({ match }) {
console.log("first test!!!!!!!!")
const response = await axios.get(`/api/product/getproduct/sub/${subname}`)
console.log("subname response data=", response.data)
setProductlist([response.data])
setProductlist(response.data)
} catch (error) {
console.log("error22")
}
// const listvalue = Object.values(productlist)
// for (let i = 0; i < listvalue.length; i++) {
// const list = listvalue[i].sub_category[0]
// console.log("list=", list)
// console.log("include=", subcategory.includes("LONG DRESS"))
// if (listvalue[i].sub_category[0] === subcategory[0]) {
// console.log("yes")
// }
// else {
// console.log("no")
// }
}
// if (productlist.sub_category) {
// }
// console.log("list", list)
// for (let i = 0; i < list.length; i++) {
// if (response.data[i] === "subcategory") {
// console.log("handlesub=", response.data[i].sub_category)
// }
// else {
// console.log("handlesub=2 ", response.data[i].sub_category)
// }
// }
// }
return (
<div>
......
......@@ -15,6 +15,7 @@ export async function handleLogout() {
export function isAuthenticated() {
const userId = localStorage.getItem('id')
// console.log("suer ID =", userId)
if (userId) {
return userId
} else {
......
......@@ -84,15 +84,13 @@ const categoryId = async (req, res, next, category) => {
const subcategoryId = async (req, res, next, subname) => {
try {
console.log("Please===>>>", subname)
const findSubname = await Product.findOne({ sub_category: subname })
// const findSubname = await Product.find({ sub_category: { $elemMatch: { subname: req.subname }}})
const findSubname = await Product.find({ sub_category: subname })
console.log("findSubname111=", findSubname)
// const onlySub = findSubname.sub_category
// console.log(";;", onlySub)
// console.log(".", Object.values(onlySub))
if (!findSubname) {
console.log("ㅏㅁㄴ우하ㅣㅜㅁㄴ어ㅏㅣ훔ㄴ어ㅏㅣ휴")
const findSubname = {
_id: 'nothing',
pro_name: '상품준비중',
......@@ -103,12 +101,10 @@ const subcategoryId = async (req, res, next, subname) => {
res.send(findSubname)
}
res.send(findSubname)
// next()
} catch (error) {
res.send('상품을 불러오지 못했습니다.')
}
}
//https://docs.mongodb.com/manual/reference/operator/projection/elemMatch/index.html
const plusPurchase = async (req, res) => {
const { products } = req.body
......
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