@licklist/design 0.44.485-dev.70 → 0.44.485-dev.71

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 (51) hide show
  1. package/dist/iframe/index.d.ts +1 -1
  2. package/dist/iframe/index.d.ts.map +1 -1
  3. package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.d.ts.map +1 -1
  4. package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.js +1 -1
  5. package/dist/iframe/order-process/components/Category/Category.d.ts +3 -3
  6. package/dist/iframe/order-process/components/Category/Category.d.ts.map +1 -1
  7. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts +3 -3
  8. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  9. package/dist/iframe/order-process/components/ErrorModal/ErrorModal.d.ts.map +1 -0
  10. package/dist/iframe/order-process/components/ErrorModal/ErrorModal.js +1 -0
  11. package/dist/iframe/order-process/components/ErrorModal/index.d.ts +2 -0
  12. package/dist/iframe/order-process/components/ErrorModal/index.d.ts.map +1 -0
  13. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts +8 -0
  14. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts.map +1 -0
  15. package/dist/iframe/order-process/components/utils/useCategoryVerification.js +1 -0
  16. package/dist/iframe/order-process/index.d.ts +3 -1
  17. package/dist/iframe/order-process/index.d.ts.map +1 -1
  18. package/dist/iframe/payment/payment-page/PaymentPage.js +1 -1
  19. package/dist/iframe/payment/payment-page/PaymentTimer.js +1 -1
  20. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.js +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
  23. package/dist/sales/manual-booking/controll/ManualBookingStepsControll.js +1 -1
  24. package/dist/snippet/snippet-template/preview/Preview.js +1 -1
  25. package/dist/types/iframe.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/iframe/index.ts +3 -1
  28. package/src/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.tsx +4 -3
  29. package/src/iframe/order-process/components/Category/Category.tsx +3 -3
  30. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +3 -3
  31. package/src/iframe/order-process/components/{CalendarStepsForm/components → ErrorModal}/ErrorModal.tsx +1 -1
  32. package/src/iframe/order-process/components/ErrorModal/index.ts +1 -0
  33. package/src/iframe/order-process/components/utils/{category.ts → useCategoryVerification.ts} +15 -10
  34. package/src/iframe/order-process/index.ts +3 -1
  35. package/src/product-set/product-category/ProductCategoryControl.tsx +1 -1
  36. package/src/sales/manual-booking/controll/ManualBookingStepsControll.tsx +1 -1
  37. package/src/types/iframe.ts +2 -0
  38. package/dist/iframe/order-process/components/CalendarStepsForm/components/ErrorModal.d.ts.map +0 -1
  39. package/dist/iframe/order-process/components/CalendarStepsForm/components/ErrorModal.js +0 -1
  40. package/dist/iframe/order-process/components/StepsForm/StepsForm.d.ts +0 -19
  41. package/dist/iframe/order-process/components/StepsForm/StepsForm.d.ts.map +0 -1
  42. package/dist/iframe/order-process/components/StepsForm/StepsForm.js +0 -1
  43. package/dist/iframe/order-process/components/StepsForm/index.d.ts +0 -2
  44. package/dist/iframe/order-process/components/StepsForm/index.d.ts.map +0 -1
  45. package/dist/iframe/order-process/components/utils/category.d.ts +0 -10
  46. package/dist/iframe/order-process/components/utils/category.d.ts.map +0 -1
  47. package/dist/iframe/order-process/components/utils/category.js +0 -1
  48. package/src/iframe/order-process/OrderProcess.stories.tsx +0 -363
  49. package/src/iframe/order-process/components/StepsForm/StepsForm.tsx +0 -176
  50. package/src/iframe/order-process/components/StepsForm/index.ts +0 -1
  51. /package/dist/iframe/order-process/components/{CalendarStepsForm/components → ErrorModal}/ErrorModal.d.ts +0 -0
@@ -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";