@licklist/design 0.66.4 → 0.66.6
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/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
- 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/page/components/PageBody/PageBody.d.ts +1 -1
- package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.d.ts +2 -1
- package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.d.ts.map +1 -1
- package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.js +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts +2 -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 +3 -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/ProductSetForm.d.ts +2 -1
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +1 -1
- package/dist/product-set/form/ProductsControl.d.ts +3 -1
- 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/StepsControl.d.ts +3 -1
- package/dist/product-set/form/StepsControl.d.ts.map +1 -1
- package/dist/product-set/form/StepsControl.js +1 -1
- package/dist/product-set/product/ProductControl.d.ts +1 -0
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/product-set/step/StepControl.d.ts +2 -1
- package/dist/product-set/step/StepControl.d.ts.map +1 -1
- package/dist/product-set/step/StepControl.js +1 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts +1 -2
- package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.js +1 -1
- package/package.json +5 -4
- package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +8 -1
- package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +1 -0
- package/src/events/edit-event-modal/utils/getDefaultProductSet.ts +1 -0
- package/src/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.tsx +8 -2
- package/src/product-set/control/ProductSetControl.tsx +10 -3
- package/src/product-set/form/ProductCategoriesControl.tsx +15 -4
- package/src/product-set/form/ProductSetForm.tsx +3 -0
- package/src/product-set/form/ProductsControl.tsx +93 -77
- package/src/product-set/form/StepsControl.tsx +15 -7
- package/src/product-set/product/ProductControl.tsx +2 -2
- package/src/product-set/step/StepControl.tsx +4 -3
- package/src/sortable-tree/SortableTreeItem.tsx +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),r=require("react-i18next"),l=require("react-bootstrap"),s=require("../static/Icon.js"),o=e(require("clsx")),i=require("@dnd-kit/core"),c=require("@dnd-kit/sortable"),d=require("@dnd-kit/utilities"),m=require("../modals/confirmation/ConfirmModal.js");require("../modals/dialog/Dialog.js"),require("../modals/dialog/DialogContext.js");var u=require("../product-set/elements/DeleteFieldButton.js"),p={step:"edit-product-step",category:"edit-product-category",product:"edit-product"};exports.ProductSetModalClasses=p,exports.SortableTreeItem=function(e){var b=this,g=e.id,v=e.title,E=e.badge,f=e.subTitle,N=e.body,y=e.children,h=e.preItem,C=e.postItem,w=e.sortableItems,_=e.isExpanded,x=void 0!==_&&_,D=e.isInvalid,S=void 0!==D&&D,q=e.isIconInHeader,M=void 0===q||q,k=e.treeLineIconColor,I=void 0===k?"":k,B=e.modalLabel,j=void 0===B?"":B,P=e.modalClass,T=e.isNewAdded,X=void 0!==T&&T,Y=e.onDelete,A=e.validate,F=e.cancelChanges,L=e.saveValidField,R=e.edit,U=e.secondaryBadge,V=e.setIsExpanded,z=e.isOverride,H=
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),r=require("react-i18next"),l=require("react-bootstrap"),s=require("../static/Icon.js"),o=e(require("clsx")),i=require("@dnd-kit/core"),c=require("@dnd-kit/sortable"),d=require("@dnd-kit/utilities"),m=require("../modals/confirmation/ConfirmModal.js");require("../modals/dialog/Dialog.js"),require("../modals/dialog/DialogContext.js");var u=require("../product-set/elements/DeleteFieldButton.js"),p={step:"edit-product-step",category:"edit-product-category",product:"edit-product"};exports.ProductSetModalClasses=p,exports.SortableTreeItem=function(e){var b=this,g=e.id,v=e.title,E=e.badge,f=e.subTitle,N=e.body,y=e.children,h=e.preItem,C=e.postItem,w=e.sortableItems,_=e.isExpanded,x=void 0!==_&&_,D=e.isInvalid,S=void 0!==D&&D,q=e.isIconInHeader,M=void 0===q||q,k=e.treeLineIconColor,I=void 0===k?"":k,B=e.modalLabel,j=void 0===B?"":B,P=e.modalClass,T=e.isNewAdded,X=void 0!==T&&T,Y=e.onDelete,A=e.validate,F=e.cancelChanges,L=e.saveValidField,R=e.edit,U=e.secondaryBadge,V=e.setIsExpanded,z=e.isOverride,H=t.__read(a.useState(x),2),K=H[0],O=H[1],G=t.__read(a.useState(X),2),J=G[0],Q=G[1],W=r.useTranslation("Design").t,Z=c.useSortable({id:g}),$=Z.attributes,ee=Z.listeners,te=Z.setNodeRef,ae=Z.transform,ne=Z.transition,re=t.__read(a.useState({pageX:0,pageY:0}),2),le=re[0],se=re[1],oe=i.useDraggable({id:g,disabled:z}),ie=oe.isDragging,ce=oe.attributes,de=oe.listeners,me=oe.setNodeRef,ue=oe.transform,pe=a.useCallback((function(e){var t=e.pageX-le.pageX,a=e.pageY-le.pageY;Math.sqrt(t*t+a*a)>5||(V?V():O((function(e){return!e})))}),[le,V]),be=Boolean(Y)&&!z,ge=a.useCallback((function(e){se({pageX:e.pageX,pageY:e.pageY})}),[]),ve=function(){return t.__awaiter(b,void 0,void 0,(function(){return t.__generator(this,(function(e){switch(e.label){case 0:return A||Q(!1),[4,null==A?void 0:A()];case 1:return e.sent()&&(L&&L(),Q(!1)),[2]}}))}))};return a.useEffect((function(){O(x)}),[x]),n.createElement("div",t.__assign({className:"sortable-tree-root",style:{transform:d.CSS.Translate.toString(ae),transition:ne}},ce,de,{ref:te}),n.createElement("div",t.__assign({className:"sortable-tree-wrapper",ref:me},ce,de,{onKeyDown:function(e){return e.stopPropagation()},onMouseDown:function(e){J&&e.stopPropagation()},onMouseUp:function(e){J&&e.stopPropagation()},role:"button",tabIndex:0,style:P===p.step?{transform:d.CSS.Translate.toString(ue),opacity:ie?.7:1}:null}),n.createElement("div",{className:"sortable-tree-line"},n.createElement(l.Button,{variant:"link",size:"sm",onMouseDown:ge,onMouseUp:pe},K?n.createElement(s.default,{type:"minus",width:".7rem"}):n.createElement("div",{className:"expand-icon-container"},n.createElement("div",null),n.createElement("div",null),n.createElement("div",null))),K&&n.createElement("svg",{className:"sortable-tree-line-icon",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none"},n.createElement("g",null,n.createElement("path",{className:o("sortable-tree-line-icon-path",I&&"sortable-tree-line-product-element"),style:{stroke:I},d:"M 50 0 V 100"})))),n.createElement("div",{className:"sortable-tree-item-wrapper"},n.createElement("div",{className:o("sortable-tree-item",S?"invalid":"")},n.createElement("div",{className:"sortable-tree-item-header"},M&&n.createElement(l.Button,t.__assign({variant:"link",className:"sortable-tree-item-handle"},$,ee),n.createElement(s.default,{type:"grip-vertical"})),n.createElement(l.Button,{className:"sortable-tree-item-toggle",variant:"link",onMouseDown:ge,onMouseUp:pe},E&&n.createElement("span",{className:"sortable-tree-item-badge"},E),n.createElement("div",{className:o(j?"sortable-tree-product-set-title-container":"sortable-tree-title-container")},n.createElement("span",{className:o("sortable-tree-item-title",j&&"sortable-tree-product-set-element-title")},v),!K&&n.createElement("span",{className:"sortable-tree-item-subtitle"},f)),n.createElement("div",{className:"border-0 open-edit-right-modal-button",role:"button",tabIndex:0,onClick:function(e){return function(e){e.stopPropagation(),R&&!J&&R(),Q(!0)}(e)},onKeyDown:function(e){return e.stopPropagation()}},n.createElement(s.default,{type:"ellipsis-h",color:"#0E8CE2",height:"1rem"})))),M?n.createElement(l.Collapse,{in:K},n.createElement("div",null,n.createElement("div",{className:"sortable-tree-item-body"},N))):n.createElement(l.Modal,{size:"lg",show:J,className:o("m-0 edit-product-set-element-modal edit-right-form-modal h-100",P),dialogClassName:"edit-event-dialog edit-step-dialog",onHide:ve},n.createElement("div",{className:"edit-step-modal-header"},n.createElement("button",{className:"p-0 cancel-add-step-btn border-0",type:"button",onClick:function(){F?(F(),Q(!1)):ve()}},n.createElement("span",null,W("Design:cancel"))),U&&n.createElement("div",{className:"secondary-badge ".concat(null==U?void 0:U.className)},null==U?void 0:U.label)),n.createElement(l.Modal.Body,{as:"form",noValidate:!0},n.createElement("div",{className:"top-label-container"},n.createElement("span",null,j)),N,n.createElement("div",{className:"d-flex product-set-element-control-btns justify-content-between"},n.createElement(l.Button,{className:"step-save-btn mt-4",type:"button",onClick:ve},W("saveAndAdd")),be&&n.createElement("div",{className:"d-flex justify-content-end mt-4 delete-btn"},n.createElement(m.ConfirmModal,null,(function(e){return n.createElement(u.DeleteFieldButton,{onDelete:function(){return e(Y)}})}))))))),w&&n.createElement("div",{className:"sortable-tree-subitems"},h,n.createElement(i.DndContext,null,n.createElement(c.SortableContext,{items:w,strategy:c.verticalListSortingStrategy},n.createElement(l.Collapse,{in:K},n.createElement("div",{className:"ml-0"},y)))),C))))};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@licklist/design",
|
|
3
|
-
"version": "0.66.
|
|
3
|
+
"version": "0.66.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"@fortawesome/free-brands-svg-icons": "5.15.2",
|
|
51
51
|
"@fortawesome/free-solid-svg-icons": "5.15.2",
|
|
52
52
|
"@fortawesome/react-fontawesome": "0.1.9",
|
|
53
|
-
"@licklist/core": "0.28.
|
|
53
|
+
"@licklist/core": "0.28.2",
|
|
54
54
|
"@licklist/eslint-config": "0.4.5",
|
|
55
|
-
"@licklist/plugins": "0.30.
|
|
55
|
+
"@licklist/plugins": "0.30.3",
|
|
56
56
|
"@mdx-js/react": "1.6.22",
|
|
57
57
|
"@popperjs/core": "2.11.8",
|
|
58
58
|
"@react-aria/utils": "3.9.0",
|
|
@@ -177,7 +177,8 @@
|
|
|
177
177
|
},
|
|
178
178
|
"resolutions": {
|
|
179
179
|
"@types/react": "17.0.2",
|
|
180
|
-
"@types/react-dom": "17.0.2"
|
|
180
|
+
"@types/react-dom": "17.0.2",
|
|
181
|
+
"cheerio": "0.22.0"
|
|
181
182
|
},
|
|
182
183
|
"lint-staged": {
|
|
183
184
|
"*.{ts,tsx}": [
|
package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx
CHANGED
|
@@ -40,6 +40,10 @@ export const SelectEventProductSet = ({
|
|
|
40
40
|
const productSetId = watch("productSetId");
|
|
41
41
|
const editedProductSet = watch("editedProductSet");
|
|
42
42
|
|
|
43
|
+
const selectedProductSet = productSets.find(
|
|
44
|
+
(productSet) => productSet.id === productSetId
|
|
45
|
+
)?.parentMenuId;
|
|
46
|
+
|
|
43
47
|
const onEditProductSet = useCallback(
|
|
44
48
|
() => {
|
|
45
49
|
setEditProductSetId(String(productSetId));
|
|
@@ -84,6 +88,9 @@ export const SelectEventProductSet = ({
|
|
|
84
88
|
setValue("productSetId", value);
|
|
85
89
|
};
|
|
86
90
|
|
|
91
|
+
const showOverrideProductSet =
|
|
92
|
+
!showEditProductSet && productSetId && !selectedProductSet;
|
|
93
|
+
|
|
87
94
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
95
|
const onSubmit = (value: EditEventFormValues["editedProductSet"]) => {
|
|
89
96
|
setShowEditProductSet(false);
|
|
@@ -159,7 +166,7 @@ export const SelectEventProductSet = ({
|
|
|
159
166
|
{t("addNewProductSet")}
|
|
160
167
|
</Button>
|
|
161
168
|
)}
|
|
162
|
-
{
|
|
169
|
+
{showOverrideProductSet && (
|
|
163
170
|
<Button
|
|
164
171
|
variant=""
|
|
165
172
|
className="btn product-set-button "
|
|
@@ -9,6 +9,7 @@ export type LeftBlockProps = PropsWithChildren<
|
|
|
9
9
|
pageTitle?: ReactNode;
|
|
10
10
|
component?: ReactNode;
|
|
11
11
|
childrenClassName?: string;
|
|
12
|
+
hasScroll?: boolean;
|
|
12
13
|
} & HTMLAttributes<HTMLDivElement>
|
|
13
14
|
>;
|
|
14
15
|
|
|
@@ -17,6 +18,7 @@ export const LeftBlock = ({
|
|
|
17
18
|
children,
|
|
18
19
|
className,
|
|
19
20
|
component,
|
|
21
|
+
hasScroll = true,
|
|
20
22
|
childrenClassName,
|
|
21
23
|
...props
|
|
22
24
|
}: LeftBlockProps) => {
|
|
@@ -41,10 +43,14 @@ export const LeftBlock = ({
|
|
|
41
43
|
</div>
|
|
42
44
|
<div
|
|
43
45
|
className={clsx("left-block-container", childrenClassName)}
|
|
44
|
-
style={leftBlockStyles}
|
|
46
|
+
style={hasScroll ? leftBlockStyles : undefined}
|
|
45
47
|
id={PAGE_LEFT_BLOCK_CONTAINER_ID}
|
|
46
48
|
>
|
|
47
|
-
<PageContextProvider
|
|
49
|
+
<PageContextProvider
|
|
50
|
+
leftBlockContainerSizes={
|
|
51
|
+
hasScroll ? leftBlockContainerSizes : undefined
|
|
52
|
+
}
|
|
53
|
+
>
|
|
48
54
|
{children}
|
|
49
55
|
</PageContextProvider>
|
|
50
56
|
</div>
|
|
@@ -88,6 +88,7 @@ export interface ProductSetControlProps {
|
|
|
88
88
|
workHours?: WorkHour[];
|
|
89
89
|
providerHasBookingManagement?: boolean;
|
|
90
90
|
isOverrides?: boolean;
|
|
91
|
+
isCreateNewOverrides?: boolean;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
export function ProductSetControl({
|
|
@@ -104,6 +105,7 @@ export function ProductSetControl({
|
|
|
104
105
|
workHours,
|
|
105
106
|
providerHasBookingManagement = false,
|
|
106
107
|
isOverrides = false,
|
|
108
|
+
isCreateNewOverrides = false,
|
|
107
109
|
}: ProductSetControlProps) {
|
|
108
110
|
const { t } = useTranslation(["Design", "Validation", "Notification"]);
|
|
109
111
|
const {
|
|
@@ -123,7 +125,7 @@ export function ProductSetControl({
|
|
|
123
125
|
|
|
124
126
|
const showSmsTemplateSelector = showSmsTemplate && !isOverrides;
|
|
125
127
|
const showEmailTemplateSelector = showEmailTemplate && !isOverrides;
|
|
126
|
-
|
|
128
|
+
const showDateSelector = !isEventEditProductSet && isOverrides;
|
|
127
129
|
return (
|
|
128
130
|
<Row
|
|
129
131
|
className={`product-set-form ${
|
|
@@ -165,7 +167,7 @@ export function ProductSetControl({
|
|
|
165
167
|
</Form.Control.Feedback>
|
|
166
168
|
</Form.Group>
|
|
167
169
|
|
|
168
|
-
{
|
|
170
|
+
{showDateSelector ? (
|
|
169
171
|
<DateInput
|
|
170
172
|
workHours={workHours}
|
|
171
173
|
isLoading={isLoading}
|
|
@@ -188,7 +190,12 @@ export function ProductSetControl({
|
|
|
188
190
|
|
|
189
191
|
<TutorialGifCard isOverrides={isOverrides} />
|
|
190
192
|
|
|
191
|
-
<StepsControl
|
|
193
|
+
<StepsControl
|
|
194
|
+
isLoading={isLoading}
|
|
195
|
+
isEventEditProductSet={isEventEditProductSet}
|
|
196
|
+
isOverrides={isOverrides}
|
|
197
|
+
isCreateNewOverrides={isCreateNewOverrides}
|
|
198
|
+
/>
|
|
192
199
|
</Col>
|
|
193
200
|
<Col md={6} sm={12}>
|
|
194
201
|
<div className="second-column">
|
|
@@ -36,6 +36,8 @@ import { useSortableTreeFunctions } from "../hooks/useSortableTreeFunctions";
|
|
|
36
36
|
interface ProductCategoriesControlProps extends WithIsLoading {
|
|
37
37
|
stepIndex: number;
|
|
38
38
|
isOverrides?: boolean;
|
|
39
|
+
isEventEditProductSet?: boolean;
|
|
40
|
+
isCreateNewOverrides?: boolean;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
const getCategoryDefaultValue = (
|
|
@@ -67,6 +69,8 @@ export function ProductCategoriesControl({
|
|
|
67
69
|
isLoading,
|
|
68
70
|
stepIndex,
|
|
69
71
|
isOverrides,
|
|
72
|
+
isEventEditProductSet,
|
|
73
|
+
isCreateNewOverrides,
|
|
70
74
|
}: ProductCategoriesControlProps) {
|
|
71
75
|
const { t } = useTranslation("Design");
|
|
72
76
|
const {
|
|
@@ -214,6 +218,11 @@ export function ProductCategoriesControl({
|
|
|
214
218
|
? String(productCategory.id)
|
|
215
219
|
: productCategory.uniqueId;
|
|
216
220
|
|
|
221
|
+
const isOverridesCategory = productCategory.products.some((product) =>
|
|
222
|
+
isEventEditProductSet ? !!product.id : !!product.originalProductId
|
|
223
|
+
);
|
|
224
|
+
const isNewOverridesCategory =
|
|
225
|
+
isCreateNewOverrides && !!productCategory.id;
|
|
217
226
|
const onSetIsExpanded = () => {
|
|
218
227
|
setIsExpanded(productCategoryId);
|
|
219
228
|
};
|
|
@@ -269,7 +278,10 @@ export function ProductCategoriesControl({
|
|
|
269
278
|
categoryName={value}
|
|
270
279
|
stepIndex={stepIndex}
|
|
271
280
|
productCategoryIndex={index}
|
|
272
|
-
isOverride={
|
|
281
|
+
isOverride={
|
|
282
|
+
isNewOverridesCategory ||
|
|
283
|
+
(isOverrides && isOverridesCategory)
|
|
284
|
+
}
|
|
273
285
|
/>
|
|
274
286
|
}
|
|
275
287
|
isOverride={isOverrides}
|
|
@@ -296,6 +308,8 @@ export function ProductCategoriesControl({
|
|
|
296
308
|
productCategoryIndex={index}
|
|
297
309
|
categoryType={productCategory.type}
|
|
298
310
|
isOverrides={isOverrides}
|
|
311
|
+
isEventEditProductSet={isEventEditProductSet}
|
|
312
|
+
isCreateNewOverrides={isCreateNewOverrides}
|
|
299
313
|
/>
|
|
300
314
|
</SortableTree.Item>
|
|
301
315
|
)}
|
|
@@ -305,9 +319,7 @@ export function ProductCategoriesControl({
|
|
|
305
319
|
</SortableTree>
|
|
306
320
|
<CreateProductSetItem
|
|
307
321
|
title={t("addCategory")}
|
|
308
|
-
isOverride={isOverrides}
|
|
309
322
|
onClick={() => {
|
|
310
|
-
if (isOverrides) return;
|
|
311
323
|
setIsSelectCategoryVisible(true);
|
|
312
324
|
}}
|
|
313
325
|
/>
|
|
@@ -316,7 +328,6 @@ export function ProductCategoriesControl({
|
|
|
316
328
|
isVisible={isSelectCategoryVisible}
|
|
317
329
|
onHide={() => setIsSelectCategoryVisible(false)}
|
|
318
330
|
onCategorySelect={(categoryType) => {
|
|
319
|
-
if (isOverrides) return;
|
|
320
331
|
append(getCategoryDefaultValue(categoryType, fields.length));
|
|
321
332
|
setShowCategoryModal(true);
|
|
322
333
|
if (
|
|
@@ -53,6 +53,7 @@ export interface ProductSetFormProps
|
|
|
53
53
|
isCreateAction?: boolean;
|
|
54
54
|
isOverrides?: boolean;
|
|
55
55
|
workHours?: WorkHour[];
|
|
56
|
+
isCreateNewOverrides?: boolean;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export function ProductSetForm({
|
|
@@ -70,6 +71,7 @@ export function ProductSetForm({
|
|
|
70
71
|
isCreateAction,
|
|
71
72
|
workHours,
|
|
72
73
|
isOverrides,
|
|
74
|
+
isCreateNewOverrides,
|
|
73
75
|
...shared
|
|
74
76
|
}: ProductSetFormProps) {
|
|
75
77
|
const { t } = useTranslation("Design");
|
|
@@ -166,6 +168,7 @@ export function ProductSetForm({
|
|
|
166
168
|
workHours={workHours}
|
|
167
169
|
providerHasBookingManagement={providerHasBookingManagement}
|
|
168
170
|
isOverrides={isOverrides}
|
|
171
|
+
isCreateNewOverrides={isCreateNewOverrides}
|
|
169
172
|
/>
|
|
170
173
|
<Row>
|
|
171
174
|
<Col md={6} sm={12} />
|
|
@@ -35,6 +35,8 @@ interface ProductsControlProps extends WithIsLoading {
|
|
|
35
35
|
categoryType: CategoryType;
|
|
36
36
|
zones?: Zone[];
|
|
37
37
|
isOverrides?: boolean;
|
|
38
|
+
isEventEditProductSet?: boolean;
|
|
39
|
+
isCreateNewOverrides?: boolean;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
const getDefaultProductValue = (sort: number): Product => ({
|
|
@@ -57,6 +59,7 @@ const getDefaultProductValue = (sort: number): Product => ({
|
|
|
57
59
|
quantitySelector: 1,
|
|
58
60
|
hasSpecialNotes: false,
|
|
59
61
|
weight: 0,
|
|
62
|
+
originalProductId: null,
|
|
60
63
|
type: DEFAULT_PRODUCT_TYPE,
|
|
61
64
|
tierId: Number(uniqueId()),
|
|
62
65
|
zoneId: null,
|
|
@@ -79,6 +82,8 @@ export function ProductsControl({
|
|
|
79
82
|
categoryType,
|
|
80
83
|
zones,
|
|
81
84
|
isOverrides,
|
|
85
|
+
isEventEditProductSet,
|
|
86
|
+
isCreateNewOverrides,
|
|
82
87
|
}: ProductsControlProps) {
|
|
83
88
|
const { t } = useTranslation("Design");
|
|
84
89
|
const form = useFormContext<ProductSetFormValues>();
|
|
@@ -203,90 +208,101 @@ export function ProductsControl({
|
|
|
203
208
|
onDragEnd={handleDragEnd}
|
|
204
209
|
sensors={[mouseSensor]}
|
|
205
210
|
>
|
|
206
|
-
{fields.map((product, index) =>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
<
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
211
|
+
{fields.map((product, index) => {
|
|
212
|
+
const isOverridesProductSet = isEventEditProductSet
|
|
213
|
+
? !!product.id
|
|
214
|
+
: isOverrides && !!product.originalProductId;
|
|
215
|
+
|
|
216
|
+
const isNewProductOverrides = isCreateNewOverrides && !!product.id;
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<Controller
|
|
220
|
+
key={product._id}
|
|
221
|
+
control={control}
|
|
222
|
+
name={`${productControlFieldName}.${index}.name` as const}
|
|
223
|
+
rules={{
|
|
224
|
+
required: t("Validation:fieldRequired", {
|
|
225
|
+
attribute: t("name"),
|
|
226
|
+
}) as string,
|
|
227
|
+
}}
|
|
228
|
+
render={({ field: { value, onChange } }) => (
|
|
229
|
+
<SortableTree.Item
|
|
230
|
+
key={`product-${product._id}`}
|
|
231
|
+
id={String(product._id)}
|
|
232
|
+
isExpanded={isFirstProductAdded}
|
|
233
|
+
isInvalid={!!categoryProductErrors}
|
|
234
|
+
title={value}
|
|
235
|
+
isOverride={isOverrides}
|
|
236
|
+
badge={
|
|
237
|
+
<Badge className="product-badge">{t("product")}</Badge>
|
|
238
|
+
}
|
|
239
|
+
isIconInHeader={false}
|
|
240
|
+
cancelChanges={() => cancelChanges(index)}
|
|
241
|
+
edit={() => edit(index)}
|
|
242
|
+
secondaryBadge={getBadgeConfig(categoryType, t(categoryType))}
|
|
243
|
+
subTitle={
|
|
244
|
+
<div className="product-set-badges-container">
|
|
245
|
+
<div className="product-set-subtitle-dot product-set-subtitle-product-dot" />
|
|
246
|
+
<span>
|
|
247
|
+
{`£${prices[index]} ${t("each")} - ${t("qty")}:${
|
|
248
|
+
!isUnlimitedQuantities[index]
|
|
249
|
+
? ` ${quantities[index]}`
|
|
250
|
+
: t(" unlimited")
|
|
251
|
+
} ${
|
|
252
|
+
!isUnlimitedQuantities[index]
|
|
253
|
+
? ` - ${t("possibleRevenue")} £${
|
|
254
|
+
prices[index] * quantities[index]
|
|
255
|
+
}`
|
|
256
|
+
: ""
|
|
257
|
+
} `}
|
|
258
|
+
</span>
|
|
259
|
+
</div>
|
|
260
|
+
}
|
|
261
|
+
modalLabel={t("addNewProduct")}
|
|
262
|
+
modalClass={ProductSetModalClasses.product}
|
|
263
|
+
isNewAdded={showProductModal}
|
|
264
|
+
body={
|
|
265
|
+
<ProductControl<ProductSetFormValues>
|
|
266
|
+
isLoading={isLoading}
|
|
267
|
+
quantityType={quantityType}
|
|
268
|
+
allowDeposits={allowDeposits}
|
|
269
|
+
hasBookingManagement={false}
|
|
270
|
+
fieldNamePrefix={
|
|
271
|
+
`${productControlFieldName}.${index}` as const
|
|
272
|
+
}
|
|
273
|
+
productName={value}
|
|
274
|
+
onProductNameChange={onChange}
|
|
275
|
+
hasTicket={hasTicket}
|
|
276
|
+
categoryType={categoryType}
|
|
277
|
+
zoneDuration={catergoryZone?.defaultDuration}
|
|
278
|
+
isOverrides={
|
|
279
|
+
isNewProductOverrides || isOverridesProductSet
|
|
280
|
+
}
|
|
281
|
+
/>
|
|
282
|
+
}
|
|
283
|
+
onDelete={() => onProductRemove(index)}
|
|
284
|
+
validate={() =>
|
|
285
|
+
trigger(`${productControlFieldName}.${index}`)
|
|
286
|
+
}
|
|
287
|
+
saveValidField={saveValidField}
|
|
288
|
+
// preItem={<Popover className="d-none d-sm-block" />}
|
|
289
|
+
>
|
|
290
|
+
<SubProductsControl
|
|
253
291
|
isLoading={isLoading}
|
|
254
292
|
quantityType={quantityType}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
`${productControlFieldName}.${index}` as const
|
|
259
|
-
}
|
|
260
|
-
productName={value}
|
|
261
|
-
onProductNameChange={onChange}
|
|
262
|
-
hasTicket={hasTicket}
|
|
263
|
-
categoryType={categoryType}
|
|
264
|
-
zoneDuration={catergoryZone?.defaultDuration}
|
|
265
|
-
isOverrides={isOverrides}
|
|
293
|
+
stepIndex={stepIndex}
|
|
294
|
+
productCategoryIndex={productCategoryIndex}
|
|
295
|
+
productIndex={index}
|
|
266
296
|
/>
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
>
|
|
273
|
-
<SubProductsControl
|
|
274
|
-
isLoading={isLoading}
|
|
275
|
-
quantityType={quantityType}
|
|
276
|
-
stepIndex={stepIndex}
|
|
277
|
-
productCategoryIndex={productCategoryIndex}
|
|
278
|
-
productIndex={index}
|
|
279
|
-
/>
|
|
280
|
-
</SortableTree.Item>
|
|
281
|
-
)}
|
|
282
|
-
/>
|
|
283
|
-
))}
|
|
297
|
+
</SortableTree.Item>
|
|
298
|
+
)}
|
|
299
|
+
/>
|
|
300
|
+
);
|
|
301
|
+
})}
|
|
284
302
|
</SortableTree>
|
|
285
303
|
<CreateProductSetItem
|
|
286
304
|
title={t("addProduct")}
|
|
287
|
-
isOverride={isOverrides}
|
|
288
305
|
onClick={() => {
|
|
289
|
-
if (isOverrides) return;
|
|
290
306
|
append(getDefaultProductValue(fields.length));
|
|
291
307
|
setShowProductModal(true);
|
|
292
308
|
|
|
@@ -19,9 +19,16 @@ import { ProductSetFormValues } from "./ProductSetForm";
|
|
|
19
19
|
interface StepsControlProps {
|
|
20
20
|
isLoading: boolean;
|
|
21
21
|
isOverrides?: boolean;
|
|
22
|
+
isEventEditProductSet?: boolean;
|
|
23
|
+
isCreateNewOverrides?: boolean;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
export function StepsControl({
|
|
26
|
+
export function StepsControl({
|
|
27
|
+
isLoading,
|
|
28
|
+
isOverrides,
|
|
29
|
+
isEventEditProductSet,
|
|
30
|
+
isCreateNewOverrides,
|
|
31
|
+
}: StepsControlProps) {
|
|
25
32
|
const form = useFormContext<ProductSetFormValues>();
|
|
26
33
|
const { t } = useTranslation("Design");
|
|
27
34
|
const [showStepModal, setShowStepModal] = useState(false);
|
|
@@ -68,9 +75,9 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
68
75
|
<>
|
|
69
76
|
{fields.map((step, index) => {
|
|
70
77
|
const stepFieldName = `steps.${index}` as const;
|
|
71
|
-
|
|
72
78
|
const stepData = getValues(stepFieldName);
|
|
73
|
-
|
|
79
|
+
const isOverrideStep =
|
|
80
|
+
(isOverrides || isCreateNewOverrides) && !!step.id;
|
|
74
81
|
return (
|
|
75
82
|
<Controller
|
|
76
83
|
key={`step-${step._id}`}
|
|
@@ -92,9 +99,9 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
92
99
|
modalLabel={t("addNewStep")}
|
|
93
100
|
modalClass={ProductSetModalClasses.step}
|
|
94
101
|
isNewAdded={showStepModal}
|
|
95
|
-
edit={() =>
|
|
102
|
+
edit={() => edit(index)}
|
|
96
103
|
cancelChanges={() => cancelChanges(index)}
|
|
97
|
-
isOverride={
|
|
104
|
+
isOverride={isOverrideStep}
|
|
98
105
|
subTitle={
|
|
99
106
|
<div className="product-set-badges-container">
|
|
100
107
|
<div className="product-set-subtitle-dot product-set-subtitle-step-dot" />
|
|
@@ -110,6 +117,7 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
110
117
|
stepIndex={index}
|
|
111
118
|
stepName={value}
|
|
112
119
|
onStepNameChange={onChange}
|
|
120
|
+
isOverrides={isOverrideStep}
|
|
113
121
|
/>
|
|
114
122
|
}
|
|
115
123
|
onDelete={() => remove(index)}
|
|
@@ -140,6 +148,8 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
140
148
|
isLoading={isLoading}
|
|
141
149
|
stepIndex={index}
|
|
142
150
|
isOverrides={isOverrides}
|
|
151
|
+
isCreateNewOverrides={isCreateNewOverrides}
|
|
152
|
+
isEventEditProductSet={isEventEditProductSet}
|
|
143
153
|
/>
|
|
144
154
|
</SortableTree.Item>
|
|
145
155
|
)}
|
|
@@ -149,9 +159,7 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
149
159
|
|
|
150
160
|
<CreateProductSetItem
|
|
151
161
|
title={t("addStep")}
|
|
152
|
-
isOverride={isOverrides}
|
|
153
162
|
onClick={() => {
|
|
154
|
-
if (isOverrides) return;
|
|
155
163
|
append(getDefaultStepsValues());
|
|
156
164
|
setShowStepModal(true);
|
|
157
165
|
if (errors.steps?.type === HookFormService.manualErrorType) {
|
|
@@ -89,6 +89,7 @@ export interface ProductControlValues
|
|
|
89
89
|
totalQuantity: number;
|
|
90
90
|
isAvailable: boolean;
|
|
91
91
|
isSoldOut: boolean;
|
|
92
|
+
originalProductId: number | null;
|
|
92
93
|
isUnlimited: boolean;
|
|
93
94
|
isRequired: boolean;
|
|
94
95
|
quantitySelector: number;
|
|
@@ -159,7 +160,6 @@ export function ProductControl<T extends FormValues>({
|
|
|
159
160
|
);
|
|
160
161
|
const capacity = watch(`${fieldNamePrefix}.capacity` as Path<T>);
|
|
161
162
|
const disabledDuration = capacity === "0" || !capacity;
|
|
162
|
-
|
|
163
163
|
const advancedId = useId();
|
|
164
164
|
const nameId = useId();
|
|
165
165
|
|
|
@@ -413,7 +413,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
413
413
|
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
414
414
|
errors
|
|
415
415
|
)}
|
|
416
|
-
disabled={isLoading}
|
|
416
|
+
disabled={isLoading || isOverrides}
|
|
417
417
|
defaultValue=""
|
|
418
418
|
>
|
|
419
419
|
<option value="">{t("Design:selectProductGroup")}</option>
|
|
@@ -26,6 +26,7 @@ export interface StepControlProps extends IsDeletableEvent {
|
|
|
26
26
|
stepIndex: number;
|
|
27
27
|
stepName: string;
|
|
28
28
|
onStepNameChange: (args: any) => void;
|
|
29
|
+
isOverrides?: boolean;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export function StepControl({
|
|
@@ -33,6 +34,7 @@ export function StepControl({
|
|
|
33
34
|
stepIndex,
|
|
34
35
|
stepName,
|
|
35
36
|
onStepNameChange,
|
|
37
|
+
isOverrides = false,
|
|
36
38
|
}: StepControlProps) {
|
|
37
39
|
const { providerHasMap } = useContext(ProductSetLoadingContext);
|
|
38
40
|
const {
|
|
@@ -42,7 +44,6 @@ export function StepControl({
|
|
|
42
44
|
watch,
|
|
43
45
|
} = useFormContext<ProductSetFormValues>();
|
|
44
46
|
const { t } = useTranslation("Design");
|
|
45
|
-
|
|
46
47
|
const fieldName = `steps.${stepIndex}.name` as const;
|
|
47
48
|
const productCategoriesFieldName =
|
|
48
49
|
`steps.${stepIndex}.productCategories` as const;
|
|
@@ -71,7 +72,7 @@ export function StepControl({
|
|
|
71
72
|
fieldName,
|
|
72
73
|
errors
|
|
73
74
|
)}
|
|
74
|
-
disabled={isLoading}
|
|
75
|
+
disabled={isLoading || isOverrides}
|
|
75
76
|
/>
|
|
76
77
|
)}
|
|
77
78
|
control={control}
|
|
@@ -114,7 +115,7 @@ export function StepControl({
|
|
|
114
115
|
name={name}
|
|
115
116
|
value={Boolean(value)}
|
|
116
117
|
onChange={onChange}
|
|
117
|
-
disabled={isLoading}
|
|
118
|
+
disabled={isLoading || isOverrides}
|
|
118
119
|
/>
|
|
119
120
|
)}
|
|
120
121
|
control={control}
|
|
@@ -53,7 +53,6 @@ export interface SortableTreeItemProps {
|
|
|
53
53
|
};
|
|
54
54
|
setIsExpanded?: () => void;
|
|
55
55
|
isOverride?: boolean;
|
|
56
|
-
isProduct?: boolean;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
export function SortableTreeItem({
|
|
@@ -81,7 +80,6 @@ export function SortableTreeItem({
|
|
|
81
80
|
secondaryBadge,
|
|
82
81
|
setIsExpanded,
|
|
83
82
|
isOverride,
|
|
84
|
-
isProduct = false,
|
|
85
83
|
}: SortableTreeItemProps) {
|
|
86
84
|
const [expanded, setExpanded] = useState(isExpanded);
|
|
87
85
|
const [isModalVisible, setIsModalVisible] = useState(isNewAdded);
|
|
@@ -152,7 +150,6 @@ export function SortableTreeItem({
|
|
|
152
150
|
};
|
|
153
151
|
|
|
154
152
|
const onEdit = (e) => {
|
|
155
|
-
if (isOverride && !isProduct) return;
|
|
156
153
|
e.stopPropagation();
|
|
157
154
|
if (edit && !isModalVisible) edit();
|
|
158
155
|
setIsModalVisible(true);
|