From 532feb8b49a1f95a14d1b2c07fe766c2f8688cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Wed, 24 Jul 2024 14:24:52 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20types=20to=20InviteCodePanelV?= =?UTF-8?q?iew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/definitions.ts | 8 +++ frontend/src/elements/AlertBox.vue | 4 +- frontend/src/models.ts | 38 ++++++++++---- .../src/views/admin/InviteCodePanelView.vue | 52 ++++++++++--------- 4 files changed, 66 insertions(+), 36 deletions(-) diff --git a/frontend/src/definitions.ts b/frontend/src/definitions.ts index 9e0719c7..3e7f0c84 100644 --- a/frontend/src/definitions.ts +++ b/frontend/src/definitions.ts @@ -98,6 +98,14 @@ export const bookingStatus = { booked: 3, }; +/** + * Status to indicate if an invite code ist still valid or no longer valid + */ +export enum InviteStatus { + Active = 1, + Revoked = 2, +}; + // available appointment views export const appointmentViews = { booked: 1, diff --git a/frontend/src/elements/AlertBox.vue b/frontend/src/elements/AlertBox.vue index d7c91612..037c5d6c 100644 --- a/frontend/src/elements/AlertBox.vue +++ b/frontend/src/elements/AlertBox.vue @@ -8,8 +8,8 @@ const { t } = useI18n(); // component properties interface Props { title?: string; // flag showing this event as busy and non-selectable - canClose: boolean; // flag for making this alert closable - scheme: AlertSchemes; // flag, are we in month view? + canClose?: boolean; // flag for making this alert closable + scheme?: AlertSchemes; // flag, are we in month view? }; withDefaults(defineProps(), { canClose: true, diff --git a/frontend/src/models.ts b/frontend/src/models.ts index 401a12e9..5c89c1a0 100644 --- a/frontend/src/models.ts +++ b/frontend/src/models.ts @@ -1,12 +1,13 @@ import { Dayjs } from 'dayjs'; import { UseFetchReturn } from '@vueuse/core'; +import { InviteStatus } from './definitions'; export type Attendee = { id: number; email: string; name: string; timezone: string; -} +}; export type Slot = { id: number; @@ -22,7 +23,7 @@ export type Slot = { subscriber_id: number; time_updated: string; attendee: Attendee; -} +}; export type Appointment = { id: number; @@ -133,6 +134,14 @@ export type Schedule = { booking_confirmation: boolean; }; +export type Invite = { + subscriber_id?: number; + code: string; + status: InviteStatus; + time_created: string; + time_updated: string; +}; + export type User = { email: string; preferredEmail: string; @@ -145,7 +154,7 @@ export type User = { accessToken: string; scheduleLinks: string[]; isSetup: boolean, -} +}; export type Subscriber = { username: string; @@ -161,13 +170,23 @@ export type Subscriber = { export type Signature = { url: string; -} +}; export type Error = { error: boolean|string|null }; +export type Exception = { + status_code?: number; + detail?: { msg: string }[]|ExceptionDetail; + headers?: any[]; +}; +export type ExceptionDetail = { + id?: string; + message?: string; + status?: number; +} export type Token = { access_token: string; token_type: string; -} +}; // Types and aliases used for our custom createFetch API calls and return types export type Fetch = (url: string) => UseFetchReturn & PromiseLike>; @@ -179,27 +198,28 @@ export type TokenResponse = UseFetchReturn; export type AppointmentListResponse = UseFetchReturn; export type CalendarListResponse = UseFetchReturn; export type ScheduleListResponse = UseFetchReturn; +export type InviteListResponse = UseFetchReturn; export type ExternalConnectionCollectionResponse = UseFetchReturn; // Utility types export type Time = { start: T; end: T; -} +}; export type TimeNumeric = Time; export type TimeFormatted = Time; export type IsoWeekdayOption = { label: string; value: string; -} +}; export type Coloring = { border?: string; background?: string; -} +}; export type HTMLElementEvent = Event & { target: HTMLElement; currentTarget: HTMLElement; -} +}; diff --git a/frontend/src/views/admin/InviteCodePanelView.vue b/frontend/src/views/admin/InviteCodePanelView.vue index 4c509f7c..e5877728 100644 --- a/frontend/src/views/admin/InviteCodePanelView.vue +++ b/frontend/src/views/admin/InviteCodePanelView.vue @@ -1,16 +1,9 @@