web client v0.10 (restaurant view)
This commit is contained in:
@@ -51,3 +51,25 @@ export const formatDateBasic = (input) => {
|
|||||||
const date = new Date(input);
|
const date = new Date(input);
|
||||||
return date.toLocaleString("pl-PL", { dateStyle: "long" });
|
return date.toLocaleString("pl-PL", { dateStyle: "long" });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getTodayHours = (workingHours) => {
|
||||||
|
const todayDate = new Date().getDay();
|
||||||
|
switch (todayDate) {
|
||||||
|
case 1:
|
||||||
|
return workingHours.pn;
|
||||||
|
case 2:
|
||||||
|
return workingHours.wt;
|
||||||
|
case 3:
|
||||||
|
return workingHours.sr;
|
||||||
|
case 4:
|
||||||
|
return workingHours.cz;
|
||||||
|
case 5:
|
||||||
|
return workingHours.pt;
|
||||||
|
case 6:
|
||||||
|
return workingHours.sb;
|
||||||
|
case 7:
|
||||||
|
return workingHours.nd;
|
||||||
|
default:
|
||||||
|
return workingHours.pn;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ export default function EditDish() {
|
|||||||
const validation = {
|
const validation = {
|
||||||
name: validator.isLength(state.name, { max: 50, min: 1 }),
|
name: validator.isLength(state.name, { max: 50, min: 1 }),
|
||||||
category: restaurant.categories.includes(state.category),
|
category: restaurant.categories.includes(state.category),
|
||||||
price: validator.isAlphanumeric(state.price),
|
price: validator.isLength(state.price, { max: 10, min: 1 }),
|
||||||
};
|
};
|
||||||
|
|
||||||
setState({
|
setState({
|
||||||
@@ -275,9 +275,8 @@ export default function EditDish() {
|
|||||||
<TextField
|
<TextField
|
||||||
className={styles.textInput}
|
className={styles.textInput}
|
||||||
required
|
required
|
||||||
label="Cena"
|
label="Cena (zł)"
|
||||||
placeholder="np. 18,50"
|
placeholder="np. 18,50"
|
||||||
type="number"
|
|
||||||
error={state.priceError}
|
error={state.priceError}
|
||||||
value={state.price}
|
value={state.price}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -294,9 +293,8 @@ export default function EditDish() {
|
|||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
className={styles.textInput}
|
className={styles.textInput}
|
||||||
label="Waga (g)"
|
label="Porcja"
|
||||||
type="number"
|
placeholder="np. 150g"
|
||||||
placeholder="np. 150"
|
|
||||||
value={state.weight}
|
value={state.weight}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ export default function NewRestaurant() {
|
|||||||
const validation = {
|
const validation = {
|
||||||
name: validator.isLength(state.name, { max: 50, min: 1 }),
|
name: validator.isLength(state.name, { max: 50, min: 1 }),
|
||||||
category: restaurant.categories.includes(state.category),
|
category: restaurant.categories.includes(state.category),
|
||||||
price: validator.isAlphanumeric(state.price),
|
price: validator.isLength(state.price, { max: 10, min: 1 }),
|
||||||
};
|
};
|
||||||
|
|
||||||
setState({
|
setState({
|
||||||
@@ -288,9 +288,8 @@ export default function NewRestaurant() {
|
|||||||
<TextField
|
<TextField
|
||||||
className={styles.textInput}
|
className={styles.textInput}
|
||||||
required
|
required
|
||||||
label="Cena"
|
label="Cena (zł)"
|
||||||
placeholder="np. 18,50"
|
placeholder="np. 18,50"
|
||||||
type="number"
|
|
||||||
error={state.priceError}
|
error={state.priceError}
|
||||||
value={state.price}
|
value={state.price}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -307,9 +306,9 @@ export default function NewRestaurant() {
|
|||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
className={styles.textInput}
|
className={styles.textInput}
|
||||||
label="Waga (g)"
|
label="Porcja"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="np. 150"
|
placeholder="np. 150g"
|
||||||
value={state.weight}
|
value={state.weight}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ export default function CardDish(props) {
|
|||||||
style={{ backgroundImage: "url(" + imgUrl + ")" }}
|
style={{ backgroundImage: "url(" + imgUrl + ")" }}
|
||||||
/>
|
/>
|
||||||
<div className="carddish-left-info">
|
<div className="carddish-left-info">
|
||||||
<h2>{name}</h2>
|
<div className="carddish-left-upper">
|
||||||
<p>{weight}</p>
|
<h2>{name}</h2>
|
||||||
|
<p>Porcja: {weight}</p>
|
||||||
|
</div>
|
||||||
<Pictograms pictograms={extractTags(allergens)} />
|
<Pictograms pictograms={extractTags(allergens)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import Pictograms from "./Pictograms";
|
import Pictograms from "./Pictograms";
|
||||||
import { fetchRestaurant } from "../../actions";
|
import { useHistory } from "react-router-dom";
|
||||||
import { useDispatch } from "react-redux";
|
import { getTodayHours } from "../../Services.js";
|
||||||
|
|
||||||
function extractTags(tags) {
|
function extractTags(tags) {
|
||||||
var results = [];
|
var results = [];
|
||||||
@@ -15,12 +15,12 @@ function extractTags(tags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function CardRestaurant(props) {
|
export default function CardRestaurant(props) {
|
||||||
const dispatch = useDispatch();
|
const history = useHistory();
|
||||||
const img = props.imgUrl;
|
const img = props.imgUrl;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
onClick={() => dispatch(fetchRestaurant(props.id))}
|
onClick={() => history.push(`/restaurant/${props.id}`)}
|
||||||
className="card-restaurant"
|
className="card-restaurant"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -32,7 +32,7 @@ export default function CardRestaurant(props) {
|
|||||||
<h1>{props.name}</h1>
|
<h1>{props.name}</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<h3>Miasto: {props.city}</h3>
|
<h3>Miasto: {props.city}</h3>
|
||||||
<h3>Otwarte: {props.hours}</h3>
|
<h3>Dziś otwarte: {getTodayHours(props.hours)}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-description">
|
<div className="card-description">
|
||||||
<p>{props.description}</p>
|
<p>{props.description}</p>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { GoogleMap, LoadScript, Marker } from "@react-google-maps/api";
|
|||||||
|
|
||||||
function GoogleMapStatic(props) {
|
function GoogleMapStatic(props) {
|
||||||
const containerStyle = {
|
const containerStyle = {
|
||||||
width: "50%",
|
width: "100%",
|
||||||
height: "500px",
|
height: "360px",
|
||||||
};
|
};
|
||||||
|
|
||||||
const center = {
|
const center = {
|
||||||
@@ -14,7 +14,7 @@ function GoogleMapStatic(props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<LoadScript googleMapsApiKey="AIzaSyDAlZSiBanP52qpZ1kaH06XkuA2zndLUd8">
|
<LoadScript googleMapsApiKey="AIzaSyDAlZSiBanP52qpZ1kaH06XkuA2zndLUd8">
|
||||||
<GoogleMap mapContainerStyle={containerStyle} center={center} zoom={7}>
|
<GoogleMap mapContainerStyle={containerStyle} center={center} zoom={15}>
|
||||||
<Marker position={center} visible={true} />
|
<Marker position={center} visible={true} />
|
||||||
</GoogleMap>
|
</GoogleMap>
|
||||||
</LoadScript>
|
</LoadScript>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { extractTags } from "../../Services";
|
|||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { fetchRestaurant } from "../../actions";
|
import { fetchRestaurant } from "../../actions";
|
||||||
import GoogleMapStatic from "./GoogleMapStatic";
|
import GoogleMapStatic from "./GoogleMapStatic";
|
||||||
|
import WorkingHours from "./WorkingHours";
|
||||||
|
|
||||||
export default function Restaurant(props) {
|
export default function Restaurant(props) {
|
||||||
const restaurant = useSelector((state) => state.restaurant);
|
const restaurant = useSelector((state) => state.restaurant);
|
||||||
@@ -33,23 +34,29 @@ export default function Restaurant(props) {
|
|||||||
<h1>{restaurant.name}</h1>
|
<h1>{restaurant.name}</h1>
|
||||||
<p>{restaurant.description}</p>
|
<p>{restaurant.description}</p>
|
||||||
<hr />
|
<hr />
|
||||||
|
<div className="restaurant-pictograms">
|
||||||
|
<PictogramsSeparate pictograms={extractTags(restaurant.tags)} />
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<h5>Informacje</h5>
|
||||||
<p>
|
<p>
|
||||||
Adres:{" "}
|
Adres:{" "}
|
||||||
<span className="restaurant-span">
|
<span className="restaurant-span">
|
||||||
{restaurant.city}, {restaurant.adress}
|
{restaurant.city}, {restaurant.adress}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p>Godziny pracy: </p>
|
|
||||||
{restaurant.phone && (
|
{restaurant.phone && (
|
||||||
<p>
|
<p>
|
||||||
Kontakt:{" "}
|
Kontakt:{" "}
|
||||||
<span className="restaurant-span">{restaurant.phone}</span>
|
<span className="restaurant-span">{restaurant.phone}</span>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
<WorkingHours hours={restaurant.workingHours} />
|
||||||
<hr />
|
<hr />
|
||||||
<div className="restaurant-pictograms">
|
<h5>Lokalizacja</h5>
|
||||||
<PictogramsSeparate pictograms={extractTags(restaurant.tags)} />
|
{restaurant.location && (
|
||||||
</div>
|
<GoogleMapStatic coordinates={restaurant.location.coordinates} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="restaurant-content">
|
<div className="restaurant-content">
|
||||||
|
|||||||
56
src/components/Output/WorkingHours.js
Normal file
56
src/components/Output/WorkingHours.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export default function WorkingHours(props) {
|
||||||
|
const { hours } = props;
|
||||||
|
return (
|
||||||
|
<div className="workingHours">
|
||||||
|
{hours && (
|
||||||
|
<div>
|
||||||
|
<h5>Godziny otwarcia</h5>
|
||||||
|
<p>
|
||||||
|
Pn:{" "}
|
||||||
|
<span className="restaurant-span">
|
||||||
|
{hours.pn ? hours.pn : "Nieczynne"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Wt:{" "}
|
||||||
|
<span className="restaurant-span">
|
||||||
|
{hours.wt ? hours.wt : "Nieczynne"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Śr:{" "}
|
||||||
|
<span className="restaurant-span">
|
||||||
|
{hours.sr ? hours.sr : "Nieczynne"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Czw:{" "}
|
||||||
|
<span className="restaurant-span">
|
||||||
|
{hours.cz ? hours.cz : "Nieczynne"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Pt:{" "}
|
||||||
|
<span className="restaurant-span">
|
||||||
|
{hours.pt ? hours.pt : "Nieczynne"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
So:{" "}
|
||||||
|
<span className="restaurant-span">
|
||||||
|
{hours.sb ? hours.sb : "Nieczynne"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Nie:{" "}
|
||||||
|
<span className="restaurant-span">
|
||||||
|
{hours.nd ? hours.nd : "Nieczynne"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,12 +8,9 @@ h4 {
|
|||||||
|
|
||||||
.carddish-container {
|
.carddish-container {
|
||||||
background-color: #303030;
|
background-color: #303030;
|
||||||
border-radius: 10px;
|
border-radius: 6px;
|
||||||
margin-right: auto;
|
margin: 2px auto 2px auto;
|
||||||
margin-left: auto;
|
padding: 8px;
|
||||||
margin-top: 10px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
@@ -33,20 +30,34 @@ h4 {
|
|||||||
.carddish-img {
|
.carddish-img {
|
||||||
background-color: $secondary-color;
|
background-color: $secondary-color;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
width: 150px;
|
width: 120px;
|
||||||
height: 150px;
|
height: 120px;
|
||||||
border-radius: 10px;
|
border-radius: 6px;
|
||||||
margin: 0px 20px 0px 0px;
|
margin: 0px 14px 0px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.carddish-left {
|
.carddish-left {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
h2 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.carddish-left-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.carddish-right {
|
.carddish-right {
|
||||||
h5 {
|
h5 {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 1.2rem;
|
font-size: 1rem;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
|
margin-right: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.pictograms-container {
|
.pictograms-container {
|
||||||
height: 30px;
|
height: 30px;
|
||||||
margin: 8px 8px 8px 0px;
|
margin: 8px 8px 0px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pictograms-container-separated {
|
.pictograms-container-separated {
|
||||||
@@ -21,12 +21,12 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: 25px;
|
border-radius: 25px;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
padding: 4px;
|
padding: 2px;
|
||||||
margin: 8px;
|
margin: 4px;
|
||||||
h4 {
|
h4 {
|
||||||
margin: 8px;
|
margin: 8px 4px 8px 8px;
|
||||||
}
|
}
|
||||||
.pictogram {
|
.pictogram {
|
||||||
margin: 8px;
|
margin: 8px 8px 8px 4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
margin-top: 20px;
|
|
||||||
border-radius: 50px;
|
border-radius: 50px;
|
||||||
.pictograms-container {
|
.pictograms-container {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
@@ -51,7 +50,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.restaurant-dishes {
|
.restaurant-dishes {
|
||||||
min-width: 60%;
|
min-width: 80%;
|
||||||
h3 {
|
h3 {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
@@ -59,8 +58,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.restaurant-content {
|
.restaurant-content {
|
||||||
padding-top: 10rem;
|
|
||||||
padding-bottom: 10rem;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -70,12 +67,11 @@
|
|||||||
.restaurant-info {
|
.restaurant-info {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: #1d1d1d;
|
background-color: #1d1d1d;
|
||||||
box-shadow: -2px 10px 20px rgba(0, 0, 0, 0.212);
|
|
||||||
p {
|
p {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
margin-top: 8px;
|
margin-top: 4px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
hr {
|
hr {
|
||||||
border: 1px solid $dark-gray;
|
border: 1px solid $dark-gray;
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
@import "./Design.scss";
|
@import "./Design.scss";
|
||||||
|
|
||||||
|
.search-results {
|
||||||
|
min-width: 60%;
|
||||||
|
max-width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
.card-restaurant {
|
.card-restaurant {
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
padding: 10px;
|
padding: 4px;
|
||||||
margin: 20px 0px 20px 0px;
|
margin: 10px 0px 10px 0px;
|
||||||
background-color: #202020;
|
background-color: #202020;
|
||||||
color: $secondary-color;
|
color: $secondary-color;
|
||||||
max-width: 70vw;
|
max-width: 70vw;
|
||||||
|
|||||||
Reference in New Issue
Block a user