From a076bb2fb034424241d85a96f26b79fc3956cd5e Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Thu, 8 May 2025 18:00:25 +0200 Subject: [PATCH] add frontend support for the date formatting option --- .../Common/Reporting/ReportingChart.vue | 2 +- .../ui/calendar/CalendarDateInput.vue | 7 +++-- .../packages/ui/src/Input/DateRangePicker.vue | 10 ++++--- .../src/TimeEntry/TimeEntryRangeSelector.vue | 9 ++++--- .../ui/src/TimeEntry/TimeEntryRowHeading.vue | 2 +- resources/js/packages/ui/src/utils/time.ts | 26 +++++++++++-------- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/resources/js/Components/Common/Reporting/ReportingChart.vue b/resources/js/Components/Common/Reporting/ReportingChart.vue index da96ec37..4a815fda 100644 --- a/resources/js/Components/Common/Reporting/ReportingChart.vue +++ b/resources/js/Components/Common/Reporting/ReportingChart.vue @@ -43,7 +43,7 @@ const xAxisLabels = computed(() => { if (props.groupedType === 'week') { return props?.groupedData?.map((el) => formatWeek(el.key)); } - return props?.groupedData?.map((el) => formatDate(el.key ?? '')); + return props?.groupedData?.map((el) => formatDate(el.key ?? '', organization?.value?.date_format)); }); const accentColor = useCssVar('--theme-color-chart', null, { observe: true }); const labelColor = useCssVar('--color-text-secondary', null, { observe: true }); diff --git a/resources/js/Components/ui/calendar/CalendarDateInput.vue b/resources/js/Components/ui/calendar/CalendarDateInput.vue index a8415756..42011362 100644 --- a/resources/js/Components/ui/calendar/CalendarDateInput.vue +++ b/resources/js/Components/ui/calendar/CalendarDateInput.vue @@ -9,7 +9,8 @@ import { Calendar } from '@/Components/ui/calendar'; import { CalendarIcon } from 'lucide-vue-next'; import { formatDateLocalized } from '@/packages/ui/src/utils/time'; import { parseDate } from '@internationalized/date'; -import { computed } from 'vue'; +import { computed, inject, type ComputedRef } from 'vue'; +import { type Organization } from '@/packages/api/src'; const model = defineModel(); const emit = defineEmits<{ @@ -27,6 +28,8 @@ const handleBlur = () => { const date = computed(() => { return model.value ? parseDate(model.value) : undefined; }); + +const organization = inject>('organization');