Manuel Bustillo be73e7018a
All checks were successful
Playwright Tests / test (pull_request) Has been skipped
Add copyright notice / copyright_notice (pull_request) Successful in 26s
Check usage of free licenses / build-static-assets (pull_request) Successful in 35s
Fix group parsing in the guest model
2024-12-11 00:16:35 +01:00

43 lines
1.2 KiB
TypeScript

/* Copyright (C) 2024 Manuel Bustillo*/
import { Serializable } from "../api/abstract-api";
import { Entity } from "./definitions";
export const guestStatuses = ['considered', 'invited', 'confirmed', 'declined', 'tentative'] as const;
export type GuestStatus = typeof guestStatuses[number];
export class Guest implements Entity {
id?: string;
name?: string;
group_name?: string;
groupId?: string;
color?: string;
status?: GuestStatus;
children?: Guest[];
constructor(id?: string, name?: string, group_name?: string, groupId?: string, color?: string, status?: GuestStatus, children?: Guest[]) {
this.id = id;
this.name = name;
this.group_name = group_name;
this.groupId = groupId;
this.color = color;
this.status = status;
this.children = children;
}
}
export class GuestSerializer implements Serializable<Guest> {
fromJson(data: any): Guest {
return new Guest(data.id, data.name, data.group?.name, data.group?.id, data.color, data.status, data.children);
}
toJson(guest: Guest): string {
return JSON.stringify({ guest: { name: guest.name, status: guest.status, group_id: guest.groupId } });
}
apiPath(): string {
return 'guests';
}
}