Commit 96d53c8a authored by kusang96's avatar kusang96
Browse files

route 손보는 중

parent 064e5fe5
...@@ -18,6 +18,7 @@ function App() { ...@@ -18,6 +18,7 @@ function App() {
return ( return (
<div> <div>
{console.log("match.params=",match.params(product))}
<MainNav /> <MainNav />
<SubNav /> <SubNav />
<Router> <Router>
...@@ -25,8 +26,8 @@ function App() { ...@@ -25,8 +26,8 @@ function App() {
<Route exact path="/" component={Home} /> <Route exact path="/" component={Home} />
<Route path="/login" component={Login} /> <Route path="/login" component={Login} />
<Route path="/signup" component={Signup} /> <Route path="/signup" component={Signup} />
<Route path="/product" component={Product} /> {/* <Route path="/product" component={Product} /> */}
<Route path="/productslist" component={ProductsList} /> <Route path="/product/:product" component={ProductsList} />
<Route path="/admin" component={Admin} /> <Route path="/admin" component={Admin} />
<Route path="/regist" component={ProductRegist} /> <Route path="/regist" component={ProductRegist} />
<Route path="/shoppingcart" component={ShoppingCart} /> <Route path="/shoppingcart" component={ShoppingCart} />
......
...@@ -14,9 +14,9 @@ function SubNav() { ...@@ -14,9 +14,9 @@ function SubNav() {
const response = await axios.get('/api/categorys') const response = await axios.get('/api/categorys')
let list = [] let list = []
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 href={url}>{ele}</Nav.Link> <Nav.Link href={`/product/${url}`}>{ele}</Nav.Link>
) )
}) })
setCategorysDiv(list) setCategorysDiv(list)
......
...@@ -3,6 +3,9 @@ import { Card, Container, Row } from 'react-bootstrap'; ...@@ -3,6 +3,9 @@ import { Card, Container, Row } from 'react-bootstrap';
function Home() { function Home() {
return ( return (
<div> <div>
<Container className="my-5"> <Container className="my-5">
......
...@@ -25,6 +25,7 @@ function ProductsList() { ...@@ -25,6 +25,7 @@ function ProductsList() {
return ( return (
<div> <div>
<style type="text/css"> <style type="text/css">
{` {`
.btn { .btn {
...@@ -118,7 +119,7 @@ function ProductsList() { ...@@ -118,7 +119,7 @@ function ProductsList() {
</Card> </Card>
</Row> </Row>
</Container> </Container>
<Pagination /> {/* <Pagination postsPerPage={postsPerPage} totalPosts={posts.length} paginate={paginate} /> */}
</div> </div>
) )
} }
......
...@@ -16,7 +16,7 @@ function Signup() { ...@@ -16,7 +16,7 @@ function Signup() {
const [user, setUser] = useState('') const [user, setUser] = useState('')
const [error, setError] = useState('') const [error, setError] = useState('')
const [validated, setValidated] = useState(false); const [validated, setValidated] = useState(false);
function handleChange(event) { function handleChange(event) {
const { name, value } = event.target const { name, value } = event.target
...@@ -41,25 +41,25 @@ const [validated, setValidated] = useState(false); ...@@ -41,25 +41,25 @@ const [validated, setValidated] = useState(false);
} catch (error) { } catch (error) {
catchErrors(error, setError) catchErrors(error, setError)
} }
} }
function checkPassword(event){ function checkPassword(event) {
const p1=user.password const p1 = user.password
const p2=user.password2 const p2 = user.password2
if(p1 !== p2){ if (p1 !== p2) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
alert('비밀번호가 일치하지 않습니다.') alert('비밀번호가 일치하지 않습니다.')
return false return false
}else{ } else {
return true return true
} }
} }
return ( return (
<div> <div>
...@@ -156,7 +156,7 @@ const [validated, setValidated] = useState(false); ...@@ -156,7 +156,7 @@ const [validated, setValidated] = useState(false);
value={user.password2} value={user.password2}
required required
onChange={handleChange} onChange={handleChange}
/> />
<Form.Control.Feedback type="invalid"> 비밀번호를 한번 입력하세요. <Form.Control.Feedback type="invalid"> 비밀번호를 한번 입력하세요.
</Form.Control.Feedback> </Form.Control.Feedback>
</Form.Row> </Form.Row>
...@@ -177,7 +177,7 @@ const [validated, setValidated] = useState(false); ...@@ -177,7 +177,7 @@ const [validated, setValidated] = useState(false);
<Button <Button
style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block
onClick={checkPassword} onClick={checkPassword}
> >
Sign Up Sign Up
</Button> </Button>
</Form> </Form>
......
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