-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can order equipment and convert an order to equipment --------- Co-authored-by: Arne Maier <arne.maier@inovex.de>
- Loading branch information
Showing
24 changed files
with
990 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ debug: false | |
domain: localhost | ||
origin: http://localhost:5173 | ||
jwtSecret: changeMe | ||
databaseConnection: ./test.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const getDate = (date: string): Date | undefined => { | ||
if (date === "0001-01-01T00:00:00Z") { | ||
return undefined; | ||
} | ||
return new Date(date); | ||
} | ||
|
||
export const formatToDate = (date?: Date): string => { | ||
if (!date) { | ||
return "-"; | ||
} | ||
return date.toLocaleDateString('de-de', { year: "numeric", month: "short", day: "numeric" }); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<script lang="ts"> | ||
import { fulfillOrder, type Order } from "./order.service"; | ||
import { Label, Input, Button, Modal, Spinner } from "flowbite-svelte"; | ||
import { createNotification } from "../../components/Notification/notificationStore"; | ||
import { push } from "svelte-spa-router"; | ||
import { routes } from "../../routes"; | ||
import { translateEquipmentType } from "../equipment/equipment.service"; | ||
export let order: Order; | ||
let fulfillModalOpen = false; | ||
let loading = false; | ||
let registrationCode = ""; | ||
function fulfillOrder_internal() { | ||
loading = true; | ||
fulfillOrder(order, registrationCode) | ||
.then((equipment) => { | ||
createNotification( | ||
{ | ||
color: "green", | ||
text: `Bestellung wurde zu einem Ausrüstungsgegenstand.`, | ||
}, | ||
5 | ||
); | ||
loading = false; | ||
fulfillModalOpen = false; | ||
push(`${routes.MemberDetail.link}${equipment.memberId}`); | ||
}) | ||
.catch(() => { | ||
createNotification( | ||
{ | ||
color: "red", | ||
text: `Bestellung konnte nicht zu einem Ausrüstungsgegenstand gemacht und zugewiesen werden. Prüfe, ob es einen neuen Ausrüstungsgegenstand gibt und probiere sonst nocheinmal.`, | ||
}, | ||
20 | ||
); | ||
fulfillModalOpen = false; | ||
loading = false; | ||
}); | ||
} | ||
</script> | ||
|
||
<Button color="green" on:click={() => (fulfillModalOpen = true)}> | ||
Bestellung einlösen | ||
</Button> | ||
<Modal | ||
title={`Bestellung ${translateEquipmentType(order.type)} einlösen`} | ||
bind:open={fulfillModalOpen} | ||
> | ||
<p> | ||
Soll die Bestellung für {translateEquipmentType(order.type)} eingelöst werden? | ||
</p> | ||
<form on:submit|preventDefault={() => fulfillOrder_internal()} disabled={loading} id="fulfilOrderForm"> | ||
<Label for="registrationCode" class="block mb-2">Registrierungsnummer</Label> | ||
<Input | ||
required | ||
class="mb-4" | ||
id="registrationCode" | ||
bind:value={registrationCode} | ||
/> | ||
</form> | ||
<svelte:fragment slot="footer"> | ||
{#if loading} | ||
<Spinner /> | ||
{:else} | ||
<Button color="green" form="fulfilOrderForm" type="submit"> | ||
Einlösen | ||
</Button> | ||
<Button color="purple">Abbrechen</Button> | ||
{/if} | ||
</svelte:fragment> | ||
</Modal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script lang="ts"> | ||
import Navigation from "../../components/Navigation/Navigation.svelte"; | ||
import { Alert, Spinner } from "flowbite-svelte"; | ||
import { getFulfilledOrders } from "./order.service"; | ||
import OrderCard from "./OrderCard.svelte"; | ||
let orderPromise = getFulfilledOrders(); | ||
</script> | ||
|
||
<Navigation /> | ||
<h1>Fertige Bestellungen</h1> | ||
|
||
{#await orderPromise} | ||
<Spinner /> | ||
{:then orders} | ||
<div> | ||
Aktuell {orders.length} Bestellungen fertig | ||
<div class="flex flex-wrap"> | ||
{#each orders as order} | ||
<OrderCard order={order} withMember={true} withDuration={true} /> | ||
{/each} | ||
</div> | ||
</div> | ||
{:catch} | ||
<Alert class="mb-4 top-alert" color="red" dismissable style="display: block;"> | ||
Leider konnten die Bestellungen nicht geladen werden. | ||
</Alert> | ||
{/await} |
Oops, something went wrong.