update
This commit is contained in:
@@ -149,6 +149,9 @@ export const refreshUserData = (token) => {
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.status === 401) {
|
||||
dispatch(logout());
|
||||
}
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
@@ -237,7 +240,7 @@ export const changePassword = (email, password, token) => {
|
||||
|
||||
export const logout = () => {
|
||||
return function (dispatch) {
|
||||
dispatch(notification("Poprawnie wylogowano.", "success"));
|
||||
dispatch(notification("Wylogowano.", "info"));
|
||||
dispatch(toggles.setLoggedOut());
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,7 +14,6 @@ import LanguageIcon from "@material-ui/icons/Language";
|
||||
import FastfoodIcon from "@material-ui/icons/Fastfood";
|
||||
import LocationCityIcon from "@material-ui/icons/LocationCity";
|
||||
import Divider from "@material-ui/core/Divider";
|
||||
import Link from "@material-ui/core/Link";
|
||||
import { decodeTags } from "../../Services";
|
||||
import validator from "validator";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
@@ -29,6 +28,7 @@ import MenuItem from "@material-ui/core/MenuItem";
|
||||
import FormControl from "@material-ui/core/FormControl";
|
||||
import Select from "@material-ui/core/Select";
|
||||
import InputLabel from "@material-ui/core/InputLabel";
|
||||
import Switch from '@material-ui/core/Switch';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
textInput: {
|
||||
@@ -159,9 +159,36 @@ export default function EditRestaurantInfo(props) {
|
||||
setState(initialState);
|
||||
};
|
||||
|
||||
const handleDelete = (password) => {
|
||||
const handleSetHidden = () => {
|
||||
dispatch(showBackdrop());
|
||||
axios({
|
||||
url: "http://localhost:4000/restaurant/delete",
|
||||
url: `${backend}restaurant/visibility`,
|
||||
method: "POST",
|
||||
data: {
|
||||
restaurantId: props.restaurant._id,
|
||||
visible: state.hidden
|
||||
},
|
||||
headers: {
|
||||
"x-auth-token": jwt,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
dispatch(refreshUserData(jwt));
|
||||
setState({ ...state, hidden: !state.hidden });
|
||||
dispatch(hideBackdrop());
|
||||
dispatch(notification("Widoczność zmieniona poprawnie", "success"));
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
dispatch(hideBackdrop());
|
||||
dispatch(notification("Wystąpił błąd :(", "error"));
|
||||
});
|
||||
}
|
||||
|
||||
const handleDelete = (password) => {
|
||||
dispatch(showBackdrop());
|
||||
axios({
|
||||
url: `${backend}restaurant/delete`,
|
||||
method: "POST",
|
||||
data: {
|
||||
restaurantId: props.restaurant._id,
|
||||
@@ -452,10 +479,17 @@ export default function EditRestaurantInfo(props) {
|
||||
<div className="editRestaurant-sectiontitle">
|
||||
<h4>Zaawansowane</h4>
|
||||
<Divider />
|
||||
<div className="editRestaurant-settings">
|
||||
<h4>Ukryj restaurację (nie wymaga zatwierdzania)</h4>
|
||||
<Switch checked={state.hidden} color="primary" onChange={handleSetHidden}/>
|
||||
</div>
|
||||
<div className="editRestaurant-settings">
|
||||
<h4>
|
||||
Usuń restaurację (operacja jest nieodwracalna!)
|
||||
</h4>
|
||||
<ButtonPrimary text="Usuń" onClick={() => setPasswordDialog(true)} />
|
||||
</div>
|
||||
</div>
|
||||
<Link className={styles.link} onClick={() => setPasswordDialog(true)}>
|
||||
Usuń restaurację
|
||||
</Link>
|
||||
</div>
|
||||
<div className="editRestaurant-bottom">
|
||||
<ButtonPrimary text="Anuluj" onClick={cancelChanges} />
|
||||
|
||||
@@ -6,5 +6,5 @@ export default function DishPrices(props) {
|
||||
const display2 = prices.price2.price !== "";
|
||||
const display3 = prices.price3.price !== "";
|
||||
|
||||
return <p>{display2 || display3 && prices.price1.priceName}{" " + prices.price1.price}zł{ display2 && " / " + prices.price2.priceName + " " + prices.price2.price + "zł"}{ display3 && " / " + prices.price3.priceName + " " + prices.price3.price + "zł"}</p>
|
||||
return <p>{(display2 || display3) ? prices.price1.priceName : ""}{" " + prices.price1.price}zł{ display2 && " / " + prices.price2.priceName + " " + prices.price2.price + "zł"}{ display3 && " / " + prices.price3.priceName + " " + prices.price3.price + "zł"}</p>
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import soy from "../../public/i_soy.svg";
|
||||
import vegan from "../../public/i_vegan.svg";
|
||||
import vegetarian from "../../public/i_vegetarian.svg";
|
||||
|
||||
export default function (props) {
|
||||
export default function Pictograms(props) {
|
||||
const pictograms = props.pictograms.map((pictogram, index) => (
|
||||
<Tooltip key={index} title={getTooltip(pictogram)}>
|
||||
<img className="pictogram" src={getImage(pictogram)} alt={pictogram} />
|
||||
|
||||
@@ -16,7 +16,7 @@ import soy from "../../public/i_soy.svg";
|
||||
import vegan from "../../public/i_vegan.svg";
|
||||
import vegetarian from "../../public/i_vegetarian.svg";
|
||||
|
||||
export default function (props) {
|
||||
export default function PictogramsSeparate(props) {
|
||||
const pictogramsSeparated = props.pictograms.map((pictogram, index) => (
|
||||
<div key={index} className="separate-pictogram">
|
||||
<h4>{getName(pictogram)}</h4>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* export const backend = "https://menui.azurewebsites.net/"; */
|
||||
export const backend = "http://localhost:4000/";
|
||||
export const backend = "https://api.menui.pl/";
|
||||
|
||||
export const restaurantTypes = [
|
||||
"afrykańska",
|
||||
|
||||
@@ -206,3 +206,19 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.editRestaurant-settings {
|
||||
display: flex;
|
||||
background-color: #222222;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border: 1px solid #1f1f1f;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
margin-top: 12px;
|
||||
margin-bottom: 12px;
|
||||
h4 {
|
||||
font-size: 14px;
|
||||
color: #c0c0c0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user