@licklist/design 0.52.0 → 0.53.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/calendar/Calendar.d.ts +3 -8
  2. package/dist/calendar/Calendar.d.ts.map +1 -1
  3. package/dist/calendar/Calendar.js +1 -1
  4. package/dist/calendar/components/CalendarButtons/CalendarButtons.d.ts +2 -2
  5. package/dist/calendar/components/CalendarButtons/CalendarButtons.d.ts.map +1 -1
  6. package/dist/calendar/components/CalendarButtons/CalendarButtons.js +1 -1
  7. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts +2 -2
  8. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts.map +1 -1
  9. package/dist/calendar/components/CalendarDates/CalendarDates.js +1 -1
  10. package/dist/calendar/utils/index.d.ts +0 -2
  11. package/dist/calendar/utils/index.d.ts.map +1 -1
  12. package/dist/calendar/utils/index.js +1 -1
  13. package/dist/date-time-button/DateTimeButton.d.ts +3 -3
  14. package/dist/date-time-button/DateTimeButton.d.ts.map +1 -1
  15. package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
  16. package/dist/events/edit-event-modal/IntervalInput.js +1 -1
  17. package/dist/events/edit-event-modal/hooks/index.d.ts +3 -0
  18. package/dist/events/edit-event-modal/hooks/index.d.ts.map +1 -0
  19. package/dist/events/edit-event-modal/hooks/useFormattedDuration.d.ts +2 -0
  20. package/dist/events/edit-event-modal/hooks/useFormattedDuration.d.ts.map +1 -0
  21. package/dist/events/edit-event-modal/hooks/useFormattedDuration.js +1 -0
  22. package/dist/events/edit-event-modal/hooks/useValidationOptions.d.ts +11 -0
  23. package/dist/events/edit-event-modal/hooks/useValidationOptions.d.ts.map +1 -0
  24. package/dist/events/edit-event-modal/hooks/useValidationOptions.js +1 -0
  25. package/dist/events/event-venue-map/components/Scrollbars/Scrollbars.js +1 -1
  26. package/dist/iframe/event/event-card/IframeEventCard.d.ts +2 -1
  27. package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
  28. package/dist/iframe/event/event-card/IframeEventCard.js +1 -1
  29. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +1 -1
  30. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  31. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
  32. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts +2 -1
  33. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts.map +1 -1
  34. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.js +1 -1
  35. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts +2 -1
  36. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts.map +1 -1
  37. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.js +1 -1
  38. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.js +1 -1
  39. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +1 -0
  40. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  41. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts.map +1 -1
  42. package/dist/iframe/order-process/components/BookingSummary/utils/index.js +1 -1
  43. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  44. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.js +1 -1
  45. package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +1 -1
  46. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts +2 -1
  47. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
  48. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +1 -1
  49. package/dist/index.js +1 -1
  50. package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
  51. package/dist/notification/email-template/control/EmailTemplateControl.js +1 -1
  52. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  53. package/dist/sales/booking/results/components/ResultCard.js +1 -1
  54. package/dist/sales/manual-booking/summary/ManualBookingSummary.d.ts +2 -1
  55. package/dist/sales/manual-booking/summary/ManualBookingSummary.d.ts.map +1 -1
  56. package/dist/sales/manual-booking/summary/ManualBookingSummary.js +1 -1
  57. package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
  58. package/dist/snippet/snippet-template/preview/Preview.js +1 -1
  59. package/dist/static/date-range-input/DateRangeInput.d.ts.map +1 -1
  60. package/dist/static/date-range-input/DateRangeInput.js +1 -1
  61. package/dist/styles/resources-blocking/_index.scss +6 -0
  62. package/dist/styles/sales/BookingFilter.scss +18 -0
  63. package/dist/styles/sales/BookingResults.scss +1 -1
  64. package/dist/styles/sales/BookingTabs.scss +63 -5
  65. package/dist/styles/sales/LifeTimeSales.scss +1 -0
  66. package/dist/styles/sales/ManualBooking.scss +62 -3
  67. package/dist/styles/sales/SourceOfSales.scss +3 -0
  68. package/dist/styles/snippet-templates/SnippetTemplateCard.scss +3 -2
  69. package/dist/styles/static/Tabs.scss +6 -0
  70. package/dist/styles/themes/bookedit/_index.scss +9 -8
  71. package/package.json +3 -3
  72. package/src/calendar/Calendar.tsx +9 -16
  73. package/src/calendar/components/CalendarButtons/CalendarButtons.tsx +8 -5
  74. package/src/calendar/components/CalendarDates/CalendarDates.tsx +12 -13
  75. package/src/calendar/utils/index.ts +0 -19
  76. package/src/date-time-button/DateTimeButton.tsx +3 -3
  77. package/src/events/edit-event-modal/IntervalInput.tsx +8 -80
  78. package/src/events/edit-event-modal/hooks/index.ts +2 -0
  79. package/src/events/edit-event-modal/hooks/useFormattedDuration.tsx +40 -0
  80. package/src/events/edit-event-modal/hooks/useValidationOptions.tsx +36 -0
  81. package/src/iframe/event/event-card/IframeEventCard.tsx +3 -1
  82. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +2 -0
  83. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.tsx +12 -6
  84. package/src/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.tsx +3 -0
  85. package/src/iframe/order-process/components/BookingSummary/types/index.ts +1 -0
  86. package/src/iframe/order-process/components/BookingSummary/utils/index.ts +2 -4
  87. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +13 -23
  88. package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +1 -1
  89. package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +9 -3
  90. package/src/notification/email-template/control/EmailTemplateControl.tsx +5 -15
  91. package/src/sales/booking/results/components/ResultCard.tsx +6 -4
  92. package/src/sales/manual-booking/summary/ManualBookingSummary.tsx +9 -1
  93. package/src/snippet/snippet-template/preview/Preview.tsx +3 -0
  94. package/src/static/date-range-input/DateRangeInput.tsx +23 -2
  95. package/src/static/switch/BooleanSwitch.tsx +1 -1
  96. package/src/styles/resources-blocking/_index.scss +6 -0
  97. package/src/styles/sales/BookingFilter.scss +18 -0
  98. package/src/styles/sales/BookingResults.scss +1 -1
  99. package/src/styles/sales/BookingTabs.scss +63 -5
  100. package/src/styles/sales/LifeTimeSales.scss +1 -0
  101. package/src/styles/sales/ManualBooking.scss +62 -3
  102. package/src/styles/sales/SourceOfSales.scss +3 -0
  103. package/src/styles/snippet-templates/SnippetTemplateCard.scss +3 -2
  104. package/src/styles/static/Tabs.scss +6 -0
  105. package/src/styles/themes/bookedit/_index.scss +9 -8
