added lunch hours | added restaurant type

This commit is contained in:
2020-10-20 19:37:45 +02:00
parent 20c7dd18a7
commit e488827335
3 changed files with 81 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ import { useSelector, useDispatch } from "react-redux";
import { notification, refreshUserData } from "../../actions"; import { notification, refreshUserData } from "../../actions";
import { showBackdrop, hideBackdrop } from "../../actions/toggles.js"; import { showBackdrop, hideBackdrop } from "../../actions/toggles.js";
import InputWorkingHours from "../Input/InputWorkingHours"; import InputWorkingHours from "../Input/InputWorkingHours";
import InputWorkingHoursSingle from "../Input/InputWorkingHoursSingle";
import { backend } from "../../config"; import { backend } from "../../config";
// ICONS // ICONS
import FastfoodIcon from "@material-ui/icons/Fastfood"; import FastfoodIcon from "@material-ui/icons/Fastfood";
@@ -96,6 +97,7 @@ export default function NewRestaurant() {
adress: "", adress: "",
coordinates: [52.354293, 19.42377], coordinates: [52.354293, 19.42377],
placesId: "", placesId: "",
type: "",
imgUrl: "", imgUrl: "",
workingHours: { workingHours: {
pn: "8:00 - 22:00", pn: "8:00 - 22:00",
@@ -106,6 +108,7 @@ export default function NewRestaurant() {
sb: "8:00 - 22:00", sb: "8:00 - 22:00",
nd: "8:00 - 22:00", nd: "8:00 - 22:00",
}, },
lunchHours: "12:30 - 13:30",
description: "", description: "",
tags: [], tags: [],
phone: "", phone: "",
@@ -118,6 +121,7 @@ export default function NewRestaurant() {
cityError: false, cityError: false,
adressError: false, adressError: false,
descriptionError: false, descriptionError: false,
typeError: false,
charLeft: 400, charLeft: 400,
}; };
const steps = ["Informacje", "Zdjęcie", "Lokalizacja"]; const steps = ["Informacje", "Zdjęcie", "Lokalizacja"];
@@ -146,6 +150,8 @@ export default function NewRestaurant() {
adress: state.adress, adress: state.adress,
coordinates: state.coordinates, coordinates: state.coordinates,
placesId: state.placesId, placesId: state.placesId,
lunchHours: state.lunchHours,
type: state.type,
imgUrl: state.imgUrl, imgUrl: state.imgUrl,
workingHours: state.workingHours, workingHours: state.workingHours,
description: state.description, description: state.description,
@@ -187,6 +193,10 @@ export default function NewRestaurant() {
}); });
}; };
const setLunchHours = (hours) => {
setState({ ...state, lunchHours: hours });
}
const setCoordinatesAndPlacesID = (coordinates, placesID) => { const setCoordinatesAndPlacesID = (coordinates, placesID) => {
if (!placesID) { if (!placesID) {
setState({ ...state, coordinates: coordinates }); setState({ ...state, coordinates: coordinates });
@@ -234,6 +244,7 @@ export default function NewRestaurant() {
nameValid: validator.isLength(state.name, { min: 1, max: 40 }), nameValid: validator.isLength(state.name, { min: 1, max: 40 }),
cityValid: validator.isLength(state.city, { min: 1, max: 40 }), cityValid: validator.isLength(state.city, { min: 1, max: 40 }),
adressValid: validator.isLength(state.name, { min: 1, max: 40 }), adressValid: validator.isLength(state.name, { min: 1, max: 40 }),
typeValid: validator.isLength(state.type, { min: 1, max: 40 }),
descriptionValid: validator.isLength(state.description, { descriptionValid: validator.isLength(state.description, {
min: 1, min: 1,
max: 400, max: 400,
@@ -243,6 +254,7 @@ export default function NewRestaurant() {
...state, ...state,
nameError: !validation.nameValid, nameError: !validation.nameValid,
cityError: !validation.cityValid, cityError: !validation.cityValid,
typeError: !validation.typeValid,
adressError: !validation.adressValid, adressError: !validation.adressValid,
descriptionError: !validation.descriptionValid, descriptionError: !validation.descriptionValid,
}); });
@@ -251,7 +263,8 @@ export default function NewRestaurant() {
validation.nameValid && validation.nameValid &&
validation.cityValid && validation.cityValid &&
validation.adressValid && validation.adressValid &&
validation.descriptionValid validation.descriptionValid &&
validation.typeValid
); );
}; };
@@ -292,6 +305,7 @@ export default function NewRestaurant() {
error={state.nameError} error={state.nameError}
value={state.name} value={state.name}
label="Nazwa lokalu" label="Nazwa lokalu"
placeholder="np. Pierożek"
variant="outlined" variant="outlined"
onChange={(event) => onChange={(event) =>
setState({ ...state, name: event.target.value }) setState({ ...state, name: event.target.value })
@@ -305,11 +319,33 @@ export default function NewRestaurant() {
}} }}
/> />
</div> </div>
<div className="newRestaurant-content-fullwidth">
<TextField
className={styles.textInputFullWidth}
fullWidth
value={state.type}
error={state.typeError}
label="Kuchnia"
placeholder="np. Meksykańska"
variant="outlined"
onChange={(event) =>
setState({ ...state, type: event.target.value })
}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<FastfoodIcon color="primary" />
</InputAdornment>
),
}}
/>
</div>
<div className="newRestaurant-content"> <div className="newRestaurant-content">
<TextField <TextField
className={styles.textInput} className={styles.textInput}
required required
label="Miasto" label="Miasto"
placeholder="np. Ciechanów"
error={state.cityError} error={state.cityError}
value={state.city} value={state.city}
variant="outlined" variant="outlined"
@@ -328,6 +364,7 @@ export default function NewRestaurant() {
className={styles.textInput} className={styles.textInput}
required required
label="Adres" label="Adres"
placeholder="np. Akacjowa 13"
variant="outlined" variant="outlined"
error={state.adressError} error={state.adressError}
value={state.adress} value={state.adress}
@@ -348,6 +385,10 @@ export default function NewRestaurant() {
setState({ ...state, workingHours: hours }) setState({ ...state, workingHours: hours })
} }
/> />
<div className="newRestaurant-content-fullwidth">
<div className="workingHours-container" style={{ marginTop: 14 }}>
<InputWorkingHoursSingle nieczynne={!state.lunchHours} hours={state.lunchHours} changeValue={(value) => setLunchHours(value)} day="Lunch hours" /></div>
</div>
<div className="newRestaurant-content-fullwidth"> <div className="newRestaurant-content-fullwidth">
<TextField <TextField
className={styles.textInputFullWidth} className={styles.textInputFullWidth}

