@licklist/design 0.66.0 → 0.66.1-dev.0

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 (96) hide show
  1. package/dist/date-time-button/DateTimeButton.js +1 -1
  2. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
  3. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
  4. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
  5. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
  6. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
  7. package/dist/product-set/control/DateAndRecurrenceInput.d.ts +1 -1
  8. package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
  9. package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
  10. package/dist/product-set/control/DateInput.js +1 -1
  11. package/dist/product-set/control/ProductSetControl.d.ts +3 -2
  12. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  13. package/dist/product-set/control/ProductSetControl.js +1 -1
  14. package/dist/product-set/form/ProductCategoriesControl.d.ts +3 -1
  15. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  16. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  17. package/dist/product-set/form/ProductSetForm.d.ts +6 -2
  18. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  19. package/dist/product-set/form/ProductSetForm.js +1 -1
  20. package/dist/product-set/form/ProductsControl.d.ts +3 -1
  21. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  22. package/dist/product-set/form/ProductsControl.js +1 -1
  23. package/dist/product-set/form/StepsControl.d.ts +3 -1
  24. package/dist/product-set/form/StepsControl.d.ts.map +1 -1
  25. package/dist/product-set/form/StepsControl.js +1 -1
  26. package/dist/product-set/product/ProductControl.d.ts +1 -0
  27. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  28. package/dist/product-set/product/ProductControl.js +1 -1
  29. package/dist/product-set/step/StepControl.d.ts +2 -1
  30. package/dist/product-set/step/StepControl.d.ts.map +1 -1
  31. package/dist/product-set/step/StepControl.js +1 -1
  32. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  33. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  34. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
  35. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +1 -1
  36. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +3 -1
  37. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  38. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  39. package/dist/recurring-date-picker-input/utils.d.ts +5 -0
  40. package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
  41. package/dist/recurring-date-picker-input/utils.js +1 -1
  42. package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts +1 -1
  43. package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts.map +1 -1
  44. package/dist/report/ReportRunnerModal/ReportRunnerModal.js +1 -1
  45. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  46. package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
  47. package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
  48. package/dist/sortable-tree/SortableTreeItem.d.ts +1 -2
  49. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  50. package/dist/sortable-tree/SortableTreeItem.js +1 -1
  51. package/dist/styles/date-time-button/DateTimeButton.scss +1 -0
  52. package/dist/styles/sales/BookingResults.scss +1 -1
  53. package/dist/styles/zones/ZoneForm.scss +2 -1
  54. package/dist/zone/form/ZoneForm.d.ts +2 -2
  55. package/dist/zone/form/ZoneForm.d.ts.map +1 -1
  56. package/dist/zone/form/ZoneForm.js +1 -1
  57. package/dist/zone/form/components/ZoneControl.d.ts +2 -2
  58. package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
  59. package/dist/zone/form/components/ZoneControl.js +1 -1
  60. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
  61. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
  62. package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
  63. package/dist/zone/form/utils/dates.d.ts.map +1 -1
  64. package/package.json +3 -5
  65. package/src/date-time-button/DateTimeButton.stories.tsx +2 -1
  66. package/src/date-time-button/DateTimeButton.tsx +7 -5
  67. package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +14 -9
  68. package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +2 -0
  69. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +1 -0
  70. package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -4
  71. package/src/product-set/control/DateInput.tsx +2 -2
  72. package/src/product-set/control/ProductSetControl.tsx +17 -5
  73. package/src/product-set/form/ProductCategoriesControl.tsx +15 -4
  74. package/src/product-set/form/ProductSetForm.tsx +13 -2
  75. package/src/product-set/form/ProductsControl.tsx +93 -77
  76. package/src/product-set/form/StepsControl.tsx +15 -7
  77. package/src/product-set/product/ProductControl.tsx +8 -5
  78. package/src/product-set/step/StepControl.tsx +4 -3
  79. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +4 -18
  80. package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +50 -21
  81. package/src/recurring-date-picker-input/RecurringDatePickerInput.stories.tsx +13 -7
  82. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +12 -1
  83. package/src/recurring-date-picker-input/utils.ts +90 -1
  84. package/src/report/ReportRunnerModal/ReportRunnerModal.stories.tsx +307 -0
  85. package/src/report/ReportRunnerModal/ReportRunnerModal.tsx +24 -14
  86. package/src/sales/booking/results/components/ResultCard.tsx +0 -3
  87. package/src/setting/admin/AdminSettingForm.tsx +2 -2
  88. package/src/sortable-tree/SortableTreeItem.tsx +0 -3
  89. package/src/static/switch/BooleanSwitch.tsx +1 -1
  90. package/src/styles/date-time-button/DateTimeButton.scss +1 -0
  91. package/src/styles/sales/BookingResults.scss +1 -1
  92. package/src/styles/zones/ZoneForm.scss +2 -1
  93. package/src/zone/form/ZoneForm.tsx +3 -2
  94. package/src/zone/form/components/ZoneControl.tsx +3 -3
  95. package/src/zone/form/components/ZoneRecurrencesControl.tsx +7 -5
  96. package/src/zone/form/utils/dates.ts +9 -10
