Skip to content

Commit

Permalink
added container height
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksanteri Heliövaara authored and Aleksanteri Heliövaara committed Jan 26, 2021
1 parent 6b0a795 commit bcc2535
Show file tree
Hide file tree
Showing 9 changed files with 1,827 additions and 114 deletions.
2 changes: 1 addition & 1 deletion client/.eslintcache

Large diffs are not rendered by default.

1,697 changes: 1,697 additions & 0 deletions client/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"node-sass": "^4.14.1",
"react": "^17.0.1",
"react-bootstrap": "^1.3.0",
"react-code-snippet": "^0.6.13",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion client/src/Components/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Navigation = (props) => {
{
props.auth ?
<Navbar.Collapse id="responsive-navbar-nav">

{console.log(user)}
<Nav className="mr-auto">
<Nav.Link className="link" href="/transportlist">Tilausseuranta</Nav.Link>
<Nav.Link href="/itemslist">Ruokalista</Nav.Link>
Expand Down
32 changes: 16 additions & 16 deletions client/src/Views/AddItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { Button, Container, Form } from 'react-bootstrap';
import axios from 'axios';
import { useHistory } from "react-router-dom";
import { withAuthenticationRequired } from "@auth0/auth0-react";
import { useAuth0 } from "@auth0/auth0-react";

const AddItem = (props) => {
let history = useHistory();

const { user } = useAuth0();
const [name, setName] = useState("")
const [description, setDescription] = useState("")
const [price, setPrice] = useState("")
Expand All @@ -19,12 +20,13 @@ const AddItem = (props) => {
params: {
name: name,
description: description,
price: price
price: price,
restaurantId: user.sub

}
})

.then(alert("Tuote lisätty"), history.push.push('/itemslist'))
.then(alert("Tuote lisätty"), history.push('/itemslist'))
}
catch (error) {
console.error(error.message)
Expand All @@ -34,31 +36,29 @@ const AddItem = (props) => {
<Container>
<Form>
<Form.Group controlId="formBasicEmail">
<Form.Label>Meal name</Form.Label>
<Form.Control type="text" placeholder="Enter meal name" value={name} onChange={(e) => setName(e.target.value)} />
<Form.Label>Annoksen nimi</Form.Label>
<Form.Control type="text" placeholder="Nimi" value={name} onChange={(e) => setName(e.target.value)} />
<Form.Text className="text-muted" >
Make it tasty!

</Form.Text>
</Form.Group>
<Form.Group controlId="formBasicEmail">
<Form.Label>Meal Description</Form.Label>
<Form.Control type="text" placeholder="Enter meal description" value={description} onChange={(e) => setDescription(e.target.value)} />
<Form.Label>Annoksen kuvaus</Form.Label>
<Form.Control type="text" placeholder="Kuvaus" value={description} onChange={(e) => setDescription(e.target.value)} />
<Form.Text className="text-muted">
Rock my world!

</Form.Text>
</Form.Group>
<Form.Group >
<Form.Label>Meal price in</Form.Label>
<Form.Control type="text" placeholder="Enter meal price" value={price} onChange={(e) => setPrice(e.target.value)} />
<Form.Label>Annoksen hinta /</Form.Label>
<Form.Control type="text" placeholder="Hinta" value={price} onChange={(e) => setPrice(e.target.value)} />
<Form.Text className="text-muted">
Make them pay!

</Form.Text>
</Form.Group>
<Form.Group controlId="formBasicCheckbox">
<Form.Check type="checkbox" label="Add item to menu" />
</Form.Group>

<Button variant="primary" type="submit" onClick={e => handleSubmit(e)}>
Submit
Lisää annos listalle
</Button>
</Form>
</Container>
Expand Down
26 changes: 21 additions & 5 deletions client/src/Views/ItemsList.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import React, { useState, useEffect } from 'react';
import { Card, Container, Button } from 'react-bootstrap';
import { Card, Container, Button, Alert, Row } from 'react-bootstrap';
import axios from 'axios'
import { useHistory } from "react-router-dom";
import { withAuthenticationRequired } from "@auth0/auth0-react";
import { useAuth0 } from "@auth0/auth0-react";
import ReactCodeSinppet from 'react-code-snippet'

const ItemsList = (props) => {
let history = useHistory();
const { user } = useAuth0();
const [items, setItems] = useState([])
const [loading, setIsLoading] = useState(false)

const GetItems = async () => {
setIsLoading(true)
await axios.get('/api/getitems', {
params: {
restaurantId: user.sub
}
})
.then(function (response) {
let data = response.data
Expand Down Expand Up @@ -40,12 +47,12 @@ const ItemsList = (props) => {
})
.finally(function () {
setIsLoading(false)

GetItems()
});
}
useEffect(() => {
GetItems()

console.log(items)
}, [])
return (
<Container style={{minHeight: "100vh"}}>
Expand Down Expand Up @@ -78,9 +85,18 @@ const ItemsList = (props) => {
:
<h1>Loading </h1>
}

<Alert variant="dark">
Voit käydä katsomassa miltä ruokalistasi
<Alert.Link target="blank" href={`https://ruokalista-app.herokuapp.com/${user.sub}`}> näyttää</Alert.Link>
</Alert>



<Alert variant="dark">
<p>Kopioi tämä koodi kotisivuillesi saadaksesi ruokalistasi näkyviin:</p>
<ReactCodeSinppet lang="html" code={`<iframe src="https://ruokalista-app.herokuapp.com/${user.sub}" style="height:1000px;width:100%;border:none" >
</iframe>`}>
</ReactCodeSinppet>
</Alert>
</Container>
);
}
Expand Down
158 changes: 84 additions & 74 deletions client/src/Views/TransportList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Timestamp from 'react-timestamp';
import { withAuthenticationRequired } from "@auth0/auth0-react";
import OrderState from '../Components/orderState';
import ClipLoader from "react-spinners/ClipLoader";
import { useAuth0 } from "@auth0/auth0-react";

const State = styled.div`
height: 60px;
Expand All @@ -21,17 +22,20 @@ const State = styled.div`


const TransportList = () => {
const { user } = useAuth0();
const [items, setItems] = useState([])
const [loading, setIsLoading] = useState(false)
const [recieved, setRecieved] = useState(true);
const [prepared, setPrepared] = useState(true);
const [inDelivery, setInDelivery] = useState(true);
const [delivered, setDelivered] = useState(true);

const GetOrders = async () => {
setIsLoading(true)
await setInterval(() => {
axios.get('/api/getorders', {
axios.get(`/api/getorders`, {
params: {
restaurantId: user.sub
}
})
.then(function (response) {
let data = response.data
Expand All @@ -46,7 +50,7 @@ const TransportList = () => {
setIsLoading(false)

});
}, 3000);
}, 10000);

}
const DeleteOrder = async ( id ) => {
Expand All @@ -67,77 +71,83 @@ const TransportList = () => {
});
}

const orderRecieved = async (id) => {
await axios.get(`/api/orderrecieved`, {
params: {
fieldState: recieved ? 1 : 0 ,
orderId: id
}
})
.then(function (response) {
GetOrders()
})
.catch(function (error) {
console.log(error);
})
.finally(function () {
// const orderRecieved = async (id) => {
// await axios.get(`/api/orderrecieved`, {
// params: {
// fieldState: recieved ? 1 : 0 ,
// orderId: id
// }
// })
// .then(function (response) {
// GetOrders()
// })
// .catch(function (error) {
// console.log(error);
// })
// .finally(function () {

});
// });

}
const orderPrepared = async (id) => {
await axios.get(`/api/orderprepared`, {
params: {
fieldState: prepared ? 1 : 0 ,
orderId: id
}
})
.then(function (response) {
GetOrders()
})
.catch(function (error) {
console.log(error);
})
.finally(function () {
});
}
const OrderInDelivery = async (id) => {
await axios.get(`/api/orderindelivery`, {
params: {
fieldState: inDelivery ? 1 : 0 ,
orderId: id
}
})
.then(function (response) {
GetOrders()
})
.catch(function (error) {
console.log(error);
})
.finally(function () {
});
}
const OrderDelivered = async (id) => {
await axios.get(`/api/orderdelivered`, {
params: {
fieldState: delivered ? 1 : 0 ,
orderId: id
}
})
.then(function (response) {
GetOrders()
})
.catch(function (error) {
console.log(error);
})
.finally(function () {
});
}
// }
// const orderPrepared = async (id) => {
// await axios.get(`/api/orderprepared`, {
// params: {
// fieldState: prepared ? 1 : 0 ,
// orderId: id
// }
// })
// .then(function (response) {
// GetOrders()
// })
// .catch(function (error) {
// console.log(error);
// })
// .finally(function () {
// });
// }
// const OrderInDelivery = async (id) => {
// await axios.get(`/api/orderindelivery`, {
// params: {
// fieldState: inDelivery ? 1 : 0 ,
// orderId: id
// }
// })
// .then(function (response) {
// GetOrders()
// })
// .catch(function (error) {
// console.log(error);
// })
// .finally(function () {
// });
// }
// const OrderDelivered = async (id) => {
// await axios.get(`/api/orderdelivered`, {
// params: {
// fieldState: delivered ? 1 : 0 ,
// orderId: id
// }
// })
// .then(function (response) {
// GetOrders()
// })
// .catch(function (error) {
// console.log(error);
// })
// .finally(function () {
// });
// }
useEffect(() => {
GetOrders()
console.log(user)
}, [])


return (
<Container style={{minHeight: "100vh"}}>
{
!items.length > 0 && !loading ? <h1>Ei tilauksia</h1> : ""
}
<Accordion >

{
Expand Down Expand Up @@ -171,7 +181,7 @@ const TransportList = () => {
</Card.Header>
<Accordion.Collapse eventKey={`${i}`} >
<Card.Body>
<Row>
{/* <Row>
<Col sm>
<State>
<Form.Check
Expand Down Expand Up @@ -207,7 +217,7 @@ const TransportList = () => {
</Col>
</Row>
</Row> */}
<Form>
<Form.Row>
<Form.Group as={Col} md="6" controlId="validationCustom01">
Expand All @@ -232,7 +242,7 @@ const TransportList = () => {

</Form.Row>
<h4>Kuljettaja täyttää:</h4>
<Row>
{/* <Row>
<Col sm>
<State>
<Form.Check
Expand Down Expand Up @@ -268,7 +278,7 @@ const TransportList = () => {
</Col>
</Row>
</Row> */}
<Form.Row>
<Form.Group as={Col} md="6" controlId="validationCustom03">
<Form.Label>Tilaus perillä noin</Form.Label>
Expand Down Expand Up @@ -302,7 +312,7 @@ const TransportList = () => {
</Form>


<Button onClick={() => DeleteOrder(item.id)}>Tuote on kuljetettu asiakkaalle</Button>
<Button onClick={() => DeleteOrder(item.id)}>Tilaus on kuljetettu asiakkaalle</Button>
</Card.Body>
</Accordion.Collapse>
</Card>
Expand All @@ -314,9 +324,9 @@ const TransportList = () => {
})

:

<div style={{width: '40px', marginLeft: 'auto', marginRight: 'auto', marginTop: '100px'}}>
<ClipLoader loading={loading} size={40} />

<ClipLoader size={40} />
</div>

}
Expand Down
Loading

0 comments on commit bcc2535

Please sign in to comment.