From 2ab14b128acef0c6d064b66e0b00bdf85f74c354 Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 26 Jul 2024 10:51:19 +0200 Subject: [PATCH] Components elements TypeScript (#577) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ➕ Add types to elements components * 🔨 Fix optional type properties * 🔨 Fix data table count and bg coloring * ➕ Add types to InviteCodePanelView * 👕 Refactor enum members to PascalCase * ➕ Add types to SubscriberPanelView * ➕ Add types to WaitingListPanelView * 🔨 Fix type order and default argument --- frontend/src/App.vue | 6 +- frontend/src/assets/styles/main.css | 11 +- frontend/src/components/CalendarMiniMonth.vue | 6 +- frontend/src/components/CalendarQalendar.vue | 3 +- frontend/src/components/DataTable.vue | 2 +- frontend/src/composables/dayjs.ts | 10 +- frontend/src/definitions.ts | 35 ++-- frontend/src/elements/AlertBox.vue | 66 ++++---- frontend/src/elements/AppointmentGridItem.vue | 66 ++++---- frontend/src/elements/AppointmentListItem.vue | 40 +++-- frontend/src/elements/BubbleSelect.vue | 23 ++- frontend/src/elements/CautionButton.vue | 28 ++-- frontend/src/elements/DropDown.vue | 18 +- frontend/src/elements/EventPopup.vue | 80 ++++----- .../src/elements/GoogleCalendarButton.vue | 15 +- frontend/src/elements/ListPagination.vue | 64 +++---- frontend/src/elements/NavBarItem.vue | 19 ++- frontend/src/elements/PrimaryButton.vue | 59 +++---- frontend/src/elements/SecondaryButton.vue | 59 +++---- frontend/src/elements/SiteNotification.vue | 20 ++- frontend/src/elements/SnackishBar.vue | 22 +-- frontend/src/elements/SwitchToggle.vue | 69 ++++---- frontend/src/elements/TextButton.vue | 63 +++---- frontend/src/elements/TextInput.vue | 38 ++--- frontend/src/elements/ToolTip.vue | 15 +- frontend/src/elements/UserAvatar.vue | 14 +- .../src/elements/calendar/CalendarEvent.vue | 6 +- .../calendar/CalendarEventPlaceholder.vue | 8 +- .../calendar/CalendarEventPreview.vue | 6 +- .../elements/calendar/CalendarEventRemote.vue | 6 +- .../calendar/CalendarEventScheduled.vue | 6 +- .../calendar/CalendarMiniMonthDay.vue | 18 +- frontend/src/elements/home/InfoBox.vue | 2 +- frontend/src/keys.ts | 16 +- frontend/src/models.ts | 63 +++++-- frontend/src/views/AppointmentsView.vue | 14 +- frontend/src/views/CalendarView.vue | 34 ++-- frontend/src/views/ContactView.vue | 21 +-- .../src/views/admin/InviteCodePanelView.vue | 158 +++++++++--------- .../src/views/admin/SubscriberPanelView.vue | 146 ++++++++-------- .../src/views/admin/WaitingListPanelView.vue | 31 ++-- 41 files changed, 742 insertions(+), 644 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 46732d36f..a4050ac6e 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -47,7 +47,7 @@ import { useAppointmentStore } from '@/stores/appointment-store'; import { useScheduleStore } from '@/stores/schedule-store'; import RouteNotFoundView from '@/views/errors/RouteNotFoundView.vue'; import NotAuthenticatedView from '@/views/errors/NotAuthenticatedView.vue'; -import { callKey } from '@/keys'; +import { callKey, refreshKey } from '@/keys'; // component constants const currentUser = useUserStore(); // data: { username, email, name, level, timezone, id } @@ -164,6 +164,8 @@ const getDbData = async () => { } }; -// provide refresh functions for components +// Deprecated - Please use refreshKey, as it's typed! provide('refresh', getDbData); +// provide refresh functions for components +provide(refreshKey, getDbData); diff --git a/frontend/src/assets/styles/main.css b/frontend/src/assets/styles/main.css index 1a4449b73..20509aa9b 100644 --- a/frontend/src/assets/styles/main.css +++ b/frontend/src/assets/styles/main.css @@ -149,18 +149,18 @@ /* custom data table with wrapper */ .data-table { - @apply rounded-xl w-full border py-2 border-gray-100 bg-white text-sm shadow-sm dark:border-gray-500 dark:bg-gray-700 mb-4 ml-auto mr-0; + @apply rounded-xl w-full border py-2 border-gray-200 bg-gray-100 text-sm shadow-sm dark:border-gray-500 dark:bg-gray-700 mb-4 ml-auto mr-0; table { - @apply w-full table-auto border-collapse bg-white text-sm shadow-sm dark:bg-gray-600; + @apply w-full table-auto border-collapse text-sm; } thead, tfoot { - @apply border-gray-200 bg-gray-100 dark:border-gray-500 dark:bg-gray-700 text-gray-600 dark:text-gray-300; + @apply text-gray-600 dark:text-gray-300; } th { - @apply px-4 text-left font-semibold border-gray-200 dark:border-gray-500; + @apply px-4 text-left font-semibold; } thead th { @apply pb-4 pt-2; @@ -171,6 +171,9 @@ td { @apply border-y border-gray-200 p-4 dark:border-gray-500; } + tbody td { + @apply bg-white dark:bg-gray-700; + } } /* Force First Time User Experience to be different from the rest of the site */ diff --git a/frontend/src/components/CalendarMiniMonth.vue b/frontend/src/components/CalendarMiniMonth.vue index e93c73706..77832c3f2 100644 --- a/frontend/src/components/CalendarMiniMonth.vue +++ b/frontend/src/components/CalendarMiniMonth.vue @@ -53,7 +53,6 @@ import { IconChevronLeft, IconChevronRight, } from '@tabler/icons-vue'; -import { appointmentState } from '@/definitions'; import { dayjsKey } from "@/keys"; // component constants @@ -121,10 +120,7 @@ const eventsByDate = (d) => { return props.placeholder ? events.value[key].filter((e) => dj(e.start).isAfter(dj())) : events.value[key].filter( - (e) => (dj(e.start).add(e.duration, 'minutes').isAfter(dj()) && e.status === appointmentState.pending) - || (e.attendee && e.status === appointmentState.pending) - || e.remote - || e.preview, + (e) => (dj(e.start).add(e.duration, 'minutes').isAfter(dj())) || e.remote || e.preview, ); } return []; diff --git a/frontend/src/components/CalendarQalendar.vue b/frontend/src/components/CalendarQalendar.vue index a4f7e402f..260f2be49 100644 --- a/frontend/src/components/CalendarQalendar.vue +++ b/frontend/src/components/CalendarQalendar.vue @@ -6,7 +6,6 @@ import { Qalendar } from 'qalendar'; import 'qalendar/dist/style.css'; import CalendarEvent from '@/elements/calendar/CalendarEvent.vue'; import { - appointmentState, bookingStatus, ColorSchemes, dateFormatStrings, @@ -202,7 +201,7 @@ const calendarEvents = computed(() => { customData: { attendee: null, slot_status: null, - booking_status: appointmentState.booked, + booking_status: bookingStatus.booked, calendar_title: event.calendar_title, calendar_color: event.calendar_color, duration: event.duration, diff --git a/frontend/src/components/DataTable.vue b/frontend/src/components/DataTable.vue index 392470db8..b7495de66 100644 --- a/frontend/src/components/DataTable.vue +++ b/frontend/src/components/DataTable.vue @@ -2,7 +2,7 @@
- {{ paginatedDataList.length }} {{ dataName }} + {{ totalDataLength }} {{ dataName }}