Ukládání pizz do DB místo dočasného souboru
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
import { EVENT_DISCONNECT, EVENT_MESSAGE, SocketContext } from './context/socket';
|
||||
import { addChoice, addPizza, changeDepartureTime, createPizzaDay, deletePizzaDay, finishDelivery, finishOrder, getData, getFood, getPizzy, getQrUrl, lockPizzaDay, removeChoice, removeChoices, removePizza, unlockPizzaDay, updateNote } from './Api';
|
||||
import { addChoice, addPizza, changeDepartureTime, createPizzaDay, deletePizzaDay, finishDelivery, finishOrder, getData, getFood, getQrUrl, lockPizzaDay, removeChoice, removeChoices, removePizza, unlockPizzaDay, updateNote } from './Api';
|
||||
import { useAuth } from './context/auth';
|
||||
import Login from './Login';
|
||||
import { Alert, Button, Col, Form, Row, Table } from 'react-bootstrap';
|
||||
@@ -14,7 +14,7 @@ import './App.css';
|
||||
import { SelectSearchOption } from 'react-select-search';
|
||||
import { faCircleCheck, faTrashCan } from '@fortawesome/free-regular-svg-icons';
|
||||
import { useBank } from './context/bank';
|
||||
import { ClientData, Restaurants, Food, Pizza, Order, Locations, PizzaOrder, PizzaDayState, FoodChoices } from './types';
|
||||
import { ClientData, Restaurants, Food, Order, Locations, PizzaOrder, PizzaDayState, FoodChoices } from './types';
|
||||
import Footer from './components/Footer';
|
||||
|
||||
const EVENT_CONNECT = "connect"
|
||||
@@ -42,7 +42,6 @@ function App() {
|
||||
const [isConnected, setIsConnected] = useState<boolean>(false);
|
||||
const [data, setData] = useState<ClientData>();
|
||||
const [food, setFood] = useState<{ [key in Restaurants]: Food[] }>();
|
||||
const [pizzy, setPizzy] = useState<Pizza[]>();
|
||||
const [myOrder, setMyOrder] = useState<Order>();
|
||||
const [foodChoiceList, setFoodChoiceList] = useState<Food[]>();
|
||||
const socket = useContext(SocketContext);
|
||||
@@ -55,9 +54,6 @@ function App() {
|
||||
if (!auth || !auth.login) {
|
||||
return
|
||||
}
|
||||
getPizzy().then(pizzy => {
|
||||
setPizzy(pizzy);
|
||||
});
|
||||
getData().then(data => {
|
||||
setData(data);
|
||||
})
|
||||
@@ -174,11 +170,11 @@ function App() {
|
||||
}
|
||||
|
||||
const pizzaSuggestions = useMemo(() => {
|
||||
if (!pizzy) {
|
||||
if (!data?.pizzaList) {
|
||||
return [];
|
||||
}
|
||||
const suggestions: SelectSearchOption[] = [];
|
||||
pizzy.forEach((pizza, index) => {
|
||||
data.pizzaList.forEach((pizza, index) => {
|
||||
const group: SelectSearchOption = { name: pizza.name, type: "group", items: [] }
|
||||
pizza.sizes.forEach((size, sizeIndex) => {
|
||||
const name = `${size.size} (${size.price} Kč)`;
|
||||
@@ -188,10 +184,10 @@ function App() {
|
||||
suggestions.push(group);
|
||||
})
|
||||
return suggestions;
|
||||
}, [pizzy]);
|
||||
}, [data?.pizzaList]);
|
||||
|
||||
const handlePizzaChange = async (value: SelectedOptionValue | SelectedOptionValue[]) => {
|
||||
if (auth?.login && pizzy) {
|
||||
if (auth?.login && data?.pizzaList) {
|
||||
if (!(typeof value === 'string')) {
|
||||
throw Error('Nepodporovaný typ hodnoty');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user