Skip to content
Snippets Groups Projects
Commit 27354b8d authored by Aaron Dötsch's avatar Aaron Dötsch
Browse files

update

parent 221e35ef
No related branches found
No related tags found
No related merge requests found
<script lang="ts"> <script lang="ts">
import H1 from "$lib/components/H1.svelte"; import H1 from "$lib/components/H1.svelte";
import { Breadcrumb, BreadcrumbItem, Button, Card, Input, Textarea } from "flowbite-svelte"; import { Breadcrumb, BreadcrumbItem, Button, Card, Fileupload, Input, Textarea } from "flowbite-svelte";
import Entry from "./Entry.svelte"; import Entry from "./Entry.svelte";
import { enhance } from "$app/forms"; import { enhance } from "$app/forms";
import { invalidateAll } from "$app/navigation"; import { invalidateAll } from "$app/navigation";
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
}}> }}>
<Input name="time" type="datetime-local" class="mb-2" required /> <Input name="time" type="datetime-local" class="mb-2" required />
<Textarea name="text" class="mb-2" /> <Textarea name="text" class="mb-2" />
<Input name="image" type="file" accept="image/png, image/jpeg" class="mb-2" /> <Fileupload name="image" accept="image/png, image/jpeg" class="mb-2" />
<Button type="submit" class="w-full">Erstellen</Button> <Button type="submit" class="w-full">Erstellen</Button>
</form> </form>
</Card> </Card>
......
<script lang="ts"> <script lang="ts">
import { Card, Textarea, Button, ButtonGroup, Input } from "flowbite-svelte"; import { Card, Textarea, Button, ButtonGroup, Fileupload, Input } from "flowbite-svelte";
import type { MrXData } from "../../../(non-admin)/mr-x/[id=number]/data/+server"; import type { MrXData } from "../../../(non-admin)/mr-x/[id=number]/data/+server";
import { enhance } from "$app/forms"; import { enhance } from "$app/forms";
import Image from "$lib/components/Image.svelte"; import Image from "$lib/components/Image.svelte";
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<input bind:this={imageInput} name="image" type="file" accept="image/png, image/jpeg" class={removeImage ? "mb-2" : "hidden"} onchange={()=>removeImage=true} /> <input bind:this={imageInput} name="image" type="file" accept="image/png, image/jpeg" class={removeImage ? "mb-2" : "hidden"} onchange={()=>removeImage=true} />
<input type="hidden" name="removeImage" value={removeImage ? "true" : null} /> <input type="hidden" name="removeImage" value={removeImage ? "true" : null} />
{:else} {:else}
<Input name="image" type="file" accept="image/png, image/jpeg" class="mb-2" /> <Fileupload name="image" accept="image/png, image/jpeg" class="mb-2" />
{/if} {/if}
<div class="flex gap-2"> <div class="flex gap-2">
<Button type="submit" class="w-full">Speichern</Button> <Button type="submit" class="w-full">Speichern</Button>
......
...@@ -72,7 +72,7 @@ export const actions = { ...@@ -72,7 +72,7 @@ export const actions = {
} }
const day = data.get(`openingHours[${currentDay}]`); const day = data.get(`openingHours[${currentDay}]`);
if(typeof day !== "string" || !(["1","2","3","4","5","6","7"].includes(day) || day==="holiday" || (day.match(/^\d{4}-\d{2}-\d{2}$/) && !isNaN(Date.parse(day))))) error(400, `Invalid day: ${day}`); if(typeof day !== "string" || !(["1","2","3","4","5","6","7"].includes(day) || day==="holiday" || (day.match(/^\d{4}-\d{2}-\d{2}$/) && !isNaN(Date.parse(day))))) error(400, `Invalid day: ${day}`);
openingHours[day as keyof Discount["openingHours"]] = hours; openingHours[day as keyof Discount["openingHours"]] = hours.sort((a,b)=>a[0][0]*60+a[0][1]-b[0][0]*60-b[0][1]);
currentDay++; currentDay++;
} }
await Discount.update(id, { await Discount.update(id, {
......
...@@ -51,6 +51,9 @@ ...@@ -51,6 +51,9 @@
function roundTo5Digits(num: number): number{ function roundTo5Digits(num: number): number{
return Math.round(num * 1e5) / 1e5; return Math.round(num * 1e5) / 1e5;
} }
// somehow got compilation errors when building with this
//function refocusMap(address: string): void;
//function refocusMap(latitude: number, longitude: number): void;
async function refocusMap(){ async function refocusMap(){
if(arguments.length === 1){ if(arguments.length === 1){
const [address] = arguments; const [address] = arguments;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import type { Discount } from "$lib/server/database/entities/Discount.entity"; import type { Discount } from "$lib/server/database/entities/Discount.entity";
import { Button, CloseButton, Input, Table, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell } from "flowbite-svelte"; import { Button, CloseButton, Input, Table, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell } from "flowbite-svelte";
let { openingHours }: { openingHours: Discount["openingHours"] } = $props(); let { openingHours = $bindable() }: { openingHours: Discount["openingHours"] } = $props();
for(const day of [1,2,3,4,5,6,7] as const){ for(const day of [1,2,3,4,5,6,7] as const){
if(!openingHours[day]) openingHours[day] = []; if(!openingHours[day]) openingHours[day] = [];
...@@ -38,14 +38,14 @@ ...@@ -38,14 +38,14 @@
<TableBodyCell class="px-3 py-1"> <TableBodyCell class="px-3 py-1">
{#each openingHours[day as keyof typeof openingHours]||[] as [start, end], j} {#each openingHours[day as keyof typeof openingHours]||[] as [start, end], j}
<div class="w-min mx-1 inline-block rtl:text-right px-2 py-[0.15rem] border focus-within:ring-1 focus-within:border-primary-500 focus-within:ring-primary-500 dark:focus-within:border-primary-500 dark:focus-within:ring-primary-500 bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white border-gray-300 dark:border-gray-600 text-sm rounded-lg"> <div class="w-min mx-1 inline-block rtl:text-right px-2 py-[0.15rem] border focus-within:ring-1 focus-within:border-primary-500 focus-within:ring-primary-500 dark:focus-within:border-primary-500 dark:focus-within:ring-primary-500 bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white border-gray-300 dark:border-gray-600 text-sm rounded-lg">
<input name="openingHours[{i}][{j}][sh]" class="w-[2em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="23" bind:value={start[0]} required /> <input name="openingHours[{i}][{j}][sh]" class="w-[2.5em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="23" bind:value={start[0]} required />
: :
<input name="openingHours[{i}][{j}][sm]" class="w-[2em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="59" bind:value={start[1]} required /> <input name="openingHours[{i}][{j}][sm]" class="w-[2.5em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="59" bind:value={start[1]} required />
bis bis
<!-- no max on this input, 25 o'clock is 1 o'clock of the next day --> <!-- no max on this input, 25 o'clock is 1 o'clock of the next day -->
<input name="openingHours[{i}][{j}][eh]" class="w-[2em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="47" bind:value={end[0]} required /> <input name="openingHours[{i}][{j}][eh]" class="w-[2.5em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="47" bind:value={end[0]} required />
: :
<input name="openingHours[{i}][{j}][em]" class="w-[2em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="59" bind:value={end[1]} required /> <input name="openingHours[{i}][{j}][em]" class="w-[2.5em] p-1 border-none focus:ring-0 [appearance:textfield] bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white" type="number" step="1" min="0" max="59" bind:value={end[1]} required />
<CloseButton name="entfernen" class="p-1 my-0" on:click={()=>openingHours = Object.assign(openingHours, {[day]: openingHours[day as keyof typeof openingHours]?.filter((_,k)=>k!==j)})} /> <CloseButton name="entfernen" class="p-1 my-0" on:click={()=>openingHours = Object.assign(openingHours, {[day]: openingHours[day as keyof typeof openingHours]?.filter((_,k)=>k!==j)})} />
</div> </div>
{/each} {/each}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment