@licklist/design 0.44.551 → 0.45.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 (65) hide show
  1. package/dist/events/event-venue-map/components/MapPoint/MapPoint.d.ts +1 -1
  2. package/dist/events/event-venue-map/components/MapPoint/MapPoint.d.ts.map +1 -1
  3. package/dist/iframe/event/event-booking-products/EventBookingProducts.d.ts +4 -2
  4. package/dist/iframe/event/event-booking-products/EventBookingProducts.d.ts.map +1 -1
  5. package/dist/iframe/event/event-booking-products/components/AccordionItem/AccordionItem.d.ts +4 -2
  6. package/dist/iframe/event/event-booking-products/components/AccordionItem/AccordionItem.d.ts.map +1 -1
  7. package/dist/iframe/event/event-order-summary/EventOrderSummary.d.ts +1 -1
  8. package/dist/iframe/event/event-order-summary/EventOrderSummary.d.ts.map +1 -1
  9. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  10. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
  11. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts +10 -0
  12. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.d.ts.map +1 -0
  13. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.js +1 -0
  14. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/index.d.ts +2 -0
  15. package/dist/iframe/order-process/components/BookingSummary/components/ProductSummary/index.d.ts.map +1 -0
  16. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts +4 -3
  17. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts.map +1 -1
  18. package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.js +1 -1
  19. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +3 -4
  20. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  21. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts +4 -2
  22. package/dist/iframe/order-process/components/BookingSummary/utils/index.d.ts.map +1 -1
  23. package/dist/iframe/order-process/components/BookingSummary/utils/index.js +1 -1
  24. package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts +1 -1
  25. package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts.map +1 -1
  26. package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts +1 -1
  27. package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts.map +1 -1
  28. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts +1 -1
  29. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  30. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts +1 -1
  31. package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
  32. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts +2 -2
  33. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts.map +1 -1
  34. package/dist/iframe/payment/payment-page/PaymentPage.d.ts.map +1 -1
  35. package/dist/iframe/payment/payment-page/PaymentPage.js +1 -1
  36. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.d.ts +2 -2
  37. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.d.ts.map +1 -1
  38. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.js +1 -1
  39. package/dist/iframe/payment/payment-status-page/component/PaymentStatusBody.d.ts +2 -2
  40. package/dist/iframe/payment/payment-status-page/component/PaymentStatusBody.d.ts.map +1 -1
  41. package/dist/styles/iframe-order-process/IframeOrderProcess.scss +6 -4
  42. package/dist/types/iframe.d.ts +2 -50
  43. package/dist/types/iframe.d.ts.map +1 -1
  44. package/package.json +1 -1
  45. package/src/events/event-venue-map/components/MapPoint/MapPoint.tsx +1 -1
  46. package/src/iframe/event/event-booking-products/EventBookingProducts.tsx +4 -3
  47. package/src/iframe/event/event-booking-products/components/AccordionItem/AccordionItem.tsx +8 -4
  48. package/src/iframe/event/event-order-summary/EventOrderSummary.tsx +0 -2
  49. package/src/iframe/order-process/components/BookingSummary/BookingSummary.stories.tsx +46 -31
  50. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +12 -19
  51. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/ProductSummary.tsx +43 -0
  52. package/src/iframe/order-process/components/BookingSummary/components/ProductSummary/index.ts +1 -0
  53. package/src/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.tsx +48 -66
  54. package/src/iframe/order-process/components/BookingSummary/types/index.ts +3 -4
  55. package/src/iframe/order-process/components/BookingSummary/utils/index.ts +11 -2
  56. package/src/iframe/order-process/components/CalendarStepsForm/components/Category.tsx +1 -1
  57. package/src/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.tsx +4 -1
  58. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +4 -1
  59. package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +4 -1
  60. package/src/iframe/order-process/components/utils/useCategoryVerification.ts +3 -2
  61. package/src/iframe/payment/payment-page/PaymentPage.tsx +5 -6
  62. package/src/iframe/payment/payment-status-page/PaymentStatusPage.tsx +13 -26
  63. package/src/iframe/payment/payment-status-page/component/PaymentStatusBody.tsx +2 -2
  64. package/src/styles/iframe-order-process/IframeOrderProcess.scss +6 -4
  65. package/src/types/iframe.ts +2 -58
