Ukládání dat výhradně do DB
This commit is contained in:
@@ -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, Order, Locations, PizzaOrder, PizzaDayState, FoodChoices } from './types';
|
||||
import { ClientData, Restaurants, Food, Order, Locations, PizzaOrder, PizzaDayState, FoodChoices, Menu } from './types';
|
||||
import Footer from './components/Footer';
|
||||
|
||||
const EVENT_CONNECT = "connect"
|
||||
@@ -41,7 +41,7 @@ function App() {
|
||||
const bank = useBank();
|
||||
const [isConnected, setIsConnected] = useState<boolean>(false);
|
||||
const [data, setData] = useState<ClientData>();
|
||||
const [food, setFood] = useState<{ [key in Restaurants]: Food[] }>();
|
||||
const [food, setFood] = useState<{ [key in Restaurants]: Menu }>();
|
||||
const [myOrder, setMyOrder] = useState<Order>();
|
||||
const [foodChoiceList, setFoodChoiceList] = useState<Food[]>();
|
||||
const socket = useContext(SocketContext);
|
||||
@@ -116,7 +116,7 @@ function App() {
|
||||
const restaurantKey = Object.keys(Restaurants).indexOf(locationsKey);
|
||||
if (restaurantKey > -1 && food) {
|
||||
const restaurant = Object.values(Restaurants)[restaurantKey];
|
||||
setFoodChoiceList(food[restaurant]);
|
||||
setFoodChoiceList(food[restaurant].food);
|
||||
} else {
|
||||
setFoodChoiceList(undefined);
|
||||
}
|
||||
@@ -242,12 +242,13 @@ function App() {
|
||||
}
|
||||
}
|
||||
|
||||
const renderFoodTable = (name: string, food: Food[]) => {
|
||||
const renderFoodTable = (name: string, menu: Menu) => {
|
||||
return <Col md={12} lg={4}>
|
||||
<h3>{name}</h3>
|
||||
{menu?.lastUpdate && <small>Poslední aktualizace: {menu.lastUpdate}</small>}
|
||||
<Table striped bordered hover>
|
||||
<tbody>
|
||||
{food?.length > 0 ? food.map((f: any, index: number) =>
|
||||
{menu?.food?.length > 0 ? menu.food.map((f: any, index: number) =>
|
||||
<tr key={index}>
|
||||
<td>{f.amount}</td>
|
||||
<td>{f.name}</td>
|
||||
@@ -279,6 +280,8 @@ function App() {
|
||||
<ul>
|
||||
<li>Podpora <a href="https://redis.io">Redis</a></li>
|
||||
<li>Možnost výběru preferovaného času odchodu</li>
|
||||
<li>Ukládání dostupných obědových menu a pizz do DB (zrušení dočasných souborů)</li>
|
||||
<li>Zobrazení času poslední aktualizace každého menu</li>
|
||||
</ul>
|
||||
</Alert>
|
||||
<h1 className='title'>Dnes je {data.date}</h1>
|
||||
@@ -349,7 +352,7 @@ function App() {
|
||||
const locationsKey = Object.keys(Locations)[Number(locationKey)]
|
||||
const restaurantKey = Object.keys(Restaurants).indexOf(locationsKey);
|
||||
const restaurant = Object.values(Restaurants)[restaurantKey];
|
||||
const foodName = food[restaurant][foodIndex].name;
|
||||
const foodName = food[restaurant].food[foodIndex].name;
|
||||
return <li key={foodIndex}>
|
||||
{foodName}
|
||||
{login === auth.login && <FontAwesomeIcon onClick={() => {
|
||||
|
||||
Reference in New Issue
Block a user