@licklist/design 0.66.12 → 0.66.13
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/edit-event-modal/utils/getDefaultProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/utils/getDefaultProductSet.js +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +1 -1
- package/dist/index.js +1 -1
- package/dist/layout/DropDown.d.ts.map +1 -1
- package/dist/layout/DropDown.js +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +1 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductCategoriesControl.js +1 -1
- package/dist/product-set/form/ProductZonesControl.d.ts +10 -0
- package/dist/product-set/form/ProductZonesControl.d.ts.map +1 -0
- package/dist/product-set/form/ProductZonesControl.js +1 -0
- package/dist/product-set/form/ProductsControl.d.ts +1 -3
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +1 -1
- package/dist/product-set/form/SubProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/VenueMapsControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.d.ts +5 -8
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/product-set/product/advanced-options/AdvancedOptions.d.ts +9 -0
- package/dist/product-set/product/advanced-options/AdvancedOptions.d.ts.map +1 -0
- package/dist/product-set/product/advanced-options/AdvancedOptions.js +1 -0
- package/dist/product-set/product/advanced-options/index.d.ts +2 -0
- package/dist/product-set/product/advanced-options/index.d.ts.map +1 -0
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.js +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.d.ts +0 -2
- package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
- package/dist/product-set/product-zone/ProductZoneControl.d.ts +16 -0
- package/dist/product-set/product-zone/ProductZoneControl.d.ts.map +1 -0
- package/dist/product-set/product-zone/ProductZoneControl.js +1 -0
- package/dist/product-set/product-zone/index.d.ts +2 -0
- package/dist/product-set/product-zone/index.d.ts.map +1 -0
- package/dist/product-set/utils/index.d.ts.map +1 -1
- package/dist/product-set/utils/index.js +1 -1
- package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
- package/dist/snippet/snippet-template/preview/Preview.js +1 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts +3 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.js +1 -1
- package/dist/styles/product-set/CreateProductSetItem.scss +8 -0
- package/dist/styles/product-set/EditZoneSettingModal.scss +16 -0
- package/dist/styles/product-set/ProductSetForm.scss +14 -1
- package/dist/styles/product-set/_index.scss +2 -1
- package/package.json +4 -4
- package/src/events/edit-event-modal/utils/getDefaultProductSet.ts +2 -4
- package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +0 -1
- package/src/layout/DropDown.tsx +1 -1
- package/src/product-set/control/ProductSetControl.tsx +11 -6
- package/src/product-set/form/ProductCategoriesControl.tsx +0 -3
- package/src/product-set/form/ProductZonesControl.tsx +181 -0
- package/src/product-set/form/ProductsControl.tsx +8 -24
- package/src/product-set/form/SubProductsControl.tsx +3 -0
- package/src/product-set/form/VenueMapsControl.tsx +3 -0
- package/src/product-set/product/ProductControl.tsx +23 -268
- package/src/product-set/product/advanced-options/AdvancedOptions.tsx +168 -0
- package/src/product-set/product/advanced-options/index.ts +1 -0
- package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +1 -1
- package/src/product-set/product-category/ProductCategoryControl.tsx +1 -60
- package/src/product-set/product-zone/ProductZoneControl.tsx +247 -0
- package/src/product-set/product-zone/index.ts +1 -0
- package/src/product-set/utils/index.ts +9 -5
- package/src/snippet/snippet-template/preview/Preview.tsx +0 -6
- package/src/sortable-tree/SortableTreeItem.tsx +59 -45
- package/src/styles/product-set/CreateProductSetItem.scss +8 -0
- package/src/styles/product-set/EditZoneSettingModal.scss +16 -0
- package/src/styles/product-set/ProductSetForm.scss +14 -1
- package/src/styles/product-set/_index.scss +2 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import React, { useContext, useState } from "react";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
ArrayPath,
|
|
7
|
+
Controller,
|
|
8
|
+
Path,
|
|
9
|
+
useFieldArray,
|
|
10
|
+
useFormContext,
|
|
11
|
+
useWatch,
|
|
12
|
+
} from "react-hook-form";
|
|
13
|
+
import { Badge } from "react-bootstrap";
|
|
14
|
+
import { CategoryType } from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
|
|
15
|
+
import { HookFormService } from "@licklist/plugins";
|
|
16
|
+
import { useTranslation } from "react-i18next";
|
|
17
|
+
import {
|
|
18
|
+
FieldNamePrefixPath,
|
|
19
|
+
FormValues,
|
|
20
|
+
} from "@licklist/plugins/dist/types/services/Form/hook-form-service";
|
|
21
|
+
import { ProductSetLoadingContext } from "./context";
|
|
22
|
+
import { useSortableTreeFunctions } from "../hooks/useSortableTreeFunctions";
|
|
23
|
+
import { ProductZoneControl, ProductZoneControlValues } from "../product-zone";
|
|
24
|
+
import { CreateProductSetItem } from "../item/CreateProductSetItem";
|
|
25
|
+
import { SortableTree } from "../../sortable-tree";
|
|
26
|
+
import { ProductSetModalClasses } from "../../sortable-tree/SortableTreeItem";
|
|
27
|
+
|
|
28
|
+
interface ProductZonesControlProps<T> extends FieldNamePrefixPath<T> {
|
|
29
|
+
isOverrides: boolean;
|
|
30
|
+
categoryType?: CategoryType;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getDefaultProductZone = (): ProductZoneControlValues => ({
|
|
34
|
+
id: null,
|
|
35
|
+
zoneId: null,
|
|
36
|
+
capacity: null,
|
|
37
|
+
duration: null,
|
|
38
|
+
subSlots: null,
|
|
39
|
+
offset: null,
|
|
40
|
+
pause: null,
|
|
41
|
+
serviceTime: null,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const ProductZonesControl = <T extends FormValues>({
|
|
45
|
+
isOverrides,
|
|
46
|
+
fieldNamePrefix,
|
|
47
|
+
categoryType,
|
|
48
|
+
}: ProductZonesControlProps<T>) => {
|
|
49
|
+
const [showProductZoneModal, setShowProductZoneModal] = useState(false);
|
|
50
|
+
const { t } = useTranslation(["Design", "Validation", "ProductSet"]);
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
control,
|
|
54
|
+
formState: { errors },
|
|
55
|
+
trigger,
|
|
56
|
+
clearErrors,
|
|
57
|
+
} = useFormContext<T>();
|
|
58
|
+
|
|
59
|
+
const productZonesFieldName =
|
|
60
|
+
`${fieldNamePrefix}.productZones` as ArrayPath<T>;
|
|
61
|
+
|
|
62
|
+
const { fields, append, remove } = useFieldArray({
|
|
63
|
+
name: productZonesFieldName,
|
|
64
|
+
control,
|
|
65
|
+
keyName: "_id",
|
|
66
|
+
rules: {
|
|
67
|
+
required: t("Validation:fieldMinNumber", {
|
|
68
|
+
attribute: t("zones"),
|
|
69
|
+
min: 1,
|
|
70
|
+
}) as string,
|
|
71
|
+
minLength: 1,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const { zones = [] } = useContext(ProductSetLoadingContext);
|
|
76
|
+
|
|
77
|
+
const { edit, saveValidField, cancelChanges } = useSortableTreeFunctions({
|
|
78
|
+
fieldName: productZonesFieldName,
|
|
79
|
+
remove,
|
|
80
|
+
isOverrides,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const productZonesError = HookFormService.getErrors<T>(
|
|
84
|
+
`${productZonesFieldName}.root` as Path<T>,
|
|
85
|
+
errors
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const zoneCapacity = useWatch({
|
|
89
|
+
control,
|
|
90
|
+
name: [
|
|
91
|
+
...fields.map(
|
|
92
|
+
(_, index) => `${productZonesFieldName}.${index}.capacity` as const
|
|
93
|
+
),
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const zoneDuration = useWatch({
|
|
98
|
+
control,
|
|
99
|
+
name: [
|
|
100
|
+
...fields.map(
|
|
101
|
+
(_, index) => `${productZonesFieldName}.${index}.duration` as const
|
|
102
|
+
),
|
|
103
|
+
],
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const onZoneSettingRemove = (index: number) => {
|
|
107
|
+
remove(index);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
{fields.map((productZones, index) => (
|
|
113
|
+
<Controller
|
|
114
|
+
key={productZones._id}
|
|
115
|
+
control={control}
|
|
116
|
+
name={`${productZonesFieldName}.${index}.zoneId` as const}
|
|
117
|
+
rules={{
|
|
118
|
+
required: t("Validation:fieldRequired", {
|
|
119
|
+
attribute: t("zone"),
|
|
120
|
+
}) as string,
|
|
121
|
+
}}
|
|
122
|
+
render={({ field: { value } }) => (
|
|
123
|
+
<SortableTree.Item
|
|
124
|
+
key={`productZones-${productZones._id}`}
|
|
125
|
+
id={String(productZones._id)}
|
|
126
|
+
title={zones.find((zone) => zone.id === Number(value))?.name}
|
|
127
|
+
badge={
|
|
128
|
+
<Badge className="product-zone-badge">{t("productZone")}</Badge>
|
|
129
|
+
}
|
|
130
|
+
isIconInHeader={false}
|
|
131
|
+
cancelChanges={() => cancelChanges(index)}
|
|
132
|
+
edit={() => edit(index)}
|
|
133
|
+
subTitle={
|
|
134
|
+
<div className="product-set-badges-container">
|
|
135
|
+
<div className="product-set-subtitle-dot product-set-subtitle-product-dot" />
|
|
136
|
+
<span>
|
|
137
|
+
{zoneCapacity[index] &&
|
|
138
|
+
`${t("Cap")}: ${zoneCapacity[index]}; `}
|
|
139
|
+
{`${t("Dur")}: ${zoneDuration[index]}`}
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
}
|
|
143
|
+
modalLabel={t("addAZone")}
|
|
144
|
+
modalClass={ProductSetModalClasses.productZones}
|
|
145
|
+
isNewAdded={showProductZoneModal}
|
|
146
|
+
shouldExpand={false}
|
|
147
|
+
body={
|
|
148
|
+
<ProductZoneControl
|
|
149
|
+
isOverrides={isOverrides}
|
|
150
|
+
categoryType={categoryType}
|
|
151
|
+
productZonesFieldName={productZonesFieldName}
|
|
152
|
+
fieldNamePrefix={
|
|
153
|
+
`${productZonesFieldName}.${index}` as Path<T>
|
|
154
|
+
}
|
|
155
|
+
/>
|
|
156
|
+
}
|
|
157
|
+
onDelete={() => onZoneSettingRemove(index)}
|
|
158
|
+
validate={() => trigger(`${productZonesFieldName}.${index}`)}
|
|
159
|
+
saveValidField={saveValidField}
|
|
160
|
+
/>
|
|
161
|
+
)}
|
|
162
|
+
/>
|
|
163
|
+
))}
|
|
164
|
+
<CreateProductSetItem
|
|
165
|
+
title={t("addZone")}
|
|
166
|
+
onClick={() => {
|
|
167
|
+
// @TODO after updating react hook form fix issue with this type
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
169
|
+
// @ts-expect-error
|
|
170
|
+
append(getDefaultProductZone());
|
|
171
|
+
setShowProductZoneModal(true);
|
|
172
|
+
|
|
173
|
+
if (productZonesError) {
|
|
174
|
+
clearErrors(productZonesFieldName);
|
|
175
|
+
}
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
<div className="manual-form-error">{productZonesError}</div>
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
@@ -14,7 +14,6 @@ import { generateUuid } from "@licklist/core/dist/Services";
|
|
|
14
14
|
import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
|
|
15
15
|
|
|
16
16
|
import { CategoryType } from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
|
|
17
|
-
import { Zone } from "@licklist/core/dist/DataMapper/Provider/ZoneDataMapper";
|
|
18
17
|
import { ProductControl, ProductControlProps, ProductSetFormValues } from "..";
|
|
19
18
|
import { SortableTree } from "../../sortable-tree";
|
|
20
19
|
import { CreateProductSetItem } from "../item/CreateProductSetItem";
|
|
@@ -33,7 +32,6 @@ interface ProductsControlProps extends WithIsLoading {
|
|
|
33
32
|
productCategoryIndex: number;
|
|
34
33
|
hasTicket?: boolean;
|
|
35
34
|
categoryType: CategoryType;
|
|
36
|
-
zones?: Zone[];
|
|
37
35
|
isOverrides?: boolean;
|
|
38
36
|
isEventEditProductSet?: boolean;
|
|
39
37
|
isCreateNewOverrides?: boolean;
|
|
@@ -50,8 +48,6 @@ const getDefaultProductValue = (sort: number): Product => ({
|
|
|
50
48
|
minQuantity: null,
|
|
51
49
|
maxQuantity: null,
|
|
52
50
|
totalQuantity: 0,
|
|
53
|
-
capacity: 0,
|
|
54
|
-
duration: 0,
|
|
55
51
|
isAvailable: true,
|
|
56
52
|
isSoldOut: false,
|
|
57
53
|
isRequired: false,
|
|
@@ -62,14 +58,9 @@ const getDefaultProductValue = (sort: number): Product => ({
|
|
|
62
58
|
originalProductId: null,
|
|
63
59
|
type: DEFAULT_PRODUCT_TYPE,
|
|
64
60
|
tierId: Number(uniqueId()),
|
|
65
|
-
zoneId: null,
|
|
66
61
|
subProducts: [],
|
|
67
62
|
images: [],
|
|
68
63
|
uuid: generateUuid(),
|
|
69
|
-
subSlots: null,
|
|
70
|
-
offset: null,
|
|
71
|
-
pause: null,
|
|
72
|
-
serviceTime: null,
|
|
73
64
|
sort,
|
|
74
65
|
});
|
|
75
66
|
|
|
@@ -80,7 +71,6 @@ export function ProductsControl({
|
|
|
80
71
|
productCategoryIndex,
|
|
81
72
|
hasTicket,
|
|
82
73
|
categoryType,
|
|
83
|
-
zones,
|
|
84
74
|
isOverrides,
|
|
85
75
|
isEventEditProductSet,
|
|
86
76
|
isCreateNewOverrides,
|
|
@@ -99,12 +89,6 @@ export function ProductsControl({
|
|
|
99
89
|
getValues,
|
|
100
90
|
} = form;
|
|
101
91
|
|
|
102
|
-
const zoneId = watch(
|
|
103
|
-
`steps.${stepIndex}.productCategories.${productCategoryIndex}.zoneId`
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const catergoryZone = zones?.find((zone) => zone.id === Number(zoneId));
|
|
107
|
-
|
|
108
92
|
const productControlFieldName =
|
|
109
93
|
`steps.${stepIndex}.productCategories.${productCategoryIndex}.products` as const;
|
|
110
94
|
|
|
@@ -123,7 +107,7 @@ export function ProductsControl({
|
|
|
123
107
|
});
|
|
124
108
|
|
|
125
109
|
const allowDeposits = watch(
|
|
126
|
-
`steps.${stepIndex}.productCategories.${productCategoryIndex}.allowDeposits
|
|
110
|
+
`steps.${stepIndex}.productCategories.${productCategoryIndex}.allowDeposits`,
|
|
127
111
|
);
|
|
128
112
|
|
|
129
113
|
// watch is required to get a reactive value of the required fields
|
|
@@ -131,7 +115,7 @@ export function ProductsControl({
|
|
|
131
115
|
control,
|
|
132
116
|
name: [
|
|
133
117
|
...fields.map(
|
|
134
|
-
(_, index) => `${productControlFieldName}.${index}.price` as const
|
|
118
|
+
(_, index) => `${productControlFieldName}.${index}.price` as const,
|
|
135
119
|
),
|
|
136
120
|
],
|
|
137
121
|
});
|
|
@@ -140,7 +124,7 @@ export function ProductsControl({
|
|
|
140
124
|
name: [
|
|
141
125
|
...fields.map(
|
|
142
126
|
(_, index) =>
|
|
143
|
-
`${productControlFieldName}.${index}.totalQuantity` as const
|
|
127
|
+
`${productControlFieldName}.${index}.totalQuantity` as const,
|
|
144
128
|
),
|
|
145
129
|
],
|
|
146
130
|
});
|
|
@@ -149,7 +133,8 @@ export function ProductsControl({
|
|
|
149
133
|
control,
|
|
150
134
|
name: [
|
|
151
135
|
...fields.map(
|
|
152
|
-
(_, index) =>
|
|
136
|
+
(_, index) =>
|
|
137
|
+
`${productControlFieldName}.${index}.isUnlimited` as const,
|
|
153
138
|
),
|
|
154
139
|
],
|
|
155
140
|
});
|
|
@@ -187,7 +172,7 @@ export function ProductsControl({
|
|
|
187
172
|
const onProductRemove = (index: number) => {
|
|
188
173
|
if (isOverrides) return;
|
|
189
174
|
const currentProduct = getValues(
|
|
190
|
-
`${productControlFieldName}.${index}` as const
|
|
175
|
+
`${productControlFieldName}.${index}` as const,
|
|
191
176
|
);
|
|
192
177
|
|
|
193
178
|
const currentPointProducts = getValues(productPointsKey);
|
|
@@ -195,8 +180,8 @@ export function ProductsControl({
|
|
|
195
180
|
setValue(
|
|
196
181
|
productPointsKey,
|
|
197
182
|
currentPointProducts?.filter(
|
|
198
|
-
(product) => product.productUuid !== currentProduct.uuid
|
|
199
|
-
) || []
|
|
183
|
+
(product) => product.productUuid !== currentProduct.uuid,
|
|
184
|
+
) || [],
|
|
200
185
|
);
|
|
201
186
|
remove(index);
|
|
202
187
|
};
|
|
@@ -274,7 +259,6 @@ export function ProductsControl({
|
|
|
274
259
|
onProductNameChange={onChange}
|
|
275
260
|
hasTicket={hasTicket}
|
|
276
261
|
categoryType={categoryType}
|
|
277
|
-
zoneDuration={catergoryZone?.defaultDuration}
|
|
278
262
|
isOverrides={
|
|
279
263
|
isNewProductOverrides || isOverridesProductSet
|
|
280
264
|
}
|
|
@@ -71,6 +71,9 @@ export function SubProductsControl({
|
|
|
71
71
|
name: `${subProduct.name} copy`,
|
|
72
72
|
images: subProducts[index]?.images as Image[],
|
|
73
73
|
};
|
|
74
|
+
// @TODO fix prod type error
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
|
+
// @ts-ignore
|
|
74
77
|
append(subProductCopy);
|
|
75
78
|
}}
|
|
76
79
|
/>
|
|
@@ -48,6 +48,9 @@ export const VenueMapsControl = ({
|
|
|
48
48
|
url={image.url}
|
|
49
49
|
name={name}
|
|
50
50
|
points={points}
|
|
51
|
+
// @TODO fix prod type error
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
53
|
+
// @ts-ignore
|
|
51
54
|
products={products}
|
|
52
55
|
pointProducts={pointProducts}
|
|
53
56
|
onPointProductsChange={onPointProductsChange}
|