@licklist/design 0.44.485-dev.70 → 0.44.485-dev.72
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.
- package/dist/events/event-venue-map/EventVenueMap.d.ts +3 -3
- package/dist/events/event-venue-map/EventVenueMap.d.ts.map +1 -1
- package/dist/events/event-venue-map/components/VenueMap/VenueMap.d.ts +2 -2
- package/dist/events/event-venue-map/components/VenueMap/VenueMap.d.ts.map +1 -1
- package/dist/iframe/event/event-venue-map/IframeEventVenueMap.d.ts +1 -4
- package/dist/iframe/event/event-venue-map/IframeEventVenueMap.d.ts.map +1 -1
- package/dist/iframe/index.d.ts +1 -1
- package/dist/iframe/index.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts +2 -2
- package/dist/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +2 -2
- package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.d.ts +2 -2
- package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.js +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts +2 -2
- package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts +2 -2
- package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts.map +1 -1
- package/dist/iframe/order-process/components/Category/Category.d.ts +3 -3
- package/dist/iframe/order-process/components/Category/Category.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts +3 -3
- package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
- package/dist/iframe/order-process/components/ErrorModal/ErrorModal.d.ts.map +1 -0
- package/dist/iframe/order-process/components/ErrorModal/ErrorModal.js +1 -0
- package/dist/iframe/order-process/components/ErrorModal/index.d.ts +2 -0
- package/dist/iframe/order-process/components/ErrorModal/index.d.ts.map +1 -0
- package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts +8 -0
- package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts.map +1 -0
- package/dist/iframe/order-process/components/utils/useCategoryVerification.js +1 -0
- package/dist/iframe/order-process/index.d.ts +3 -1
- package/dist/iframe/order-process/index.d.ts.map +1 -1
- package/dist/iframe/payment/payment-page/PaymentPage.js +1 -1
- package/dist/iframe/payment/payment-page/PaymentTimer.js +1 -1
- package/dist/iframe/payment/payment-status-page/PaymentStatusPage.js +1 -1
- package/dist/index.js +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
- package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts +2 -2
- package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts.map +1 -1
- package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts +2 -2
- package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts.map +1 -1
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts +2 -2
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts.map +1 -1
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.js +1 -1
- package/dist/snippet/snippet-template/preview/Preview.js +1 -1
- package/dist/types/iframe.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/events/event-venue-map/EventVenueMap.tsx +2 -2
- package/src/events/event-venue-map/components/VenueMap/VenueMap.tsx +2 -2
- package/src/iframe/index.ts +3 -1
- package/src/iframe/order-process/components/BookingSummary/components/ProductsByMenuStep/ProductsByMenuStep.tsx +2 -2
- package/src/iframe/order-process/components/BookingSummary/types/index.ts +2 -2
- package/src/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.tsx +6 -5
- package/src/iframe/order-process/components/CalendarStepsForm/components/Category.tsx +2 -2
- package/src/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.tsx +2 -2
- package/src/iframe/order-process/components/Category/Category.tsx +3 -3
- package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +3 -3
- package/src/iframe/order-process/components/{CalendarStepsForm/components → ErrorModal}/ErrorModal.tsx +1 -1
- package/src/iframe/order-process/components/ErrorModal/index.ts +1 -0
- package/src/iframe/order-process/components/utils/{category.ts → useCategoryVerification.ts} +15 -10
- package/src/iframe/order-process/index.ts +3 -1
- package/src/product-set/product-category/ProductCategoryControl.tsx +1 -1
- package/src/sales/manual-booking/category-product/CategoryProduct.tsx +2 -2
- package/src/sales/manual-booking/category-products/CategoryProducts.tsx +2 -2
- package/src/sales/manual-booking/controll/ManualBookingStepsControll.tsx +3 -3
- package/src/types/iframe.ts +2 -0
- package/dist/iframe/order-process/components/CalendarStepsForm/components/ErrorModal.d.ts.map +0 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/ErrorModal.js +0 -1
- package/dist/iframe/order-process/components/StepsForm/StepsForm.d.ts +0 -19
- package/dist/iframe/order-process/components/StepsForm/StepsForm.d.ts.map +0 -1
- package/dist/iframe/order-process/components/StepsForm/StepsForm.js +0 -1
- package/dist/iframe/order-process/components/StepsForm/index.d.ts +0 -2
- package/dist/iframe/order-process/components/StepsForm/index.d.ts.map +0 -1
- package/dist/iframe/order-process/components/utils/category.d.ts +0 -10
- package/dist/iframe/order-process/components/utils/category.d.ts.map +0 -1
- package/dist/iframe/order-process/components/utils/category.js +0 -1
- package/src/iframe/order-process/OrderProcess.stories.tsx +0 -363
- package/src/iframe/order-process/components/StepsForm/StepsForm.tsx +0 -176
- package/src/iframe/order-process/components/StepsForm/index.ts +0 -1
- /package/dist/iframe/order-process/components/{CalendarStepsForm/components → ErrorModal}/ErrorModal.d.ts +0 -0
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
3
|
-
import { MenuStep } from "../../../../types";
|
|
4
|
-
export interface StepsFormProps {
|
|
5
|
-
step: MenuStep;
|
|
6
|
-
isLastMenuStep: boolean;
|
|
7
|
-
onSubmit: (values: Record<string, any>) => void;
|
|
8
|
-
setFormValues: (values: Record<string, any>) => void;
|
|
9
|
-
defaultValues: Record<string, any>;
|
|
10
|
-
setFormErrors?: (errors: Record<string, any>) => void;
|
|
11
|
-
id?: string;
|
|
12
|
-
productsWithErrors?: ProductQuantityCheckResponse["products"];
|
|
13
|
-
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
14
|
-
}
|
|
15
|
-
export type StepsFormRef = {
|
|
16
|
-
getFormValues: () => Record<string, any>;
|
|
17
|
-
};
|
|
18
|
-
export declare const StepsForm: React.ForwardRefExoticComponent<StepsFormProps & React.RefAttributes<StepsFormRef>>;
|
|
19
|
-
//# sourceMappingURL=StepsForm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StepsForm.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/StepsForm/StepsForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAChD,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kBAAkB,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;IAC9D,eAAe,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;CAC5D;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,SAAS,qFAsIrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),s=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,o=require("react-i18next"),u=require("react-bootstrap"),i=require("react-hook-form"),a=require("lodash"),l=require("@licklist/plugins/dist/hooks/Value/usePreviousValue"),n=require("@licklist/plugins/dist/utils/ScrollUtils"),c=require("@licklist/plugins/dist/utils/FormValues"),d=require("../Category/Category.js"),m=require("../../constants.js"),f=require("../CalendarStepsForm/components/ErrorModal.js"),E=require("../utils/category.js"),p="NO_ORDER_ITEMS_ERROR",g=t.forwardRef((function(e,g){var v=e.step,y=e.isLastMenuStep,q=e.setFormValues,F=e.defaultValues,S=e.onSubmit,V=e.setFormErrors,_=e.id,C=void 0===_?m.STEP_FORM_ID:_,h=e.productsWithErrors,O=e.soldOutProducts,P=i.useForm({defaultValues:F}),b=o.useTranslation(["Design","Validation"]).t,j=r.__read(t.useState(""),2),R=j[0],T=j[1],k=E.useCategory().verifyCategoryItems,M=P.control,x=P.formState.errors,I=P.getValues,D=P.setError,K=P.clearErrors,N=P.reset,W=i.useWatch({control:M}),L=l.usePreviousValue(x);t.useImperativeHandle(g,(function(){return{getFormValues:function(){return I()}}})),t.useEffect((function(){h&&T(b("soldOutProduct"))}),[h]);return t.useEffect((function(){x&&setTimeout(K,0),q(W)}),[W]),t.useEffect((function(){c.isFormValuesEmpty(W)||K(p)}),[W,K]),t.useEffect((function(){N(F)}),[F]),t.useEffect((function(){!a.isEqual(x,L)&&V&&V(x)}),[x,L,V]),s.createElement(u.Form,{onSubmit:P.handleSubmit((function(e){if(y&&c.isFormValuesEmpty(e))return D(p,{}),void n.scrollToError(p);var r=k(e,v);if(r)return T(r.message),void D("category_".concat(r.id),{message:r.message});S(e)}),(function(e){n.scrollToError(c.getFirstErrorKey(e)),T(b("pleaseCheckSelectedProducts"))})),id:C},s.createElement(i.FormProvider,r.__assign({},P),s.createElement(f.ErrorModal,{isOpen:Boolean(R),messageKey:R,onClose:function(){return T("")}}),s.createElement("div",null,s.createElement("div",{className:"iframe-event"},s.createElement(d.Category,{productCategories:null==v?void 0:v.productCategories,productsWithErrors:h,errors:x,soldOutProducts:O}),x[p]&&s.createElement("div",{className:"d-flex m-5 justify-content-center form-error",id:p},s.createElement(o.Trans,{t:b,i18nKey:"pleaseSelectAtLeastFrom",values:{min:1,type:"item",from:"those categories"}}))))))}));exports.StepsForm=g;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/StepsForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MenuStep } from "../../../../types";
|
|
2
|
-
interface CategoryError {
|
|
3
|
-
message: string;
|
|
4
|
-
id: number;
|
|
5
|
-
}
|
|
6
|
-
export declare const useCategory: () => {
|
|
7
|
-
verifyCategoryItems: (values: Record<string, any>, step: MenuStep) => CategoryError | void;
|
|
8
|
-
};
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=category.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"category.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/utils/category.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AACD,eAAO,MAAM,WAAW;kCAGZ,OAAO,MAAM,EAAE,GAAG,CAAC,QACrB,QAAQ,KACb,aAAa,GAAG,IAAI;CAmCxB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react-i18next");exports.useCategory=function(){var t=e.useTranslation("Validation").t;return{verifyCategoryItems:function(e,r){var i,n=Object.values(e).filter((function(e){return(null==e?void 0:e.quantity)>0}));return null==r||r.productCategories.forEach((function(e){var r=e.minSubItems,a=e.maxSubItems,u=e.id,o=e.name;if(r||a){var s=n.filter((function(e){return Number(null==e?void 0:e.productsCategoryId)===Number(u)})).length;if(s<r){var c=t("Validation:fieldMinNumber",{min:r,attribute:"number of products in the ".concat(o," category")});i={id:u,message:c}}else if(a&&s>a){c=t("Validation:fieldMaxNumber",{max:a,attribute:"number of products in the ".concat(o," category")});i={id:u,message:c}}}})),i}}};
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
useState,
|
|
4
|
-
useContext,
|
|
5
|
-
createContext,
|
|
6
|
-
useRef,
|
|
7
|
-
useMemo,
|
|
8
|
-
} from "react";
|
|
9
|
-
import { MemoryRouter, Route, useHistory } from "react-router-dom";
|
|
10
|
-
import { Meta } from "@storybook/react";
|
|
11
|
-
import { Timer } from "./components/Timer";
|
|
12
|
-
import { BookingSummary } from "./components/BookingSummary";
|
|
13
|
-
import { NavigationSteps } from "./components/NavigationSteps";
|
|
14
|
-
import { StepsForm } from "./components/StepsForm";
|
|
15
|
-
import { Page, PageBody, PageHeader } from "../page";
|
|
16
|
-
import { StepsFormRef } from "./components/StepsForm/StepsForm";
|
|
17
|
-
import { BookingSummaryFooter } from "./components/BookingSummaryFooter";
|
|
18
|
-
import { Order } from "../../types";
|
|
19
|
-
// eslint-disable-next-line max-len
|
|
20
|
-
import { RenderNumberOfPeopleInputComponent } from "../event/event-details/components/number-of-people-input/component/RenderNumberOfPeopleInputComponent";
|
|
21
|
-
|
|
22
|
-
const ROUTES = [
|
|
23
|
-
{ pathname: "/step1", key: "/step1", name: "Burger" },
|
|
24
|
-
{ pathname: "/step2", key: "/step2", name: "Cheese" },
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
const IMAGES = [
|
|
28
|
-
{
|
|
29
|
-
id: 1,
|
|
30
|
-
path: "test",
|
|
31
|
-
imageType: "image",
|
|
32
|
-
url: "https://fastly.picsum.photos/id/13/2500/1667.jpg?hmac=SoX9UoHhN8HyklRA4A3vcCWJMVtiBXUg0W4ljWTor7s",
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
const productCategories = [
|
|
37
|
-
{
|
|
38
|
-
id: 1,
|
|
39
|
-
name: "Early Bird General Admission",
|
|
40
|
-
allowDeposits: true,
|
|
41
|
-
minSubItems: 2,
|
|
42
|
-
products: [
|
|
43
|
-
{
|
|
44
|
-
id: 7,
|
|
45
|
-
name: "Beer",
|
|
46
|
-
description: `Ticket <em>is</em> valid for students and non students.
|
|
47
|
-
You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
|
|
48
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
49
|
-
|
|
50
|
-
price: 5,
|
|
51
|
-
deposit: 3,
|
|
52
|
-
minSub: 10,
|
|
53
|
-
isRequired: true,
|
|
54
|
-
images: IMAGES,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 8,
|
|
58
|
-
name: "Wine",
|
|
59
|
-
description: `Ticket is valid for students and non students.
|
|
60
|
-
You do not need <strong>student ID</strong> for this event but do require regular age ID e.g. driving licence or passport.
|
|
61
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
62
|
-
|
|
63
|
-
price: 1,
|
|
64
|
-
images: IMAGES,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: 2,
|
|
70
|
-
name: "Nice",
|
|
71
|
-
maxSubItems: 1,
|
|
72
|
-
products: [
|
|
73
|
-
{
|
|
74
|
-
id: 3,
|
|
75
|
-
name: "Beer",
|
|
76
|
-
description: `Ticket is valid for students and non students.
|
|
77
|
-
You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
|
|
78
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
79
|
-
|
|
80
|
-
price: 1,
|
|
81
|
-
images: IMAGES,
|
|
82
|
-
maxAmount: 1,
|
|
83
|
-
minAmount: 1,
|
|
84
|
-
isRequired: true,
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
id: 5,
|
|
88
|
-
name: "Wine",
|
|
89
|
-
description: `Ticket is valid for students and non students.
|
|
90
|
-
You do not need <strong>student ID</strong> for this event but do require regular age ID e.g. driving licence or passport.
|
|
91
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
92
|
-
|
|
93
|
-
price: 1,
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
|
|
99
|
-
const productCategories2 = [
|
|
100
|
-
{
|
|
101
|
-
id: 3,
|
|
102
|
-
name: "fine",
|
|
103
|
-
products: [
|
|
104
|
-
{
|
|
105
|
-
id: 9,
|
|
106
|
-
name: "Beer",
|
|
107
|
-
description: `Ticket is valid for students and non students.
|
|
108
|
-
You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
|
|
109
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
110
|
-
|
|
111
|
-
price: 1,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: 10,
|
|
115
|
-
name: "Wine",
|
|
116
|
-
description: `Ticket is valid for students and non students.
|
|
117
|
-
You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
|
|
118
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
119
|
-
|
|
120
|
-
price: 1,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
id: 4,
|
|
126
|
-
name: "Twice",
|
|
127
|
-
products: [
|
|
128
|
-
{
|
|
129
|
-
id: 11,
|
|
130
|
-
name: "Beer",
|
|
131
|
-
description: `Ticket is valid for students and non students.
|
|
132
|
-
You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
|
|
133
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
134
|
-
|
|
135
|
-
price: 1,
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: 12,
|
|
139
|
-
name: "Wine",
|
|
140
|
-
description: `Ticket is valid for students and non students.
|
|
141
|
-
You do not need student ID for this event but do require regular age ID e.g. driving licence or passport.
|
|
142
|
-
Ticket valid for entry before 11.30pm for 12.30am showtime.`,
|
|
143
|
-
|
|
144
|
-
price: 1,
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
const menuSteps = [
|
|
151
|
-
{
|
|
152
|
-
id: 1,
|
|
153
|
-
name: "Burger",
|
|
154
|
-
productCategories,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
id: 2,
|
|
158
|
-
name: "Cheese",
|
|
159
|
-
productCategories: productCategories2,
|
|
160
|
-
},
|
|
161
|
-
];
|
|
162
|
-
|
|
163
|
-
const OrderProcessContext = createContext<{
|
|
164
|
-
orderFormValues: Record<string, any>;
|
|
165
|
-
setOrderFormValues: (values: Record<string, any>) => void;
|
|
166
|
-
formValues: Record<string, any>;
|
|
167
|
-
setFormValues: (values: Record<string, any>) => void;
|
|
168
|
-
}>({
|
|
169
|
-
orderFormValues: {},
|
|
170
|
-
setOrderFormValues: () => undefined,
|
|
171
|
-
formValues: {},
|
|
172
|
-
setFormValues: () => undefined,
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
const OrderProcessContextProvider: React.FC = ({ children }) => {
|
|
176
|
-
const [orderFormValues, setOrderFormValues] = useState<Record<string, any>>(
|
|
177
|
-
{}
|
|
178
|
-
);
|
|
179
|
-
const [formValues, setFormValues] = useState<Record<string, any>>({});
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<OrderProcessContext.Provider
|
|
183
|
-
value={{
|
|
184
|
-
orderFormValues,
|
|
185
|
-
setOrderFormValues,
|
|
186
|
-
formValues,
|
|
187
|
-
setFormValues,
|
|
188
|
-
}}
|
|
189
|
-
>
|
|
190
|
-
{children}
|
|
191
|
-
</OrderProcessContext.Provider>
|
|
192
|
-
);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export default {
|
|
196
|
-
title: "Iframe/Order-Process/OrderProcess",
|
|
197
|
-
component: Default,
|
|
198
|
-
} as Meta;
|
|
199
|
-
|
|
200
|
-
const TimerWrapper = () => {
|
|
201
|
-
const [timer, setTimer] = useState(120000);
|
|
202
|
-
const updateTimerState = () => {
|
|
203
|
-
setTimer((prevValue) => {
|
|
204
|
-
if (prevValue <= 0) {
|
|
205
|
-
return 0;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const nexValue = prevValue - 1000;
|
|
209
|
-
|
|
210
|
-
return nexValue;
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
useEffect(() => {
|
|
215
|
-
setInterval(updateTimerState, 1000);
|
|
216
|
-
}, []);
|
|
217
|
-
|
|
218
|
-
return <Timer timer={timer} />;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
export function Default() {
|
|
222
|
-
const externalHistory = useHistory();
|
|
223
|
-
const formRef = useRef<StepsFormRef | null>(null);
|
|
224
|
-
const [peopleAmount, setPeopleAmount] = useState(0);
|
|
225
|
-
const [peopleAmountError, setPeopleAmountError] = useState(false);
|
|
226
|
-
|
|
227
|
-
return (
|
|
228
|
-
<MemoryRouter initialEntries={ROUTES} initialIndex={0}>
|
|
229
|
-
<OrderProcessContextProvider>
|
|
230
|
-
{ROUTES.map(({ pathname }, index) => {
|
|
231
|
-
const step = menuSteps[index];
|
|
232
|
-
|
|
233
|
-
return (
|
|
234
|
-
<Route
|
|
235
|
-
path={pathname}
|
|
236
|
-
exact
|
|
237
|
-
key={pathname}
|
|
238
|
-
component={() => {
|
|
239
|
-
const history = useHistory();
|
|
240
|
-
const {
|
|
241
|
-
orderFormValues,
|
|
242
|
-
setOrderFormValues,
|
|
243
|
-
formValues,
|
|
244
|
-
setFormValues,
|
|
245
|
-
} = useContext(OrderProcessContext);
|
|
246
|
-
const relyOnPeopleCategoryIds = [4];
|
|
247
|
-
const onPrevStep = () => {
|
|
248
|
-
if (formRef.current?.getFormValues()) {
|
|
249
|
-
setFormValues(formRef.current?.getFormValues());
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (index === 0) {
|
|
253
|
-
// external History push
|
|
254
|
-
externalHistory.push("/");
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
history.push(ROUTES[index - 1].pathname);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
const onNextStep = (values: Record<string, any>) => {
|
|
262
|
-
setOrderFormValues(values);
|
|
263
|
-
const nextRoute = ROUTES[index + 1];
|
|
264
|
-
if (nextRoute) {
|
|
265
|
-
history.push(ROUTES[index + 1].pathname);
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
const shouldShowPeopleInput = useMemo(() => {
|
|
270
|
-
const values = Object.values(formValues).filter(
|
|
271
|
-
Boolean
|
|
272
|
-
) as Order[];
|
|
273
|
-
const filteredValues = values.filter(
|
|
274
|
-
(product) =>
|
|
275
|
-
relyOnPeopleCategoryIds.includes(
|
|
276
|
-
product.productsCategoryId
|
|
277
|
-
) && product.quantity > 0
|
|
278
|
-
);
|
|
279
|
-
|
|
280
|
-
return Boolean(filteredValues.length);
|
|
281
|
-
}, [formValues, relyOnPeopleCategoryIds]);
|
|
282
|
-
const onChangePeopleAmount = (value: number) => {
|
|
283
|
-
if (!setPeopleAmount) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
setPeopleAmount(value);
|
|
287
|
-
if (value > 0) {
|
|
288
|
-
if (peopleAmountError) {
|
|
289
|
-
setPeopleAmountError(false);
|
|
290
|
-
}
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
setPeopleAmountError(true);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
return (
|
|
298
|
-
<Page
|
|
299
|
-
headerBlock={
|
|
300
|
-
<PageHeader
|
|
301
|
-
showCloseButton
|
|
302
|
-
onCloseButtonClick={onPrevStep}
|
|
303
|
-
showBackButton
|
|
304
|
-
onBackButtonClick={onPrevStep}
|
|
305
|
-
>
|
|
306
|
-
<TimerWrapper />
|
|
307
|
-
<NavigationSteps steps={ROUTES} />
|
|
308
|
-
</PageHeader>
|
|
309
|
-
}
|
|
310
|
-
>
|
|
311
|
-
<PageBody
|
|
312
|
-
leftBlock={
|
|
313
|
-
<PageBody.LeftBlock title={step.name}>
|
|
314
|
-
<StepsForm
|
|
315
|
-
isLastMenuStep={!ROUTES[index + 1]}
|
|
316
|
-
step={step as any}
|
|
317
|
-
setFormValues={setFormValues}
|
|
318
|
-
defaultValues={orderFormValues}
|
|
319
|
-
onSubmit={onNextStep}
|
|
320
|
-
ref={formRef}
|
|
321
|
-
/>
|
|
322
|
-
</PageBody.LeftBlock>
|
|
323
|
-
}
|
|
324
|
-
rightBlock={
|
|
325
|
-
<PageBody.RightBlock
|
|
326
|
-
bottomBlock={
|
|
327
|
-
<BookingSummaryFooter>
|
|
328
|
-
{shouldShowPeopleInput && (
|
|
329
|
-
<RenderNumberOfPeopleInputComponent
|
|
330
|
-
peopleAmount={peopleAmount || 0}
|
|
331
|
-
onChangePeopleAmount={onChangePeopleAmount}
|
|
332
|
-
peopleAmountError={peopleAmountError}
|
|
333
|
-
/>
|
|
334
|
-
)}
|
|
335
|
-
<BookingSummary.SummaryTotal
|
|
336
|
-
formValues={formValues}
|
|
337
|
-
totalWithDiscount={5}
|
|
338
|
-
/>
|
|
339
|
-
</BookingSummaryFooter>
|
|
340
|
-
}
|
|
341
|
-
>
|
|
342
|
-
<BookingSummary
|
|
343
|
-
hasPeopleInput={shouldShowPeopleInput}
|
|
344
|
-
date="29 Sept 2022 at 09:00"
|
|
345
|
-
menuSteps={menuSteps as any}
|
|
346
|
-
formValues={formValues}
|
|
347
|
-
peopleAmount={peopleAmount}
|
|
348
|
-
totalWithDiscount={5}
|
|
349
|
-
eventName="Glam!"
|
|
350
|
-
/>
|
|
351
|
-
</PageBody.RightBlock>
|
|
352
|
-
}
|
|
353
|
-
/>
|
|
354
|
-
</Page>
|
|
355
|
-
);
|
|
356
|
-
}}
|
|
357
|
-
/>
|
|
358
|
-
);
|
|
359
|
-
})}
|
|
360
|
-
</OrderProcessContextProvider>
|
|
361
|
-
</MemoryRouter>
|
|
362
|
-
);
|
|
363
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
forwardRef,
|
|
4
|
-
useImperativeHandle,
|
|
5
|
-
useState,
|
|
6
|
-
} from "react";
|
|
7
|
-
import { useWatch, useForm, FormProvider } from "react-hook-form";
|
|
8
|
-
import { isEqual } from "lodash";
|
|
9
|
-
import { Form } from "react-bootstrap";
|
|
10
|
-
import { useTranslation, Trans } from "react-i18next";
|
|
11
|
-
import { scrollToError } from "@licklist/plugins/dist/utils/ScrollUtils";
|
|
12
|
-
import { usePreviousValue } from "@licklist/plugins/dist/hooks/Value/usePreviousValue";
|
|
13
|
-
import {
|
|
14
|
-
getFirstErrorKey,
|
|
15
|
-
isFormValuesEmpty,
|
|
16
|
-
} from "@licklist/plugins/dist/utils/FormValues";
|
|
17
|
-
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
18
|
-
import { Category } from "../Category";
|
|
19
|
-
import { MenuStep } from "../../../../types";
|
|
20
|
-
import { STEP_FORM_ID } from "../../constants";
|
|
21
|
-
import { ErrorModal } from "../CalendarStepsForm/components/ErrorModal";
|
|
22
|
-
import { useCategory } from "../utils/category";
|
|
23
|
-
|
|
24
|
-
const NO_ORDER_ITEMS_ERROR = "NO_ORDER_ITEMS_ERROR";
|
|
25
|
-
|
|
26
|
-
export interface StepsFormProps {
|
|
27
|
-
step: MenuStep;
|
|
28
|
-
isLastMenuStep: boolean;
|
|
29
|
-
onSubmit: (values: Record<string, any>) => void;
|
|
30
|
-
setFormValues: (values: Record<string, any>) => void;
|
|
31
|
-
defaultValues: Record<string, any>;
|
|
32
|
-
setFormErrors?: (errors: Record<string, any>) => void;
|
|
33
|
-
id?: string;
|
|
34
|
-
productsWithErrors?: ProductQuantityCheckResponse["products"];
|
|
35
|
-
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type StepsFormRef = {
|
|
39
|
-
getFormValues: () => Record<string, any>;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const StepsForm = forwardRef<StepsFormRef, StepsFormProps>(
|
|
43
|
-
(
|
|
44
|
-
{
|
|
45
|
-
step,
|
|
46
|
-
isLastMenuStep,
|
|
47
|
-
setFormValues,
|
|
48
|
-
defaultValues,
|
|
49
|
-
onSubmit,
|
|
50
|
-
setFormErrors,
|
|
51
|
-
id = STEP_FORM_ID,
|
|
52
|
-
productsWithErrors,
|
|
53
|
-
soldOutProducts,
|
|
54
|
-
},
|
|
55
|
-
ref
|
|
56
|
-
) => {
|
|
57
|
-
const form = useForm({ defaultValues });
|
|
58
|
-
const { t } = useTranslation(["Design", "Validation"]);
|
|
59
|
-
const [formStepError, setStepFormError] = useState("");
|
|
60
|
-
|
|
61
|
-
const { verifyCategoryItems } = useCategory();
|
|
62
|
-
const {
|
|
63
|
-
control,
|
|
64
|
-
formState: { errors },
|
|
65
|
-
getValues,
|
|
66
|
-
setError,
|
|
67
|
-
clearErrors,
|
|
68
|
-
reset,
|
|
69
|
-
} = form;
|
|
70
|
-
const formValues = useWatch({ control });
|
|
71
|
-
const prevErrors = usePreviousValue(errors);
|
|
72
|
-
|
|
73
|
-
useImperativeHandle(ref, () => {
|
|
74
|
-
return {
|
|
75
|
-
getFormValues: () => getValues(),
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
if (!productsWithErrors) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
setStepFormError(t("soldOutProduct"));
|
|
84
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
|
-
}, [productsWithErrors]);
|
|
86
|
-
|
|
87
|
-
const submitCurrentForm = (values: Record<string, any>) => {
|
|
88
|
-
if (isLastMenuStep && isFormValuesEmpty(values)) {
|
|
89
|
-
setError(NO_ORDER_ITEMS_ERROR, {});
|
|
90
|
-
scrollToError(NO_ORDER_ITEMS_ERROR);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// @TODO it's temporary solution, please remove it later
|
|
95
|
-
const categoryError = verifyCategoryItems(values, step);
|
|
96
|
-
|
|
97
|
-
if (categoryError) {
|
|
98
|
-
setStepFormError(categoryError.message);
|
|
99
|
-
setError(`category_${categoryError.id}`, {
|
|
100
|
-
message: categoryError.message,
|
|
101
|
-
});
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
onSubmit(values);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const onErrorSubmit = (submitErrors) => {
|
|
109
|
-
scrollToError(getFirstErrorKey(submitErrors));
|
|
110
|
-
setStepFormError(t("pleaseCheckSelectedProducts"));
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
if (errors) {
|
|
115
|
-
setTimeout(clearErrors, 0);
|
|
116
|
-
}
|
|
117
|
-
setFormValues(formValues);
|
|
118
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
|
-
}, [formValues]);
|
|
120
|
-
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
if (isFormValuesEmpty(formValues)) return;
|
|
123
|
-
|
|
124
|
-
clearErrors(NO_ORDER_ITEMS_ERROR);
|
|
125
|
-
}, [formValues, clearErrors]);
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
reset(defaultValues);
|
|
129
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
130
|
-
}, [defaultValues]);
|
|
131
|
-
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
if (isEqual(errors, prevErrors) || !setFormErrors) return;
|
|
134
|
-
|
|
135
|
-
setFormErrors(errors);
|
|
136
|
-
}, [errors, prevErrors, setFormErrors]);
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<Form
|
|
140
|
-
onSubmit={form.handleSubmit(submitCurrentForm, onErrorSubmit)}
|
|
141
|
-
id={id}
|
|
142
|
-
>
|
|
143
|
-
<FormProvider {...form}>
|
|
144
|
-
<ErrorModal
|
|
145
|
-
isOpen={Boolean(formStepError)}
|
|
146
|
-
messageKey={formStepError}
|
|
147
|
-
onClose={() => setStepFormError("")}
|
|
148
|
-
/>
|
|
149
|
-
<div>
|
|
150
|
-
<div className="iframe-event">
|
|
151
|
-
<Category
|
|
152
|
-
productCategories={step?.productCategories}
|
|
153
|
-
productsWithErrors={productsWithErrors}
|
|
154
|
-
errors={errors}
|
|
155
|
-
soldOutProducts={soldOutProducts}
|
|
156
|
-
/>
|
|
157
|
-
|
|
158
|
-
{errors[NO_ORDER_ITEMS_ERROR] && (
|
|
159
|
-
<div
|
|
160
|
-
className="d-flex m-5 justify-content-center form-error"
|
|
161
|
-
id={NO_ORDER_ITEMS_ERROR}
|
|
162
|
-
>
|
|
163
|
-
<Trans
|
|
164
|
-
t={t}
|
|
165
|
-
i18nKey="pleaseSelectAtLeastFrom"
|
|
166
|
-
values={{ min: 1, type: "item", from: "those categories" }}
|
|
167
|
-
/>
|
|
168
|
-
</div>
|
|
169
|
-
)}
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
</FormProvider>
|
|
173
|
-
</Form>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { StepsForm } from "./StepsForm";
|
|
File without changes
|