@licklist/design 0.44.551-dev.8 → 0.44.551

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 (138) hide show
  1. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts.map +1 -1
  2. package/dist/calendar/components/CalendarDates/CalendarDates.js +1 -1
  3. package/dist/date-time-button/DateContent.d.ts +2 -2
  4. package/dist/date-time-button/DateContent.d.ts.map +1 -1
  5. package/dist/date-time-button/DateContent.js +1 -1
  6. package/dist/date-time-button/DateTimeButton.d.ts +6 -10
  7. package/dist/date-time-button/DateTimeButton.d.ts.map +1 -1
  8. package/dist/date-time-button/DateTimeButton.js +1 -1
  9. package/dist/events/event-venue-map/components/MapPoint/MapPoint.d.ts +1 -1
  10. package/dist/events/event-venue-map/components/MapPoint/MapPoint.d.ts.map +1 -1
  11. package/dist/iframe/event/event-booking-products/EventBookingProducts.d.ts +2 -4
  12. package/dist/iframe/event/event-booking-products/EventBookingProducts.d.ts.map +1 -1
  13. package/dist/iframe/event/event-booking-products/components/AccordionItem/AccordionItem.d.ts +2 -4
  14. package/dist/iframe/event/event-booking-products/components/AccordionItem/AccordionItem.d.ts.map +1 -1
  15. package/dist/iframe/event/event-order-summary/EventOrderSummary.d.ts +1 -1
  16. package/dist/iframe/event/event-order-summary/EventOrderSummary.d.ts.map +1 -1
  17. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  18. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
  19. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts +3 -4
  20. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts.map +1 -1
  21. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.js +1 -1
  22. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +4 -3
  23. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  24. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts +2 -4
  25. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts.map +1 -1
  26. package/dist/iframe/order-process/components/BookingSummary/utils/index.js +1 -1
  27. package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts +1 -1
  28. package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts.map +1 -1
  29. package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts +1 -1
  30. package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts.map +1 -1
  31. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts +1 -1
  32. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  33. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts +1 -1
  34. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
  35. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts +2 -2
  36. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts.map +1 -1
  37. package/dist/iframe/payment/payment-page/PaymentPage.d.ts.map +1 -1
  38. package/dist/iframe/payment/payment-page/PaymentPage.js +1 -1
  39. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.d.ts +2 -2
  40. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.d.ts.map +1 -1
  41. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.js +1 -1
  42. package/dist/iframe/payment/payment-status-page/component/PaymentStatusBody.d.ts +2 -2
  43. package/dist/iframe/payment/payment-status-page/component/PaymentStatusBody.d.ts.map +1 -1
  44. package/dist/index.js +1 -1
  45. package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
  46. package/dist/report/index.d.ts +0 -3
  47. package/dist/report/index.d.ts.map +1 -1
  48. package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts +1 -4
  49. package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts.map +1 -1
  50. package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.js +1 -1
  51. package/dist/static/switch/BooleanSwitch.d.ts +1 -3
  52. package/dist/static/switch/BooleanSwitch.d.ts.map +1 -1
  53. package/dist/static/switch/BooleanSwitch.js +1 -1
  54. package/dist/styles/date-time-button/DateTimeButton.scss +4 -0
  55. package/dist/styles/iframe-order-process/IframeOrderProcess.scss +4 -6
  56. package/dist/styles/iframe-page/PageBody.scss +3 -3
  57. package/dist/styles/report/_index.scss +1 -3
  58. package/dist/styles/sales/BookingFilter.scss +1 -3
  59. package/dist/styles/sales/BookingResults.scss +1 -1
  60. package/dist/styles/sales/ManualBooking.scss +4 -1
  61. package/dist/styles/static/Switch.scss +0 -1
  62. package/dist/table/TableHelperComponent.d.ts +1 -2
  63. package/dist/table/TableHelperComponent.d.ts.map +1 -1
  64. package/dist/table/TableHelperComponent.js +1 -1
  65. package/dist/types/iframe.d.ts +50 -2
  66. package/dist/types/iframe.d.ts.map +1 -1
  67. package/package.json +3 -3
  68. package/src/calendar/components/CalendarDates/CalendarDates.tsx +4 -3
  69. package/src/date-time-button/DateContent.tsx +9 -27
  70. package/src/date-time-button/DateTimeButton.stories.tsx +14 -13
  71. package/src/date-time-button/DateTimeButton.tsx +26 -35
  72. package/src/events/event-venue-map/components/MapPoint/MapPoint.tsx +1 -1
  73. package/src/iframe/event/event-booking-products/EventBookingProducts.tsx +3 -4
  74. package/src/iframe/event/event-booking-products/components/AccordionItem/AccordionItem.tsx +4 -8
  75. package/src/iframe/event/event-order-summary/EventOrderSummary.tsx +2 -0
  76. package/src/iframe/order-process/components/BookingSummary/BookingSummary.stories.tsx +31 -46
  77. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +19 -12
  78. package/src/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.tsx +66 -48
  79. package/src/iframe/order-process/components/BookingSummary/types/index.ts +4 -3
  80. package/src/iframe/order-process/components/BookingSummary/utils/index.ts +2 -11
  81. package/src/iframe/order-process/components/CalendarStepsForm/components/Category.tsx +1 -1
  82. package/src/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.tsx +1 -4
  83. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +1 -4
  84. package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +1 -4
  85. package/src/iframe/order-process/components/utils/useCategoryVerification.ts +2 -3
  86. package/src/iframe/payment/payment-page/PaymentPage.tsx +6 -5
  87. package/src/iframe/payment/payment-status-page/PaymentStatusPage.tsx +26 -13
  88. package/src/iframe/payment/payment-status-page/component/PaymentStatusBody.tsx +2 -2
  89. package/src/product-set/control/DateAndRecurrenceInput.tsx +1 -2
  90. package/src/report/index.ts +0 -3
  91. package/src/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.tsx +5 -19
  92. package/src/static/switch/BooleanSwitch.tsx +2 -6
  93. package/src/styles/date-time-button/DateTimeButton.scss +4 -0
  94. package/src/styles/iframe-order-process/IframeOrderProcess.scss +4 -6
  95. package/src/styles/iframe-page/PageBody.scss +3 -3
  96. package/src/styles/report/_index.scss +1 -3
  97. package/src/styles/sales/BookingFilter.scss +1 -3
  98. package/src/styles/sales/BookingResults.scss +1 -1
  99. package/src/styles/sales/ManualBooking.scss +4 -1
  100. package/src/styles/static/Switch.scss +0 -1
  101. package/src/table/TableHelperComponent.tsx +3 -18
  102. package/src/types/iframe.ts +58 -2
  103. package/dist/assets/dashboard/info.svg +0 -8
  104. package/dist/assets/dashboard/info.svg.js +0 -1
  105. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts +0 -10
  106. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts.map +0 -1
  107. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.js +0 -1
  108. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/index.d.ts +0 -2
  109. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/index.d.ts.map +0 -1
  110. package/dist/report/DataFieldsSelector/DataFieldsSelector.d.ts +0 -13
  111. package/dist/report/DataFieldsSelector/DataFieldsSelector.d.ts.map +0 -1
  112. package/dist/report/DataFieldsSelector/DataFieldsSelector.js +0 -1
  113. package/dist/report/DataFieldsSelector/index.d.ts +0 -2
  114. package/dist/report/DataFieldsSelector/index.d.ts.map +0 -1
  115. package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts +0 -22
  116. package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts.map +0 -1
  117. package/dist/report/ReportRunnerModal/ReportRunnerModal.js +0 -1
  118. package/dist/report/ReportRunnerModal/index.d.ts +0 -2
  119. package/dist/report/ReportRunnerModal/index.d.ts.map +0 -1
  120. package/dist/report/ReportTypeSelect/ReportTypeSelect.d.ts +0 -3
  121. package/dist/report/ReportTypeSelect/ReportTypeSelect.d.ts.map +0 -1
  122. package/dist/report/ReportTypeSelect/ReportTypeSelect.js +0 -1
  123. package/dist/report/ReportTypeSelect/index.d.ts +0 -2
  124. package/dist/report/ReportTypeSelect/index.d.ts.map +0 -1
  125. package/dist/styles/report/ReportEditorModal.scss +0 -98
  126. package/dist/styles/report/ReportRunnerModal.scss +0 -95
  127. package/src/assets/dashboard/info.svg +0 -8
  128. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.tsx +0 -43
  129. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/index.ts +0 -1
  130. package/src/report/DataFieldsSelector/DataFieldsSelector.tsx +0 -112
  131. package/src/report/DataFieldsSelector/index.ts +0 -1
  132. package/src/report/ReportRunnerModal/ReportRunnerModal.tsx +0 -187
  133. package/src/report/ReportRunnerModal/index.ts +0 -1
  134. package/src/report/ReportTypeSelect/ReportTypeSelect.tsx +0 -68
  135. package/src/report/ReportTypeSelect/index.ts +0 -1
  136. package/src/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.stories.tsx +0 -48
  137. package/src/styles/report/ReportEditorModal.scss +0 -98
  138. package/src/styles/report/ReportRunnerModal.scss +0 -95
