Commit 3783f660 authored by Piyaphorn Arphornsri's avatar Piyaphorn Arphornsri

add Data

parent 994792a7
...@@ -35,7 +35,10 @@ exports.register = async (req, res) => { ...@@ -35,7 +35,10 @@ exports.register = async (req, res) => {
const newUser = await User.create({ const newUser = await User.create({
name: registerData.name, name: registerData.name,
email: registerData.email, email: registerData.email,
password: passwordHash password: passwordHash,
address: registerData.address,
tel: registerData.tel,
role: registerData.role
}); });
const token = await createToken(newUser.id); const token = await createToken(newUser.id);
res.status(200).send("success"); res.status(200).send("success");
...@@ -50,8 +53,8 @@ exports.login = async (req, res) => { ...@@ -50,8 +53,8 @@ exports.login = async (req, res) => {
const user = await User.findOne({ const user = await User.findOne({
where: { email: loginData.email } where: { email: loginData.email }
}); });
if (!User) { if (!user) {
return res.status(400).json({ message: "รหัสผ่านไม่ถูกต้อง" }); return res.status(400).json({ message: "email หรือ รหัสผ่านไม่ถูกต้อง" });
} else { } else {
const chkPassword = await bcryptjs.compare( const chkPassword = await bcryptjs.compare(
loginData.password, loginData.password,
...@@ -61,15 +64,16 @@ exports.login = async (req, res) => { ...@@ -61,15 +64,16 @@ exports.login = async (req, res) => {
return res.status(400).json({ message: "รหัสผ่านไม่ถูกต้อง" }); return res.status(400).json({ message: "รหัสผ่านไม่ถูกต้อง" });
} }
const token = await createToken(user.dataValues.id); const token = await createToken(user.dataValues.id);
res.status(200).json({success}) res.status(200).send("success");
} }
}; };
exports.currentUser = async (req, res) =>{
exports.currentUser = async (req, res) => {
const token = req.headers.token; const token = req.headers.token;
const decode = await JWT.verify(token, config.JWT_SECRET) const decode = await JWT.verify(token, config.JWT_SECRET);
const user = await User.findOne({ const user = await User.findOne({
where: { where: {
id: decode.id id: decode.id
} }
}) });
} };
\ No newline at end of file
const List = require("../../models/list");
const config = require("../../config");
createToken = id => {
return JWT.sign({ id }, config.JWT_SECRET);
};
exports.list = async (req, res) => {
try {
const listData = req.body;
List.create(listData);
} catch (err) {
console.log(err);
res.sendStatus(401);
}
};
const Shop = require("../../models/shop");
const config = require("../../config");
createToken = id => {
return JWT.sign({ id }, config.JWT_SECRET);
};
exports.Shop = async (req, res) => {
try{
const shopData =req.body;
Shop.create(shopData);
}catch(err){
console.log(err);
res.sendStatus(401);
}
};
const Sequelize = require("sequelize"); const Sequelize = require("sequelize");
const db = require("../../db"); const db = require("../../db");
module.exports = db.sequelize.define("beauticianImage", { module.exports = db.sequelize.define("beauticianImages", {
beauticianImgID: { id: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
beauticianImgPic: { image: {
type: Sequelize.STRING type: Sequelize.TEXT
}, },
userbeauticianImgID: { beautician: {
type: Sequelize.INTEGER type: Sequelize.INTEGER,
references: "users",
referencesKey: "id"
} }
}); });
const Sequelize = require("sequelize"); const Sequelize = require("sequelize");
const db = require("../../db"); const db = require("../../db");
module.exports = db.sequelize.define("booking", { module.exports = db.sequelize.define("bookings", {
bookingID: { id: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
userID: { user: {
type: Sequelize.INTEGER type: Sequelize.INTEGER,
references: 'users',
referencesKey: 'id'
},
shop: {
type: Sequelize.INTEGER,
references: 'shops',
referencesKey: 'id'
}, },
shopID: { list: {
type: Sequelize.INTEGER type: Sequelize.INTEGER,
references: 'lists',
referencesKey: 'id'
}, },
listID: { beautician:{
type: Sequelize.INTEGER type:Sequelize.INTEGER,
references: 'users',
referencesKey: 'id'
}, },
bookingDete: { dete: {
type: Sequelize.DATE type: Sequelize.DATE
}, },
bookingTime: { time: {
type: Sequelize.TIME type: Sequelize.TIME
} }
}); });
const Sequelize = require("sequelize"); const Sequelize = require("sequelize");
const db = require("../../db"); const db = require("../../db");
module.exports = db.sequelize.define("list", { module.exports = db.sequelize.define("lists", {
listID: { id: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
slistName: { name: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
listprice: { price: {
type: Sequelize.INTEGER type: Sequelize.INTEGER
}, },
listTime: { time: {
type: Sequelize.INTEGER type: Sequelize.INTEGER
}, },
shopID: { shop: {
type: Sequelize.INTEGER type: Sequelize.INTEGER,
references: 'shops',
referencesKey: 'id'
} }
}); });
const Sequelize = require("sequelize"); const Sequelize = require("sequelize");
const db = require("../../db"); const db = require("../../db");
module.exports = db.sequelize.define("promotion", { module.exports = db.sequelize.define("promotions", {
promotionID: { id: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
promotionDete: { dete: {
type: Sequelize.DATE type: Sequelize.DATE
}, },
shopID: {
type: Sequelize.INTEGER detail: {
},
promotionDetail: {
type: Sequelize.STRING type: Sequelize.STRING
},
shop: {
type: Sequelize.INTEGER,
references: 'shops',
referencesKey: 'id'
} }
}); });
...@@ -2,28 +2,32 @@ const Sequelize = require("sequelize"); ...@@ -2,28 +2,32 @@ const Sequelize = require("sequelize");
const db = require("../../db"); const db = require("../../db");
module.exports = db.sequelize.define("reviwes", { module.exports = db.sequelize.define("reviwes", {
reviewsID: { id: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
reviewsTopic: { topic: {
type: Sequelize.INTEGER type: Sequelize.INTEGER
}, },
reviewsMessage: { message: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
reviewsPoint: { point: {
type: Sequelize.INTEGER type: Sequelize.INTEGER
}, },
reviewsPic: { image: {
type: Sequelize.STRING type: Sequelize.TEXT
}, },
shopID: { shop: {
type: Sequelize.INTEGER type: Sequelize.INTEGER,
references: 'shops',
referencesKey: 'id'
}, },
userID: { user: {
type: Sequelize.INTEGER type: Sequelize.INTEGER,
references: 'users',
referencesKey: 'id'
} }
}); });
const Sequelize = require("sequelize"); const Sequelize = require("sequelize");
const db = require("../../db"); const db = require("../../db");
module.exports = db.sequelize.define("shop", { module.exports = db.sequelize.define("shops", {
shopID: { id: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
shopName: { name: {
type: Sequelize.INTEGER type: Sequelize.INTEGER
}, },
shopTimeopen: { timeopen: {
type: Sequelize.TIME type: Sequelize.TIME
}, },
shopTimeClose: { timeclose: {
type: Sequelize.TIME type: Sequelize.TIME
}, },
shopAddress: { address: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
shopTel: { tel: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
shopDetial: { detial: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
shopMap: { map: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
shopType: { type: {
type: Sequelize.ENUM('สปาและนวด', 'ผิวหน้า', 'ขนตาและคิ้ว', 'ทำเล็บ', 'ชาลอน', 'แต่งหน้าทำผม') type: Sequelize.ENUM(
"สปาและนวด",
"ผิวหน้า",
"ขนตาและคิ้ว",
"ทำเล็บ",
"ชาลอน",
"แต่งหน้าทำผม"
)
} }
}); });
const Sequelize = require("sequelize"); const Sequelize = require("sequelize");
const db = require("../../db"); const db = require("../../db");
module.exports = db.sequelize.define("shopimage", { module.exports = db.sequelize.define("shopimages", {
shopImageID: { id: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
primaryKey: true, primaryKey: true,
autoIncrement: true autoIncrement: true
}, },
shopImagePic: { image: {
type: Sequelize.STRING type: Sequelize.TEXT
}, },
shopID: { shop: {
type: Sequelize.INTEGER type: Sequelize.INTEGER,
references: 'shops',
referencesKey: 'id'
} }
}); });
...@@ -18,8 +18,17 @@ module.exports = db.sequelize.define( ...@@ -18,8 +18,17 @@ module.exports = db.sequelize.define(
password: { password: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
photo: { address: {
type: Sequelize.STRING
},
tel: {
type: Sequelize.STRING type: Sequelize.STRING
}, },
photo: {
type: Sequelize.TEXT
},
role: {
type: Sequelize.INTEGER
}
}, },
); );
\ No newline at end of file
const Sequelize = require("sequelize");
const db = require("../../db");
module.exports = db.sequelize.define("usersShopOwner", {
userShopOwnerID: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
userShopOwnerName: {
type: Sequelize.INTEGER
},
userShopOwnerEmail: {
type: Sequelize.STRING
},
userShopOwnerPassword: {
type: Sequelize.STRING
},
userShopOwnerAddress: {
type: Sequelize.STRING
},
userShoppownerTel: {
type: Sequelize.STRING
},
userShopOwnerPic: {
type: Sequelize.STRING
}
});
const Sequelize = require("sequelize");
const db = require("../../db");
module.exports = db.sequelize.define("userbeautician", {
userbeauticianID: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
userbeauticianName: {
type: Sequelize.INTEGER
},
userbeauticianEmail: {
type: Sequelize.STRING
},
userbeauticianPassword: {
type: Sequelize.STRING
},
userbeauticianAddres: {
type: Sequelize.STRING
},
userbeauticianTel: {
type: Sequelize.STRING
},
shopID: {
type: Sequelize.STRING
},
userbeauticianPic: {
type: Sequelize.STRING
}
});
const express = require('express'); const express = require("express");
const router = express.Router(); const router = express.Router();
const authController = require('../../controllers/auth'); const authController = require("../../controllers/auth");
router.get('/get', (req, res) => { router.get("/get", (req, res) => {
res.json({"test": "Test get"}); res.json({ test: "Test get" });
}); });
router.get('/getUserById/:id', authController.getUserById); router.get("/getUserById/:id", authController.getUserById);
router.post("/register", authController.register);
router.post("/login", authController.login);
router.post('/register', authController.register);
module.exports = router; module.exports = router;
const auth = require('./auth'); const auth = require('./auth');
const list = require('./list');
const shop = require('./shop')
module.exports = { module.exports = {
auth auth,
list,
shop,
} }
\ No newline at end of file
const express = require("express");
const router = express.Router();
const authController = require("../../controllers/list");
router.post("/list", authController.list);
module.exports = router;
const express = require("express");
const router = express.Router();
const authController = require("../../controllers/shop");
router.post("/shop", authController.shop);
module.exports = router;
...@@ -10,6 +10,8 @@ app.use(cors()); ...@@ -10,6 +10,8 @@ app.use(cors());
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.urlencoded({ extended: false }))
app.use('/api/auth', router.auth); app.use('/api/auth', router.auth);
app.use('/api/list', router.list);
app.use('/api/shop', router.shop);
app.listen(port, () => { app.listen(port, () => {
console.log('Express server listening on port ' + port) console.log('Express server listening on port ' + port)
......
b_beauty_project/public/logo192.png

5.22 KB | W: | H:

b_beauty_project/public/logo192.png

2.93 KB | W: | H:

b_beauty_project/public/logo192.png
b_beauty_project/public/logo192.png
b_beauty_project/public/logo192.png
b_beauty_project/public/logo192.png
  • 2-up
  • Swipe
  • Onion skin
b_beauty_project/public/logo512.png

9.44 KB | W: | H:

b_beauty_project/public/logo512.png

2.93 KB | W: | H:

b_beauty_project/public/logo512.png
b_beauty_project/public/logo512.png
b_beauty_project/public/logo512.png
b_beauty_project/public/logo512.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -11,6 +11,10 @@ import SupervisedUserCircleOutlinedIcon from "@material-ui/icons/SupervisedUserC ...@@ -11,6 +11,10 @@ import SupervisedUserCircleOutlinedIcon from "@material-ui/icons/SupervisedUserC
import MapIcon from "@material-ui/icons/MapOutlined"; import MapIcon from "@material-ui/icons/MapOutlined";
import compose from "recompose/compose"; import compose from "recompose/compose";
import { withRouter } from "react-router-dom"; import { withRouter } from "react-router-dom";
import SpaIcon from '@material-ui/icons/Spa';
import FaceIcon from '@material-ui/icons/Face';
import RemoveRedEyeIcon from '@material-ui/icons/RemoveRedEye';
import PanToolIcon from '@material-ui/icons/PanTool';
const styles = theme => ({ const styles = theme => ({
root: { root: {
...@@ -65,13 +69,15 @@ class Dashboard extends Component { ...@@ -65,13 +69,15 @@ class Dashboard extends Component {
> >
<Tab <Tab
label="สปาและนวด" label="สปาและนวด"
icon={ icon={
<Badge <Badge
className={classes.margin} className={classes.margin}
//badgeContent={badgeOrder} //badgeContent={badgeOrder}
color="secondary" color="secondary"
> >
<ShoppingBasket /> <SpaIcon/>
</Badge> </Badge>
} }
className={classes.flex} className={classes.flex}
...@@ -84,7 +90,7 @@ class Dashboard extends Component { ...@@ -84,7 +90,7 @@ class Dashboard extends Component {
//badgeContent={badgeUser} //badgeContent={badgeUser}
color="secondary" color="secondary"
> >
<AccountCircle /> <FaceIcon />
</Badge> </Badge>
} }
className={classes.flex} className={classes.flex}
...@@ -97,24 +103,48 @@ class Dashboard extends Component { ...@@ -97,24 +103,48 @@ class Dashboard extends Component {
//badgeContent={badgeCredit} //badgeContent={badgeCredit}
color="secondary" color="secondary"
> >
<CreditCard /> <RemoveRedEyeIcon />
</Badge> </Badge>
} }
className={classes.flex} className={classes.flex}
/> />
<Tab <Tab
label="ทำเล็บ" label="ทำเล็บ"
icon={<SupervisedUserCircleOutlinedIcon />} icon={
<Badge
className={classes.margin}
//badgeContent={badgeCredit}
color="secondary"
>
<PanToolIcon />
</Badge>
}
className={classes.flex} className={classes.flex}
/> />
<Tab <Tab
label="ชาลอน" label="ชาลอน"
icon={<LiveHelpIcon />} icon={
<Badge
className={classes.margin}
//badgeContent={badgeCredit}
color="secondary"
>
<FaceIcon />
</Badge>
}
className={classes.flex} className={classes.flex}
/> />
<Tab <Tab
label="แต่งหน้าทำผม" label="แต่งหน้าทำผม"
icon={<HelpIcon />} icon={
<Badge
className={classes.margin}
//badgeContent={badgeCredit}
color="secondary"
>
<FaceIcon />
</Badge>
}
className={classes.flex} className={classes.flex}
/> />
</Tabs> </Tabs>
......
import React from 'react'; import React, { Component } from "react";
import { makeStyles } from '@material-ui/core/styles'; import { withRouter } from "react-router-dom";
import AppBar from '@material-ui/core/AppBar'; import compose from "recompose/compose";
import Toolbar from '@material-ui/core/Toolbar'; import { withStyles } from "@material-ui/core/styles";
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button'; import AppBar from "@material-ui/core/AppBar";
import IconButton from '@material-ui/core/IconButton'; import Toolbar from "@material-ui/core/Toolbar";
import MenuIcon from '@material-ui/icons/Menu'; import Typography from "@material-ui/core/Typography";
import Button from "@material-ui/core/Button";
const useStyles = makeStyles(theme => ({ import IconButton from "@material-ui/core/IconButton";
import MenuIcon from "@material-ui/icons/Menu";
const styles = theme => ({
root: { root: {
flexGrow: 1, flexGrow: 1
}, },
menuButton: { menuButton: {
marginRight: theme.spacing(2), marginRight: theme.spacing(2)
}, },
title: { title: {
flexGrow: 1, flexGrow: 1
}, }
})); });
class AppHeader extends Component {
export default function ButtonAppBar() { render() {
const classes = useStyles(); const { classes } = this.props;
return ( return (
<div className={classes.root}> <div className={classes.root}>
<AppBar position="static"> <AppBar position="static">
<Toolbar> <Toolbar>
<IconButton edge="start" className={classes.menuButton} color="inherit" aria-label="menu" Link href="/" > <IconButton
edge="start"
className={classes.menuButton}
color="inherit"
aria-label="menu"
Link
href="/"
>
B Beauty B Beauty
</IconButton> </IconButton>
<Typography variant="h6" className={classes.title}> <Typography variant="h6" className={classes.title}></Typography>
<Button color="inherit" Link href="/LoginPage">
</Typography> Login
<Button color="inherit" Link href="/LoginPage" >Login</Button> </Button>
<Button color="inherit" Link href="/RigisterPage" >rigister</Button> <Button color="inherit" Link href="/RigisterPage">
<Button color="inherit" Link href="/RigisterShopPage" >rigistershop</Button> rigister
</Button>
<Button color="inherit" Link href="/RigisterShopPage">
rigistershop
</Button>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
</div> </div>
); );
}
} }
export default compose(withStyles(styles), withRouter)(AppHeader);
...@@ -69,6 +69,16 @@ class HomePage extends Component { ...@@ -69,6 +69,16 @@ class HomePage extends Component {
open: false open: false
}); });
}; };
handleClickOpen2 = () => {
this.setState({
open: true
});
};
handleClose2 = () => {
this.setState({
open: false
});
};
componentDidMount = () => { componentDidMount = () => {
let { pathname } = this.props.location; let { pathname } = this.props.location;
...@@ -172,7 +182,7 @@ class HomePage extends Component { ...@@ -172,7 +182,7 @@ class HomePage extends Component {
<img <img
src="https://www.smeleader.com/wp-content/uploads/2018/05/%E0%B9%81%E0%B8%9F%E0%B8%A3%E0%B8%99%E0%B9%84%E0%B8%8A%E0%B8%AA%E0%B9%8C%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%99%E0%B9%80%E0%B8%AA%E0%B8%A3%E0%B8%B4%E0%B8%A1%E0%B8%AA%E0%B8%A7%E0%B8%A2-%E0%B8%A3%E0%B8%A7%E0%B8%A1%E0%B9%81%E0%B8%9A%E0%B8%A3%E0%B8%99%E0%B8%94%E0%B9%8C%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%99%E0%B8%8B%E0%B8%B2%E0%B8%A5%E0%B8%AD%E0%B8%99-%E0%B8%AA%E0%B8%B2%E0%B8%99%E0%B8%9D%E0%B8%B1%E0%B8%99%E0%B8%98%E0%B8%B8%E0%B8%A3%E0%B8%81%E0%B8%B4%E0%B8%88%E0%B8%97%E0%B8%A3%E0%B8%87%E0%B8%9C%E0%B8%A1.jpg" src="https://www.smeleader.com/wp-content/uploads/2018/05/%E0%B9%81%E0%B8%9F%E0%B8%A3%E0%B8%99%E0%B9%84%E0%B8%8A%E0%B8%AA%E0%B9%8C%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%99%E0%B9%80%E0%B8%AA%E0%B8%A3%E0%B8%B4%E0%B8%A1%E0%B8%AA%E0%B8%A7%E0%B8%A2-%E0%B8%A3%E0%B8%A7%E0%B8%A1%E0%B9%81%E0%B8%9A%E0%B8%A3%E0%B8%99%E0%B8%94%E0%B9%8C%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%99%E0%B8%8B%E0%B8%B2%E0%B8%A5%E0%B8%AD%E0%B8%99-%E0%B8%AA%E0%B8%B2%E0%B8%99%E0%B8%9D%E0%B8%B1%E0%B8%99%E0%B8%98%E0%B8%B8%E0%B8%A3%E0%B8%81%E0%B8%B4%E0%B8%88%E0%B8%97%E0%B8%A3%E0%B8%87%E0%B8%9C%E0%B8%A1.jpg"
width="70%" width="70%"
></img> />
</div> </div>
</div> </div>
...@@ -185,9 +195,7 @@ class HomePage extends Component { ...@@ -185,9 +195,7 @@ class HomePage extends Component {
</div> </div>
<div className="row"> <div className="row">
<h4> <h4>โปรโมชั่น : จองคิวผ่าน B Beauty ลด 5 %</h4>
โปรโมชั่น : จองคิวผ่าน B Beauty ลด 5 %
</h4>
</div> </div>
<div className="row"> <div className="row">
...@@ -237,18 +245,19 @@ class HomePage extends Component { ...@@ -237,18 +245,19 @@ class HomePage extends Component {
/> />
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={this.handleClose} color="primary"> <Button variant="outlined" onClick={this.handleClose} color="primary">
Disagree ยกเลิก
</Button> </Button>
<Button <Button
onClick={this.handleClose} variant="outlined"
color="primary" color="primary"
autoFocus onClick={this.handleClickOpen}
> >
Agree ถัดไป
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -10,6 +10,8 @@ import AddPhotoAlternateIcon from "@material-ui/icons/AddPhotoAlternate"; ...@@ -10,6 +10,8 @@ import AddPhotoAlternateIcon from "@material-ui/icons/AddPhotoAlternate";
import MailOutlineIcon from "@material-ui/icons/MailOutline"; import MailOutlineIcon from "@material-ui/icons/MailOutline";
import VpnKeyIcon from "@material-ui/icons/VpnKey"; import VpnKeyIcon from "@material-ui/icons/VpnKey";
import Button from "@material-ui/core/Button"; import Button from "@material-ui/core/Button";
import ContactPhoneIcon from "@material-ui/icons/ContactPhone";
import BusinessIcon from "@material-ui/icons/Business";
import axios from "axios"; import axios from "axios";
...@@ -28,7 +30,10 @@ class RegisterPage extends Component { ...@@ -28,7 +30,10 @@ class RegisterPage extends Component {
email: "", email: "",
password: "", password: "",
password2: "", password2: "",
image: "" address: "",
tel: "",
image: "",
rolr: "0"
}; };
handleChange = event => { handleChange = event => {
...@@ -38,20 +43,21 @@ class RegisterPage extends Component { ...@@ -38,20 +43,21 @@ class RegisterPage extends Component {
this.setState({ this.setState({
[event.target.name]: event.target.value [event.target.name]: event.target.value
}); });
// this.setState({
// name: name,
// email: email,
// password: password,
// password2: password2,
// image: image
// });
}; };
render() { render() {
const { classes } = this.props; const { classes } = this.props;
// const { } = this.state; // const { } = this.state;
const { name, email, password, password2, image } = this.state; const {
name,
email,
password,
password2,
address,
tel,
image,
role
} = this.state;
return ( return (
<div className="row center"> <div className="row center">
<h2>ลงทะเบียน</h2> <h2>ลงทะเบียน</h2>
...@@ -132,6 +138,43 @@ class RegisterPage extends Component { ...@@ -132,6 +138,43 @@ class RegisterPage extends Component {
/> />
</div> </div>
<br></br> <br></br>
<div>
<TextField
className={classes.margin}
id="address"
name="address"
value={address}
label="ที่อยู่"
autoComplete="address"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<BusinessIcon />
</InputAdornment>
)
}}
onChange={this.handleChange}
/>
<TextField
className={classes.margin}
id="tel"
name="tel"
value={tel}
label="เบอร์โทร"
autoComplete="Phone number"
variant="outlined"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<ContactPhoneIcon />
</InputAdornment>
)
}}
onChange={this.handleChange}
/>
</div>
<br></br>
<div> <div>
<TextField <TextField
className={classes.margin} className={classes.margin}
...@@ -168,7 +211,10 @@ class RegisterPage extends Component { ...@@ -168,7 +211,10 @@ class RegisterPage extends Component {
email: email, email: email,
password: password, password: password,
name: name, name: name,
image: image image: image,
address: address,
tel: tel,
role:role
}) })
.then(response => { .then(response => {
console.log("สร้างผู้ใช้สำเร็จ", response); console.log("สร้างผู้ใช้สำเร็จ", response);
...@@ -179,7 +225,7 @@ class RegisterPage extends Component { ...@@ -179,7 +225,7 @@ class RegisterPage extends Component {
}); });
// alert("ลงทะเบียนสำเร็จ"); // alert("ลงทะเบียนสำเร็จ");
} else { } else {
alert("password ไม่ตรงกันโว๊ยยยย"); alert("password ไม่ถูกต้อง");
} }
}} }}
> >
......
import React, { Component } from "react"; import React, { Component } from "react";
import { withStyles } from "@material-ui/core/styles"; import { withStyles } from "@material-ui/core/styles";
import { withRouter } from "react-router-dom"; import { Input, InputLabel } from "@material-ui/core";
import compose from "recompose/compose";
import Input from "@material-ui/core/Input";
import InputLabel from "@material-ui/core/InputLabel";
import InputAdornment from "@material-ui/core/InputAdornment"; import InputAdornment from "@material-ui/core/InputAdornment";
import FormControl from "@material-ui/core/FormControl"; import FormControl from "@material-ui/core/FormControl";
import TextField from "@material-ui/core/TextField"; import TextField from "@material-ui/core/TextField";
...@@ -13,20 +10,54 @@ import AddPhotoAlternateIcon from "@material-ui/icons/AddPhotoAlternate"; ...@@ -13,20 +10,54 @@ import AddPhotoAlternateIcon from "@material-ui/icons/AddPhotoAlternate";
import MailOutlineIcon from "@material-ui/icons/MailOutline"; import MailOutlineIcon from "@material-ui/icons/MailOutline";
import VpnKeyIcon from "@material-ui/icons/VpnKey"; import VpnKeyIcon from "@material-ui/icons/VpnKey";
import Button from "@material-ui/core/Button"; import Button from "@material-ui/core/Button";
import TextareaAutosize from "@material-ui/core/TextareaAutosize";
import ContactPhoneIcon from "@material-ui/icons/ContactPhone"; import ContactPhoneIcon from "@material-ui/icons/ContactPhone";
import BusinessIcon from "@material-ui/icons/Business"; import BusinessIcon from "@material-ui/icons/Business";
import axios from "axios";
import { withRouter } from "react-router-dom";
import compose from "recompose/compose";
const styles = theme => ({ const styles = theme => ({
margin: { margin: {
margin: theme.spacing(1) margin: theme.spacing(1)
} }
}); });
class Registershop extends Component { class RegisterShopPage extends Component {
state = {
name: "",
email: "",
password: "",
password2: "",
address: "",
tel: "",
image: "",
rolr: "1"
};
handleChange = event => {
console.log("name : ", event.target.name);
console.log("value : ", event.target.value);
this.setState({
[event.target.name]: event.target.value
});
};
render() { render() {
const { classes } = this.props; const { classes } = this.props;
// const { } = this.state;
const {
name,
email,
password,
password2,
address,
tel,
image,
role
} = this.state;
return ( return (
<div className="row center"> <div className="row center">
<h2>ลงทะเบียนธุรกิจ</h2> <h2>ลงทะเบียนธุรกิจ</h2>
...@@ -34,8 +65,10 @@ class Registershop extends Component { ...@@ -34,8 +65,10 @@ class Registershop extends Component {
<div> <div>
<TextField <TextField
className={classes.margin} className={classes.margin}
id="outlined-uncontrolled" id="name"
label="ชื่อร้าน" name="name"
value={name}
label="ชื่อ-สกุล"
variant="outlined" variant="outlined"
InputProps={{ InputProps={{
startAdornment: ( startAdornment: (
...@@ -44,11 +77,14 @@ class Registershop extends Component { ...@@ -44,11 +77,14 @@ class Registershop extends Component {
</InputAdornment> </InputAdornment>
) )
}} }}
onChange={this.handleChange}
/> />
<TextField <TextField
className={classes.margin} className={classes.margin}
id="outlined-uncontrolled" id="email"
name="email"
value={email}
label="E_mail" label="E_mail"
variant="outlined" variant="outlined"
InputProps={{ InputProps={{
...@@ -58,13 +94,16 @@ class Registershop extends Component { ...@@ -58,13 +94,16 @@ class Registershop extends Component {
</InputAdornment> </InputAdornment>
) )
}} }}
onChange={this.handleChange}
/> />
</div> </div>
<br></br> <br></br>
<div> <div>
<TextField <TextField
className={classes.margin} className={classes.margin}
id="outlined-password-input" id="password"
name="password"
value={password}
label="Password" label="Password"
type="password" type="password"
autoComplete="current-password" autoComplete="current-password"
...@@ -76,11 +115,14 @@ class Registershop extends Component { ...@@ -76,11 +115,14 @@ class Registershop extends Component {
</InputAdornment> </InputAdornment>
) )
}} }}
onChange={this.handleChange}
/> />
<TextField <TextField
className={classes.margin} className={classes.margin}
id="outlined-password-input" id="password2"
name="password2"
value={password2}
label="Confirm-Password" label="Confirm-Password"
type="password" type="password"
autoComplete="current-password" autoComplete="current-password"
...@@ -92,13 +134,16 @@ class Registershop extends Component { ...@@ -92,13 +134,16 @@ class Registershop extends Component {
</InputAdornment> </InputAdornment>
) )
}} }}
onChange={this.handleChange}
/> />
</div> </div>
<br></br> <br></br>
<div> <div>
<TextField <TextField
className={classes.margin} className={classes.margin}
id="outlined-password-input" id="address"
name="address"
value={address}
label="ที่อยู่" label="ที่อยู่"
autoComplete="address" autoComplete="address"
variant="outlined" variant="outlined"
...@@ -109,10 +154,13 @@ class Registershop extends Component { ...@@ -109,10 +154,13 @@ class Registershop extends Component {
</InputAdornment> </InputAdornment>
) )
}} }}
onChange={this.handleChange}
/> />
<TextField <TextField
className={classes.margin} className={classes.margin}
id="outlined-password-input" id="tel"
name="tel"
value={tel}
label="เบอร์โทร" label="เบอร์โทร"
autoComplete="Phone number" autoComplete="Phone number"
variant="outlined" variant="outlined"
...@@ -123,13 +171,16 @@ class Registershop extends Component { ...@@ -123,13 +171,16 @@ class Registershop extends Component {
</InputAdornment> </InputAdornment>
) )
}} }}
onChange={this.handleChange}
/> />
</div> </div>
<br></br> <br></br>
<div> <div>
<TextField <TextField
className={classes.margin} className={classes.margin}
id="outlined-file-input" id="image"
name="image"
value={image}
label="เพิ่มรูปภาพ" label="เพิ่มรูปภาพ"
type="file" type="file"
autoComplete="current-password" autoComplete="current-password"
...@@ -141,6 +192,7 @@ class Registershop extends Component { ...@@ -141,6 +192,7 @@ class Registershop extends Component {
</InputAdornment> </InputAdornment>
) )
}} }}
onChange={this.handleChange}
/> />
</div> </div>
<br></br> <br></br>
...@@ -149,7 +201,34 @@ class Registershop extends Component { ...@@ -149,7 +201,34 @@ class Registershop extends Component {
ยกเลิก ยกเลิก
</Button>{" "} </Button>{" "}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<Button variant="contained" color="primary"> <Button
variant="contained"
color="primary"
onClick={() => {
if (password === password2) {
axios
.post("http://localhost:9000/api/auth/register", {
email: email,
password: password,
name: name,
image: image,
address: address,
tel: tel,
role:role
})
.then(response => {
console.log("สร้างผู้ใช้สำเร็จ", response);
window.location.href = "/";
})
.catch(error => {
console.log(error);
});
// alert("ลงทะเบียนสำเร็จ");
} else {
alert("password ไม่ถูกต้อง");
}
}}
>
ลงทะเบียน ลงทะเบียน
</Button> </Button>
</div> </div>
...@@ -157,4 +236,5 @@ class Registershop extends Component { ...@@ -157,4 +236,5 @@ class Registershop extends Component {
); );
} }
} }
export default compose(withStyles(styles), withRouter)(Registershop);
export default compose(withStyles(styles), withRouter)(RegisterShopPage);
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