Loader při zakládání Pizza day, mock data
This commit is contained in:
@@ -16,7 +16,7 @@ import { faCircleCheck, faTrashCan } from '@fortawesome/free-regular-svg-icons';
|
||||
import { useBank } from './context/bank';
|
||||
import { ClientData, Restaurants, Food, Order, Locations, PizzaOrder, PizzaDayState, FoodChoices, Menu } from './types';
|
||||
import Footer from './components/Footer';
|
||||
import { faChainBroken, faChevronLeft, faChevronRight, faSatelliteDish, faSearch } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faChainBroken, faChevronLeft, faChevronRight, faGear, faSatelliteDish, faSearch } from '@fortawesome/free-solid-svg-icons';
|
||||
import Loader from './components/Loader';
|
||||
|
||||
const EVENT_CONNECT = "connect"
|
||||
@@ -37,6 +37,7 @@ function App() {
|
||||
const poznamkaRef = useRef<HTMLInputElement>(null);
|
||||
const [failure, setFailure] = useState<boolean>(false);
|
||||
const [dayIndex, setDayIndex] = useState<number>();
|
||||
const [loadingPizzaDay, setLoadingPizzaDay] = useState<boolean>(false);
|
||||
// Prazvláštní workaround, aby socket.io listener viděl aktuální hodnotu
|
||||
// https://medium.com/@kishorkrishna/cant-access-latest-state-inside-socket-io-listener-heres-how-to-fix-it-1522a5abebdb
|
||||
const dayIndexRef = useRef<number | undefined>(dayIndex);
|
||||
@@ -353,6 +354,7 @@ function App() {
|
||||
<ul>
|
||||
<li>Oprava generování QR kódů pro Pizza day</li>
|
||||
<li>Serverová validace času odchodu</li>
|
||||
<li>Loader při zakládání Pizza day</li>
|
||||
</ul>
|
||||
</Alert>
|
||||
{dayIndex != null &&
|
||||
@@ -464,9 +466,16 @@ function App() {
|
||||
{!data.pizzaDay &&
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<p>Pro dnešní den není aktuálně založen Pizza day.</p>
|
||||
<Button onClick={async () => {
|
||||
await createPizzaDay();
|
||||
}}>Založit Pizza day</Button>
|
||||
{loadingPizzaDay ?
|
||||
<span>
|
||||
<FontAwesomeIcon icon={faGear} className='fa-spin' /> Zjišťujeme dostupné pizzy
|
||||
</span>
|
||||
:
|
||||
<Button onClick={async () => {
|
||||
setLoadingPizzaDay(true);
|
||||
await createPizzaDay().then(() => setLoadingPizzaDay(false));
|
||||
}}>Založit Pizza day</Button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
{data.pizzaDay &&
|
||||
|
||||
Reference in New Issue
Block a user