Commit b7ade783 authored by kusang96's avatar kusang96
Browse files

Merge remote-tracking branch 'origin/sangho' into ourMaster

parents 520cf554 9c8a9fa8
...@@ -9,17 +9,19 @@ function MainNav() { ...@@ -9,17 +9,19 @@ function MainNav() {
return ( return (
<Navbar sticky="top" style={{ background: "#CDC5C2" }}> <Navbar sticky="top" style={{ background: "#CDC5C2" }}>
<Navbar.Brand href="/home" className="text-light"> <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# {' '}KU#
</Navbar.Brand> </Navbar.Brand>
<Nav className="ml-auto"> <Nav className="ml-auto d-flex align-items-center">
{user ? <> <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link> {user ?
<Nav.Link className="text-light" href="/account"> Mypage </Nav.Link> <>
<Nav.Link href="/shoppingcart"> <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link>
<img alt="카트" src="/icon/cart.svg" width="30" height="30" /> <Nav.Link className="text-light" href="/account"> Mypage </Nav.Link>
</Nav.Link> <Nav.Link href="/shoppingcart">
</> <img alt="카트" src="/icon/cart.svg" width="30" height="30" />
: ( </Nav.Link>
</>
: (
<> <>
<Nav.Link className="text-light" href='/login'>Login</Nav.Link> <Nav.Link className="text-light" href='/login'>Login</Nav.Link>
<Nav.Link className="text-light" href='/signup'>Sign Up</Nav.Link> <Nav.Link className="text-light" href='/signup'>Sign Up</Nav.Link>
......
...@@ -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)
......
...@@ -17,6 +17,7 @@ function Account() { ...@@ -17,6 +17,7 @@ function Account() {
const [error, setError] = useState("") const [error, setError] = useState("")
const userId = isAuthenticated() const userId = isAuthenticated()
const [ordered, setOrdered] = useState('') const [ordered, setOrdered] = useState('')
async function getUsername(user) { async function getUsername(user) {
try { try {
...@@ -87,6 +88,7 @@ function Account() { ...@@ -87,6 +88,7 @@ function Account() {
} }
} }
return ( return (
<Container className="px-3"> <Container className="px-3">
<style type="text/css"> <style type="text/css">
......
...@@ -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) {
...@@ -166,20 +172,20 @@ function Product({ match, location }) { ...@@ -166,20 +172,20 @@ function Product({ match, location }) {
<h3 style={{ borderBottom: "1px solid #91877F", paddingBottom: "5px", marginBottom: "1em" }} className="p-3"> <h3 style={{ borderBottom: "1px solid #91877F", paddingBottom: "5px", marginBottom: "1em" }} className="p-3">
설명 설명
</h3> </h3>
<Col className='m-3 text-center d-flex justify-content-center'> <Col className='justify-content-center '>
<div style={{ wordBreak: 'break-all', wordWrap: 'break-word', fontFamily: "맑은 고딕" }} className="p-3"> <h2 className='p-2 text-center border' style={{background : '#CDC5C2'}}>{product.name} </h2>
<h1 className='m-3'>{product.name} </h1>
<> <>
<Image src={`/images/${product.main_img}`} style={{ objectFit: "contain", width: '100%'}} /> <Image src={`/images/${product.main_img}`} style={{ objectFit: "contain", maxWidth: "100%"}} />
</> </>
<Card className='m-3 d-flex justify-content-center'> <Card className='m-3 d-flex justify-content-center'>
<Card.Body> <Card.Body className='text-center'>
{product.description} {replace}
</Card.Body> </Card.Body>
</Card> </Card>
<h3 className='mt-5'>[ Detail Images ]</h3> <>
<Image src={`/images/${product.detail_imgs}`} style={{ objectFit: "contain"}} className='m-3' /> <h4 className='my-4 text-center'>[ Detail Images ]</h4>
</div> <Image src={`/images/${product.detail_imgs}`} style={{ objectFit: "contain", maxWidth: "100%"}}/>
</>
</Col> </Col>
</Col> </Col>
</Row> </Row>
......
...@@ -182,15 +182,15 @@ function ProductsRegist() { ...@@ -182,15 +182,15 @@ function ProductsRegist() {
<Form.Group> <Form.Group>
<Form.Label>분류</Form.Label> <Form.Label>분류</Form.Label>
<Row> <Row>
<Col md={4}> <Col md={4} className="mb-1">
<Form.Control as="select" name="main_category" onChange={handleCategory} disabled={product["sub_category"].length > 0}> <Form.Control as="select" name="main_category" onChange={handleCategory} disabled={product["sub_category"].length > 0} >
<option value="" >상위분류</option> <option value="" >상위분류</option>
{categories[0].map((main) => ( {categories[0].map((main) => (
<option value={main}>{main}</option> <option value={main}>{main}</option>
))} ))}
</Form.Control> </Form.Control>
</Col> </Col>
<Col md={6}> <Col md={6} className="mb-2">
<Form.Control as="select" ref={selectRef} name="sub_category" onChange={handleCategory}> <Form.Control as="select" ref={selectRef} name="sub_category" onChange={handleCategory}>
<option value="" >하위분류</option> <option value="" >하위분류</option>
{(categoryNum === '') ? '' : (categories[1][categoryNum].map((sub) => ( {(categoryNum === '') ? '' : (categories[1][categoryNum].map((sub) => (
...@@ -206,7 +206,7 @@ function ProductsRegist() { ...@@ -206,7 +206,7 @@ function ProductsRegist() {
</Form.Group> </Form.Group>
<Form.Group> <Form.Group>
<Form.Label>사이즈</Form.Label> <Form.Label>사이즈</Form.Label>
<Row> <Row className="px-3">
<Col> <Col>
<Form.Check type="checkbox" name="sizes" label="210" value="210" onChange={handleCheckBox} /> <Form.Check type="checkbox" name="sizes" label="210" value="210" onChange={handleCheckBox} />
<Form.Check type="checkbox" name="sizes" label="215" value="215" onChange={handleCheckBox} /> <Form.Check type="checkbox" name="sizes" label="215" value="215" onChange={handleCheckBox} />
...@@ -235,10 +235,10 @@ function ProductsRegist() { ...@@ -235,10 +235,10 @@ function ProductsRegist() {
<Form.Group> <Form.Group>
<Form.Label>색상</Form.Label> <Form.Label>색상</Form.Label>
<Row> <Row>
<Col md={10}> <Col md={9} xs={9} className="pr-1">
<Form.Control as="input" ref={colorRef} name="colors" placeholder="색상" onChange={handleColor} /> <Form.Control as="input" ref={colorRef} name="colors" placeholder="색상" onChange={handleColor} />
</Col> </Col>
<Col> <Col className="pl-1">
<Button className="float-right" style={{ background: '#91877F', borderColor: '#91877F' }} onClick={addColor}>추가</Button> <Button className="float-right" style={{ background: '#91877F', borderColor: '#91877F' }} onClick={addColor}>추가</Button>
</Col> </Col>
</Row> </Row>
......
...@@ -4,7 +4,7 @@ import ListCard from '../Components/ListCard'; ...@@ -4,7 +4,7 @@ import ListCard from '../Components/ListCard';
import Pagination from "../Components/Pagination"; import Pagination from "../Components/Pagination";
import axios from 'axios'; import axios from 'axios';
import catchError from '../utils/catchErrors'; import catchError from '../utils/catchErrors';
import { Container, Row, Col, Form, FormControl, Button, Dropdown, ButtonGroup } from 'react-bootstrap'; import { Container, Row, Col, Form, FormControl, Button, Dropdown, ButtonGroup, Image } from 'react-bootstrap';
function ProductsList({ match }) { function ProductsList({ match }) {
const [search, setSearch] = useState({ word: '' }) const [search, setSearch] = useState({ word: '' })
...@@ -61,7 +61,6 @@ function ProductsList({ match }) { ...@@ -61,7 +61,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}`)
setProductlist(response.data) setProductlist(response.data)
...@@ -79,16 +78,17 @@ function ProductsList({ match }) { ...@@ -79,16 +78,17 @@ 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("error22") catchError(error, setError)
} }
} }
...@@ -115,47 +115,53 @@ function ProductsList({ match }) { ...@@ -115,47 +115,53 @@ function ProductsList({ match }) {
<h1 style={{ fontSize: "3rem" }} className="text-center">{mainCategory}</h1> <h1 style={{ fontSize: "3rem" }} className="text-center">{mainCategory}</h1>
<div className="text-center"> <div className="text-center">
<ButtonGroup className="m-3" variant="outline-light secondary" style={{ display: "inline-block" }}> <ButtonGroup className="m-3" variant="outline-light secondary" style={{ display: "inline-block" }}>
{subCategory.map(el => (<Button className="m-1" variant="secondary" name={el} onClick={handleSubname}>{el}</Button>))} {subcategory.map(el => (<Button className="m-1" variant="secondary" name={el} onClick={handleSubname}>{el}</Button>))}
</ButtonGroup> </ButtonGroup>
</div> </div>
</Col> </Col>
</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 onClick={() => handleSort('purchase')}>인기상품</Dropdown.Item> <Dropdown.Item>인기상품</Dropdown.Item>
<Dropdown.Item onClick={() => handleSort('newest')}>신상품</Dropdown.Item> <Dropdown.Item>신상품</Dropdown.Item>
<Dropdown.Item onClick={() => handleSort('lowest')}>낮은가격</Dropdown.Item> <Dropdown.Item>낮은가격</Dropdown.Item>
<Dropdown.Item onClick={() => handleSort('highest')}>높은가격</Dropdown.Item> <Dropdown.Item>높은가격</Dropdown.Item>
</Dropdown.Menu> </Dropdown.Menu>
</Dropdown> </Dropdown>
<Form inline onSubmit={handleSearch} className="justify-content-end mx-0"> <Form as={Row} onSubmit={handleSearch} className="justify-content-end mx-0">
<FormControl type="text" onChange={handleChange} placeholder="Search" style={{ width: "13rem" }} /> <FormControl type="text" placeholder="Search" style={{ width: "13rem" }} />
<Button type="submit" className="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>
</Row> </Row>
<Row md={8} sm={12} className="justify-content-center m-2"> <Row md={8} sm={12} className="justify-content-center m-2">
{productlist.map(pro => ( {productlist.length > 0 ?
<Link to={{ productlist.map(pro => (
pathname: `/product/${pro._id}`, <Link to={{
state: { pathname: `/product/${pro._id}`,
id: pro._id, state: {
name: pro.pro_name, id: pro._id,
price: pro.price, name: pro.pro_name,
colors: pro.colors, price: pro.price,
sizes: pro.sizes, colors: pro.colors,
description: pro.description, sizes: pro.sizes,
main_img: pro.main_imgUrl, description: pro.description,
detail_imgs: pro.detail_imgUrls main_img: pro.main_imgUrl,
} detail_imgs: pro.detail_imgUrls
}}> }
<ListCard id={pro._id} name={pro.pro_name} price={pro.price} main_img={pro.main_imgUrl} /> }}>
</Link> <ListCard id={pro._id} name={pro.pro_name} price={pro.price} main_img={pro.main_imgUrl}
))} />
{/* <Pagination className="justify-content-center" index={} endPage={} handlePage={}/> */} </Link>
))
: (
<Image src="/sryimready.jpg"
style={{ objectFit: "cover", width: "45 rem", height: "45 rem" }}></Image>
)
}
</Row> </Row>
</Container> </Container>
) )
......
...@@ -59,14 +59,6 @@ const getlist = (req, res) => { ...@@ -59,14 +59,6 @@ const getlist = (req, res) => {
} }
} }
const subname = async (req, res) => {
try {
console.log("last subname::: LET ME SEE")
res.json(req.findsubname)
} catch (error) {
res.status(500).send('상품을 불러오지 못했습니다.')
}
}
const categoryId = async (req, res, next, category) => { const categoryId = async (req, res, next, category) => {
const { search } = req.body const { search } = req.body
...@@ -84,22 +76,11 @@ const categoryId = async (req, res, next, category) => { ...@@ -84,22 +76,11 @@ const categoryId = async (req, res, next, category) => {
} }
} }
const subcategoryId = async (req, res, next, subname) => { const subname = async (req, res) => {
console.log("req.query", req.query)
try { try {
console.log("Please===>>>", subname) const findSubname = await Product.find({ sub_category: req.query.subname })
const findSubname = await Product.find({ sub_category: subname })
console.log("findSubname111=", findSubname) console.log("findSubname111=", findSubname)
if (!findSubname) {
const findSubname = {
_id: 'nothing',
pro_name: '상품준비중',
price: 0,
main_imgUrl:''
}
console.log("findSubname2222=", findSubname)
res.send(findSubname)
}
res.send(findSubname) res.send(findSubname)
} catch (error) { } catch (error) {
res.send('상품을 불러오지 못했습니다.') res.send('상품을 불러오지 못했습니다.')
...@@ -126,4 +107,4 @@ const plusPurchase = async (req, res) => { ...@@ -126,4 +107,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
...@@ -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