@@ -1,14 +1,14 @@
1
1
  import React from "react";
2
2
  import { Meta, Story } from "@storybook/react";
3
3
  import { DateTime } from "luxon";
4
- import { DateTimeButton, DateTimeButtonProps, Variant } from "./DateTimeButton";
4
+ import { DateTimeButton, DateTimeButtonProps } from "./DateTimeButton";
5
5
 
6
6
  export default {
7
7
  title: "DateTimeButton",
8
8
  component: DateTimeButton,
9
9
  } as Meta;
10
10
 
11
- const date = DateTime.now();
11
+ const date = DateTime.fromISO("2023-12-28T10:10:10.000Z");
12
12
 
13
13
  export const Default: Story<DateTimeButtonProps> = (args) => {
14
14
  return <DateTimeButton {...args} />;
@@ -48,23 +48,22 @@ export const Time: Story<DateTimeButtonProps> = (args) => {
48
48
  };
49
49
 
50
50
  Time.args = {
51
- date: DateTime.now().plus({ hours: 10 }),
51
+ date: "10:10",
52
52
  isSelected: false,
53
- isDisabled: false,
53
+ isDisabled: true,
54
54
  onSelect: () => null,
55
- variant: Variant.time,
56
55
  };
57
56
 
58
- export const Calendar: Story<DateTimeButtonProps> = (args) => {
57
+ export const OnlyTime: Story<DateTimeButtonProps> = (args) => {
59
58
  return <DateTimeButton {...args} />;
60
59
  };
61
60
 
62
- Calendar.args = {
63
- date: DateTime.now(),
61
+ OnlyTime.args = {
62
+ date: "10:10",
64
63
  isSelected: false,
65
- isDisabled: false,
64
+ isDisabled: true,
66
65
  onSelect: () => null,
67
- variant: Variant.month,
66
+ isOnlyTimeContainer: true,
68
67
  };
69
68
 
70
69
  export const WithPrice: Story<DateTimeButtonProps> = (args) => {
@@ -76,6 +75,7 @@ WithPrice.args = {
76
75
  isSelected: false,
77
76
  isDisabled: false,
78
77
  onSelect: () => null,
78
+ isOnlyTimeContainer: false,
79
79
  price: "from $8000",
80
80
  };
81
81
 
@@ -88,9 +88,10 @@ WithAvailability.args = {
88
88
  isSelected: false,
89
89
  isDisabled: false,
90
90
  onSelect: () => null,
91
- showResources: true,
91
+ isOnlyTimeContainer: false,
92
+ price: "from $8000",
92
93
  resources: {
93
- bookedResources: 1,
94
- totalResources: 3,
94
+ booked: 1,
95
+ total: 3,
95
96
  },
96
97
  };
@@ -5,44 +5,36 @@ import { ZoneResourcesAvailability } from "@licklist/core/dist/DataMapper/Order/
5
5
  import { AvailabilityIndicator } from "../availability-indicator";
6
6
  import { DateContent } from "./DateContent";
7
7
 
8
- export enum Variant {
9
- week = "week",
10
- month = "month",
11
- time = "time",
12
- }
13
-
14
- export type DateTimeButtonProps = {
15
- date: DateTime;
8
+ export type DateTimeButtonProps<T = DateTime | string> = {
9
+ date: T;
16
10
  isSelected?: boolean;
17
11
  isDisabled?: boolean;
18
12
  isSoldOut?: boolean;
19
- onSelect: (date: DateTime) => void;
13
+ onSelect: (date: T) => void;
14
+ isOnlyTimeContainer?: boolean;
20
15
  price?: string | number | ReactElement | null;
21
16
  resources?: ZoneResourcesAvailability | null;
17
+ calendarView?: boolean;
22
18
  showResources?: boolean;
23
- variant: Variant;
24
19
  };
25
20
 
26
- export const DateTimeButton = ({
21
+ export const DateTimeButton = <T extends DateTime | string>({
27
22
  date,
28
23
  isDisabled: _isDisabled,
29
24
  isSelected,
30
- isSoldOut: _isSoldOut,
25
+ isSoldOut,
31
26
  onSelect,
27
+ isOnlyTimeContainer,
32
28
  price,
33
29
  resources,
30
+ calendarView,
34
31
  showResources,
35
- variant = Variant.week,
36
- }: DateTimeButtonProps) => {
37
- const isSoldOut =
38
- _isSoldOut ||
39
- (resources && resources.bookedResources >= resources.totalResources);
40
-
41
- const isTimeVariant = variant === Variant.time;
42
-
43
- const isTimeInPast = isTimeVariant && isDateInPast(date);
32
+ }: DateTimeButtonProps<T>) => {
33
+ const isTimeVariant = typeof date === "string";
44
34
 
45
- const isDisabled = _isDisabled || isSoldOut || isTimeInPast;
35
+ const isDisabled =
36
+ _isDisabled ||
37
+ (resources && resources.bookedResources === resources.totalResources);
46
38
 
47
39
  return (
48
40
  <button
@@ -53,32 +45,31 @@ export const DateTimeButton = ({
53
45
  "date-time-button",
54
46
  isDisabled && "disabled",
55
47
  isSelected && "selected",
56
- // TODO refactor this
57
48
  isTimeVariant && "time-button",
58
- isTimeVariant && "only-time-container",
49
+ isOnlyTimeContainer && "only-time-container",
59
50
  !isTimeVariant && "today",
60
- variant === Variant.month && "calendar-view"
51
+ calendarView && "calendar-view"
61
52
  )}
62
53
  >
63
- <DateContent
64
- date={date}
65
- isDisabled={isDisabled}
66
- isSelected={isSelected}
67
- variant={variant}
68
- />
54
+ {isTimeVariant ? (
55
+ date
56
+ ) : (
57
+ <DateContent
58
+ date={date}
59
+ isDisabled={isDisabled}
60
+ isSelected={isSelected}
61
+ />
62
+ )}
69
63
 
70
64
  {price && !isDisabled && <div className="price">{price}</div>}
71
65
 
72
66
  {showResources && resources && (
73
67
  <AvailabilityIndicator
74
68
  resources={resources}
75
- isUnavailable={_isDisabled || isTimeInPast}
69
+ isUnavailable={_isDisabled}
76
70
  isSoldOut={isSoldOut}
77
71
  />
78
72
  )}
79
73
  </button>
80
74
  );
81
75
  };
82
-
83
- const isDateInPast = (date: DateTime): boolean =>
84
- date.toUTC() <= DateTime.now().toUTC();
@@ -3,7 +3,6 @@ import { Group } from "react-konva";
3
3
  import Konva from "konva";
4
4
  import { EventVenueMapContext } from "@licklist/plugins/dist/context/event/EventVenueMapContext";
5
5
  import { Point } from "@licklist/plugins/dist/types/context/event/point";
6
- import { Product } from "@licklist/plugins/dist/types/context/sale/menuSteps";
7
6
  import { ImageOffset } from "../../types";
8
7
  import { PointIcon } from "./components/PointIcon";
9
8
  import {
@@ -11,6 +10,7 @@ import {
11
10
  calculatePointsCoordinates,
12
11
  } from "../../utils";
13
12
  import { ProductIcon } from "./components/ProductIcon";
13
+ import { Product } from "../../../../types";
14
14
 
15
15
  type MapPointProps = Partial<Point> &
16
16
  ImageOffset & {
@@ -1,14 +1,13 @@
1
1
  import React from "react";
2
+
2
3
  import Accordion from "react-bootstrap/Accordion";
3
- import { OrderItems } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
4
- import { ProductCategory } from "@licklist/plugins/dist/types/context/sale/menuSteps";
5
- import { SetOrderFn } from "../../../types";
4
+ import { ProductCategory, Order, SetOrderFn } from "../../../types";
6
5
  import { AccordionItem } from "./components/AccordionItem";
7
6
 
8
7
  export interface EventBookingProductsProps {
9
8
  productsCategories?: ProductCategory[];
10
9
  setOrder: SetOrderFn;
11
- order: OrderItems;
10
+ order: Record<number, Order>;
12
11
  }
13
12
 
14
13
  export function EventBookingProducts({
@@ -1,18 +1,14 @@
1
1
  import React from "react";
2
2
  import clsx from "clsx";
3
3
  import { useIntl } from "react-intl";
4
+
4
5
  import Accordion from "react-bootstrap/Accordion";
5
6
  import Card from "react-bootstrap/Card";
6
7
  import { useAccordionToggle } from "react-bootstrap/AccordionToggle";
7
8
  import AccordionContext from "react-bootstrap/AccordionContext";
8
- import {
9
- OrderItem,
10
- OrderItems,
11
- } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
12
- import { Product } from "@licklist/plugins/dist/types/context/sale/menuSteps";
13
9
  import { NumberInput } from "../../../../../static";
14
10
  import Icon from "../../../../../static/Icon";
15
- import { SetOrderFn } from "../../../../../types";
11
+ import { Order, Product, SetOrderFn } from "../../../../../types";
16
12
 
17
13
  interface CustomToggleProps {
18
14
  eventKey: string;
@@ -23,7 +19,7 @@ interface AccordionItemProps {
23
19
  name: string;
24
20
  products: Product[];
25
21
  setOrder: SetOrderFn;
26
- order: Record<number, OrderItem>;
22
+ order: Record<number, Order>;
27
23
  productsCategoryId: number;
28
24
  }
29
25
 
@@ -90,7 +86,7 @@ interface ProductItemProps {
90
86
  name: string;
91
87
  price: number;
92
88
  description: string;
93
- order: OrderItems;
89
+ order: Record<number, Order>;
94
90
  setOrder: SetOrderFn;
95
91
  productsCategoryId: number;
96
92
  }
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
  import { useTranslation } from "react-i18next";
3
+
3
4
  import { StaticTable, StaticTableData } from "../../../table/StaticTable";
4
5
 
6
+ export { Order } from "../../../types";
5
7
  interface EventOrderSummaryProps {
6
8
  data: StaticTableData[];
7
9
  tableName?: string;
@@ -10,11 +10,11 @@ export default {
10
10
  const productCategories = [
11
11
  {
12
12
  id: 1,
13
- name: "cat 1",
13
+ name: "Early Bird General Admission",
14
14
  products: [
15
15
  {
16
- id: 11,
17
- name: "cat 1 prod 1",
16
+ id: 7,
17
+ name: "Beer",
18
18
  description: `Ticket <em>is</em> valid for students and non students.
19
19
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
20
20
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -23,8 +23,8 @@ const productCategories = [
23
23
  price: 1,
24
24
  },
25
25
  {
26
- id: 12,
27
- name: "cat 2 prod 2",
26
+ id: 8,
27
+ name: "Wine",
28
28
  description: `Ticket is valid for students and non students.
29
29
  You do not need <strong>student ID</strong> for this event but do require regular age ID e.g. driving licence or passport.
30
30
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -37,11 +37,11 @@ const productCategories = [
37
37
  },
38
38
  {
39
39
  id: 2,
40
- name: "cat 2",
40
+ name: "Nice",
41
41
  products: [
42
42
  {
43
- id: 21,
44
- name: "cat 2 prod 1",
43
+ id: 3,
44
+ name: "Beer",
45
45
  description: `Ticket is valid for students and non students.
46
46
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
47
47
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -50,8 +50,8 @@ const productCategories = [
50
50
  price: 1,
51
51
  },
52
52
  {
53
- id: 22,
54
- name: "cat 2 prod 2",
53
+ id: 5,
54
+ name: "Wine",
55
55
  description: `Ticket is valid for students and non students.
56
56
  You do not need <strong>student ID</strong> for this event but do require regular age ID e.g. driving licence or passport.
57
57
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -66,11 +66,11 @@ const productCategories = [
66
66
  const productCategories2 = [
67
67
  {
68
68
  id: 3,
69
- name: "cat 3",
69
+ name: "fine",
70
70
  products: [
71
71
  {
72
- id: 31,
73
- name: "cat 3 prod 1",
72
+ id: 9,
73
+ name: "Beer",
74
74
  description: `Ticket is valid for students and non students.
75
75
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
76
76
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -79,8 +79,8 @@ const productCategories2 = [
79
79
  price: 1,
80
80
  },
81
81
  {
82
- id: 32,
83
- name: "cat 3 prod 2",
82
+ id: 10,
83
+ name: "Wine",
84
84
  description: `Ticket is valid for students and non students.
85
85
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
86
86
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -90,15 +90,14 @@ const productCategories2 = [
90
90
  // isRequired: true,
91
91
  },
92
92
  ],
93
- zone: 1,
94
93
  },
95
94
  {
96
95
  id: 4,
97
- name: "cat 4",
96
+ name: "Twice",
98
97
  products: [
99
98
  {
100
- id: 41,
101
- name: "cat 4 prod 1",
99
+ id: 11,
100
+ name: "Beer",
102
101
  description: `Ticket is valid for students and non students.
103
102
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
104
103
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -107,8 +106,8 @@ const productCategories2 = [
107
106
  price: 1,
108
107
  },
109
108
  {
110
- id: 42,
111
- name: "cat 4 prod 1",
109
+ id: 12,
110
+ name: "Wine",
112
111
  description: `Ticket is valid for students and non students.
113
112
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
114
113
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -142,40 +141,26 @@ export function Default() {
142
141
  menuSteps={menuSteps as any}
143
142
  peopleAmount={5}
144
143
  formValues={{
145
- "11": {
146
- id: 11,
144
+ "3": {
145
+ id: 3,
147
146
  quantity: 1,
148
- name: "cat 1 prod 1",
147
+ name: "Beer",
149
148
  price: 0,
150
- productsCategoryId: 1,
149
+ productsCategoryId: 2,
151
150
  },
152
- "21": {
153
- id: 21,
151
+ "5": {
152
+ id: 5,
154
153
  quantity: 2,
155
- name: "cat 2 prod 1",
154
+ name: "Wine",
156
155
  price: 1,
157
156
  productsCategoryId: 2,
158
157
  },
159
- "31": {
160
- id: 31,
158
+ "7": {
159
+ id: 7,
161
160
  quantity: 4,
162
- name: "cat 3 prod 1",
161
+ name: "Beer",
163
162
  price: 1,
164
- productsCategoryId: 3,
165
- },
166
- "32": {
167
- id: 32,
168
- quantity: 4,
169
- name: "cat 3 prod 2",
170
- price: 1,
171
- productsCategoryId: 3,
172
- },
173
- "41": {
174
- id: 41,
175
- quantity: 4,
176
- name: "cat 4 prod 1",
177
- price: 1,
178
- productsCategoryId: 4,
163
+ productsCategoryId: 1,
179
164
  },
180
165
  }}
181
166
  totalWithDiscount={5}
@@ -1,9 +1,9 @@
1
- import React from "react";
1
+ import React, { useMemo } from "react";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import { useIntl } from "react-intl";
4
4
  import * as Config from "@licklist/core/dist/Config";
5
- import { values } from "lodash";
6
5
  import { LoaderIndicator } from "../../../../static";
6
+ import { MenuStep, Order } from "../../../../types";
7
7
  import { ProductsByMenuStep } from "./components/ProductsByMenuStep";
8
8
  import { BookingSummaryProps } from "./types";
9
9
  import { SummaryTotal } from "./components/SummaryTotal";
@@ -13,11 +13,11 @@ export const BookingSummary = ({
13
13
  date,
14
14
  time,
15
15
  menuSteps,
16
- formValues = {},
16
+ formValues,
17
17
  shouldHidePeopleAmount,
18
18
  eventName,
19
19
  transactionFee = 0,
20
- productsWithErrors = [],
20
+ productsWithErrors,
21
21
  isLoading,
22
22
  hasPeopleInput,
23
23
  peopleAmount,
@@ -25,6 +25,15 @@ export const BookingSummary = ({
25
25
  const { t } = useTranslation("Design");
26
26
  const { formatNumber } = useIntl();
27
27
 
28
+ const orderProducts = useMemo(() => {
29
+ if (!formValues) {
30
+ return undefined;
31
+ }
32
+ const products = Object.values(formValues).filter(Boolean) as Order[];
33
+
34
+ return products?.filter((prod) => prod?.quantity !== 0);
35
+ }, [formValues]);
36
+
28
37
  if (isLoading) {
29
38
  return (
30
39
  <div className="payment-booking-summary">
@@ -43,20 +52,19 @@ export const BookingSummary = ({
43
52
  </div>
44
53
  <hr />
45
54
 
46
- {values(formValues)?.length > 0 ? (
55
+ {orderProducts?.length > 0 ? (
47
56
  <div>
48
57
  <div className="cart-items">
49
- <div className="products-by-menu-step">
50
- {menuSteps.map((menuStep) => (
58
+ {menuSteps.map((menuStep: MenuStep) => {
59
+ return (
51
60
  <ProductsByMenuStep
52
61
  key={menuStep.id}
53
- orderItems={formValues}
62
+ orderProducts={orderProducts}
54
63
  step={menuStep}
55
64
  productsWithErrors={productsWithErrors}
56
65
  />
57
- ))}
58
- </div>
59
-
66
+ );
67
+ })}
60
68
  {!shouldHidePeopleAmount && peopleAmount > 0 && (
61
69
  <>
62
70
  <hr />
@@ -66,7 +74,6 @@ export const BookingSummary = ({
66
74
  </div>
67
75
  </>
68
76
  )}
69
-
70
77
  {!!transactionFee && (
71
78
  <>
72
79
  <hr />
@@ -1,72 +1,90 @@
1
- import React from "react";
1
+ import React, { useMemo } from "react";
2
+ import { useTranslation } from "react-i18next";
3
+ import { useIntl } from "react-intl";
4
+ import * as Config from "@licklist/core/dist/Config";
2
5
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
3
- import {
4
- OrderItem,
5
- OrderItems,
6
- } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
7
- import { MenuStep } from "@licklist/plugins/dist/types/context/sale/menuSteps";
8
- import { values } from "lodash";
9
- import { ProductSummary } from "../ProductSummary";
10
- import { getProductError } from "../../utils";
11
-
12
- const doesStepHaveItems = (orderItems: OrderItems, step: MenuStep): boolean => {
13
- const categoriesIds = step.productCategories.map((category) => category.id);
14
-
15
- const stepItems = values(orderItems).filter((item) =>
16
- categoriesIds.includes(item.productsCategoryId)
17
- );
18
-
19
- return stepItems.length > 0;
20
- };
21
-
22
- const getOrderItemsForCategory = (
23
- orderItems: OrderItems,
24
- categoryId: number
25
- ): OrderItem[] =>
26
- values(orderItems).filter((item) => item.productsCategoryId === categoryId);
6
+ import { Order, MenuStep } from "../../../../../../types";
27
7
 
28
8
  export type ProductsByMenuStepsProps = {
29
- orderItems: OrderItems;
9
+ orderProducts: Order[];
30
10
  step: MenuStep;
31
11
  productsWithErrors?: QuantityCheckProductInfo[];
32
12
  };
33
13
 
14
+ const getIdFromEntity = (entities: { id: number }[]) =>
15
+ entities.map(({ id }) => id);
16
+
34
17
  export const ProductsByMenuStep = ({
35
- orderItems,
18
+ orderProducts,
36
19
  step,
37
- productsWithErrors = [],
20
+ productsWithErrors,
38
21
  }: ProductsByMenuStepsProps) => {
22
+ const { t } = useTranslation("Design");
23
+ const { formatNumber } = useIntl();
39
24
  const { productCategories } = step;
40
25
 
41
- if (!doesStepHaveItems(orderItems, step)) return null;
26
+ const productsByCategories = useMemo(() => {
27
+ const productsInCategoriesIds = getIdFromEntity(productCategories);
28
+
29
+ return orderProducts.filter(({ productsCategoryId }) =>
30
+ productsInCategoriesIds.includes(productsCategoryId)
31
+ );
32
+ }, [productCategories, orderProducts]);
33
+
34
+ const productIds = getIdFromEntity(productsByCategories);
35
+
36
+ if (!productsByCategories.length) {
37
+ return null;
38
+ }
42
39
 
43
40
  return (
44
- <div className="categories">
45
- {productCategories.map((category) => {
46
- const categoryOrderItems = getOrderItemsForCategory(
47
- orderItems,
48
- category.id
41
+ <div className="products-by-menu-step">
42
+ {productCategories.map(({ name, id, products }) => {
43
+ const selectedProducts = products.filter(({ id: productId }) =>
44
+ productIds.includes(productId)
49
45
  );
50
46
 
51
- if (categoryOrderItems.length === 0) return null;
47
+ if (!selectedProducts.length) {
48
+ return null;
49
+ }
52
50
 
53
51
  return (
54
- <div key={category.id} className="products">
55
- <p className="m-0 title">{category.name}</p>
56
-
57
- {categoryOrderItems.map((orderItem) => {
58
- const productQuantityError = getProductError(
59
- productsWithErrors,
60
- orderItem.id
52
+ <div key={id} className="products">
53
+ <p className="m-0 title">{name}</p>
54
+ {selectedProducts.map(({ id, name }) => {
55
+ const orderProduct = productsByCategories.find(
56
+ ({ id: productId }) => productId === id
61
57
  );
62
58
 
59
+ const productQuantityError = (productsWithErrors ?? []).find(
60
+ (productWithError) =>
61
+ productWithError.product_id === orderProduct.id
62
+ )?.message;
63
+
63
64
  return (
64
- <ProductSummary
65
- key={orderItem.id}
66
- name={orderItem.name}
67
- productQuantityError={productQuantityError}
68
- orderProduct={orderItem}
69
- />
65
+ <div className="product" key={id}>
66
+ <p className="m-0 name">{name}</p>
67
+ <div className="d-flex justify-content-between">
68
+ <p className="m-0">
69
+ {t("shortQuantity")}:&nbsp;{orderProduct?.quantity}
70
+ </p>
71
+ <p className="price">
72
+ {formatNumber(
73
+ (orderProduct?.deposit || orderProduct?.price || 0) *
74
+ orderProduct?.quantity,
75
+ {
76
+ style: "currency",
77
+ currency: Config.Currency.GBP,
78
+ }
79
+ )}
80
+ </p>
81
+ </div>
82
+ {productQuantityError && (
83
+ <p className="iframe-event__message-error">
84
+ {productQuantityError}
85
+ </p>
86
+ )}
87
+ </div>
70
88
  );
71
89
  })}
72
90
  </div>
@@ -1,6 +1,5 @@
1
1
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
2
- import { OrderItems } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
3
- import { MenuStep } from "@licklist/plugins/dist/types/context/sale/menuSteps";
2
+ import { MenuStep, Order } from "../../../../../types";
4
3
 
5
4
  export const MOBILE_WIDTH = 576;
6
5
  export const ACCORDION_KEY = "booking-summary";
@@ -9,7 +8,9 @@ export type BookingSummaryProps = {
9
8
  date: string;
10
9
  time?: string;
11
10
  menuSteps?: MenuStep[];
12
- formValues?: OrderItems;
11
+ formValues?: {
12
+ [key: string]: Order;
13
+ };
13
14
  totalWithDiscount?: number;
14
15
  shouldHidePeopleAmount?: boolean;
15
16
  eventName?: string;
@@ -1,7 +1,6 @@
1
- import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
2
- import { OrderItem } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
1
+ import { Order } from "../../../../../types";
3
2
 
4
- export const cartSumByOrderProducts = (orderProducts?: OrderItem[]) => {
3
+ export const cartSumByOrderProducts = (orderProducts?: Order[]) => {
5
4
  if (!orderProducts || !orderProducts.length) {
6
5
  return 0;
7
6
  }
@@ -13,11 +12,3 @@ export const cartSumByOrderProducts = (orderProducts?: OrderItem[]) => {
13
12
  );
14
13
  }, 0);
15
14
  };
16
-
17
- export const getProductError = (
18
- productsWithErrors: QuantityCheckProductInfo[],
19
- productId: OrderItem["id"]
20
- ): string | undefined =>
21
- productsWithErrors.find(
22
- (productWithError) => productWithError.product_id === productId
23
- )?.message;