@licklist/design 0.44.485-dev.90 → 0.44.485-dev.91
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/index.js +1 -1
- package/dist/sales/manual-booking/index.d.ts +1 -5
- package/dist/sales/manual-booking/index.d.ts.map +1 -1
- package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts +1 -0
- package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts.map +1 -1
- package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.js +1 -1
- package/dist/sales/manual-booking/search-user/SearchUser.js +1 -1
- package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts +3 -2
- package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts.map +1 -1
- package/dist/sales/manual-booking/select-menu/SelectMenu.js +1 -1
- package/dist/styles/sales/ManualBooking.scss +7 -1
- package/dist/types/iframe.d.ts +2 -0
- package/dist/types/iframe.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/sales/manual-booking/index.ts +1 -5
- package/src/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.tsx +3 -1
- package/src/sales/manual-booking/select-menu/SelectMenu.tsx +4 -2
- package/src/styles/sales/ManualBooking.scss +7 -1
- package/src/types/iframe.ts +2 -0
- package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts +0 -16
- package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts.map +0 -1
- package/dist/sales/manual-booking/category-product/CategoryProduct.js +0 -1
- package/dist/sales/manual-booking/category-product/index.d.ts +0 -2
- package/dist/sales/manual-booking/category-product/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts +0 -17
- package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts.map +0 -1
- package/dist/sales/manual-booking/category-products/CategoryProducts.js +0 -1
- package/dist/sales/manual-booking/category-products/index.d.ts +0 -2
- package/dist/sales/manual-booking/category-products/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts +0 -15
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts.map +0 -1
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.js +0 -1
- package/dist/sales/manual-booking/controll/index.d.ts +0 -2
- package/dist/sales/manual-booking/controll/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/create-user/CreateUser.d.ts +0 -6
- package/dist/sales/manual-booking/create-user/CreateUser.d.ts.map +0 -1
- package/dist/sales/manual-booking/create-user/CreateUser.js +0 -1
- package/dist/sales/manual-booking/create-user/index.d.ts +0 -2
- package/dist/sales/manual-booking/create-user/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/customer-info/CustomerInfo.d.ts +0 -7
- package/dist/sales/manual-booking/customer-info/CustomerInfo.d.ts.map +0 -1
- package/dist/sales/manual-booking/customer-info/CustomerInfo.js +0 -1
- package/dist/sales/manual-booking/customer-info/index.d.ts +0 -2
- package/dist/sales/manual-booking/customer-info/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/final-step/FinalStep.d.ts +0 -7
- package/dist/sales/manual-booking/final-step/FinalStep.d.ts.map +0 -1
- package/dist/sales/manual-booking/final-step/FinalStep.js +0 -1
- package/dist/sales/manual-booking/final-step/index.d.ts +0 -2
- package/dist/sales/manual-booking/final-step/index.d.ts.map +0 -1
- package/src/sales/manual-booking/category-product/CategoryProduct.tsx +0 -285
- package/src/sales/manual-booking/category-product/index.ts +0 -1
- package/src/sales/manual-booking/category-products/CategoryProducts.tsx +0 -69
- package/src/sales/manual-booking/category-products/index.ts +0 -1
- package/src/sales/manual-booking/controll/ManualBookingStepsControll.tsx +0 -121
- package/src/sales/manual-booking/controll/index.ts +0 -1
- package/src/sales/manual-booking/create-user/CreateUser.stories.tsx +0 -27
- package/src/sales/manual-booking/create-user/CreateUser.tsx +0 -224
- package/src/sales/manual-booking/create-user/index.ts +0 -1
- package/src/sales/manual-booking/customer-info/CustomerInfo.tsx +0 -128
- package/src/sales/manual-booking/customer-info/index.ts +0 -1
- package/src/sales/manual-booking/final-step/FinalStep.tsx +0 -38
- package/src/sales/manual-booking/final-step/index.ts +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,a=require("react-i18next"),n=require("react-hook-form"),o=require("../customer-info/CustomerInfo.js");exports.FinalStep=function(e){var t=e.providerId,l=a.useTranslation("Sale").t,s=n.useFormContext().control;return r.createElement(r.Fragment,null,r.createElement("div",{className:"manual-booking-header mt-6 mt-5 border-bottom"},r.createElement("div",{className:"manual-booking-title"},l("Sale:finalSteps"))),r.createElement(o.CustomerInfo,{providerId:t}),r.createElement(n.Controller,{control:s,name:"specialNotes",render:function(e){var t=e.field,a=t.onChange,n=t.value,o=t.ref;return r.createElement("div",{className:"special-notes-container"},r.createElement("div",{className:"margin-top-2-rem input-label "},l("specialNotes")),r.createElement("textarea",{rows:3,onChange:a,ref:o,value:n,className:"special-notes"}))}}))};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sales/manual-booking/final-step/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
|
|
3
|
-
import { useFormContext, Controller } from "react-hook-form";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
import { useTranslation } from "react-i18next";
|
|
6
|
-
import { OverlayTrigger, Tooltip } from "react-bootstrap";
|
|
7
|
-
import MediaService from "@licklist/plugins/dist/services/Media/MediaService";
|
|
8
|
-
import { OrderProduct } from "@licklist/core/dist/DataMapper/Order/OrderProductDataMapper";
|
|
9
|
-
import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
10
|
-
import { NumberInputHorizontal } from "../number-input-horizontal";
|
|
11
|
-
import { Product } from "../../../types";
|
|
12
|
-
import { TipTapEditor } from "../../../tiptap-editor";
|
|
13
|
-
|
|
14
|
-
interface CategoryProductProps {
|
|
15
|
-
product: Product;
|
|
16
|
-
fieldIndex: `steps.${number}.productCategories.${number}.products.${number}`;
|
|
17
|
-
productsWithErrors?: QuantityCheckProductInfo[];
|
|
18
|
-
isLoading?: boolean;
|
|
19
|
-
isEditMode?: boolean;
|
|
20
|
-
isProductSetAvailable?: boolean;
|
|
21
|
-
orderProducts?: OrderProduct[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const CategoryProduct = ({
|
|
25
|
-
product,
|
|
26
|
-
fieldIndex,
|
|
27
|
-
productsWithErrors,
|
|
28
|
-
isLoading = false,
|
|
29
|
-
isEditMode = false,
|
|
30
|
-
isProductSetAvailable = false,
|
|
31
|
-
orderProducts,
|
|
32
|
-
}: CategoryProductProps) => {
|
|
33
|
-
const { t } = useTranslation(["Design", "Validation"]);
|
|
34
|
-
const { control, clearErrors, setError } = useFormContext();
|
|
35
|
-
const [isEditingPrice, setEditingPrice] = useState(false);
|
|
36
|
-
const imageSrc = product.images
|
|
37
|
-
? MediaService.getImageSrc(product.images)
|
|
38
|
-
: null;
|
|
39
|
-
|
|
40
|
-
const currentProductMaxValue: number | undefined = useMemo(() => {
|
|
41
|
-
if (!orderProducts) return undefined;
|
|
42
|
-
|
|
43
|
-
const orderProduct = orderProducts.find(
|
|
44
|
-
(orderProduct) => orderProduct.productId === product.id
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
if (!orderProduct) return undefined;
|
|
48
|
-
|
|
49
|
-
return orderProduct.quantity;
|
|
50
|
-
}, [orderProducts, product.id]);
|
|
51
|
-
|
|
52
|
-
const onPriceClick = () => {
|
|
53
|
-
// disable change price when not edit mode
|
|
54
|
-
// and product isSoldOut or isLoading new data
|
|
55
|
-
if ((!isEditMode && product.isSoldOut) || isLoading) return;
|
|
56
|
-
|
|
57
|
-
setEditingPrice(true);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const productQuantityError = useMemo(() => {
|
|
61
|
-
if (!productsWithErrors) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const error = productsWithErrors.find(
|
|
66
|
-
(productWithError) => productWithError.product_id === product.id
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
return error?.message;
|
|
70
|
-
}, [productsWithErrors, product.id]);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (!productQuantityError) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setError(`${fieldIndex}.quantity`, {
|
|
78
|
-
message: productQuantityError,
|
|
79
|
-
type: "validate",
|
|
80
|
-
});
|
|
81
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
-
}, [productQuantityError]);
|
|
83
|
-
|
|
84
|
-
const PriceControl = ({ ref, onChange, value, invalid }) => (
|
|
85
|
-
<NumberInputHorizontal
|
|
86
|
-
ref={ref}
|
|
87
|
-
onChange={(val) => {
|
|
88
|
-
onChange(val);
|
|
89
|
-
// @TODO: change any to some type
|
|
90
|
-
clearErrors(`${fieldIndex}.price` as any);
|
|
91
|
-
}}
|
|
92
|
-
onMinusClick={() => {
|
|
93
|
-
onChange(value - 1 || 0);
|
|
94
|
-
// @TODO: change any to some type
|
|
95
|
-
clearErrors(`${fieldIndex}.price` as any);
|
|
96
|
-
}}
|
|
97
|
-
onPlusClick={() => {
|
|
98
|
-
onChange((value ?? 0) + 1);
|
|
99
|
-
// @TODO: change any to some type
|
|
100
|
-
clearErrors(`${fieldIndex}.price` as any);
|
|
101
|
-
}}
|
|
102
|
-
min={0}
|
|
103
|
-
disabled={
|
|
104
|
-
isLoading || (!isEditMode && product.isSoldOut) || !isEditingPrice
|
|
105
|
-
}
|
|
106
|
-
value={Number(value || 0)}
|
|
107
|
-
className={clsx(invalid && "error")}
|
|
108
|
-
isLoading={isLoading}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<>
|
|
114
|
-
<Controller
|
|
115
|
-
// @TODO: change any to some type
|
|
116
|
-
name={`${fieldIndex}.price` as any}
|
|
117
|
-
control={control}
|
|
118
|
-
render={({
|
|
119
|
-
field: { onChange, value, ref },
|
|
120
|
-
fieldState: { invalid, error },
|
|
121
|
-
}) => {
|
|
122
|
-
return (
|
|
123
|
-
<>
|
|
124
|
-
<div className="medium-accordition-description-container">
|
|
125
|
-
<TipTapEditor
|
|
126
|
-
viewMode
|
|
127
|
-
disabled
|
|
128
|
-
content={product.description}
|
|
129
|
-
editorStyle={{ backgroundColor: "transparent" }}
|
|
130
|
-
/>
|
|
131
|
-
{!product.isSoldOut ? (
|
|
132
|
-
<OverlayTrigger
|
|
133
|
-
key="status-tooltip"
|
|
134
|
-
placement="top"
|
|
135
|
-
overlay={
|
|
136
|
-
<Tooltip id="tooltip-right">
|
|
137
|
-
<span>{t("Sale:clickToEdit")}</span>
|
|
138
|
-
</Tooltip>
|
|
139
|
-
}
|
|
140
|
-
>
|
|
141
|
-
<div
|
|
142
|
-
role="button"
|
|
143
|
-
tabIndex={0}
|
|
144
|
-
onClick={onPriceClick}
|
|
145
|
-
onKeyDown={onPriceClick}
|
|
146
|
-
>
|
|
147
|
-
<PriceControl
|
|
148
|
-
ref={ref}
|
|
149
|
-
onChange={onChange}
|
|
150
|
-
value={value}
|
|
151
|
-
invalid={invalid}
|
|
152
|
-
/>
|
|
153
|
-
</div>
|
|
154
|
-
</OverlayTrigger>
|
|
155
|
-
) : (
|
|
156
|
-
<PriceControl
|
|
157
|
-
ref={ref}
|
|
158
|
-
onChange={onChange}
|
|
159
|
-
value={value}
|
|
160
|
-
invalid={invalid}
|
|
161
|
-
/>
|
|
162
|
-
)}
|
|
163
|
-
</div>
|
|
164
|
-
{invalid && (
|
|
165
|
-
<div className="d-flex mt-3 w-100">
|
|
166
|
-
<p className="iframe-event__message-error">
|
|
167
|
-
{error &&
|
|
168
|
-
HookFormService.hasError(error, "validate") &&
|
|
169
|
-
error?.message}
|
|
170
|
-
</p>
|
|
171
|
-
</div>
|
|
172
|
-
)}
|
|
173
|
-
</>
|
|
174
|
-
);
|
|
175
|
-
}}
|
|
176
|
-
/>
|
|
177
|
-
|
|
178
|
-
<Controller
|
|
179
|
-
control={control}
|
|
180
|
-
name={`${fieldIndex}.quantity` as string}
|
|
181
|
-
rules={{
|
|
182
|
-
validate: (value) => {
|
|
183
|
-
if (!value) return true;
|
|
184
|
-
|
|
185
|
-
const { maxAmount = 0, isUnlimited = false } = product;
|
|
186
|
-
|
|
187
|
-
// In case when we edit order and product set not
|
|
188
|
-
// available by current date we should check on
|
|
189
|
-
// max amount which equals orderProduct.quantity
|
|
190
|
-
// We should check this before all next validations
|
|
191
|
-
if (currentProductMaxValue !== undefined && isEditMode) {
|
|
192
|
-
if (isUnlimited && isProductSetAvailable) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!isProductSetAvailable && value > currentProductMaxValue) {
|
|
197
|
-
return t("Validation:quantityMaxNumber", {
|
|
198
|
-
max: currentProductMaxValue,
|
|
199
|
-
}) as string;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (isUnlimited) {
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (value > maxAmount) {
|
|
208
|
-
return t("Validation:quantityMaxNumber", {
|
|
209
|
-
max: product.maxAmount,
|
|
210
|
-
}) as string;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return true;
|
|
214
|
-
},
|
|
215
|
-
}}
|
|
216
|
-
render={({
|
|
217
|
-
field: { onChange, value, ref },
|
|
218
|
-
fieldState: { invalid, error },
|
|
219
|
-
}) => {
|
|
220
|
-
return (
|
|
221
|
-
<div className="mb-8">
|
|
222
|
-
<div className="quantity-container">
|
|
223
|
-
<div className="number-input-horizontal-wrapper">
|
|
224
|
-
<NumberInputHorizontal
|
|
225
|
-
ref={ref}
|
|
226
|
-
size="big"
|
|
227
|
-
onChange={(val) => {
|
|
228
|
-
onChange(val);
|
|
229
|
-
}}
|
|
230
|
-
onMinusClick={() => {
|
|
231
|
-
onChange(value - 1 || 0);
|
|
232
|
-
}}
|
|
233
|
-
onPlusClick={() => {
|
|
234
|
-
onChange((value ?? 0) + 1);
|
|
235
|
-
}}
|
|
236
|
-
min={0}
|
|
237
|
-
disabled={
|
|
238
|
-
isLoading ||
|
|
239
|
-
(!isEditMode && !isProductSetAvailable) ||
|
|
240
|
-
(product.isSoldOut && !isEditMode) ||
|
|
241
|
-
(isEditMode &&
|
|
242
|
-
currentProductMaxValue === undefined &&
|
|
243
|
-
!isProductSetAvailable)
|
|
244
|
-
}
|
|
245
|
-
value={value || 0}
|
|
246
|
-
className={clsx(invalid && "error")}
|
|
247
|
-
isLoading={isLoading}
|
|
248
|
-
/>
|
|
249
|
-
</div>
|
|
250
|
-
{imageSrc && (
|
|
251
|
-
<div
|
|
252
|
-
className={[
|
|
253
|
-
"image-wrapper",
|
|
254
|
-
product.isSoldOut && "opacity-50",
|
|
255
|
-
].join(" ")}
|
|
256
|
-
>
|
|
257
|
-
<img src={imageSrc} alt={product.name} />
|
|
258
|
-
</div>
|
|
259
|
-
)}
|
|
260
|
-
</div>
|
|
261
|
-
|
|
262
|
-
{invalid && (
|
|
263
|
-
<div className="d-flex mt-3 w-100">
|
|
264
|
-
<p className="iframe-event__message-error">
|
|
265
|
-
{error &&
|
|
266
|
-
HookFormService.hasError(error, "validate") &&
|
|
267
|
-
error?.message}
|
|
268
|
-
</p>
|
|
269
|
-
</div>
|
|
270
|
-
)}
|
|
271
|
-
|
|
272
|
-
{!isLoading && !isProductSetAvailable && (
|
|
273
|
-
<div className="d-flex mt-3 w-100">
|
|
274
|
-
<p className="iframe-event__message-error">
|
|
275
|
-
{t("Design:productIsNotAvailableForSelectedDate")}
|
|
276
|
-
</p>
|
|
277
|
-
</div>
|
|
278
|
-
)}
|
|
279
|
-
</div>
|
|
280
|
-
);
|
|
281
|
-
}}
|
|
282
|
-
/>
|
|
283
|
-
</>
|
|
284
|
-
);
|
|
285
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./CategoryProduct";
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { Accordion } from "react-bootstrap";
|
|
4
|
-
import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
5
|
-
import { OrderProduct } from "@licklist/core/dist/DataMapper/Order/OrderProductDataMapper";
|
|
6
|
-
import { CollapsibleInputGroup } from "../../../collapsible-input-group";
|
|
7
|
-
import { Product } from "../../../types";
|
|
8
|
-
import { CategoryProduct } from "../category-product/CategoryProduct";
|
|
9
|
-
|
|
10
|
-
interface CategoryProductsProps {
|
|
11
|
-
stepIndex: number;
|
|
12
|
-
categoryIndex: number;
|
|
13
|
-
products?: Product[];
|
|
14
|
-
productsWithErrors?: QuantityCheckProductInfo[];
|
|
15
|
-
isLoading?: boolean;
|
|
16
|
-
isEditMode?: boolean;
|
|
17
|
-
isProductSetAvailable?: boolean;
|
|
18
|
-
orderProducts?: OrderProduct[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const CategoryProducts = ({
|
|
22
|
-
products,
|
|
23
|
-
stepIndex,
|
|
24
|
-
categoryIndex,
|
|
25
|
-
productsWithErrors,
|
|
26
|
-
isLoading = false,
|
|
27
|
-
isEditMode = false,
|
|
28
|
-
isProductSetAvailable = false,
|
|
29
|
-
orderProducts,
|
|
30
|
-
}: CategoryProductsProps) => {
|
|
31
|
-
return (
|
|
32
|
-
<>
|
|
33
|
-
{products?.map((product, index) => {
|
|
34
|
-
const fieldIndex =
|
|
35
|
-
`steps.${stepIndex}.productCategories.${categoryIndex}.products.${index}` as const;
|
|
36
|
-
return (
|
|
37
|
-
<Accordion
|
|
38
|
-
defaultActiveKey="product"
|
|
39
|
-
key={product.id}
|
|
40
|
-
className="medium-accordition"
|
|
41
|
-
>
|
|
42
|
-
<CollapsibleInputGroup
|
|
43
|
-
description=""
|
|
44
|
-
alwaysOpen
|
|
45
|
-
eventKey="product"
|
|
46
|
-
label={
|
|
47
|
-
<div className="medium-accordition-header">
|
|
48
|
-
<div className="medium-accordition-title">
|
|
49
|
-
{product?.name}
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
}
|
|
53
|
-
>
|
|
54
|
-
<CategoryProduct
|
|
55
|
-
fieldIndex={fieldIndex}
|
|
56
|
-
product={product}
|
|
57
|
-
productsWithErrors={productsWithErrors}
|
|
58
|
-
isLoading={isLoading}
|
|
59
|
-
isEditMode={isEditMode}
|
|
60
|
-
isProductSetAvailable={isProductSetAvailable}
|
|
61
|
-
orderProducts={orderProducts}
|
|
62
|
-
/>
|
|
63
|
-
</CollapsibleInputGroup>
|
|
64
|
-
</Accordion>
|
|
65
|
-
);
|
|
66
|
-
})}
|
|
67
|
-
</>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./CategoryProducts";
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { Accordion } from "react-bootstrap";
|
|
3
|
-
import { useFormContext } from "react-hook-form";
|
|
4
|
-
import { useTranslation } from "react-i18next";
|
|
5
|
-
import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
6
|
-
import { OrderProduct } from "@licklist/core/dist/DataMapper/Order/OrderProductDataMapper";
|
|
7
|
-
import { ErrorModal } from "../../../iframe/order-process/components/ErrorModal/ErrorModal";
|
|
8
|
-
import { MenuStep } from "../../../types";
|
|
9
|
-
import { CollapsibleInputGroup } from "../../../collapsible-input-group";
|
|
10
|
-
import { CategoryProducts } from "../category-products/CategoryProducts";
|
|
11
|
-
|
|
12
|
-
export interface ManualBookingStepsControllProps {
|
|
13
|
-
step: MenuStep;
|
|
14
|
-
stepIndex: number;
|
|
15
|
-
productsWithErrors?: QuantityCheckProductInfo[];
|
|
16
|
-
isLoading?: boolean;
|
|
17
|
-
isEditMode?: boolean;
|
|
18
|
-
isProductSetAvailable?: boolean;
|
|
19
|
-
orderProducts?: OrderProduct[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const ManualBookingStepsControll = ({
|
|
23
|
-
step,
|
|
24
|
-
stepIndex,
|
|
25
|
-
productsWithErrors,
|
|
26
|
-
isLoading = false,
|
|
27
|
-
isEditMode = false,
|
|
28
|
-
isProductSetAvailable = false,
|
|
29
|
-
orderProducts,
|
|
30
|
-
}: ManualBookingStepsControllProps) => {
|
|
31
|
-
const {
|
|
32
|
-
formState: { errors },
|
|
33
|
-
} = useFormContext();
|
|
34
|
-
const { t } = useTranslation(["Design"]);
|
|
35
|
-
const stepError =
|
|
36
|
-
errors && errors?.steps ? errors?.steps[stepIndex] : undefined;
|
|
37
|
-
|
|
38
|
-
const [showProductQuatityError, setShowProductQuantityError] =
|
|
39
|
-
useState(false);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (!productsWithErrors) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
setShowProductQuantityError(true);
|
|
46
|
-
}, [productsWithErrors]);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Accordion key={step.id} defaultActiveKey="step">
|
|
50
|
-
<ErrorModal
|
|
51
|
-
isOpen={showProductQuatityError}
|
|
52
|
-
onClose={() => setShowProductQuantityError(false)}
|
|
53
|
-
messageKey="pleaseCheckSelectedProducts"
|
|
54
|
-
/>
|
|
55
|
-
<CollapsibleInputGroup
|
|
56
|
-
alwaysOpen
|
|
57
|
-
description=""
|
|
58
|
-
eventKey="step"
|
|
59
|
-
label={
|
|
60
|
-
<>
|
|
61
|
-
<div className="step-title">{step?.name}</div>
|
|
62
|
-
{stepError && (
|
|
63
|
-
<div className="d-flex mt-3 w-100">
|
|
64
|
-
<p className="iframe-event__message-error mb-0">
|
|
65
|
-
{t("notValidStep")}
|
|
66
|
-
</p>
|
|
67
|
-
</div>
|
|
68
|
-
)}
|
|
69
|
-
</>
|
|
70
|
-
}
|
|
71
|
-
>
|
|
72
|
-
{step.productCategories.map((productCategory, categoryIndex) => {
|
|
73
|
-
const categoryError =
|
|
74
|
-
stepError && stepError?.productCategories
|
|
75
|
-
? stepError?.productCategories[categoryIndex]
|
|
76
|
-
: undefined;
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<Accordion
|
|
80
|
-
key={productCategory.id}
|
|
81
|
-
defaultActiveKey={
|
|
82
|
-
step.productCategories.length === 1 ? "categories" : undefined
|
|
83
|
-
}
|
|
84
|
-
>
|
|
85
|
-
<CollapsibleInputGroup
|
|
86
|
-
description=""
|
|
87
|
-
eventKey="categories"
|
|
88
|
-
alwaysOpen={step.productCategories.length === 1}
|
|
89
|
-
label={
|
|
90
|
-
<>
|
|
91
|
-
<div className="category-title">
|
|
92
|
-
{productCategory?.name}
|
|
93
|
-
</div>
|
|
94
|
-
{categoryError && (
|
|
95
|
-
<div className="d-flex mt-3 w-100">
|
|
96
|
-
<p className="iframe-event__message-error mb-0">
|
|
97
|
-
{t("notValidCategory")}
|
|
98
|
-
</p>
|
|
99
|
-
</div>
|
|
100
|
-
)}
|
|
101
|
-
</>
|
|
102
|
-
}
|
|
103
|
-
>
|
|
104
|
-
<CategoryProducts
|
|
105
|
-
products={productCategory?.products}
|
|
106
|
-
stepIndex={stepIndex}
|
|
107
|
-
categoryIndex={categoryIndex}
|
|
108
|
-
productsWithErrors={productsWithErrors}
|
|
109
|
-
isLoading={isLoading}
|
|
110
|
-
isEditMode={isEditMode}
|
|
111
|
-
isProductSetAvailable={isProductSetAvailable}
|
|
112
|
-
orderProducts={orderProducts}
|
|
113
|
-
/>
|
|
114
|
-
</CollapsibleInputGroup>
|
|
115
|
-
</Accordion>
|
|
116
|
-
);
|
|
117
|
-
})}
|
|
118
|
-
</CollapsibleInputGroup>
|
|
119
|
-
</Accordion>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./ManualBookingStepsControll";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Meta } from "@storybook/react";
|
|
3
|
-
import { useForm, FormProvider } from "react-hook-form";
|
|
4
|
-
import { Form } from "react-bootstrap";
|
|
5
|
-
import { CreateUser } from "./CreateUser";
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: "Sales/ManualBooking/CreateUser",
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
export const Default = (args) => {
|
|
12
|
-
const form = useForm({ mode: "onChange" });
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<FormProvider {...form}>
|
|
16
|
-
<Form>
|
|
17
|
-
<div style={{ height: "550px" }}>
|
|
18
|
-
<CreateUser {...args} />
|
|
19
|
-
</div>
|
|
20
|
-
</Form>
|
|
21
|
-
</FormProvider>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
Default.args = {
|
|
26
|
-
goToSearchUsers: () => {},
|
|
27
|
-
};
|