@@ -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
- {!showEditProductSet && productSetId && (
169
+ {showOverrideProductSet && (
163
170
  <Button
164
171
  variant=""
165
172
  className="btn product-set-button "
@@ -199,14 +206,12 @@ export const SelectEventProductSet = ({
199
206
  </Form.Group>
200
207
  </div>
201
208
  {showEditProductSet && productSetId && (
202
- <>
203
- <EditEventProductSet
204
- onSubmit={onSubmit}
205
- defaultValues={
206
- productSetId === editedProductSet?.id && editedProductSet
207
- }
208
- />
209
- </>
209
+ <EditEventProductSet
210
+ onSubmit={onSubmit}
211
+ defaultValues={
212
+ productSetId === editedProductSet?.id && editedProductSet
213
+ }
214
+ />
210
215
  )}
211
216
  </>
212
217
  );
@@ -124,6 +124,8 @@ export const EditEventProductSet = ({
124
124
  companyName={selectedCompany?.title}
125
125
  fee={feeInPercent}
126
126
  isEventEditProductSet
127
+ isOverrides
128
+ workHours={undefined}
127
129
  />
128
130
  <Button
129
131
  disabled={isLoading}
@@ -63,6 +63,7 @@ const processedPaymentSummary = ({
63
63
  const total = calculateTotalPrice(order, externalPaymentDetail);
64
64
 
65
65
  const totalDiscount = calculateTotalDiscount(order.payments);
66
+
66
67
  let summaryItems: SummaryItem[] = [
67
68
  {
68
69
  translateKey: AMOUNT_TOTAL,
@@ -28,15 +28,13 @@ import {
28
28
  AvailableTimesControlRef,
29
29
  } from "../../zone/form/components/AvailableTimesControl";
30
30
 
31
- // eslint-disable-next-line max-len
32
-
33
31
  export interface DateAndRecurrenceInputValues {
34
32
  menuRecurrences?: Partial<ProductSetRecurrence>[];
35
33
  }
36
34
 
37
35
  interface DateAndRecurrenceInputProps {
38
36
  isEventEditProductSet?: boolean;
39
- workHours?: WorkHour[];
37
+ workHours: WorkHour[] | undefined;
40
38
  providerHasBookingManagement: boolean;
41
39
  isLoading?: boolean;
42
40
  }
@@ -90,7 +88,7 @@ export const DateAndRecurrenceInput = ({
90
88
  clearEditState();
91
89
  });
92
90
 
93
- const popoverId = useId()!;
91
+ const popoverId = useId();
94
92
 
95
93
  const { t } = useTranslation("Design");
96
94
 
@@ -228,6 +226,7 @@ export const DateAndRecurrenceInput = ({
228
226
  defaultValues={editState.values}
229
227
  onChange={handleRecurringDateChange}
230
228
  onDelete={handleDelete}
229
+ workHours={workHours}
231
230
  >
232
231
  {providerHasBookingManagement && (
233
232
  <AvailableTimesControl
@@ -5,7 +5,7 @@ import { Form, OverlayTrigger, Popover } from "react-bootstrap";
5
5
  import { useFieldArray, useFormContext } from "react-hook-form";
6
6
  import { useTranslation } from "react-i18next";
7
7
  import { useClickAway } from "react-use";
8
- import { TIMEZONE, TIME_FORMAT } from "@licklist/core/dist/Config/Date";
8
+ import { UTC_TIMEZONE, TIME_FORMAT } from "@licklist/core/dist/Config/Date";
9
9
  import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
10
10
  import { DateTime } from "luxon";
11
11
  import RRule, { Frequency } from "rrule";
@@ -136,7 +136,7 @@ export const DateInput = ({
136
136
  until: (start as DateTime).toJSDate(),
137
137
  byweekday: [],
138
138
  freq: Frequency.DAILY,
139
- tzid: TIMEZONE,
139
+ tzid: UTC_TIMEZONE,
140
140
  interval: 1,
141
141
  }).replace("RRULE:", "");
142
142
 
@@ -85,9 +85,10 @@ export interface ProductSetControlProps {
85
85
  fieldSets?: FieldSet[];
86
86
  showEmailTemplate?: boolean;
87
87
  showSmsTemplate?: boolean;
88
- workHours?: WorkHour[];
88
+ workHours: WorkHour[] | undefined;
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,6 +125,11 @@ export function ProductSetControl({
123
125
 
124
126
  const showSmsTemplateSelector = showSmsTemplate && !isOverrides;
125
127
  const showEmailTemplateSelector = showEmailTemplate && !isOverrides;
128
+ const showDateSelector = !isEventEditProductSet && isOverrides;
129
+
130
+ const isZoneAdded = steps.some(({ productCategories }) =>
131
+ productCategories.some(({ zoneId }) => zoneId)
132
+ );
126
133
 
127
134
  return (
128
135
  <Row
@@ -165,9 +172,9 @@ export function ProductSetControl({
165
172
  </Form.Control.Feedback>
166
173
  </Form.Group>
167
174
 
168
- {isOverrides ? (
175
+ {showDateSelector ? (
169
176
  <DateInput
170
- workHours={workHours}
177
+ workHours={isZoneAdded ? workHours : undefined}
171
178
  isLoading={isLoading}
172
179
  providerHasBookingManagement={providerHasBookingManagement}
173
180
  />
@@ -176,7 +183,7 @@ export function ProductSetControl({
176
183
  {isCreateAction && (
177
184
  <DateAndRecurrenceInput
178
185
  isEventEditProductSet={isEventEditProductSet}
179
- workHours={workHours}
186
+ workHours={isZoneAdded ? workHours : undefined}
180
187
  isLoading={isLoading}
181
188
  providerHasBookingManagement={providerHasBookingManagement}
182
189
  />
@@ -188,7 +195,12 @@ export function ProductSetControl({
188
195
 
189
196
  <TutorialGifCard isOverrides={isOverrides} />
190
197
 
191
- <StepsControl isLoading={isLoading} isOverrides={isOverrides} />
198
+ <StepsControl
199
+ isLoading={isLoading}
200
+ isEventEditProductSet={isEventEditProductSet}
201
+ isOverrides={isOverrides}
202
+ isCreateNewOverrides={isCreateNewOverrides}
203
+ />
192
204
  </Col>
193
205
  <Col md={6} sm={12}>
194
206
  <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={isOverrides}
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 (
@@ -26,12 +26,16 @@ import { checkAvailableTimesErrors, getFilteredTemplates } from "../utils";
26
26
  export interface WithIsLoading {
27
27
  isLoading: boolean;
28
28
  }
29
+ export interface WithIdOptional {
30
+ id?: number;
31
+ }
32
+
29
33
  export interface WithId {
30
34
  id: number;
31
35
  }
32
36
  export interface ProductSetFormValues
33
37
  extends FormValues,
34
- WithId,
38
+ WithIdOptional,
35
39
  ProductSetControlValues {
36
40
  steps: Step[];
37
41
  isOverrides?: boolean;
@@ -53,6 +57,7 @@ export interface ProductSetFormProps
53
57
  isCreateAction?: boolean;
54
58
  isOverrides?: boolean;
55
59
  workHours?: WorkHour[];
60
+ isCreateNewOverrides?: boolean;
56
61
  }
57
62
 
58
63
  export function ProductSetForm({
@@ -70,6 +75,7 @@ export function ProductSetForm({
70
75
  isCreateAction,
71
76
  workHours,
72
77
  isOverrides,
78
+ isCreateNewOverrides,
73
79
  ...shared
74
80
  }: ProductSetFormProps) {
75
81
  const { t } = useTranslation("Design");
@@ -115,7 +121,11 @@ export function ProductSetForm({
115
121
  }, [serverErrors, setError]);
116
122
 
117
123
  useEffect(() => {
118
- window.history.pushState(null, "", window.location.pathname);
124
+ window.history.pushState(
125
+ null,
126
+ "",
127
+ window.location.pathname + window.location.search
128
+ );
119
129
  window.addEventListener("beforeunload", onBeforeUnload);
120
130
  window.addEventListener("popstate", onPopState);
121
131
 
@@ -166,6 +176,7 @@ export function ProductSetForm({
166
176
  workHours={workHours}
167
177
  providerHasBookingManagement={providerHasBookingManagement}
168
178
  isOverrides={isOverrides}
179
+ isCreateNewOverrides={isCreateNewOverrides}
169
180
  />
170
181
  <Row>
171
182
  <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
- <Controller
208
- key={product._id}
209
- control={control}
210
- name={`${productControlFieldName}.${index}.name` as const}
211
- rules={{
212
- required: t("Validation:fieldRequired", {
213
- attribute: t("name"),
214
- }) as string,
215
- }}
216
- render={({ field: { value, onChange } }) => (
217
- <SortableTree.Item
218
- key={`product-${product._id}`}
219
- id={String(product._id)}
220
- isExpanded={isFirstProductAdded}
221
- isInvalid={!!categoryProductErrors}
222
- title={value}
223
- isOverride={isOverrides}
224
- badge={<Badge className="product-badge">{t("product")}</Badge>}
225
- isIconInHeader={false}
226
- cancelChanges={() => cancelChanges(index)}
227
- edit={() => edit(index)}
228
- isProduct
229
- secondaryBadge={getBadgeConfig(categoryType, t(categoryType))}
230
- subTitle={
231
- <div className="product-set-badges-container">
232
- <div className="product-set-subtitle-dot product-set-subtitle-product-dot" />
233
- <span>
234
- {`£${prices[index]} ${t("each")} - ${t("qty")}:${
235
- !isUnlimitedQuantities[index]
236
- ? ` ${quantities[index]}`
237
- : t(" unlimited")
238
- } ${
239
- !isUnlimitedQuantities[index]
240
- ? ` - ${t("possibleRevenue")} £${
241
- prices[index] * quantities[index]
242
- }`
243
- : ""
244
- } `}
245
- </span>
246
- </div>
247
- }
248
- modalLabel={t("addNewProduct")}
249
- modalClass={ProductSetModalClasses.product}
250
- isNewAdded={showProductModal}
251
- body={
252
- <ProductControl<ProductSetFormValues>
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
- allowDeposits={allowDeposits}
256
- hasBookingManagement={false}
257
- fieldNamePrefix={
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
- onDelete={() => onProductRemove(index)}
269
- validate={() => trigger(`${productControlFieldName}.${index}`)}
270
- saveValidField={saveValidField}
271
- // preItem={<Popover className="d-none d-sm-block" />}
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({ isLoading, isOverrides }: StepsControlProps) {
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={() => !isOverrides && edit(index)}
102
+ edit={() => edit(index)}
96
103
  cancelChanges={() => cancelChanges(index)}
97
- isOverride={isOverrides}
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) {
@@ -7,14 +7,17 @@ import {
7
7
  QUANTITY_TYPE_LIST_DTO,
8
8
  QUANTITY_TYPE_RECHARGING,
9
9
  } from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
10
- import { ProductType } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
10
+ import {
11
+ ProductType,
12
+ PRODUCT_DEfAULT_COLORS,
13
+ } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
11
14
  import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
15
+ import clsx from "clsx";
12
16
  import {
13
17
  FieldNamePrefixPath,
14
18
  FormValues,
15
19
  } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
16
20
  import { useId } from "@react-aria/utils";
17
- import clsx from "clsx";
18
21
  import React, {
19
22
  ChangeEvent,
20
23
  useCallback,
@@ -36,7 +39,7 @@ import {
36
39
  } from "react-hook-form";
37
40
  import { useTranslation } from "react-i18next";
38
41
  import { useImages } from "@licklist/plugins/dist/hooks/Media/useImages";
39
- import { PRODUCT_DEfAULT_COLORS } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
42
+
40
43
  import {
41
44
  Image,
42
45
  IMAGE_TYPE_IMAGE,
@@ -86,6 +89,7 @@ export interface ProductControlValues
86
89
  totalQuantity: number;
87
90
  isAvailable: boolean;
88
91
  isSoldOut: boolean;
92
+ originalProductId: number | null;
89
93
  isUnlimited: boolean;
90
94
  isRequired: boolean;
91
95
  quantitySelector: number;
@@ -156,7 +160,6 @@ export function ProductControl<T extends FormValues>({
156
160
  );
157
161
  const capacity = watch(`${fieldNamePrefix}.capacity` as Path<T>);
158
162
  const disabledDuration = capacity === "0" || !capacity;
159
-
160
163
  const advancedId = useId();
161
164
  const nameId = useId();
162
165
 
@@ -410,7 +413,7 @@ export function ProductControl<T extends FormValues>({
410
413
  `${fieldNamePrefix}.productGroupId` as Path<T>,
411
414
  errors
412
415
  )}
413
- disabled={isLoading}
416
+ disabled={isLoading || isOverrides}
414
417
  defaultValue=""
415
418
  >
416
419
  <option value="">{t("Design:selectProductGroup")}</option>