@@ -28,12 +28,13 @@ $snippet-template-card-button-transition: $product-set-card-transition !default;
28
28
  border: 1px solid #ccc;
29
29
  border-radius: $border-radius;
30
30
  height: 10rem;
31
- width: 15rem;
31
+ min-width: 15rem;
32
32
  padding: 1rem;
33
33
 
34
34
  @include media-breakpoint-down(sm) {
35
35
  height: 100%;
36
36
  max-height: 10rem;
37
+ width: 100%;
37
38
  }
38
39
 
39
40
  p {
@@ -109,4 +110,4 @@ $snippet-template-card-button-transition: $product-set-card-transition !default;
109
110
  &:hover {
110
111
  border: 2px solid $blue;
111
112
  }
112
- }
113
+ }
@@ -11,6 +11,12 @@ $tab-nav-link-active-border-bottom: 1px solid $tab-nav-link-active-color !defaul
11
11
  margin-left: -1.25rem;
12
12
  border-bottom: 1px solid $nav-tabs-border-color;
13
13
 
14
+ @include media-breakpoint-down(sm) {
15
+ display: flex;
16
+ flex-direction: column;
17
+ white-space: nowrap;
18
+ }
19
+
14
20
  .nav-link {
15
21
  color: $tab-nav-link-color;
16
22
  background-color: transparent;
@@ -98,7 +98,8 @@
98
98
  color: gray("600");
99
99
 
100
100
  &.sortable {
101
- &::before, &::after {
101
+ &::before,
102
+ &::after {
102
103
  opacity: 1;
103
104
  }
104
105
 
@@ -132,20 +133,20 @@
132
133
  width: 2.5rem;
133
134
  height: 2.5rem;
134
135
  background-color: transparent;
135
-
136
+
136
137
  svg {
137
138
  margin-bottom: 2.5px;
138
139
  }
139
140
 
140
141
  &:hover {
141
142
  cursor: pointer;
142
- border-radius: .5rem;
143
+ border-radius: 0.5rem;
143
144
  background-color: lighten($primary, 40);
144
145
  }
145
146
  }
146
147
 
147
148
  .page-item {
148
- margin-left: .4rem;
149
+ margin-left: 0.4rem;
149
150
  min-width: 15px;
150
151
  width: 2.5rem;
151
152
  height: 2.5rem;
@@ -153,7 +154,7 @@
153
154
  .page-link {
154
155
  border: 0;
155
156
  padding: 0;
156
- border-radius: .5rem;
157
+ border-radius: 0.5rem;
157
158
  height: 100%;
158
159
  display: flex;
159
160
  align-items: center;
@@ -162,13 +163,13 @@
162
163
  color: $black;
163
164
  font-weight: 600;
164
165
  font-size: 0.875rem;
165
-
166
+
166
167
  &:hover {
167
- border-radius: .5rem;
168
+ border-radius: 0.5rem;
168
169
  background-color: lighten($primary, 40);
169
170
  }
170
171
  }
171
-
172
+
172
173
  &.active {
173
174
  .page-link {
174
175
  border: 2px solid $primary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.52.0",
3
+ "version": "0.53.0-dev.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -53,9 +53,9 @@
53
53
  "@fortawesome/free-brands-svg-icons": "5.15.2",
54
54
  "@fortawesome/free-solid-svg-icons": "5.15.2",
55
55
  "@fortawesome/react-fontawesome": "0.1.9",
56
- "@licklist/core": "^0.17.0",
56
+ "@licklist/core": ">=0.15.41-dev.0 < 0.15.41",
57
57
  "@licklist/eslint-config": "0.3.4",
58
- "@licklist/plugins": "^0.25.0",
58
+ "@licklist/plugins": ">=0.24.0-dev.0 < 0.24.0",
59
59
  "@mdx-js/react": "1.6.22",
60
60
  "@popperjs/core": "2.11.8",
61
61
  "@react-aria/utils": "3.9.0",
@@ -1,12 +1,9 @@
1
1
  import React, { Dispatch, ReactElement, SetStateAction } from "react";
2
2
  import { DateTime } from "luxon";
3
- import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/ZoneResourcesAvailabilityDataMapper";
3
+ import { DateTimeButtonProps } from "src/date-time-button";
4
4
  import { CalendarButtons } from "./components/CalendarButtons";
5
5
  import { CalendarDates } from "./components/CalendarDates";
6
6
 
7
- // same as apps/iframe/src/types/availability.ts
8
- export type AvailableTimes = Record<string, string[]>;
9
-
10
7
  export const defaultStartDay = DateTime.now().set({
11
8
  millisecond: 0,
12
9
  second: 0,
@@ -18,32 +15,28 @@ export type CalendarProps = {
18
15
  currentDate: DateTime;
19
16
  setCurrentDate: Dispatch<SetStateAction<DateTime>>;
20
17
  calendarDates: DateTime[];
21
- disabledDates?: DateTime[];
22
18
  selectedDate: DateTime | null;
23
19
  setSelectedDate: Dispatch<SetStateAction<DateTime | null>>;
24
20
  fromPrice?: string | ReactElement | null;
25
21
  isLoading?: boolean;
26
22
  initialDate?: DateTime;
27
- getAvailability?: (date: DateTime) => ZoneResourcesAvailability | null;
28
- includeAvailability?: boolean;
29
- availableTimes?: AvailableTimes;
30
- shouldCalculateResources?: boolean;
23
+ getDateTimeButtonProps: (
24
+ date: DateTime
25
+ ) => Pick<
26
+ DateTimeButtonProps,
27
+ "resources" | "showResources" | "shouldCalculateResources" | "isDisabled"
28
+ >;
31
29
  };
32
30
 
33
31
  export const Calendar = ({
34
- disabledDates = [],
35
32
  initialDate = defaultStartDay,
36
33
  ...props
37
34
  }: CalendarProps) => {
38
35
  return (
39
36
  <div className="calendar-wrapper">
40
37
  <div className="calendar">
41
- <CalendarButtons
42
- disabledDates={disabledDates}
43
- initialDate={initialDate}
44
- {...props}
45
- />
46
- <CalendarDates disabledDates={disabledDates} {...props} />
38
+ <CalendarButtons initialDate={initialDate} {...props} />
39
+ <CalendarDates {...props} />
47
40
  </div>
48
41
  </div>
49
42
  );
@@ -4,26 +4,25 @@ import { useTranslation } from "react-i18next";
4
4
  import { range } from "lodash";
5
5
  import { ReactComponent as SelectArrow } from "../../../assets/iframe/selectArrow.svg";
6
6
  import { CalendarSelect } from "../CalendarSelect";
7
- import { isDateDisabled } from "../../utils";
8
7
  import { CalendarProps } from "../../Calendar";
9
8
 
10
9
  type CalendarButtonsProps = Pick<
11
10
  CalendarProps,
12
11
  | "isLoading"
13
- | "disabledDates"
14
12
  | "initialDate"
15
13
  | "currentDate"
16
14
  | "setCurrentDate"
17
15
  | "setSelectedDate"
16
+ | "getDateTimeButtonProps"
18
17
  >;
19
18
 
20
19
  export const CalendarButtons = ({
21
- disabledDates = [],
22
20
  isLoading = false,
23
21
  initialDate,
24
22
  currentDate,
25
23
  setCurrentDate,
26
24
  setSelectedDate,
25
+ getDateTimeButtonProps,
27
26
  }: CalendarButtonsProps) => {
28
27
  const { t } = useTranslation("Design");
29
28
 
@@ -66,7 +65,9 @@ export const CalendarButtons = ({
66
65
  const onTodayClick = () => {
67
66
  setCurrentDate(initialDate);
68
67
 
69
- if (isDateDisabled(initialDate, disabledDates)) return;
68
+ const { isDisabled } = getDateTimeButtonProps(initialDate);
69
+
70
+ if (isDisabled) return;
70
71
 
71
72
  setSelectedDate(initialDate);
72
73
  };
@@ -75,7 +76,9 @@ export const CalendarButtons = ({
75
76
  const nextDate = initialDate.set({ day: initialDate.day + 1 });
76
77
  setCurrentDate(nextDate);
77
78
 
78
- if (isDateDisabled(nextDate, disabledDates)) return;
79
+ const { isDisabled } = getDateTimeButtonProps(initialDate);
80
+
81
+ if (isDisabled) return;
79
82
 
80
83
  setSelectedDate(nextDate);
81
84
  };
@@ -2,25 +2,25 @@ import React, { useMemo } from "react";
2
2
  import { DateTime } from "luxon";
3
3
  import { DateTimeButton, Variant } from "../../../date-time-button";
4
4
  import { CalendarWeekdays } from "../CalendarWeekdays";
5
- import { isDateDisabled } from "../../utils";
6
5
  import { CalendarProps } from "../../Calendar";
7
6
 
8
- export type CalendarDatesProps = Omit<
7
+ export type CalendarDatesProps = Pick<
9
8
  CalendarProps,
10
- "currentDate" | "setCurrentDate" | "initialDate"
9
+ | "isLoading"
10
+ | "calendarDates"
11
+ | "selectedDate"
12
+ | "setSelectedDate"
13
+ | "fromPrice"
14
+ | "getDateTimeButtonProps"
11
15
  >;
12
16
 
13
17
  export const CalendarDates = ({
14
- disabledDates = [],
15
18
  isLoading = false,
16
19
  calendarDates,
17
20
  selectedDate,
18
21
  setSelectedDate,
19
22
  fromPrice,
20
- getAvailability,
21
- includeAvailability,
22
- shouldCalculateResources,
23
- availableTimes,
23
+ getDateTimeButtonProps,
24
24
  }: CalendarDatesProps) => {
25
25
  const fillCalendarDates = useMemo(() => {
26
26
  let firstDayOfWeek = calendarDates[0]?.weekday ?? 0;
@@ -46,8 +46,9 @@ export const CalendarDates = ({
46
46
  {fillCalendarDates.map((date: DateTime | null) => {
47
47
  if (date === null) return <div />;
48
48
 
49
- const isDisabled =
50
- isLoading || isDateDisabled(date, disabledDates, availableTimes);
49
+ const props = getDateTimeButtonProps(date);
50
+
51
+ const isDisabled = isLoading || props.isDisabled;
51
52
 
52
53
  return (
53
54
  <DateTimeButton
@@ -59,10 +60,8 @@ export const CalendarDates = ({
59
60
  date={date}
60
61
  onSelect={() => setSelectedDate(date)}
61
62
  price={fromPrice}
62
- resources={getAvailability?.(date)}
63
- showResources={includeAvailability}
64
63
  variant={Variant.month}
65
- shouldCalculateResources={shouldCalculateResources}
64
+ {...props}
66
65
  />
67
66
  );
68
67
  })}
@@ -1,23 +1,4 @@
1
1
  import { DateTime, Interval } from "luxon";
2
- import isEqual from "lodash/isEqual";
3
- import { DATE_FORMAT } from "@licklist/core/dist/Config";
4
- import { AvailableTimes } from "../Calendar";
5
-
6
- export const isDateDisabled = (
7
- date: DateTime,
8
- disabledDates: DateTime[] = [],
9
- availableTimes?: AvailableTimes
10
- ): boolean => {
11
- const disabledByDates = !!disabledDates.find((disabledDate) =>
12
- isEqual(disabledDate.toObject(), date.toObject())
13
- );
14
-
15
- const noAvailableTimes = availableTimes
16
- ? !availableTimes?.[date.toFormat(DATE_FORMAT)]
17
- : false;
18
-
19
- return disabledByDates || noAvailableTimes;
20
- };
21
2
 
22
3
  export const getMonthCalendarDates = (initialDate: DateTime): DateTime[] => {
23
4
  const startOfMonth = initialDate.startOf("month");
@@ -14,12 +14,12 @@ export enum Variant {
14
14
 
15
15
  export type DateTimeButtonProps = {
16
16
  date: DateTime;
17
- isSelected?: boolean;
18
- isDisabled?: boolean;
17
+ isSelected: boolean;
18
+ isDisabled: boolean;
19
19
  isSoldOut?: boolean;
20
20
  onSelect: (date: DateTime) => void;
21
21
  price?: string | number | ReactElement | null;
22
- resources: ZoneResourcesAvailability | null | undefined;
22
+ resources?: ZoneResourcesAvailability | null;
23
23
  showResources?: boolean;
24
24
  shouldCalculateResources?: boolean;
25
25
  variant: Variant;
@@ -1,9 +1,8 @@
1
- import React, { useMemo, useState, useRef, useEffect } from "react";
2
- import { DateTime, Interval } from "luxon";
1
+ import React, { useState, useRef, useEffect } from "react";
2
+ import { DateTime } from "luxon";
3
3
  import { Col, Form } from "react-bootstrap";
4
- import { Controller, RegisterOptions, useFormContext } from "react-hook-form";
4
+ import { Controller, useFormContext, useWatch } from "react-hook-form";
5
5
  import { useTranslation } from "react-i18next";
6
- import { useIntl } from "react-intl";
7
6
 
8
7
  import { useId } from "@react-aria/utils";
9
8
  import { ProductSet } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
@@ -11,6 +10,7 @@ import HTMLInputDateElement from "../../types/static/HTMLInputDateElement";
11
10
  import { RecurrenceInput } from "../../recurrence-input";
12
11
  import { WarningMessage } from "../../static";
13
12
  import { ProductSetFormValues } from "../../product-set/form";
13
+ import { useFormattedDuration, useValidationOptions } from "./hooks";
14
14
 
15
15
  interface IntervalInputProps {
16
16
  editedProductSet?: ProductSetFormValues;
@@ -35,7 +35,6 @@ export function IntervalInput({
35
35
  const {
36
36
  register,
37
37
  formState: { errors },
38
- watch,
39
38
  control,
40
39
  trigger,
41
40
  setValue,
@@ -44,9 +43,9 @@ export function IntervalInput({
44
43
  const formattedDuration = useFormattedDuration();
45
44
  const validationOptions = useValidationOptions();
46
45
 
47
- const rrule = watch("rrule");
48
- const start = watch("start");
49
- const end = watch("end");
46
+ const rrule = useWatch({ control, name: "rrule" });
47
+ const start = useWatch({ control, name: "start" });
48
+ const end = useWatch({ control, name: "end" });
50
49
  const [recurrent, setRecurrent] = useState(Boolean(rrule));
51
50
  const [isOverriden, setIsOverriden] = useState(false);
52
51
  const recurrentId = useId();
@@ -123,6 +122,7 @@ export function IntervalInput({
123
122
  onChangeEndDate(nextEndtDate)
124
123
  }
125
124
  min={start}
125
+ required
126
126
  isInvalid={Boolean(errors.end)}
127
127
  onClick={() => endDateInput?.current?.showPicker()}
128
128
  ref={endDateInput}
@@ -180,75 +180,3 @@ export function IntervalInput({
180
180
  </>
181
181
  );
182
182
  }
183
-
184
- const useFormattedDuration = () => {
185
- const { watch } = useFormContext<IntervalInputValues>();
186
- const start = watch("start");
187
- const end = watch("end");
188
- const { formatList, formatNumber } = useIntl();
189
-
190
- return useMemo(() => {
191
- const interval = Interval.fromDateTimes(
192
- DateTime.fromISO(start),
193
- DateTime.fromISO(end)
194
- ).toDuration(["days", "hours", "minutes"]);
195
-
196
- if (!interval.isValid) return undefined;
197
-
198
- const formatUnit = (value: number, unit: string) =>
199
- formatNumber(value, { style: "unit", unit, unitDisplay: "long" });
200
-
201
- const units = (
202
- [
203
- [interval.days, "day"],
204
- [interval.hours, "hour"],
205
- [interval.minutes, "minute"],
206
- ] as Parameters<typeof formatUnit>[]
207
- ).filter(([value]) => value);
208
-
209
- return formatList(
210
- units.map((args) => formatUnit(...args)),
211
- { style: "long", type: "unit" }
212
- );
213
- // eslint-disable-next-line react-hooks/exhaustive-deps
214
- }, [start, end]);
215
- };
216
-
217
- const useValidationOptions = () => {
218
- const { watch } = useFormContext();
219
- const { t } = useTranslation(["Design", "Validation"]);
220
- const start = watch("start");
221
- const end = watch("end");
222
-
223
- return {
224
- start: useMemo<RegisterOptions>(
225
- () => ({
226
- required: t("Validation:fieldRequired", {
227
- attribute: t("start"),
228
- }) as string,
229
- // TODO: uncomment when event splitting is implemented
230
- // and extract into plugins
231
- validate: (value) =>
232
- DateTime.fromISO(value).diffNow().toMillis() > 0 ||
233
- (t("Validation:fieldValidEventStart") as string),
234
- }),
235
- // eslint-disable-next-line react-hooks/exhaustive-deps
236
- []
237
- ),
238
-
239
- end: useMemo<RegisterOptions>(
240
- () => ({
241
- // TODO: uncomment when event splitting is implemented
242
- // and extract into plugins
243
- validate: (value) =>
244
- // endAt not required
245
- value
246
- ? DateTime.fromISO(value).diff(DateTime.fromISO(start)).toMillis() >
247
- 0 || (t("Validation:fieldValidEventEnd") as string)
248
- : true,
249
- }),
250
- // eslint-disable-next-line react-hooks/exhaustive-deps
251
- [start, end]
252
- ),
253
- };
254
- };
@@ -0,0 +1,2 @@
1
+ export * from "./useFormattedDuration";
2
+ export * from "./useValidationOptions";
@@ -0,0 +1,40 @@
1
+ import { useMemo } from "react";
2
+ import { useFormContext, useWatch } from "react-hook-form";
3
+ import { useIntl } from "react-intl";
4
+ import { DateTime, Interval } from "luxon";
5
+ import { IntervalInputValues } from "../IntervalInput";
6
+
7
+ export const useFormattedDuration = () => {
8
+ const { control } = useFormContext<IntervalInputValues>();
9
+ const start = useWatch({ control, name: "start" });
10
+ const end = useWatch({ control, name: "end" });
11
+ const { formatList, formatNumber } = useIntl();
12
+
13
+ const duration = useMemo(() => {
14
+ const interval = Interval.fromDateTimes(
15
+ DateTime.fromISO(start),
16
+ DateTime.fromISO(end)
17
+ ).toDuration(["days", "hours", "minutes"]);
18
+
19
+ if (!interval.isValid) return undefined;
20
+
21
+ const formatUnit = (value: number, unit: string) =>
22
+ formatNumber(value, { style: "unit", unit, unitDisplay: "long" });
23
+
24
+ const units = (
25
+ [
26
+ [interval.days, "day"],
27
+ [interval.hours, "hour"],
28
+ [interval.minutes, "minute"],
29
+ ] as Parameters<typeof formatUnit>[]
30
+ ).filter(([value]) => value);
31
+
32
+ return formatList(
33
+ units.map((args) => formatUnit(...args)),
34
+ { style: "long", type: "unit" }
35
+ );
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, [start, end]);
38
+
39
+ return duration;
40
+ };
@@ -0,0 +1,36 @@
1
+ import { DateTime } from "luxon";
2
+ import { useFormContext, useWatch } from "react-hook-form";
3
+ import { useTranslation } from "react-i18next";
4
+
5
+ export const useValidationOptions = () => {
6
+ const { control } = useFormContext();
7
+ const { t } = useTranslation(["Design", "Validation"]);
8
+ const start = useWatch({ control, name: "start" });
9
+
10
+ return {
11
+ start: {
12
+ required: t("Validation:fieldRequired", {
13
+ attribute: t("start"),
14
+ }) as string,
15
+ // TODO: uncomment when event splitting is implemented
16
+ // and extract into plugins
17
+ validate: (value) =>
18
+ DateTime.fromISO(value).diffNow().toMillis() > 0 ||
19
+ (t("Validation:fieldValidEventStart") as string),
20
+ },
21
+
22
+ end: {
23
+ required: t("Validation:fieldRequired", {
24
+ attribute: t("end"),
25
+ }) as string,
26
+ // TODO: uncomment when event splitting is implemented
27
+ // and extract into plugins
28
+ validate: (value) =>
29
+ // endAt not required
30
+ value
31
+ ? DateTime.fromISO(value).diff(DateTime.fromISO(start)).toMillis() >
32
+ 0 || (t("Validation:fieldValidEventEnd") as string)
33
+ : true,
34
+ },
35
+ };
36
+ };
@@ -28,6 +28,7 @@ interface IframeEventCardProps {
28
28
  shortDate: string;
29
29
  titleId?: string;
30
30
  descriptionId?: string;
31
+ imageClassName?: string;
31
32
  }
32
33
 
33
34
  export function IframeEventCard({
@@ -44,6 +45,7 @@ export function IframeEventCard({
44
45
  shortDate,
45
46
  titleId,
46
47
  descriptionId,
48
+ imageClassName,
47
49
  }: IframeEventCardProps) {
48
50
  const { formatNumber } = useIntl();
49
51
  const { t } = useTranslation("Design");
@@ -70,7 +72,7 @@ export function IframeEventCard({
70
72
  >
71
73
  {imageSrc && (
72
74
  <Card.Img
73
- className="card-image"
75
+ className={imageClassName ?? "card-image"}
74
76
  variant="top"
75
77
  as="div"
76
78
  style={{ backgroundImage: `url("${imageSrc}")` }}
@@ -20,6 +20,7 @@ export const BookingSummary = ({
20
20
  productsWithErrors = [],
21
21
  isLoading,
22
22
  hasPeopleInput,
23
+ isPaymentLink,
23
24
  peopleAmount,
24
25
  }: Omit<BookingSummaryProps, "totallWithDiscount">) => {
25
26
  const { t } = useTranslation("Design");
@@ -49,6 +50,7 @@ export const BookingSummary = ({
49
50
  <div className="products-by-menu-step">
50
51
  {menuSteps.map((menuStep) => (
51
52
  <ProductsByMenuStep
53
+ isPaymentLink={isPaymentLink}
52
54
  key={menuStep.id}
53
55
  orderItems={formValues}
54
56
  step={menuStep}
@@ -8,21 +8,27 @@ type ProductSummaryProps = {
8
8
  name?: string;
9
9
  productQuantityError?: string;
10
10
  orderProduct: OrderItem;
11
+ isPaymentLink?: boolean;
11
12
  };
12
13
 
13
14
  export const ProductSummary = ({
14
15
  name,
15
16
  productQuantityError,
16
17
  orderProduct,
18
+ isPaymentLink,
17
19
  }: ProductSummaryProps) => {
18
20
  const { t } = useTranslation("Design");
19
21
  const { formatNumber } = useIntl();
20
22
 
21
- const price = formatNumber(
22
- (orderProduct?.deposit || orderProduct?.price || 0) *
23
- orderProduct?.quantity,
24
- { style: "currency", currency: Config.Currency.GBP }
25
- );
23
+ const priceForOneProduct =
24
+ !isPaymentLink && orderProduct?.hasDeposit
25
+ ? orderProduct?.deposit
26
+ : orderProduct?.price;
27
+
28
+ const fullPrice = formatNumber(priceForOneProduct * orderProduct?.quantity, {
29
+ style: "currency",
30
+ currency: Config.Currency.GBP,
31
+ });
26
32
 
27
33
  return (
28
34
  <div className="product">
@@ -32,7 +38,7 @@ export const ProductSummary = ({
32
38
  {t("shortQuantity")}:&nbsp;{orderProduct?.quantity}
33
39
  </p>
34
40
 
35
- <p className="price">{price}</p>
41
+ <p className="price">{fullPrice}</p>
36
42
  </div>
37
43
 
38
44
  {productQuantityError && (
@@ -29,12 +29,14 @@ export type ProductsByMenuStepsProps = {
29
29
  orderItems: OrderItems;
30
30
  step: MenuStep;
31
31
  productsWithErrors?: QuantityCheckProductInfo[];
32
+ isPaymentLink?: boolean;
32
33
  };
33
34
 
34
35
  export const ProductsByMenuStep = ({
35
36
  orderItems,
36
37
  step,
37
38
  productsWithErrors = [],
39
+ isPaymentLink,
38
40
  }: ProductsByMenuStepsProps) => {
39
41
  const { productCategories } = step;
40
42
 
@@ -62,6 +64,7 @@ export const ProductsByMenuStep = ({
62
64
 
63
65
  return (
64
66
  <ProductSummary
67
+ isPaymentLink={isPaymentLink}
65
68
  key={orderItem.id}
66
69
  name={orderItem.name}
67
70
  productQuantityError={productQuantityError}
@@ -19,4 +19,5 @@ export type BookingSummaryProps = {
19
19
  productsWithErrors?: QuantityCheckProductInfo[];
20
20
  isLoading?: boolean;
21
21
  peopleAmount: number;
22
+ isPaymentLink?: boolean;
22
23
  };
@@ -7,10 +7,8 @@ export const cartSumByOrderProducts = (orderProducts?: OrderItem[]) => {
7
7
  }
8
8
  return orderProducts.reduce((prevSumValue: number, product) => {
9
9
  if (!product) return 0;
10
-
11
- return (
12
- prevSumValue + (product?.deposit || product?.price) * product.quantity
13
- );
10
+ const price = product?.hasDeposit ? product?.deposit : product?.price;
11
+ return prevSumValue + price * product.quantity;
14
12
  }, 0);
15
13
  };
16
14