View File

@@ -13,6 +13,7 @@ import InstagramIcon from "@material-ui/icons/Instagram";
import LanguageIcon from "@material-ui/icons/Language"; import LanguageIcon from "@material-ui/icons/Language";
import FastfoodIcon from "@material-ui/icons/Fastfood"; import FastfoodIcon from "@material-ui/icons/Fastfood";
import LocationCityIcon from "@material-ui/icons/LocationCity"; import LocationCityIcon from "@material-ui/icons/LocationCity";
import InputWorkingHoursSingle from "../Input/InputWorkingHoursSingle";
import Divider from "@material-ui/core/Divider"; import Divider from "@material-ui/core/Divider";
import Link from "@material-ui/core/Link"; import Link from "@material-ui/core/Link";
import { decodeTags } from "../../Services"; import { decodeTags } from "../../Services";
@@ -65,6 +66,7 @@ export default function EditRestaurantInfo(props) {
city: props.restaurant.city, city: props.restaurant.city,
adress: props.restaurant.adress, adress: props.restaurant.adress,
description: props.restaurant.description, description: props.restaurant.description,
type: props.restaurant.type,
phone: props.restaurant.phone, phone: props.restaurant.phone,
hidden: props.restaurant.hidden, hidden: props.restaurant.hidden,
links: props.restaurant.links, links: props.restaurant.links,
@@ -76,6 +78,7 @@ export default function EditRestaurantInfo(props) {
cityError: false, cityError: false,
adressError: false, adressError: false,
descriptionError: false, descriptionError: false,
typeError: false
}; };
const [state, setState] = useState(initialState); const [state, setState] = useState(initialState);
const [passwordDialog, setPasswordDialog] = useState(false); const [passwordDialog, setPasswordDialog] = useState(false);
@@ -102,6 +105,7 @@ export default function EditRestaurantInfo(props) {
const validation = { const validation = {
nameValid: validator.isLength(state.name, { min: 1, max: 40 }), nameValid: validator.isLength(state.name, { min: 1, max: 40 }),
cityValid: validator.isLength(state.city, { min: 1, max: 40 }), cityValid: validator.isLength(state.city, { min: 1, max: 40 }),
typeValid: validator.isLength(state.type, { min: 1, max: 40 }),
adressValid: validator.isLength(state.name, { min: 1, max: 40 }), adressValid: validator.isLength(state.name, { min: 1, max: 40 }),
descriptionValid: validator.isLength(state.description, { descriptionValid: validator.isLength(state.description, {
min: 1, min: 1,
@@ -113,6 +117,7 @@ export default function EditRestaurantInfo(props) {
nameError: !validation.nameValid, nameError: !validation.nameValid,
cityError: !validation.cityValid, cityError: !validation.cityValid,
adressError: !validation.adressValid, adressError: !validation.adressValid,
typeError: !validation.typeValid,
descriptionError: !validation.descriptionValid, descriptionError: !validation.descriptionValid,
}); });
@@ -120,7 +125,8 @@ export default function EditRestaurantInfo(props) {
validation.nameValid && validation.nameValid &&
validation.cityValid && validation.cityValid &&
validation.adressValid && validation.adressValid &&
validation.descriptionValid validation.descriptionValid &&
validation.typeValid
); );
}; };
@@ -154,6 +160,10 @@ export default function EditRestaurantInfo(props) {
}); });
}; };
const setLunchHours = (hours) => {
setState({ ...state, lunchHours: hours });
}
const handleSendForm = () => { const handleSendForm = () => {
if (validateForm()) { if (validateForm()) {
const formattedTags = prepareTags(state.tags); const formattedTags = prepareTags(state.tags);
@@ -167,6 +177,7 @@ export default function EditRestaurantInfo(props) {
adress: state.adress, adress: state.adress,
coordinates: props.restaurant.location.coordinates, coordinates: props.restaurant.location.coordinates,
placesId: props.restaurant.placesId, placesId: props.restaurant.placesId,
type: state.type,
imgUrl: props.restaurant.imgUrl, imgUrl: props.restaurant.imgUrl,
workingHours: state.workingHours, workingHours: state.workingHours,
lunchHours: state.lunchHours, lunchHours: state.lunchHours,
@@ -231,6 +242,28 @@ export default function EditRestaurantInfo(props) {
variant="outlined" variant="outlined"
/> />
</div> </div>
<div className="editRestaurant-fullWidth">
<TextField
className={styles.textInputFullWidth}
fullWidth
value={state.type}
error={state.typeError}
onChange={(event) =>
setState({ ...state, type: event.target.value })
}
InputLabelProps={{ shrink: true }}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<FastfoodIcon color="primary" />
</InputAdornment>
),
}}
label="Kuchnia"
placeholder="np. Meksykańska"
variant="outlined"
/>
</div>
<TextField <TextField
className={styles.textInput} className={styles.textInput}
@@ -308,6 +341,10 @@ export default function EditRestaurantInfo(props) {
setHours={(hours) => setState({ ...state, workingHours: hours })} setHours={(hours) => setState({ ...state, workingHours: hours })}
hours={state.workingHours} hours={state.workingHours}
/> />
<div className="newRestaurant-content-fullwidth">
<div className="workingHours-container" style={{ marginTop: 14 }}>
<InputWorkingHoursSingle nieczynne={!state.lunchHours} hours={state.lunchHours} changeValue={(value) => setLunchHours(value)} day="Lunch hours" /></div>
</div>
<div className="editRestaurant-sectiontitle"> <div className="editRestaurant-sectiontitle">
<h4>Dane kontaktowe</h4> <h4>Dane kontaktowe</h4>
<Divider /> <Divider />

View File

@@ -6,7 +6,7 @@ import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
backdrop: { backdrop: {
zIndex: theme.zIndex.drawer + 1, zIndex: theme.zIndex.drawer + 15,
color: "#fff", color: "#fff",
}, },
})); }));