@licklist/design 0.51.3 → 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 (147) hide show
  1. package/dist/assets/dashboard/addImage.svg.js +1 -1
  2. package/dist/assets/dashboard/chartBar.svg.js +1 -1
  3. package/dist/assets/dashboard/genderFemale.svg.js +1 -1
  4. package/dist/assets/dashboard/genderMale.svg.js +1 -1
  5. package/dist/assets/dashboard/increment.svg.js +1 -1
  6. package/dist/assets/dashboard/info.svg.js +1 -1
  7. package/dist/assets/dashboard/managerRole.svg.js +1 -1
  8. package/dist/assets/dashboard/subManagerRole.svg.js +1 -1
  9. package/dist/assets/dashboard/viewerRole.svg.js +1 -1
  10. package/dist/assets/dashboard/visitedProviderLink.svg.js +1 -1
  11. package/dist/assets/dashboard/warning.svg.js +1 -1
  12. package/dist/assets/editor/bold.svg.js +1 -1
  13. package/dist/assets/editor/double-quotes-l.svg.js +1 -1
  14. package/dist/assets/editor/format-clear.svg.js +1 -1
  15. package/dist/assets/editor/h1.svg.js +1 -1
  16. package/dist/assets/editor/h2.svg.js +1 -1
  17. package/dist/assets/editor/italic.svg.js +1 -1
  18. package/dist/assets/editor/paragraph.svg.js +1 -1
  19. package/dist/assets/editor/separator.svg.js +1 -1
  20. package/dist/assets/editor/strikethrough.svg.js +1 -1
  21. package/dist/assets/editor/text-wrap.svg.js +1 -1
  22. package/dist/assets/iframe/available.svg.js +1 -1
  23. package/dist/assets/iframe/calendar.svg.js +1 -1
  24. package/dist/assets/iframe/clock.svg.js +1 -1
  25. package/dist/assets/iframe/close.svg.js +1 -1
  26. package/dist/assets/iframe/limited.svg.js +1 -1
  27. package/dist/assets/iframe/selectArrow.svg.js +1 -1
  28. package/dist/assets/iframe/soldOut.svg.js +1 -1
  29. package/dist/assets/iframe/success.svg.js +1 -1
  30. package/dist/assets/iframe/ticket.svg.js +1 -1
  31. package/dist/assets/logo/bookedit.svg.js +1 -1
  32. package/dist/assets/logo/licklist.sm.svg.js +1 -1
  33. package/dist/assets/logo/licklist.svg.js +1 -1
  34. package/dist/calendar/Calendar.d.ts +3 -8
  35. package/dist/calendar/Calendar.d.ts.map +1 -1
  36. package/dist/calendar/Calendar.js +1 -1
  37. package/dist/calendar/components/CalendarButtons/CalendarButtons.d.ts +2 -2
  38. package/dist/calendar/components/CalendarButtons/CalendarButtons.d.ts.map +1 -1
  39. package/dist/calendar/components/CalendarButtons/CalendarButtons.js +1 -1
  40. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts +2 -2
  41. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts.map +1 -1
  42. package/dist/calendar/components/CalendarDates/CalendarDates.js +1 -1
  43. package/dist/calendar/utils/index.d.ts +0 -2
  44. package/dist/calendar/utils/index.d.ts.map +1 -1
  45. package/dist/calendar/utils/index.js +1 -1
  46. package/dist/date-time-button/DateTimeButton.d.ts +3 -3
  47. package/dist/date-time-button/DateTimeButton.d.ts.map +1 -1
  48. package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
  49. package/dist/events/edit-event-modal/IntervalInput.js +1 -1
  50. package/dist/events/edit-event-modal/hooks/index.d.ts +3 -0
  51. package/dist/events/edit-event-modal/hooks/index.d.ts.map +1 -0
  52. package/dist/events/edit-event-modal/hooks/useFormattedDuration.d.ts +2 -0
  53. package/dist/events/edit-event-modal/hooks/useFormattedDuration.d.ts.map +1 -0
  54. package/dist/events/edit-event-modal/hooks/useFormattedDuration.js +1 -0
  55. package/dist/events/edit-event-modal/hooks/useValidationOptions.d.ts +11 -0
  56. package/dist/events/edit-event-modal/hooks/useValidationOptions.d.ts.map +1 -0
  57. package/dist/events/edit-event-modal/hooks/useValidationOptions.js +1 -0
  58. package/dist/events/event-card/EventCard.d.ts +2 -1
  59. package/dist/events/event-card/EventCard.d.ts.map +1 -1
  60. package/dist/events/event-card/EventCard.js +1 -1
  61. package/dist/events/event-venue-map/components/Scrollbars/Scrollbars.js +1 -1
  62. package/dist/iframe/event/event-card/IframeEventCard.d.ts +2 -1
  63. package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
  64. package/dist/iframe/event/event-card/IframeEventCard.js +1 -1
  65. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +1 -1
  66. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  67. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
  68. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts +2 -1
  69. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts.map +1 -1
  70. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.js +1 -1
  71. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts +2 -1
  72. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts.map +1 -1
  73. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.js +1 -1
  74. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.js +1 -1
  75. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +1 -0
  76. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  77. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts.map +1 -1
  78. package/dist/iframe/order-process/components/BookingSummary/utils/index.js +1 -1
  79. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  80. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.js +1 -1
  81. package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +1 -1
  82. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts +2 -1
  83. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
  84. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +1 -1
  85. package/dist/index.js +1 -1
  86. package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
  87. package/dist/notification/email-template/control/EmailTemplateControl.js +1 -1
  88. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  89. package/dist/sales/booking/results/components/ResultCard.js +1 -1
  90. package/dist/sales/manual-booking/summary/ManualBookingSummary.d.ts +2 -1
  91. package/dist/sales/manual-booking/summary/ManualBookingSummary.d.ts.map +1 -1
  92. package/dist/sales/manual-booking/summary/ManualBookingSummary.js +1 -1
  93. package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
  94. package/dist/snippet/snippet-template/preview/Preview.js +1 -1
  95. package/dist/static/date-range-input/DateRangeInput.d.ts.map +1 -1
  96. package/dist/static/date-range-input/DateRangeInput.js +1 -1
  97. package/dist/styles/affiliate/AffiliateCard.scss +26 -6
  98. package/dist/styles/events/EventCard.scss +3 -6
  99. package/dist/styles/resources-blocking/_index.scss +6 -0
  100. package/dist/styles/sales/BookingFilter.scss +18 -0
  101. package/dist/styles/sales/BookingResults.scss +1 -1
  102. package/dist/styles/sales/BookingTabs.scss +63 -5
  103. package/dist/styles/sales/LifeTimeSales.scss +1 -0
  104. package/dist/styles/sales/ManualBooking.scss +62 -3
  105. package/dist/styles/sales/SourceOfSales.scss +3 -0
  106. package/dist/styles/snippet-templates/SnippetTemplateCard.scss +3 -2
  107. package/dist/styles/static/Tabs.scss +6 -0
  108. package/dist/styles/themes/bookedit/_index.scss +9 -8
  109. package/package.json +3 -3
  110. package/src/calendar/Calendar.tsx +9 -16
  111. package/src/calendar/components/CalendarButtons/CalendarButtons.tsx +8 -5
  112. package/src/calendar/components/CalendarDates/CalendarDates.tsx +12 -13
  113. package/src/calendar/utils/index.ts +0 -19
  114. package/src/date-time-button/DateTimeButton.tsx +3 -3
  115. package/src/events/edit-event-modal/IntervalInput.tsx +8 -80
  116. package/src/events/edit-event-modal/hooks/index.ts +2 -0
  117. package/src/events/edit-event-modal/hooks/useFormattedDuration.tsx +40 -0
  118. package/src/events/edit-event-modal/hooks/useValidationOptions.tsx +36 -0
  119. package/src/events/event-card/EventCard.stories.tsx +1 -0
  120. package/src/events/event-card/EventCard.tsx +27 -2
  121. package/src/iframe/event/event-card/IframeEventCard.tsx +3 -1
  122. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +2 -0
  123. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.tsx +12 -6
  124. package/src/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.tsx +3 -0
  125. package/src/iframe/order-process/components/BookingSummary/types/index.ts +1 -0
  126. package/src/iframe/order-process/components/BookingSummary/utils/index.ts +2 -4
  127. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +13 -23
  128. package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +1 -1
  129. package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +9 -3
  130. package/src/notification/email-template/control/EmailTemplateControl.tsx +5 -15
  131. package/src/sales/booking/results/components/ResultCard.tsx +6 -4
  132. package/src/sales/manual-booking/summary/ManualBookingSummary.tsx +9 -1
  133. package/src/snippet/snippet-template/preview/Preview.tsx +3 -0
  134. package/src/static/date-range-input/DateRangeInput.tsx +23 -2
  135. package/src/static/switch/BooleanSwitch.tsx +1 -1
  136. package/src/styles/affiliate/AffiliateCard.scss +26 -6
  137. package/src/styles/events/EventCard.scss +3 -6
  138. package/src/styles/resources-blocking/_index.scss +6 -0
  139. package/src/styles/sales/BookingFilter.scss +18 -0
  140. package/src/styles/sales/BookingResults.scss +1 -1
  141. package/src/styles/sales/BookingTabs.scss +63 -5
  142. package/src/styles/sales/LifeTimeSales.scss +1 -0
  143. package/src/styles/sales/ManualBooking.scss +62 -3
  144. package/src/styles/sales/SourceOfSales.scss +3 -0
  145. package/src/styles/snippet-templates/SnippetTemplateCard.scss +3 -2
  146. package/src/styles/static/Tabs.scss +6 -0
  147. package/src/styles/themes/bookedit/_index.scss +9 -8
