Init project

This commit is contained in:
2025-12-26 11:25:45 +02:00
commit 8f8fc50310
79 changed files with 9970 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
// state.svelte.ts
import { CalendarDate, getDayOfWeek } from "@internationalized/date";
import { trace } from "@tauri-apps/plugin-log";
export interface Resident {
id: string;
name: string;
negativeShifts: CalendarDate[];
manualShifts: CalendarDate[];
maxShifts: number | undefined;
allowedTypes: string[];
hasReducedLoad: boolean;
}
export interface ForbiddenPair {
id1: string;
id2: string;
}
export class RotaState {
currentStep = $state(1);
residents = $state<Resident[]>([]);
selectedMonth = $state(2);
selectedYear = $state(2026);
holidays = $state<CalendarDate[]>([]);
forbiddenPairs = $state<ForbiddenPair[]>([]);
projectMonth = $derived(new CalendarDate(this.selectedYear, this.selectedMonth, 1));
projectMonthDays = $derived(this.projectMonth.calendar.getDaysInMonth(this.projectMonth));
daysArray = $derived(Array.from({ length: this.projectMonthDays }, (_, i) => i + 1));
emptySlots = $derived(Array.from({ length: getDayOfWeek(this.projectMonth, "en-GB") }));
addResident() {
this.residents.push({
id: crypto.randomUUID(),
name: "",
negativeShifts: [],
manualShifts: [],
maxShifts: undefined,
allowedTypes: ["OpenAsFirst", "OpenAsSecond", "Closed"],
hasReducedLoad: false,
});
}
removeResident(id: string) {
this.residents = this.residents.filter((p) => p.id !== id);
}
addForbiddenPair() {
if (this.residents.length < 2) return;
this.forbiddenPairs.push({
id1: this.residents[0].id,
id2: this.residents[1].id
});
}
removeForbiddenPair(index: number) {
this.forbiddenPairs.splice(index, 1);
}
}
export const rota = new RotaState();
export const steps = [
{
id: 1,
title: "Βασικές Ρυθμίσεις",
description: "Καθόρισε την περίοδο και τις αργίες του μήνα."
},
{
id: 2,
title: "Ρύθμιση Προσωπικού",
description: "Δημιούργησε νέα εγγραφή ειδικευόμενου."
},
{
id: 3,
title: "Προχωρημένες Ρυθμίσεις",
description: "Επίλεξε ζευγάρια ατόμων που δεν μπορούν να κάνουν μαζί εφημερία."
},
{
id: 4,
title: "Επισκόπηση Προγράμματος",
description: "Έλεγξε το πρόγραμμα με τις υποχρεωτικές υπάρχουσες εφημερίες."
},
{
id: 5,
title: "Δημιουργία Προγράμματος",
description: "Τρέξε τον αλγόριθμο ανάθεσης εφημεριών, εξήγαγε τα αποτελέσματα."
}
];