From 45297fa84ee2a1c2eec021f6224625d4ea3b21ea Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Thu, 25 Apr 2024 15:50:55 +0200 Subject: [PATCH] Update `ConfirmAddRepeatedOpeningHour` component to use Date objects and transform the date into the required strings inside. --- .../ConfirmAddRepeatedOpeningHour.tsx | 15 +++++++-------- src/apps/opening-hours-editor/EventForm.tsx | 5 ++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/apps/opening-hours-editor/ConfirmAddRepeatedOpeningHour.tsx b/src/apps/opening-hours-editor/ConfirmAddRepeatedOpeningHour.tsx index ace984c31b..089d701a7e 100644 --- a/src/apps/opening-hours-editor/ConfirmAddRepeatedOpeningHour.tsx +++ b/src/apps/opening-hours-editor/ConfirmAddRepeatedOpeningHour.tsx @@ -1,21 +1,20 @@ import React from "react"; import { useText } from "../../core/utils/text"; import { OpeningHoursCategoriesType } from "./types"; +import { getDateString, getWeekDayName } from "./helper"; type ConfirmAddRepeatedOpeningHourType = { - startDateString: string; - weekDayName: string; + startDate: Date; category: OpeningHoursCategoriesType; startTime: string; endTime: string; - repeatedEndDate: string; + repeatedEndDate: Date; confirmSubmit: () => void; closeDialog: () => void; }; const ConfirmAddRepeatedOpeningHour = ({ - startDateString, - weekDayName, + startDate, category, startTime, endTime, @@ -51,15 +50,15 @@ const ConfirmAddRepeatedOpeningHour = ({ {t("openingHoursEventFormStartDateText")}: - {startDateString} + {getDateString(startDate)} {t("openingHoursEventFormEndDateText")}: - {repeatedEndDate} + {getDateString(repeatedEndDate)} {t("openingHoursEventFormEveryWeekdayText")}: - {weekDayName} + {getWeekDayName(startDate)} diff --git a/src/apps/opening-hours-editor/EventForm.tsx b/src/apps/opening-hours-editor/EventForm.tsx index 41f31e63bc..e28ecbaa01 100644 --- a/src/apps/opening-hours-editor/EventForm.tsx +++ b/src/apps/opening-hours-editor/EventForm.tsx @@ -86,12 +86,11 @@ const EventForm: React.FC = ({ if (repeatedEndDate) { openDialogWithContent( onSubmit(category, startTime, endTime, repeatedEndDate) }