Commit 33f14441 authored by 박상호's avatar 박상호 🎼
Browse files

0120

parent 22e80f26
...@@ -13,6 +13,7 @@ const INIT_ACCOUNT = { ...@@ -13,6 +13,7 @@ const INIT_ACCOUNT = {
function Account() { function Account() {
const [account, setAccount] = useState(INIT_ACCOUNT) const [account, setAccount] = useState(INIT_ACCOUNT)
const [show, setShow] = useState(false); const [show, setShow] = useState(false);
const [proshow, setProshow] = useState(false)
const [error, setError] = useState("") const [error, setError] = useState("")
const userId = isAuthenticated() const userId = isAuthenticated()
...@@ -21,7 +22,7 @@ function Account() { ...@@ -21,7 +22,7 @@ function Account() {
try { try {
const response = await axios.get(`/api/users/account/${user}`) const response = await axios.get(`/api/users/account/${user}`)
setAccount(response.data) setAccount(response.data)
// console.log('555555555', response.data); console.log('555555555', response.data);
} catch (error) { } catch (error) {
catchError(error, setError) catchError(error, setError)
// console.log('error2222', error) // console.log('error2222', error)
...@@ -104,8 +105,8 @@ function Account() { ...@@ -104,8 +105,8 @@ function Account() {
)} )}
</Button> </Button>
<Modal show={show} onHide={() => setShow(false)}> <Modal show={show} onHide={() => setShow(false)}>
<Modal.Header closeButton> <Modal.Header closeButton style={{background:"#F7F3F3"}}>
<Modal.Title>이미지를 변경하시겠습니까?</Modal.Title> <Modal.Title >이미지를 변경하시겠습니까?</Modal.Title>
</Modal.Header> </Modal.Header>
<Form onSubmit={handleSubmit}> <Form onSubmit={handleSubmit}>
<Modal.Body> <Modal.Body>
...@@ -127,7 +128,28 @@ function Account() { ...@@ -127,7 +128,28 @@ function Account() {
<Row className="mt-4 text-center"> <Row className="mt-4 text-center">
<Col> <Col>
<h2> <h2>
<strong>{account.name}</strong> <small>({account.id}){" "}님</small> <strong title='회원정보' style={{ cursor: "pointer", textDecoration: 'underline' }} onClick={() => setProshow(true)}>
{account.name}
</strong>
<Modal
size="sm"
show={proshow}
onHide={() => setProshow(false)}>
<Modal.Header closeButton style={{background:"#F7F3F3"}}>
<Modal.Title>회원정보</Modal.Title>
</Modal.Header>
<Modal.Body>
<Col className="p-1">
<li><strong>Role :</strong> {account.role}</li>
<li><strong>ID :</strong> {account.id}</li>
<li><strong>Username :</strong> {account.name}</li>
<li><strong>Email :</strong> {account.email}</li>
<li><strong>Tel :</strong> {account.tel}</li>
</Col>
</Modal.Body>
</Modal>
<small>{' '}({account.id}){" "}</small>
</h2> </h2>
</Col> </Col>
</Row> </Row>
......
...@@ -89,8 +89,8 @@ function Login() { ...@@ -89,8 +89,8 @@ function Login() {
</Form.Control.Feedback> </Form.Control.Feedback>
</Form.Row> </Form.Row>
</Form.Group> </Form.Group>
<Button style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block>Login</Button> <Button style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block >Login</Button>
<div className="loginLine"> <div className="loginLine m-1">
<Link to="/signup" style={{ color: '#91877F' }}>회원이 아니십니까?</Link> <Link to="/signup" style={{ color: '#91877F' }}>회원이 아니십니까?</Link>
</div> </div>
</Form> </Form>
......
...@@ -159,7 +159,7 @@ function Product({ match, location }) { ...@@ -159,7 +159,7 @@ function Product({ match, location }) {
<Row className="justify-content-center mx-0 pt-3 px-2" style={{ position: "fixed", bottom: "0", width: "100%", backgroundColor: "#fff" }}> <Row className="justify-content-center mx-0 pt-3 px-2" style={{ position: "fixed", bottom: "0", width: "100%", backgroundColor: "#fff" }}>
<Col sm={12} md={9}> <Col sm={12} md={9}>
<h6 style={{ borderBottom: "1px solid", paddingBottom: "5px", marginBottom: "1em" }}>회원님이 선호할만한 상품 추천 <h6 style={{ borderBottom: "1px solid", paddingBottom: "5px", marginBottom: "1em" }}>회원님이 선호할만한 상품 추천
<a className="close float-right" onClick={(e) => handleClick(e)} style={{ fontSize: "1rem" }}>X</a> <a className="close float-right" onClick={(e) => handleClick(e)} style={{ fontSize: "1rem", cursor: "pointer" }}>X</a>
</h6> </h6>
<Row className="justify-content-space mx-0" style={{ flexWrap: "nowrap", width: "100%", overflowX: "auto" }}> <Row className="justify-content-space mx-0" style={{ flexWrap: "nowrap", width: "100%", overflowX: "auto" }}>
<Col as={Card} style={{ minWidth: "10rem", marginRight: "1rem" }}> <Col as={Card} style={{ minWidth: "10rem", marginRight: "1rem" }}>
......
...@@ -74,7 +74,7 @@ function ProductsList({ match }) { ...@@ -74,7 +74,7 @@ function ProductsList({ match }) {
<Col sm={10} xs={12} > <Col sm={10} xs={12} >
<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="d-flex flex-wrap" variant="outline-light secondary"> <ButtonGroup className="m-3" variant="outline-light secondary" style={{ display: "inline-block" }}>
{subcategory.map(el => (<Button className="m-1" variant="secondary">{el}</Button>))} {subcategory.map(el => (<Button className="m-1" variant="secondary">{el}</Button>))}
</ButtonGroup> </ButtonGroup>
</div> </div>
......
...@@ -10,7 +10,8 @@ const INIT_USER = { ...@@ -10,7 +10,8 @@ const INIT_USER = {
id: '', id: '',
password: '', password: '',
password2: '', password2: '',
tel: '' tel: '',
email: ''
} }
function Signup() { function Signup() {
...@@ -61,134 +62,157 @@ function Signup() { ...@@ -61,134 +62,157 @@ function Signup() {
if (success) { if (success) {
alert('회원가입 되었습니다.') alert('회원가입 되었습니다.')
return <Redirect to='/login'/> return <Redirect to='/login' />
} }
return ( return (
<div> <div>
<Container className="my-5"> <Container className="my-5">
<Row className="justify-content-center"> <Row className="justify-content-center">
<Col md={6} xs={10} className="border" style={{ background: '#F7F3F3' }}> <Col md={6} xs={10} className="border" style={{ background: '#F7F3F3' }}>
<h2 className="text-center mt-5">Sign Up</h2> <h2 className="text-center mt-5">Sign Up</h2>
{error && <Alert variant='danger'> {error && <Alert variant='danger'>
{error} {error}
</Alert>} </Alert>}
<Form <Form
noValidate validated={validated} noValidate validated={validated}
onSubmit={handleSubmit} onSubmit={handleSubmit}
className="p-5"> className="p-5">
<Form.Group controlId="formBasicName"> <Form.Group controlId="formBasicName">
<Form.Row> <Form.Row>
<Col sm={4} xs={6} as={Form.Label} for="id"> </Col> <Col sm={4} xs={6} as={Form.Label} for="id"> </Col>
<Col sm={8} xs={12} as={Form.Control} <Col sm={8} xs={12} as={Form.Control}
required type="text"
name="name"
placeholder="Name"
style={{ width: '160px' }}
value={user.name}
onChange={handleChange} />
<Form.Control.Feedback type="invalid">이름을 입력하세요. </Form.Control.Feedback>
</Form.Row>
</Form.Group>
<Form.Group controlId="formBasicNumber">
<Form.Row>
<Col sm={4} xs={6} as={Form.Label} for="number">주민등록번호</Col>
<Col as={Row} sm={8} xs={10} >
<Form.Control
required type="text" required type="text"
name="number1" name="name"
maxlength="6" placeholder="Name"
className="mx-2" style={{ width: '17 0px' }} style={{ width: '160px' }}
value={user.number1} value={user.name}
onChange={handleChange}> onChange={handleChange} />
</Form.Control> <Form.Control.Feedback type="invalid">이름을 입력하세요. </Form.Control.Feedback>
- </Form.Row>
<Form.Control </Form.Group>
required type="text" <Form.Group controlId="formBasicNumber">
name="number2" <Form.Row>
maxlength="1" className="mx-3" <Col sm={4} xs={6} as={Form.Label} for="number">주민등록번호</Col>
style={{ width: '50px' }} <Row>
value={user.number2} <Form.Control
onChange={handleChange}> required type="text"
</Form.Control> name="number1"
****** maxlength="6"
<Form.Control.Feedback type="invalid">주민등록번호를 입력하세요.</Form.Control.Feedback> className="mx-3 p-1" style={{ width: '80px' }}
</Col> value={user.number1}
</Form.Row> onChange={handleChange}>
</Form.Group> </Form.Control>
<Form.Group controlId="formBasicId"> <div className='font-weight-bold d-flex align-items-center' style={{ text: 'center' }}>
<Form.Row> -
<Col sm={4} xs={6} as={Form.Label} for="id">아이디</Col> </div>
<Col sm={8} xs={12} as={Form.Control} <Form.Control
required required type="text"
type="text" name="number2"
name="id" maxlength="1" className="mx-3 p-1"
placeholder="ID" style={{ width: '30px' }}
style={{ width: '160px' }} value={user.number2}
value={user.id} onChange={handleChange}>
onChange={handleChange} /> </Form.Control>
<Form.Control.Feedback type="invalid"> 아이디를 입력하세요.</Form.Control.Feedback> <div className='font-weight-bold d-flex align-items-center'>
</Form.Row> * * * * * *
</Form.Group> </div>
<Form.Group controlId="formBasicPassword"> <Form.Control.Feedback type="invalid">주민등록번호를 입력하세요.</Form.Control.Feedback>
<Form.Row> </Row>
<Col sm={4} xs={6} as={Form.Label} for="password">비밀번호</Col> </Form.Row>
<Col sm={8} xs={12} as={Form.Control} </Form.Group>
type="password" <Form.Group controlId="formBasicId">
name="password" <Form.Row>
placeholder="Password" <Col sm={4} xs={6} as={Form.Label} for="id">아이디</Col>
style={{ width: '160px' }} <Col sm={8} xs={12} as={Form.Control}
value={user.password} required
required type="text"
onChange={handleChange} name="id"
/> placeholder="ID"
<Form.Control.Feedback className="text-center" type="invalid"> style={{ width: '160px' }}
비밀번호를 입력하세요. value={user.id}
onChange={handleChange} />
<Form.Control.Feedback type="invalid"> 아이디를 입력하세요.</Form.Control.Feedback>
</Form.Row>
</Form.Group>
<Form.Group controlId="formBasicPassword">
<Form.Row>
<Col sm={4} xs={6} as={Form.Label} for="password">비밀번호</Col>
<Col sm={8} xs={12} as={Form.Control}
type="password"
name="password"
placeholder="Password"
style={{ width: '160px' }}
value={user.password}
required
onChange={handleChange}
/>
<Form.Control.Feedback className="text-center" type="invalid">
비밀번호를 입력하세요.
</Form.Control.Feedback> </Form.Control.Feedback>
</Form.Row> </Form.Row>
</Form.Group> </Form.Group>
<Form.Group controlId="formBasicPassword2"> <Form.Group controlId="formBasicPassword2">
<Form.Row> <Form.Row>
<Col sm={4} xs={6} as={Form.Label} for="password">비밀번호 확인</Col> <Col sm={4} xs={6} as={Form.Label} for="password">비밀번호 확인</Col>
<Col sm={8} xs={12} as={Form.Control} <Col sm={8} xs={12} as={Form.Control}
type="password" type="password"
name="password2" name="password2"
placeholder="Password" placeholder="Password"
style={{ width: '160px' }} style={{ width: '160px' }}
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>
</Form.Group> </Form.Group>
<Form.Group controlId="formBasicTel"> <Form.Group controlId="formBasicEmail">
<Form.Row> <Form.Row>
<Col sm={4} xs={6} as={Form.Label} for="tel">휴대전화</Col> <Col sm={4} xs={6} as={Form.Label} for="email">이메일</Col>
<Col sm={8} xs={12} as={Form.Control} <Col sm={8} xs={12} as={Form.Control}
required required type="email"
type="text" name="email"
name="tel" placeholder="E-mail"
size="sm" style={{ width: '160px' }} style={{ width: '160px' }}
value={user.tel} value={user.email}
onChange={handleChange} /> onChange={handleChange} />
<Form.Control.Feedback type="invalid"> 휴대전화를 입력하세요. </Form.Control.Feedback> <Form.Control.Feedback type="invalid"> 이메일 입력하세요. </Form.Control.Feedback>
</Form.Row> </Form.Row>
</Form.Group> </Form.Group>
<Button <Form.Group controlId="formBasicTel">
style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block <Form.Row>
onClick={checkPassword} <Col sm={4} xs={6} as={Form.Label} for="tel">휴대전화</Col>
> <Col sm={8} xs={12} style={{ width: '160px' }} className='p-0'>
Sign Up <Col
as={Form.Control}
required type="text"
name="tel"
placeholder="Telephone"
className='p-1'
value={user.tel}
onChange={handleChange}>
</Col>
<div className='d-flex justify-content-end mt-1'><small >' - ' 함께 입력해주세요^^</small></div>
</Col>
<Form.Control.Feedback type="invalid"> 휴대전화를 입력하세요. </Form.Control.Feedback>
</Form.Row>
</Form.Group>
<Button
style={{ background: '#91877F', borderColor: '#91877F' }} type="submit" block
onClick={checkPassword}
>
Sign Up
</Button> </Button>
</Form> </Form>
</Col> </Col>
</Row> </Row>
</Container> </Container>
</div> </div>
) )
} }
export default Signup export default Signup
\ No newline at end of file
...@@ -31,8 +31,8 @@ const userById = async (req, res, next, id) => { ...@@ -31,8 +31,8 @@ const userById = async (req, res, next, id) => {
const signup = async (req, res) => { const signup = async (req, res) => {
const { name, number1, number2, id, password, tel } = req.body const { name, number1, number2, id, password, tel, email } = req.body
console.log(req.body) console.log("whatup",req.body)
try { try {
if (!isLength(password, { min: 8, max: 15 })) { if (!isLength(password, { min: 8, max: 15 })) {
return res.status(422).send('비밀번호는 8-15자리로 입력해주세요.') return res.status(422).send('비밀번호는 8-15자리로 입력해주세요.')
...@@ -51,8 +51,9 @@ const signup = async (req, res) => { ...@@ -51,8 +51,9 @@ const signup = async (req, res) => {
id, id,
password: hash, password: hash,
tel, tel,
email
}).save() }).save()
await new Cart({ userId: newUser._id, role }).save() await new Cart({ userId: newUser._id }).save()
console.log(newUser) console.log(newUser)
res.json(newUser) res.json(newUser)
......
...@@ -34,6 +34,10 @@ const UserSchema = new mongoose.Schema({ ...@@ -34,6 +34,10 @@ const UserSchema = new mongoose.Schema({
default: 'user', default: 'user',
enum: ['user', 'admin', 'root'] enum: ['user', 'admin', 'root']
}, },
email : {
type : String,
required: true,
},
avatarUrl: { avatarUrl: {
type: String type: String
} }
......
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