@@ -1,9 +1,7 @@
1
1
  import React from "react";
2
2
  import { useTranslation } from "react-i18next";
3
-
4
3
  import { StaticTable, StaticTableData } from "../../../table/StaticTable";
5
4
 
6
- export { Order } from "../../../types";
7
5
  interface EventOrderSummaryProps {
8
6
  data: StaticTableData[];
9
7
  tableName?: string;
@@ -10,11 +10,11 @@ export default {
10
10
  const productCategories = [
11
11
  {
12
12
  id: 1,
13
- name: "Early Bird General Admission",
13
+ name: "cat 1",
14
14
  products: [
15
15
  {
16
- id: 7,
17
- name: "Beer",
16
+ id: 11,
17
+ name: "cat 1 prod 1",
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: 8,
27
- name: "Wine",
26
+ id: 12,
27
+ name: "cat 2 prod 2",
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: "Nice",
40
+ name: "cat 2",
41
41
  products: [
42
42
  {
43
- id: 3,
44
- name: "Beer",
43
+ id: 21,
44
+ name: "cat 2 prod 1",
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: 5,
54
- name: "Wine",
53
+ id: 22,
54
+ name: "cat 2 prod 2",
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: "fine",
69
+ name: "cat 3",
70
70
  products: [
71
71
  {
72
- id: 9,
73
- name: "Beer",
72
+ id: 31,
73
+ name: "cat 3 prod 1",
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: 10,
83
- name: "Wine",
82
+ id: 32,
83
+ name: "cat 3 prod 2",
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,14 +90,15 @@ const productCategories2 = [
90
90
  // isRequired: true,
91
91
  },
92
92
  ],
93
+ zone: 1,
93
94
  },
94
95
  {
95
96
  id: 4,
96
- name: "Twice",
97
+ name: "cat 4",
97
98
  products: [
98
99
  {
99
- id: 11,
100
- name: "Beer",
100
+ id: 41,
101
+ name: "cat 4 prod 1",
101
102
  description: `Ticket is valid for students and non students.
102
103
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
103
104
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -106,8 +107,8 @@ const productCategories2 = [
106
107
  price: 1,
107
108
  },
108
109
  {
109
- id: 12,
110
- name: "Wine",
110
+ id: 42,
111
+ name: "cat 4 prod 1",
111
112
  description: `Ticket is valid for students and non students.
112
113
  You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
113
114
  Ticket valid for entry before 11.30pm for 12.30am showtime.`,
@@ -141,26 +142,40 @@ export function Default() {
141
142
  menuSteps={menuSteps as any}
142
143
  peopleAmount={5}
143
144
  formValues={{
144
- "3": {
145
- id: 3,
145
+ "11": {
146
+ id: 11,
146
147
  quantity: 1,
147
- name: "Beer",
148
+ name: "cat 1 prod 1",
148
149
  price: 0,
149
- productsCategoryId: 2,
150
+ productsCategoryId: 1,
150
151
  },
151
- "5": {
152
- id: 5,
152
+ "21": {
153
+ id: 21,
153
154
  quantity: 2,
154
- name: "Wine",
155
+ name: "cat 2 prod 1",
155
156
  price: 1,
156
157
  productsCategoryId: 2,
157
158
  },
158
- "7": {
159
- id: 7,
159
+ "31": {
160
+ id: 31,
160
161
  quantity: 4,
161
- name: "Beer",
162
+ name: "cat 3 prod 1",
162
163
  price: 1,
163
- productsCategoryId: 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,
164
179
  },
165
180
  }}
166
181
  totalWithDiscount={5}
@@ -1,9 +1,9 @@
1
- import React, { useMemo } from "react";
1
+ import React 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";
5
6
  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,15 +25,6 @@ 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
-
37
28
  if (isLoading) {
38
29
  return (
39
30
  <div className="payment-booking-summary">
@@ -52,19 +43,20 @@ export const BookingSummary = ({
52
43
  </div>
53
44
  <hr />
54
45
 
55
- {orderProducts?.length > 0 ? (
46
+ {values(formValues)?.length > 0 ? (
56
47
  <div>
57
48
  <div className="cart-items">
58
- {menuSteps.map((menuStep: MenuStep) => {
59
- return (
49
+ <div className="products-by-menu-step">
50
+ {menuSteps.map((menuStep) => (
60
51
  <ProductsByMenuStep
61
52
  key={menuStep.id}
62
- orderProducts={orderProducts}
53
+ orderItems={formValues}
63
54
  step={menuStep}
64
55
  productsWithErrors={productsWithErrors}
65
56
  />
66
- );
67
- })}
57
+ ))}
58
+ </div>
59
+
68
60
  {!shouldHidePeopleAmount && peopleAmount > 0 && (
69
61
  <>
70
62
  <hr />
@@ -74,6 +66,7 @@ export const BookingSummary = ({
74
66
  </div>
75
67
  </>
76
68
  )}
69
+
77
70
  {!!transactionFee && (
78
71
  <>
79
72
  <hr />
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import { useTranslation } from "react-i18next";
3
+ import { useIntl } from "react-intl";
4
+ import * as Config from "@licklist/core/dist/Config";
5
+ import { OrderItem } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
6
+
7
+ type ProductSummaryProps = {
8
+ name?: string;
9
+ productQuantityError?: string;
10
+ orderProduct: OrderItem;
11
+ };
12
+
13
+ export const ProductSummary = ({
14
+ name,
15
+ productQuantityError,
16
+ orderProduct,
17
+ }: ProductSummaryProps) => {
18
+ const { t } = useTranslation("Design");
19
+ const { formatNumber } = useIntl();
20
+
21
+ const price = formatNumber(
22
+ (orderProduct?.deposit || orderProduct?.price || 0) *
23
+ orderProduct?.quantity,
24
+ { style: "currency", currency: Config.Currency.GBP }
25
+ );
26
+
27
+ return (
28
+ <div className="product">
29
+ <p className="m-0 name">{name ?? orderProduct?.name}</p>
30
+ <div className="d-flex justify-content-between">
31
+ <p className="m-0">
32
+ {t("shortQuantity")}:&nbsp;{orderProduct?.quantity}
33
+ </p>
34
+
35
+ <p className="price">{price}</p>
36
+ </div>
37
+
38
+ {productQuantityError && (
39
+ <p className="iframe-event__message-error">{productQuantityError}</p>
40
+ )}
41
+ </div>
42
+ );
43
+ };
@@ -0,0 +1 @@
1
+ export * from "./ProductSummary";
@@ -1,90 +1,72 @@
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";
1
+ import React from "react";
5
2
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
6
- import { Order, MenuStep } from "../../../../../../types";
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);
7
27
 
8
28
  export type ProductsByMenuStepsProps = {
9
- orderProducts: Order[];
29
+ orderItems: OrderItems;
10
30
  step: MenuStep;
11
31
  productsWithErrors?: QuantityCheckProductInfo[];
12
32
  };
13
33
 
14
- const getIdFromEntity = (entities: { id: number }[]) =>
15
- entities.map(({ id }) => id);
16
-
17
34
  export const ProductsByMenuStep = ({
18
- orderProducts,
35
+ orderItems,
19
36
  step,
20
- productsWithErrors,
37
+ productsWithErrors = [],
21
38
  }: ProductsByMenuStepsProps) => {
22
- const { t } = useTranslation("Design");
23
- const { formatNumber } = useIntl();
24
39
  const { productCategories } = step;
25
40
 
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
- }
41
+ if (!doesStepHaveItems(orderItems, step)) return null;
39
42
 
40
43
  return (
41
- <div className="products-by-menu-step">
42
- {productCategories.map(({ name, id, products }) => {
43
- const selectedProducts = products.filter(({ id: productId }) =>
44
- productIds.includes(productId)
44
+ <div className="categories">
45
+ {productCategories.map((category) => {
46
+ const categoryOrderItems = getOrderItemsForCategory(
47
+ orderItems,
48
+ category.id
45
49
  );
46
50
 
47
- if (!selectedProducts.length) {
48
- return null;
49
- }
51
+ if (categoryOrderItems.length === 0) return null;
50
52
 
51
53
  return (
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
57
- );
54
+ <div key={category.id} className="products">
55
+ <p className="m-0 title">{category.name}</p>
58
56
 
59
- const productQuantityError = (productsWithErrors ?? []).find(
60
- (productWithError) =>
61
- productWithError.product_id === orderProduct.id
62
- )?.message;
57
+ {categoryOrderItems.map((orderItem) => {
58
+ const productQuantityError = getProductError(
59
+ productsWithErrors,
60
+ orderItem.id
61
+ );
63
62
 
64
63
  return (
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>
64
+ <ProductSummary
65
+ key={orderItem.id}
66
+ name={orderItem.name}
67
+ productQuantityError={productQuantityError}
68
+ orderProduct={orderItem}
69
+ />
88
70
  );
89
71
  })}
90
72
  </div>
@@ -1,5 +1,6 @@
1
1
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
2
- import { MenuStep, Order } from "../../../../../types";
2
+ import { OrderItems } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
3
+ import { MenuStep } from "@licklist/plugins/dist/types/context/sale/menuSteps";
3
4
 
4
5
  export const MOBILE_WIDTH = 576;
5
6
  export const ACCORDION_KEY = "booking-summary";
@@ -8,9 +9,7 @@ export type BookingSummaryProps = {
8
9
  date: string;
9
10
  time?: string;
10
11
  menuSteps?: MenuStep[];
11
- formValues?: {
12
- [key: string]: Order;
13
- };
12
+ formValues?: OrderItems;
14
13
  totalWithDiscount?: number;
15
14
  shouldHidePeopleAmount?: boolean;
16
15
  eventName?: string;
@@ -1,6 +1,7 @@
1
- import { Order } from "../../../../../types";
1
+ import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
2
+ import { OrderItem } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
2
3
 
3
- export const cartSumByOrderProducts = (orderProducts?: Order[]) => {
4
+ export const cartSumByOrderProducts = (orderProducts?: OrderItem[]) => {
4
5
  if (!orderProducts || !orderProducts.length) {
5
6
  return 0;
6
7
  }
@@ -12,3 +13,11 @@ export const cartSumByOrderProducts = (orderProducts?: Order[]) => {
12
13
  );
13
14
  }, 0);
14
15
  };
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;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { PointProduct } from "@licklist/core/dist/DataMapper/Product/PointProductDataMapper";
3
3
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
4
- import { ProductCategory } from "../../../../../types";
4
+ import { ProductCategory } from "@licklist/plugins/dist/types/context/sale/menuSteps";
5
5
  import { CategoryProductModal } from "./CategoryProductModal";
6
6
 
7
7
  export type CategoryProps = {
@@ -3,7 +3,10 @@ import clsx from "clsx";
3
3
  import { Button } from "react-bootstrap";
4
4
  import { PointProduct } from "@licklist/core/dist/DataMapper/Product/PointProductDataMapper";
5
5
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
6
- import { ProductCategory, Product } from "../../../../../types";
6
+ import {
7
+ Product,
8
+ ProductCategory,
9
+ } from "@licklist/plugins/dist/types/context/sale/menuSteps";
7
10
  import { CategoryProduct } from "../../CategoryProduct";
8
11
  import Icon from "../../../../../static/Icon";
9
12
 
@@ -6,8 +6,11 @@ import { useIntl } from "react-intl";
6
6
  import * as Config from "@licklist/core/dist/Config";
7
7
  import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
8
8
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
9
+ import {
10
+ Product,
11
+ ProductCategory,
12
+ } from "@licklist/plugins/dist/types/context/sale/menuSteps";
9
13
  import { TicketDescription } from "../../../event/ticket-description";
10
- import { ProductCategory, Product } from "../../../../types";
11
14
  import { ProductQuantityInput } from "./components/ProductQuantityInput";
12
15
 
13
16
  interface CategoryProductProps {
@@ -4,8 +4,11 @@ import { Button } from "react-bootstrap";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import { FieldValues, RefCallBack, UseFormClearErrors } from "react-hook-form";
6
6
  import { Zone } from "@licklist/core/dist/DataMapper/Provider/ZoneDataMapper";
7
+ import {
8
+ Product,
9
+ ProductCategory,
10
+ } from "@licklist/plugins/dist/types/context/sale/menuSteps";
7
11
  import { NumberInput } from "../NumberInput";
8
- import { Product, ProductCategory } from "../../../../../../types";
9
12
 
10
13
  interface FormOrderItem {
11
14
  id: number;
@@ -2,7 +2,7 @@ import { ProductCategory } from "@licklist/core/dist/DataMapper/Product/ProductC
2
2
  import { Currency } from "@licklist/core/dist/Config";
3
3
  import { useIntl } from "react-intl";
4
4
  import { useTranslation } from "react-i18next";
5
- import { Order } from "src/types";
5
+ import { OrderItems } from "@licklist/plugins/dist/types/context/Iframe/orderItems";
6
6
 
7
7
  interface CategoryError {
8
8
  message: string;
@@ -13,8 +13,9 @@ interface CategoryError {
13
13
  export const useCategoryVerification = () => {
14
14
  const { t } = useTranslation("Validation");
15
15
  const { formatNumber } = useIntl();
16
+
16
17
  return (
17
- values: Record<Order["id"], Order>,
18
+ values: OrderItems,
18
19
  productCategories?: ProductCategory[],
19
20
  isLastPage?: boolean
20
21
  ): CategoryError | void => {
@@ -49,7 +49,7 @@ export const PaymentPage = ({
49
49
  );
50
50
 
51
51
  const onCloseWindow = () => {
52
- // @TODO discuss redirect to site
52
+ // TODO discuss redirect to site
53
53
  window.location.href = "https://booked.it/";
54
54
  };
55
55
 
@@ -101,14 +101,13 @@ export const PaymentPage = ({
101
101
  }
102
102
 
103
103
  const orderTotalAmountByFormValues = cartSumByOrderProducts(
104
- bookingSummaryProps && bookingSummaryProps?.formValues
105
- ? Object.values(bookingSummaryProps?.formValues)
106
- : undefined
104
+ bookingSummaryProps?.formValues &&
105
+ Object.values(bookingSummaryProps?.formValues)
107
106
  );
108
107
 
109
108
  // User can fill promo code only in iframe application.
110
- // It didn't possible via payment link. This check will
111
- // be applied when there are no metadata and in case when
109
+ // It isn't possible via payment link. This check will
110
+ // be applied when there is no metadata and in case when
112
111
  // orderValues sum is greater than amount in order.
113
112
  const isCalculatedAmountGreaterThanOrderAmount =
114
113
  orderTotalAmountByFormValues > data?.amount;
@@ -1,7 +1,5 @@
1
- // eslint-disable-next-line max-len
2
1
  import React, { ReactNode } from "react";
3
2
  import { useTranslation } from "react-i18next";
4
-
5
3
  import { PaymentStatusBody } from "./component";
6
4
  import { LoaderIndicator } from "../../../static/loader/LoaderIndicator";
7
5
  import { Page, PageBody } from "../../page";
@@ -16,7 +14,7 @@ export const ORDER_STATUS_FAILED = "failed";
16
14
  export const ORDER_STATUS_SUCCESS = "success";
17
15
  export const ORDER_STATUS_PENDING = "pending";
18
16
 
19
- export type OrderStatusPrefix =
17
+ export type OrderStatus =
20
18
  | typeof ORDER_STATUS_SUCCESS
21
19
  | typeof ORDER_STATUS_FAILED
22
20
  | typeof ORDER_STATUS_PENDING;
@@ -26,7 +24,7 @@ interface PaymentStatusComponentProps {
26
24
  onBack?: () => void;
27
25
  onTryAgain?: () => void;
28
26
  isLoading?: boolean;
29
- status: OrderStatusPrefix;
27
+ status: OrderStatus;
30
28
  isAppUsingInIframe?: boolean;
31
29
  bookingSummaryProps?: BookingSummaryProps;
32
30
  EventCardComponent?: ReactNode;
@@ -36,6 +34,12 @@ interface PaymentStatusComponentProps {
36
34
  paymentMetadata?: PaymentMetadata;
37
35
  }
38
36
 
37
+ const titles: Record<OrderStatus, string> = {
38
+ [ORDER_STATUS_SUCCESS]: "purchaseSuccessful",
39
+ [ORDER_STATUS_PENDING]: "pendingPayment",
40
+ [ORDER_STATUS_FAILED]: "purchaseFailed",
41
+ };
42
+
39
43
  // @TODO In future think, how to reuse this component in Iframe Pending, Success and Failed Pages
40
44
  export const PaymentStatusPage = ({
41
45
  onCloseWindow,
@@ -53,27 +57,10 @@ export const PaymentStatusPage = ({
53
57
  }: PaymentStatusComponentProps) => {
54
58
  const { t } = useTranslation("Design");
55
59
 
56
- const getTitle = () => {
57
- switch (status) {
58
- case ORDER_STATUS_SUCCESS:
59
- return t("purchaseSuccessful");
60
- case ORDER_STATUS_PENDING:
61
- return t("pendingPayment");
62
- default:
63
- return t("purchaseFailed");
64
- }
65
- };
66
-
67
- const title = getTitle();
68
-
69
- if (isLoading) {
70
- return <LoaderIndicator isLoaded={false} />;
71
- }
60
+ if (isLoading) return <LoaderIndicator isLoaded={false} />;
72
61
 
73
62
  const orderTotalAmounByFormValues = cartSumByOrderProducts(
74
- bookingSummaryProps && bookingSummaryProps?.formValues
75
- ? Object.values(bookingSummaryProps?.formValues)
76
- : undefined
63
+ Object.values(bookingSummaryProps?.formValues ?? {})
77
64
  );
78
65
 
79
66
  // User can fill promocode only in iframe appcliation.
@@ -88,6 +75,7 @@ export const PaymentStatusPage = ({
88
75
  return (
89
76
  <Page
90
77
  className="payment-status-page"
78
+ isAppUsingInIframe={isAppUsingInIframe}
91
79
  headerBlock={
92
80
  <PaymentStatusHeader
93
81
  success={status !== ORDER_STATUS_FAILED}
@@ -98,11 +86,10 @@ export const PaymentStatusPage = ({
98
86
  }
99
87
  />
100
88
  }
101
- isAppUsingInIframe={isAppUsingInIframe}
102
89
  >
103
90
  <PageBody
104
91
  leftBlock={
105
- <PageBody.LeftBlock title={title}>
92
+ <PageBody.LeftBlock title={t(titles[status])}>
106
93
  <div>
107
94
  {EventCardComponent}
108
95
  <PaymentStatusBody
@@ -168,7 +155,7 @@ export const PaymentStatusPage = ({
168
155
  {bookingSummaryProps ? (
169
156
  <BookingSummary {...bookingSummaryProps} />
170
157
  ) : (
171
- <h6>{title}</h6>
158
+ <h6>{t(titles[status])}</h6>
172
159
  )}
173
160
  </PageBody.RightBlock>
174
161
  }