Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotel app initial commit #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Hotel app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

/node_modules
25 changes: 25 additions & 0 deletions Hotel app/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.py",
"FLASK_ENV": "development",
"FLASK_DEBUG": "0"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true
}
]
}
5 changes: 5 additions & 0 deletions Hotel app/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true
}
18 changes: 18 additions & 0 deletions Hotel app/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

1,623 changes: 1,623 additions & 0 deletions Hotel app/frontend/README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions Hotel app/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.8.2",
"@material-ui/icons": "^4.5.1",
"material-table": "^1.54.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "0.9.5",
"semantic-ui-react-form-validator": "^1.0.2"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000"
}
Binary file added Hotel app/frontend/public/favicon.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions Hotel app/frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<title>React App</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
31 changes: 31 additions & 0 deletions Hotel app/frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { Component } from 'react';
import {BrowserRouter , Route , Switch} from 'react-router-dom';
import { PrivateRoute } from './components/PrivateRoute';
import Registerform from './components/Registerform';
import Loginform from './components/Loginform';
import Main from './components/Main';
import Menumanagement from './components/Menumanagement';
import Additem from './components/Additem';
import Updateitem from './components/Updateitem';
import {isLoggedIn} from './components/auth';

class App extends Component {

render() {
return (
<BrowserRouter>
<Switch>

<Route exact path="/" component={Registerform} />
<Route exact path="/login" component={Loginform} />
<PrivateRoute exact isloggedin={isLoggedIn()} path="/main" component={Main} />
<PrivateRoute exact path="/menu" component={Menumanagement} />
<PrivateRoute exact path="/add" component={Additem} />
<PrivateRoute exact path="/update" component={Updateitem} />
</Switch>
</BrowserRouter>
);
}
}

export default App;
209 changes: 209 additions & 0 deletions Hotel app/frontend/src/components/Additem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
import React , {useState} from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import CssBaseline from '@material-ui/core/CssBaseline';
import Toolbar from '@material-ui/core/Toolbar';
import List from '@material-ui/core/List';
import Typography from '@material-ui/core/Typography';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import Button from '@material-ui/core/Button';
import {deleteTokens} from './auth';
import ExpandLess from '@material-ui/icons/ExpandLess';
import ExpandMore from '@material-ui/icons/ExpandMore';
import Collapse from '@material-ui/core/Collapse';
import TextField from '@material-ui/core/TextField';
import Container from '@material-ui/core/Container';
import Paper from '@material-ui/core/Paper';

const drawerWidth = 240;

const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
},
drawer: {
width: drawerWidth,
flexShrink: 0,
},
drawerPaper: {
width: drawerWidth,
},
content: {
flexGrow: 1,
padding: theme.spacing(3),
},
toolbar: theme.mixins.toolbar,
}));

const logout = (e) => {
e.preventDefault();
deleteTokens();
window.location.replace('/');
}

const homepage = () => {
window.location.replace("/main")
}

const menupage = () => {
window.location.replace("/menu");
}

const paymentpage = () => {
window.location.replace("/payment")
}

const additem = () => {
window.location.replace("/add")
}

const updateitem = () => {
window.location.replace("/update")
}

const deleteitem = () => {
window.location.replace("/delete")
}


export default function ClippedDrawer(props) {
const classes = useStyles();
const [name , setName] = useState("");
const [id , setId] = useState(0);
const [description , setDescription] = useState("");
const [amount, setAmount] = useState(0);
const [open, setOpen] = useState(true);

const handleClick = () => {
setOpen(!open);
};

const onSubmit = (e) => {
e.preventDefault();
const data = { id, name, description, amount }
fetch('/menu_create', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
}).then( res => {
if(res.ok){
window.location.replace("/menu")
}
})
};

return (
<div className={classes.root}>
<CssBaseline />
<AppBar position="fixed" className={classes.appBar}>
<Toolbar>
<Typography variant="h6" noWrap>
Hotel App
</Typography>
<Button color="inherit" onClick={logout}>Logout</Button>
</Toolbar>
</AppBar>
<Drawer
className={classes.drawer}
variant="permanent"
classes={{
paper: classes.drawerPaper,
}}
>
<div className={classes.toolbar} />
<List>
<ListItem button>
<ListItemText primary="Order" />
</ListItem>
<ListItem button onClick={handleClick}>
<ListItemText primary="Menu" />
{open ? <ExpandLess /> : <ExpandMore />}
</ListItem>
<Collapse in={open} timeout="auto" unmountOnExit>
<List component="div" disablePadding>
<ListItem button className={classes.nested}>
<ListItemText primary="Menu List" onClick={menupage} />
</ListItem>
<ListItem button className={classes.nested}>
<ListItemText primary="Add Item" onClick={additem} />
</ListItem>
<ListItem button className={classes.nested}>
<ListItemText primary="Update Item" onClick={updateitem} />
</ListItem>
<ListItem button className={classes.nested}>
<ListItemText primary="Delete Item" onClick={deleteitem} />
</ListItem>
</List>
</Collapse>
<ListItem button>
<ListItemText primary="Profile" />
</ListItem>
</List>
</Drawer>
<main className={classes.content}>
<div className={classes.toolbar} />
<div>
<Paper />
<Container maxWidth="sm">
<h1>Add Item</h1>
<TextField
placeholder="Enter Id of Item"
label="Item Id"
value={id}
onChange={event => setId(event.target.value)}
variant="outlined"
fullWidth="true"
margin="normal"
/>
<br />
<TextField
placeholder="Enter Name of Item"
label="Name"
value={name}
onChange={event => setName(event.target.value)}
variant="outlined"
margin="normal"
fullWidth="true"
/>
<br />
<TextField
placeholder="Enter Description"
label="Description"
value={description}
onChange={event => setDescription(event.target.value)}
variant="outlined"
margin="normal"
fullWidth="true"
/>
<br />
<TextField
placeholder="Enter Price"
label="Amount"
value={amount}
onChange={event => setAmount(event.target.value)}
variant="outlined"
margin="normal"
fullWidth="true"
/>
<br />
<br/>
<br/>
<Button
color="primary"
variant="contained"
onClick={onSubmit}
>Add Item
</Button>
</Container>
</div>
</main>
</div>
);
}
Loading