Do funkce jdemeObed doplněn parametr locationKey

This commit is contained in:
Michal Hájek
2025-02-23 01:11:25 +01:00
parent 8137ca6fc0
commit 2f39d04120
8 changed files with 59 additions and 43 deletions

View File

@@ -206,9 +206,9 @@ function App() {
}
}
const doJdemeObed = async () => {
const doJdemeObed = async (locationKey: LocationKey) => {
if (auth?.login) {
await jdemeObed();
await jdemeObed(locationKey);
}
}
@@ -471,6 +471,7 @@ function App() {
return;
}
const locationLoginList = Object.entries(loginObject);
const disabled = false;
return (
<tr key={key}>
<td>{locationName}</td>
@@ -519,6 +520,9 @@ function App() {
</tbody>
</Table>
</td>
<td>
<Button onClick={() => doJdemeObed(locationKey)} disabled={false}>Jdeme na oběd</Button>
</td>
</tr>)
}
)}
@@ -542,7 +546,6 @@ function App() {
setLoadingPizzaDay(true);
await createPizzaDay().then(() => setLoadingPizzaDay(false));
}}>Založit Pizza day</Button>
<Button onClick={doJdemeObed} style={{ marginLeft: "14px" }}>Jdeme na oběd !</Button>
</>
}
</div>

View File

@@ -1,4 +1,12 @@
import { AddChoiceRequest, ChangeDepartureTimeRequest, LocationKey, RemoveChoiceRequest, RemoveChoicesRequest, UpdateNoteRequest } from "../../../types";
import {
AddChoiceRequest,
ChangeDepartureTimeRequest,
JdemeObedRequest,
LocationKey,
RemoveChoiceRequest,
RemoveChoicesRequest,
UpdateNoteRequest
} from "../../../types";
import { api } from "./Api";
const FOOD_API_PREFIX = '/api/food';
@@ -23,6 +31,6 @@ export const changeDepartureTime = async (time: string, dayIndex?: number) => {
return await api.post<ChangeDepartureTimeRequest, void>(`${FOOD_API_PREFIX}/changeDepartureTime`, { time, dayIndex });
}
export const jdemeObed = async () => {
return await api.post<undefined, void>(`${FOOD_API_PREFIX}/jdemeObed`);
export const jdemeObed = async (locationKey: LocationKey) => {
return await api.post<JdemeObedRequest, void>(`${FOOD_API_PREFIX}/jdemeObed`, { locationKey });
}