Skip to content

Commit

Permalink
Update ConfirmAddRepeatedOpeningHour component to use Date objects
Browse files Browse the repository at this point in the history
and transform the date into the required strings inside.
  • Loading branch information
kasperbirch1 committed Apr 26, 2024
1 parent bd06203 commit 45297fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
15 changes: 7 additions & 8 deletions src/apps/opening-hours-editor/ConfirmAddRepeatedOpeningHour.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -51,15 +50,15 @@ const ConfirmAddRepeatedOpeningHour = ({
</tr>
<tr>
<td>{t("openingHoursEventFormStartDateText")}:</td>
<td>{startDateString}</td>
<td>{getDateString(startDate)}</td>
</tr>
<tr>
<td>{t("openingHoursEventFormEndDateText")}:</td>
<td>{repeatedEndDate}</td>
<td>{getDateString(repeatedEndDate)}</td>
</tr>
<tr>
<td>{t("openingHoursEventFormEveryWeekdayText")}:</td>
<td>{weekDayName}</td>
<td>{getWeekDayName(startDate)}</td>
</tr>
</tbody>
</table>
Expand Down
5 changes: 2 additions & 3 deletions src/apps/opening-hours-editor/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ const EventForm: React.FC<EventFormProps> = ({
if (repeatedEndDate) {
openDialogWithContent(
<ConfirmAddRepeatedOpeningHour
startDateString={startDateString}
weekDayName={weekDayName}
startDate={startDate}
category={category}
startTime={startTime}
endTime={endTime}
repeatedEndDate={getDateString(new Date(repeatedEndDate))}
repeatedEndDate={new Date(repeatedEndDate)}
confirmSubmit={() =>
onSubmit(category, startTime, endTime, repeatedEndDate)
}
Expand Down

0 comments on commit 45297fa

Please sign in to comment.