Dodanie raportów, dnd, listy gości i innych.

This commit is contained in:
Kazimierz Ciołek
2026-07-05 15:53:52 +02:00
parent 4828573cae
commit b584cbc8ce
18 changed files with 1804 additions and 56 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from "svelte";
import { ScheduleState } from "$lib/schedule.svelte";
import { MONTH_NAMES, todayISO } from "$lib/dates";
import { formatShort, MONTH_NAMES, todayISO } from "$lib/dates";
import ScheduleGrid from "$lib/components/ScheduleGrid.svelte";
import ReservationDialog from "$lib/components/ReservationDialog.svelte";
import CabinsDialog from "$lib/components/CabinsDialog.svelte";
@@ -50,6 +50,30 @@
function editReservation(r: Reservation) {
dialogParams = { reservation: r };
}
let moveError = $state<string | null>(null);
async function moveReservation(
r: Reservation,
cabinId: number,
arrival: string,
departure: string
) {
moveError = null;
try {
const conflicts = await db.findConflicts(cabinId, arrival, departure, r.id);
if (conflicts.length > 0) {
const c = conflicts[0];
moveError = `Nie można przenieść — termin koliduje z rezerwacją: ${c.guest_name} (${formatShort(c.arrival)}${formatShort(c.departure)}).`;
setTimeout(() => (moveError = null), 5000);
return;
}
await db.updateReservation(r.id, { ...r, cabin_id: cabinId, arrival, departure });
await schedule.reload();
} catch (e) {
moveError = `Nie udało się przenieść rezerwacji: ${e}`;
}
}
</script>
<svelte:head>
@@ -84,6 +108,10 @@
</div>
{/if}
{#if moveError}
<p class="error">{moveError}</p>
{/if}
{#if schedule.error}
<p class="error">{schedule.error}</p>
{:else if !schedule.loading && schedule.cabins.length === 0}
@@ -98,11 +126,13 @@
reservations={schedule.reservations}
onCellClick={(cabinId, date) => newReservation(cabinId, date)}
onReservationClick={editReservation}
onReservationMove={moveReservation}
/>
<footer class="legend">
<span><span class="sw confirmed"></span>Potwierdzona</span>
<span><span class="sw option"></span>Opcja (niepotwierdzona)</span>
<span class="hint">✓ = zaliczka wpłacona · kliknij pustą komórkę, aby dodać rezerwację</span>
<span><span class="sw ok"></span>Rozliczony</span>
<span class="hint">✓ = zaliczka · klik w pustą komórkę dodaje · przeciąganie paska przenosi pobyt</span>
</footer>
{/if}
</main>
@@ -248,6 +278,9 @@
.legend .sw.option {
background: var(--bar-option-bg);
}
.legend .sw.ok {
background: var(--ok);
}
.legend .hint {
margin-left: auto;
}