Change ResidentId(String) to ResidentId(u8), impl Copy for ShiftType, use u8 for all UserConfig params
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { CalendarDate, getDayOfWeek } from "@internationalized/date";
|
||||
|
||||
export interface Resident {
|
||||
id: string;
|
||||
id: number;
|
||||
name: string;
|
||||
negativeShifts: CalendarDate[];
|
||||
manualShifts: CalendarDate[];
|
||||
@@ -12,12 +12,13 @@ export interface Resident {
|
||||
}
|
||||
|
||||
export interface ForbiddenPair {
|
||||
id1: string;
|
||||
id2: string;
|
||||
id1: number;
|
||||
id2: number;
|
||||
}
|
||||
|
||||
export class RotaState {
|
||||
currentStep = $state(1);
|
||||
residentsCounter = $state(0);
|
||||
residents = $state<Resident[]>([]);
|
||||
selectedMonth = $state(2);
|
||||
selectedYear = $state(2026);
|
||||
@@ -38,7 +39,7 @@ export class RotaState {
|
||||
|
||||
addResident() {
|
||||
this.residents.push({
|
||||
id: crypto.randomUUID(),
|
||||
id: ++this.residentsCounter,
|
||||
name: "",
|
||||
negativeShifts: [],
|
||||
manualShifts: [],
|
||||
@@ -48,11 +49,11 @@ export class RotaState {
|
||||
});
|
||||
}
|
||||
|
||||
removeResident(id: string) {
|
||||
removeResident(id: number) {
|
||||
this.residents = this.residents.filter((r) => r.id !== id);
|
||||
}
|
||||
|
||||
findResident(id: string) {
|
||||
findResident(id: number) {
|
||||
return this.residents.find((r) => r.id === id);
|
||||
}
|
||||
|
||||
@@ -102,11 +103,11 @@ export type UserConfigDTO = {
|
||||
year: number;
|
||||
holidays: Array<number>;
|
||||
residents: Array<ResidentDTO>;
|
||||
toxic_pairs: Array<[string, string]>;
|
||||
toxic_pairs: Array<[number, number]>;
|
||||
};
|
||||
|
||||
export type ResidentDTO = {
|
||||
id: string;
|
||||
id: number;
|
||||
name: string;
|
||||
negativeShifts: Array<number>;
|
||||
manualShifts: Array<{ day: number; position: ShiftPosition }>;
|
||||
|
||||
Reference in New Issue
Block a user