@@ -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
+ };
@@ -33,6 +33,7 @@ export const Default: Story<EventCardProps> = () => {
33
33
  RuPaul's Drag Race UK to VINYL Cambridge! So get excited because
34
34
  the...`}
35
35
  date="2023-08-31T09:35:00.000+03:00"
36
+ productSetName="New product set"
36
37
  imageUrl={showImage ? `https://source.unsplash.com/random` : null}
37
38
  hasPermission={hasPermission}
38
39
  onPreview={() => undefined}
@@ -1,5 +1,11 @@
1
1
  import React, { useMemo } from "react";
2
- import { Badge, Card, ProgressBar } from "react-bootstrap";
2
+ import {
3
+ Badge,
4
+ Card,
5
+ OverlayTrigger,
6
+ Popover,
7
+ ProgressBar,
8
+ } from "react-bootstrap";
3
9
  import { useIntl } from "react-intl";
4
10
  import clsx from "clsx";
5
11
  import { useTranslation } from "react-i18next";
@@ -30,6 +36,7 @@ export interface EventCardProps extends HasPermissionProp {
30
36
  onStatistic: () => void;
31
37
  titleId?: string;
32
38
  descriptionId?: string;
39
+ productSetName?: string;
33
40
  }
34
41
 
35
42
  export function EventCard({
@@ -43,6 +50,7 @@ export function EventCard({
43
50
  onCopy,
44
51
  onRemove,
45
52
  hasPermission = true,
53
+ productSetName,
46
54
  onStatistic,
47
55
  eventStatistic,
48
56
  titleId,
@@ -123,7 +131,24 @@ export function EventCard({
123
131
  ))}
124
132
  </div>
125
133
  </Card.Body>
126
- <Card.Footer>
134
+ <Card.Footer className="flex-column">
135
+ {productSetName && (
136
+ <OverlayTrigger
137
+ // Workaround for bootstrap error with "hover trigger"
138
+ trigger={["hover", "hover"]}
139
+ overlay={
140
+ <Popover id="event-product-set-popover">
141
+ <Popover.Content className="event-product-set-card">
142
+ {productSetName}
143
+ </Popover.Content>
144
+ </Popover>
145
+ }
146
+ >
147
+ <div className="pl-3 text-truncate">
148
+ {t("Design:productSet")}: {productSetName}
149
+ </div>
150
+ </OverlayTrigger>
151
+ )}
127
152
  <div className="d-flex w-100 justify-content-between">
128
153
  <div className="d-flex">
129
154
  <button
@@ -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
 
@@ -42,18 +42,6 @@ export const CategoryProduct = ({
42
42
  return error?.message;
43
43
  }, [productsWithErrors, product.id]);
44
44
 
45
- const deposit = useMemo(() => {
46
- if (
47
- !category.allowDeposits ||
48
- !product.deposit ||
49
- product?.isSoldOut ||
50
- product.deposit >= product.price
51
- ) {
52
- return undefined;
53
- }
54
- return product.deposit;
55
- }, [category, product]);
56
-
57
45
  const checkIfSoldOutProduct = () => {
58
46
  if (!soldOutProducts || product?.isSoldOut) {
59
47
  return undefined;
@@ -146,10 +134,13 @@ export const CategoryProduct = ({
146
134
  </div>
147
135
  <div className="iframe-event__product-price-wrapper">
148
136
  <span className="product-price">
149
- {formatNumber(deposit ?? product.price, {
150
- style: "currency",
151
- currency: Config.Currency.GBP,
152
- })}
137
+ {formatNumber(
138
+ category.allowDeposits ? product?.deposit : product.price,
139
+ {
140
+ style: "currency",
141
+ currency: Config.Currency.GBP,
142
+ }
143
+ )}
153
144
  </span>
154
145
  <ProductQuantityInput
155
146
  onChange={onChange}
@@ -162,17 +153,16 @@ export const CategoryProduct = ({
162
153
  }}
163
154
  category={category}
164
155
  invalid={invalid}
165
- deposit={deposit}
166
156
  />
167
157
  </div>
168
- {deposit && !category?.remainderExpireAfter && (
158
+ {category.allowDeposits && !category?.remainderExpireAfter && (
169
159
  <div className="mt-4">
170
160
  {t("Design:payNowAndUponArrival", {
171
- deposit: formatNumber(deposit, {
161
+ deposit: formatNumber(product?.deposit, {
172
162
  style: "currency",
173
163
  currency: Config.Currency.GBP,
174
164
  }),
175
- remainder: formatNumber(product.price - deposit, {
165
+ remainder: formatNumber(product.price - product?.deposit, {
176
166
  style: "currency",
177
167
  currency: Config.Currency.GBP,
178
168
  }),
@@ -180,14 +170,14 @@ export const CategoryProduct = ({
180
170
  </div>
181
171
  )}
182
172
 
183
- {deposit && category?.remainderExpireAfter > 0 && (
173
+ {category.allowDeposits && category?.remainderExpireAfter > 0 && (
184
174
  <div className="mt-4">
185
175
  {t("Design:payNowAndReminderDays", {
186
- deposit: formatNumber(deposit, {
176
+ deposit: formatNumber(product?.deposit, {
187
177
  style: "currency",
188
178
  currency: Config.Currency.GBP,
189
179
  }),
190
- remainder: formatNumber(product.price - deposit, {
180
+ remainder: formatNumber(product.price - product?.deposit, {
191
181
  style: "currency",
192
182
  currency: Config.Currency.GBP,
193
183
  }),
@@ -32,7 +32,7 @@ export const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
32
32
  ref
33
33
  ) => {
34
34
  const handleArrowUpClick = () => {
35
- if (max !== undefined && value < max) {
35
+ if (max !== undefined && (value || 0) < max) {
36
36
  onArrowUp(value + 1);
37
37
  }
38
38
  if (max === undefined) {
@@ -15,6 +15,7 @@ interface FormOrderItem {
15
15
  name: string;
16
16
  price: number;
17
17
  productCategoryId: number;
18
+ hasDeposit?: boolean;
18
19
  zoneId?: Zone["id"];
19
20
  deposit?: number | null;
20
21
  quantity: number;
@@ -40,19 +41,23 @@ export const ProductQuantityInput = ({
40
41
  refCallback,
41
42
  productInfo,
42
43
  invalid,
43
- deposit,
44
44
  }: ProductQuantityInputProps) => {
45
45
  const { t } = useTranslation("Design");
46
46
 
47
47
  const onChange = (quantity: number | null) => {
48
+ let productQuantity = quantity;
49
+ if (product?.maxAmount && quantity > product?.maxAmount) {
50
+ productQuantity = product?.maxAmount;
51
+ }
48
52
  _onChange({
49
53
  id: product.id,
50
54
  name: product.name,
51
- deposit,
55
+ deposit: product?.deposit,
56
+ hasDeposit: category.allowDeposits,
52
57
  price: product.price,
53
58
  productCategoryId: category.id,
54
59
  zoneId: category.zone?.id,
55
- quantity,
60
+ quantity: productQuantity,
56
61
  capacity: product?.capacity,
57
62
  });
58
63
  };
@@ -99,6 +104,7 @@ export const ProductQuantityInput = ({
99
104
  clearErrors(`${product.id}` as const);
100
105
  }}
101
106
  min={0}
107
+ max={product?.maxAmount ? Number(product?.maxAmount) : undefined}
102
108
  placeholder="0"
103
109
  disabled={product.isSoldOut}
104
110
  value={productInfo?.quantity}