@licklist/design 0.58.8 → 0.58.10

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 (92) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/product-set/card/ProductSetCard.d.ts +2 -1
  3. package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
  4. package/dist/product-set/card/ProductSetCard.js +1 -1
  5. package/dist/product-set/control/DateInput.d.ts +17 -0
  6. package/dist/product-set/control/DateInput.d.ts.map +1 -0
  7. package/dist/product-set/control/DateInput.js +1 -0
  8. package/dist/product-set/control/ProductSetControl.d.ts +2 -1
  9. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  10. package/dist/product-set/control/ProductSetControl.js +1 -1
  11. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts +11 -0
  12. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts.map +1 -0
  13. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.js +1 -0
  14. package/dist/product-set/control/TutorialGifCard.d.ts +2 -1
  15. package/dist/product-set/control/TutorialGifCard.d.ts.map +1 -1
  16. package/dist/product-set/control/TutorialGifCard.js +1 -1
  17. package/dist/product-set/form/ProductCategoriesControl.d.ts +2 -1
  18. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  19. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  20. package/dist/product-set/form/ProductSetForm.d.ts +3 -1
  21. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  22. package/dist/product-set/form/ProductSetForm.js +1 -1
  23. package/dist/product-set/form/ProductsControl.d.ts +2 -1
  24. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  25. package/dist/product-set/form/ProductsControl.js +1 -1
  26. package/dist/product-set/form/StepsControl.d.ts +2 -1
  27. package/dist/product-set/form/StepsControl.d.ts.map +1 -1
  28. package/dist/product-set/form/StepsControl.js +1 -1
  29. package/dist/product-set/form/SubProductsControl.d.ts +2 -1
  30. package/dist/product-set/form/SubProductsControl.d.ts.map +1 -1
  31. package/dist/product-set/form/SubProductsControl.js +1 -1
  32. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts +2 -1
  33. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
  34. package/dist/product-set/hooks/useSortableTreeFunctions.js +1 -1
  35. package/dist/product-set/item/CreateProductSetItem.d.ts +2 -1
  36. package/dist/product-set/item/CreateProductSetItem.d.ts.map +1 -1
  37. package/dist/product-set/item/CreateProductSetItem.js +1 -1
  38. package/dist/product-set/product/ProductControl.d.ts +2 -1
  39. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  40. package/dist/product-set/product/ProductControl.js +1 -1
  41. package/dist/product-set/product/constants.d.ts +1 -0
  42. package/dist/product-set/product/constants.d.ts.map +1 -1
  43. package/dist/product-set/product/constants.js +1 -1
  44. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts +4 -2
  45. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +1 -1
  46. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.js +1 -1
  47. package/dist/product-set/product/quantity/ProductQuantityControl.d.ts +1 -0
  48. package/dist/product-set/product/quantity/ProductQuantityControl.d.ts.map +1 -1
  49. package/dist/product-set/product/quantity/ProductQuantityControl.js +1 -1
  50. package/dist/product-set/product-category/ProductCategoryControl.d.ts +2 -1
  51. package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
  52. package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
  53. package/dist/recurring-date-picker-input/DatePickerInput.d.ts +19 -0
  54. package/dist/recurring-date-picker-input/DatePickerInput.d.ts.map +1 -0
  55. package/dist/recurring-date-picker-input/DatePickerInput.js +1 -0
  56. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts +15 -0
  57. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts.map +1 -0
  58. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.js +1 -0
  59. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +2 -0
  60. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  61. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  62. package/dist/sortable-list/SortableList.d.ts +2 -1
  63. package/dist/sortable-list/SortableList.d.ts.map +1 -1
  64. package/dist/sortable-list/SortableList.js +1 -1
  65. package/dist/sortable-tree/SortableTreeItem.d.ts +3 -1
  66. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  67. package/dist/sortable-tree/SortableTreeItem.js +1 -1
  68. package/dist/styles/product-set/EditVenueMapSetModal.scss +1 -1
  69. package/package.json +1 -1
  70. package/src/product-set/card/ProductSetCard.tsx +12 -1
  71. package/src/product-set/control/DateInput.tsx +318 -0
  72. package/src/product-set/control/ProductSetControl.tsx +46 -24
  73. package/src/product-set/control/ProductSetRecurrenceOverridesControl.tsx +63 -0
  74. package/src/product-set/control/TutorialGifCard.tsx +11 -3
  75. package/src/product-set/form/ProductCategoriesControl.tsx +12 -1
  76. package/src/product-set/form/ProductSetForm.tsx +5 -0
  77. package/src/product-set/form/ProductsControl.tsx +10 -0
  78. package/src/product-set/form/StepsControl.tsx +8 -2
  79. package/src/product-set/form/SubProductsControl.tsx +3 -0
  80. package/src/product-set/hooks/useSortableTreeFunctions.ts +4 -0
  81. package/src/product-set/item/CreateProductSetItem.tsx +3 -0
  82. package/src/product-set/product/ProductControl.tsx +32 -13
  83. package/src/product-set/product/constants.ts +1 -0
  84. package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +10 -2
  85. package/src/product-set/product/quantity/ProductQuantityControl.tsx +4 -3
  86. package/src/product-set/product-category/ProductCategoryControl.tsx +12 -8
  87. package/src/recurring-date-picker-input/DatePickerInput.tsx +93 -0
  88. package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +137 -0
  89. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +4 -1
  90. package/src/sortable-list/SortableList.tsx +3 -0
  91. package/src/sortable-tree/SortableTreeItem.tsx +13 -5
  92. package/src/styles/product-set/EditVenueMapSetModal.scss +1 -1
@@ -0,0 +1,318 @@
1
+ import React, { useRef, useState } from "react";
2
+ import { Modifier } from "@popperjs/core";
3
+ import { useId } from "@react-aria/utils";
4
+ import { Form, OverlayTrigger, Popover } from "react-bootstrap";
5
+ import { useFieldArray, useFormContext } from "react-hook-form";
6
+ import { useTranslation } from "react-i18next";
7
+ import { useClickAway } from "react-use";
8
+ import { TIMEZONE } from "@licklist/core/dist/Config/Date";
9
+ import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
10
+ import { TIME_FORMAT } from "@licklist/core/dist/Config/Date";
11
+ import { DateTime } from "luxon";
12
+ import RRule, { Frequency } from "rrule";
13
+ import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
14
+
15
+ import { DatePickerInput } from "../../recurring-date-picker-input/DatePickerInput";
16
+ import { CONFIRM_MODAL_ACTIONS } from "../../modals/confirmation/ConfirmModal";
17
+ import { Icon } from "../../static";
18
+
19
+ import {
20
+ AvailableTimesControl,
21
+ AvailableTimesControlRef,
22
+ } from "../../zone/form/components/AvailableTimesControl";
23
+ import {
24
+ RecurringDatePickerInputValues,
25
+ getDateTimeObject,
26
+ } from "../../recurring-date-picker-input/RecurringDatePickerInput";
27
+ import { ProductSetRecurrenceOverridesControl } from "./ProductSetRecurrenceOverridesControl";
28
+ import { MAX_QUANTITY_RECURRENCE_DATE_IN_OVERRIDE } from "../product/constants";
29
+
30
+
31
+ export interface DateAndRecurrenceInputValues {
32
+ menuRecurrences?: Partial<ProductSetRecurrence>[];
33
+ }
34
+
35
+ interface DateAndRecurrenceInputProps {
36
+ isEventEditProductSet?: boolean;
37
+ workHours?: WorkHour[];
38
+ providerHasBookingManagement: boolean;
39
+ isLoading?: boolean;
40
+ }
41
+
42
+ export const DateInput = ({
43
+ isEventEditProductSet,
44
+ isLoading,
45
+ workHours,
46
+ providerHasBookingManagement,
47
+ }: DateAndRecurrenceInputProps) => {
48
+ const {
49
+ control,
50
+ register,
51
+ formState: { errors },
52
+ getValues,
53
+ setValue,
54
+ clearErrors,
55
+ } = useFormContext<DateAndRecurrenceInputValues>();
56
+
57
+ const { fields, append, update } = useFieldArray({
58
+ name: "menuRecurrences",
59
+ control,
60
+ keyName: "_id",
61
+ });
62
+
63
+ const [isDatePopoverVisible, setIsDatePopoverVisible] = useState(false);
64
+ const availableTimesFormRef = useRef<AvailableTimesControlRef>();
65
+ const [editState, setEditState] = useState<{
66
+ index: number;
67
+ values: Partial<ProductSetRecurrence>;
68
+ }>({
69
+ index: null,
70
+ values: null,
71
+ });
72
+ const clearEditState = () => setEditState({ index: null, values: null });
73
+
74
+ const popoverRef = useRef<HTMLDivElement>();
75
+
76
+ useClickAway(popoverRef, (event) => {
77
+ const isModal = CONFIRM_MODAL_ACTIONS.includes(
78
+ (event.target as HTMLElement)?.attributes?.getNamedItem("data-id")?.value
79
+ );
80
+
81
+ if (isModal) {
82
+ return;
83
+ }
84
+
85
+ setIsDatePopoverVisible(false);
86
+ clearEditState();
87
+ });
88
+
89
+ const popoverId = useId()!;
90
+
91
+ const handleOnEdit = (next: Partial<ProductSetRecurrence>, index) => {
92
+ clearEditState();
93
+
94
+ // Hotfix for an issue with Popover close & open actions
95
+ setTimeout(() => {
96
+ setEditState({ index, values: next });
97
+ setIsDatePopoverVisible(() => true);
98
+ }, 100);
99
+ };
100
+
101
+ const { t } = useTranslation("Design");
102
+
103
+ // in this method we should fulfill the form with a proper data
104
+ const handleRecurringDateChange = async (
105
+ next: RecurringDatePickerInputValues
106
+ ) => {
107
+ const isAvailableTimesFormValid =
108
+ await availableTimesFormRef.current?.trigger();
109
+
110
+ if (next?.startTime && next?.endTime && isAvailableTimesFormValid) {
111
+ const startTime = DateTime.fromISO(next.startTime);
112
+ const endTime = DateTime.fromISO(next.endTime);
113
+ const { availableTimes } = availableTimesFormRef.current.getValues();
114
+ const validAvalilableTimes = availableTimes.every((time) => {
115
+ const currentAvailableTime = DateTime.fromFormat(time, TIME_FORMAT);
116
+
117
+ return (
118
+ currentAvailableTime.diff(startTime, "minutes").minutes >= 0 &&
119
+ currentAvailableTime.diff(endTime, "minutes").minutes <= 0
120
+ );
121
+ });
122
+ if (!validAvalilableTimes) {
123
+ availableTimesFormRef.current.setError("availableTimes", {
124
+ message: t("Validation:fieldTimeBetween", {
125
+ attribute: t("Design:startTimesSmall"),
126
+ min: startTime.toFormat(TIME_FORMAT),
127
+ max: endTime.toFormat(TIME_FORMAT),
128
+ }),
129
+ });
130
+
131
+ return;
132
+ }
133
+ }
134
+ const start = getDateTimeObject(next.startDate, next.endTime || "23:59:59");
135
+
136
+ const rrule = RRule.optionsToString({
137
+ until: (start as DateTime).toJSDate(),
138
+ byweekday: [],
139
+ freq: Frequency.DAILY,
140
+ tzid: TIMEZONE,
141
+ interval: 1,
142
+ }).replace("RRULE:", "");
143
+
144
+ const availableTime =
145
+ availableTimesFormRef?.current?.getValues()?.availableTimes || null;
146
+ const values = {
147
+ rrule,
148
+ startDate: next.startDate,
149
+ endDate: next.startDate,
150
+ startTime: next.startTime,
151
+ endTime: next.endTime,
152
+ availableTimes: availableTime,
153
+ } as Partial<ProductSetRecurrence>;
154
+
155
+ if (editState.values?.id) {
156
+ values.id = editState.values?.id;
157
+ }
158
+
159
+ if (editState.index !== null) {
160
+ update(editState.index, values);
161
+ } else {
162
+ append(values);
163
+ }
164
+
165
+ setIsDatePopoverVisible(() => false);
166
+ clearEditState();
167
+ };
168
+
169
+ const handleOnAdd = () => {
170
+ if (fields.length >= 1) return;
171
+ clearEditState();
172
+ setIsDatePopoverVisible((prevValue) => !prevValue);
173
+ };
174
+
175
+ const handleDelete = () => {
176
+ const removeIndex = editState.index;
177
+
178
+ setIsDatePopoverVisible(false);
179
+ clearEditState();
180
+
181
+ setTimeout(() => {
182
+ const { menuRecurrences = [] } = getValues();
183
+
184
+ // @TODO looks like workaround
185
+ // Need recheck other places with remove method.
186
+ // or update react-hook-form version.
187
+ // Remove method from useFormFieldArray throw
188
+ // errors while try to remove element by index.
189
+ // So we remove them manually
190
+ setValue(
191
+ "menuRecurrences",
192
+ menuRecurrences.filter(
193
+ (_currentMenuRecurrence, index) => index !== removeIndex
194
+ )
195
+ );
196
+ }, 100);
197
+ };
198
+
199
+ return (
200
+ <Form.Group>
201
+ <Form.Label>
202
+ {t(
203
+ isEventEditProductSet
204
+ ? "whenOverridesAvailable"
205
+ : "productSetAvailable"
206
+ )}
207
+ </Form.Label>
208
+
209
+ <OverlayTrigger
210
+ show={isDatePopoverVisible}
211
+ overlay={
212
+ <Popover id={popoverId} className="rounded">
213
+ <Popover.Content className="shadow-lg rounded" ref={popoverRef}>
214
+ <DatePickerInput
215
+ defaultValues={editState.values}
216
+ onChange={handleRecurringDateChange}
217
+ onDelete={handleDelete}
218
+ >
219
+ {providerHasBookingManagement && (
220
+ <AvailableTimesControl
221
+ workHours={workHours}
222
+ isLoading={isLoading}
223
+ ref={availableTimesFormRef}
224
+ defaultValues={[]}
225
+ errorMessage={
226
+ errors?.menuRecurrences?.[`${editState?.index}`]
227
+ ?.availableTimes?.message
228
+ }
229
+ clearErrorMessage={() =>
230
+ clearErrors(
231
+ `menuRecurrences.${editState?.index}.availableTimes`
232
+ )
233
+ }
234
+ />
235
+ )}
236
+ </DatePickerInput>
237
+ </Popover.Content>
238
+ </Popover>
239
+ }
240
+ trigger="click"
241
+ placement="bottom"
242
+ popperConfig={{ modifiers: [sameWidthPopperModifier] }}
243
+ >
244
+ <div className="product-set-recurrences">
245
+ {fields.map((menuRecurrence, index) => (
246
+ <ProductSetRecurrenceOverridesControl
247
+ key={menuRecurrence._id}
248
+ menuRecurrence={menuRecurrence}
249
+ onEdit={() => handleOnEdit(menuRecurrence, index)}
250
+ errorMessage={
251
+ errors?.menuRecurrences?.[`${index}`]?.availableTimes?.message
252
+ }
253
+ />
254
+ ))}
255
+ {fields.length < MAX_QUANTITY_RECURRENCE_DATE_IN_OVERRIDE && (
256
+ <div
257
+ className="product-set-recurrence-icon-wrapper"
258
+ role="button"
259
+ tabIndex={0}
260
+ onClick={handleOnAdd}
261
+ onKeyDown={handleOnAdd}
262
+ >
263
+ <Icon
264
+ type="plus-circle"
265
+ height="1rem"
266
+ className="product-set-recurrence-icon-add mr-2"
267
+ />
268
+ {t("addDates")}
269
+ </div>
270
+ )}
271
+
272
+ <Form.Control
273
+ type="hidden"
274
+ {...register("menuRecurrences", {
275
+ required: {
276
+ value: true,
277
+ message: t("Validation:fieldMinNumber", {
278
+ attribute: t("dates"),
279
+ min: 1,
280
+ }),
281
+ },
282
+ })}
283
+ />
284
+
285
+ <div className="manual-form-error">
286
+ {errors.menuRecurrences?.message}
287
+ </div>
288
+ </div>
289
+ </OverlayTrigger>
290
+ </Form.Group>
291
+ );
292
+ };
293
+
294
+ export const sameWidthPopperModifier: Modifier<
295
+ "sameWidth",
296
+ Record<string, unknown>
297
+ > = {
298
+ name: "sameWidth",
299
+ enabled: true,
300
+ phase: "beforeWrite",
301
+ requires: ["computeStyles"],
302
+ fn({ state }) {
303
+ const style = {
304
+ width: `${state.rects.reference.width + 4}px`,
305
+ marginLeft: "-2px",
306
+ maxWidth: "unset",
307
+ };
308
+ Object.assign(state.styles.popper, style);
309
+ },
310
+ effect({ state }) {
311
+ const { width } = state.elements.reference.getBoundingClientRect();
312
+ const style = {
313
+ width: `${width}px`,
314
+ maxWidth: "unset",
315
+ };
316
+ Object.assign(state.elements.popper.style, style);
317
+ },
318
+ };
@@ -34,6 +34,7 @@ import TutorialGifCard from "./TutorialGifCard";
34
34
  import { Step } from "../types";
35
35
  import { StepsControl } from "../form/StepsControl";
36
36
  import { Typeahead } from "../../typeahead";
37
+ import { DateInput } from "./DateInput";
37
38
 
38
39
  const OPERATIONAL_COST_TITLES = {
39
40
  [OPERATIONAL_COST_PROVIDER]: "operationalCostProvider",
@@ -86,6 +87,7 @@ export interface ProductSetControlProps {
86
87
  showSmsTemplate?: boolean;
87
88
  workHours?: WorkHour[];
88
89
  providerHasBookingManagement?: boolean;
90
+ isOverrides?: boolean;
89
91
  }
90
92
 
91
93
  export function ProductSetControl({
@@ -101,6 +103,7 @@ export function ProductSetControl({
101
103
  showSmsTemplate,
102
104
  workHours,
103
105
  providerHasBookingManagement = false,
106
+ isOverrides = false,
104
107
  }: ProductSetControlProps) {
105
108
  const { t } = useTranslation(["Design", "Validation", "Notification"]);
106
109
  const {
@@ -118,6 +121,9 @@ export function ProductSetControl({
118
121
  const termsAndConditionsId = useId();
119
122
  const relyOnPeopleTypeId = useId();
120
123
 
124
+ const showSmsTemplateSelector = showSmsTemplate && !isOverrides;
125
+ const showEmailTemplateSelector = showEmailTemplate && !isOverrides;
126
+
121
127
  return (
122
128
  <Row
123
129
  className={`product-set-form ${
@@ -159,20 +165,30 @@ export function ProductSetControl({
159
165
  </Form.Control.Feedback>
160
166
  </Form.Group>
161
167
 
162
- {isCreateAction && (
163
- <DateAndRecurrenceInput
164
- isEventEditProductSet={isEventEditProductSet}
168
+ {isOverrides ? (
169
+ <DateInput
165
170
  workHours={workHours}
166
171
  isLoading={isLoading}
167
172
  providerHasBookingManagement={providerHasBookingManagement}
168
173
  />
174
+ ) : (
175
+ <>
176
+ {isCreateAction && (
177
+ <DateAndRecurrenceInput
178
+ isEventEditProductSet={isEventEditProductSet}
179
+ workHours={workHours}
180
+ isLoading={isLoading}
181
+ providerHasBookingManagement={providerHasBookingManagement}
182
+ />
183
+ )}
184
+ </>
169
185
  )}
170
186
 
171
187
  <div className="divider" />
172
188
 
173
- <TutorialGifCard />
189
+ <TutorialGifCard isOverrides={isOverrides} />
174
190
 
175
- <StepsControl isLoading={isLoading} />
191
+ <StepsControl isLoading={isLoading} isOverrides={isOverrides} />
176
192
  </Col>
177
193
  <Col md={6} sm={12}>
178
194
  <div className="second-column">
@@ -212,6 +228,7 @@ export function ProductSetControl({
212
228
  {...register("operationalCost", { required: true })}
213
229
  as="select"
214
230
  defaultValue={OPERATIONAL_COST_PROVIDER}
231
+ disabled={isOverrides}
215
232
  isInvalid={HookFormService.isInvalid("operationalCost", errors)}
216
233
  >
217
234
  {Object.keys(OPERATIONAL_COST_TYPES).map((operationalCost) => (
@@ -241,6 +258,7 @@ export function ProductSetControl({
241
258
  {...register("relyOnPeopleType")}
242
259
  as="select"
243
260
  defaultValue={null}
261
+ disabled={isOverrides}
244
262
  isInvalid={HookFormService.isInvalid("relyOnPeopleType", errors)}
245
263
  >
246
264
  <option value="">{t("notRequired")} </option>
@@ -268,7 +286,7 @@ export function ProductSetControl({
268
286
  {...register("termsAndConditions")}
269
287
  as="textarea"
270
288
  rows={2}
271
- disabled={isLoading}
289
+ disabled={isLoading || isOverrides}
272
290
  isInvalid={HookFormService.isInvalid(
273
291
  "termsAndConditions",
274
292
  errors
@@ -283,30 +301,32 @@ export function ProductSetControl({
283
301
  <Form.Label className="mt-4">
284
302
  {t("Design:emailTemplate")}
285
303
  </Form.Label>
286
- {showEmailTemplate ? (
287
- <Typeahead
288
- name="emailTemplates"
289
- options={emailTemplates}
290
- isMultipleChoise
291
- placeholder={t("Design:choose")}
292
- noOptionsMessage={t("Design:noActiveTemplates", {
293
- notification: t("Design:email"),
294
- })}
295
- />
296
- ) : (
297
- <WarningMessage
298
- message={t("Design:noActiveTemplates", {
299
- notification: t("Design:email"),
300
- })}
301
- />
302
- )}
304
+ <>
305
+ {showEmailTemplateSelector ? (
306
+ <Typeahead
307
+ name="emailTemplates"
308
+ options={emailTemplates}
309
+ isMultipleChoise
310
+ placeholder={t("Design:choose")}
311
+ noOptionsMessage={t("Design:noActiveTemplates", {
312
+ notification: t("Design:email"),
313
+ })}
314
+ />
315
+ ) : (
316
+ <WarningMessage
317
+ message={t("Design:noActiveTemplates", {
318
+ notification: t("Design:email"),
319
+ })}
320
+ />
321
+ )}
322
+ </>
303
323
 
304
324
  <Form.Label
305
325
  className={clsx(emailTemplates.length > 0 ? "mt-4" : "mt-1")}
306
326
  >
307
327
  {t("Design:smsTemplate")}
308
328
  </Form.Label>
309
- {showSmsTemplate ? (
329
+ {showSmsTemplateSelector ? (
310
330
  <Typeahead
311
331
  name="smsTemplates"
312
332
  options={smsTemplates}
@@ -339,6 +359,7 @@ export function ProductSetControl({
339
359
  onChange={field.onChange}
340
360
  value={fieldValue}
341
361
  as="select"
362
+ disabled={isOverrides}
342
363
  isInvalid={HookFormService.isInvalid(
343
364
  "fieldSetId",
344
365
  errors
@@ -375,6 +396,7 @@ export function ProductSetControl({
375
396
  }) as string;
376
397
  },
377
398
  })}
399
+ disabled={isOverrides}
378
400
  isInvalid={HookFormService.isInvalid("thankYouPageUrl", errors)}
379
401
  />
380
402
 
@@ -0,0 +1,63 @@
1
+ import React from "react";
2
+ import { useIntl } from "react-intl";
3
+ import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
4
+
5
+ import { Icon } from "../../static";
6
+
7
+ export interface ProductSetRecurrenceControlProps {
8
+ menuRecurrence?: { _id: string } & Partial<ProductSetRecurrence>;
9
+ onEdit?: (onEdit: Partial<ProductSetRecurrence>) => void;
10
+ errorMessage?: string;
11
+ }
12
+
13
+ export const ProductSetRecurrenceOverridesControl = ({
14
+ menuRecurrence,
15
+ onEdit,
16
+ errorMessage,
17
+ }: ProductSetRecurrenceControlProps) => {
18
+ const { formatDate } = useIntl();
19
+
20
+ return (
21
+ <div className="sortable-tree-root flex-column" role="button" tabIndex={0}>
22
+ <div
23
+ key={menuRecurrence.rrule}
24
+ className="product-set-recurrence d-flex flex-column mr-0 mb-3 p-3 px-4 flex-grow-1"
25
+ >
26
+ <span className="d-flex flex-row align-items-center">
27
+ <Icon
28
+ type="calendar"
29
+ height="1rem"
30
+ className="product-set-recurrence-icon-calendar"
31
+ />
32
+ <span className="product-set-recurrence-title d-flex flex-grow-1">
33
+ {formatDate(menuRecurrence.startDate, {
34
+ dateStyle: "medium",
35
+ })}{" "}
36
+ </span>
37
+
38
+ <div
39
+ className="d-inline-flex"
40
+ role="button"
41
+ tabIndex={0}
42
+ onClick={() => onEdit(menuRecurrence)}
43
+ onKeyDown={() => onEdit(menuRecurrence)}
44
+ >
45
+ <Icon
46
+ type="ellipsis-h"
47
+ height="1rem"
48
+ className="product-set-recurrence-icon-more"
49
+ />
50
+ </div>
51
+ </span>
52
+ <span className="product-set-recurrence-description">
53
+ {formatDate(menuRecurrence.startDate, {
54
+ dateStyle: "medium",
55
+ })}{" "}
56
+ </span>
57
+ </div>
58
+ <div className={`manual-form-error ${!errorMessage && "d-none"}`}>
59
+ {errorMessage}
60
+ </div>
61
+ </div>
62
+ );
63
+ };
@@ -9,10 +9,14 @@ import { Icon, Image } from "../../static";
9
9
 
10
10
  export interface TutorialGifCardProps {
11
11
  tutorialAsset?: string;
12
+ isOverrides?: boolean;
12
13
  }
13
14
 
14
15
  // @TODO: Tutorial GIF asset should be passed as context, which is better
15
- const TutorialGifCard = ({ tutorialAsset }: TutorialGifCardProps) => {
16
+ const TutorialGifCard = ({
17
+ tutorialAsset,
18
+ isOverrides,
19
+ }: TutorialGifCardProps) => {
16
20
  const { pathname } = useLocation();
17
21
  const [isVisible, setIsVisible] = useState(pathname?.includes("/create"));
18
22
  const { t } = useTranslation(["Design"]);
@@ -46,8 +50,12 @@ const TutorialGifCard = ({ tutorialAsset }: TutorialGifCardProps) => {
46
50
  </button>
47
51
  </Card.Header>
48
52
  <Card.Body className="tutorial-card-body">
49
- <p>{t("buildProductSet")}</p>
50
- <span>{t("buildProductSetDesc")}</span>
53
+ <p>
54
+ {t(isOverrides ? "buildOverrideProductSet" : "buildProductSet")}
55
+ </p>
56
+ <span>
57
+ {t(isOverrides ? "buildOverrideRules" : "buildProductSetDesc")}
58
+ </span>
51
59
  {tutorialAsset && <Image src={tutorialAsset} alt="Tutorial Gif" />}
52
60
  </Card.Body>
53
61
  </Card>
@@ -35,6 +35,7 @@ import { useSortableTreeFunctions } from "../hooks/useSortableTreeFunctions";
35
35
 
36
36
  interface ProductCategoriesControlProps extends WithIsLoading {
37
37
  stepIndex: number;
38
+ isOverrides?: boolean;
38
39
  }
39
40
 
40
41
  const getCategoryDefaultValue = (
@@ -65,6 +66,7 @@ const getCategoryDefaultValue = (
65
66
  export function ProductCategoriesControl({
66
67
  isLoading,
67
68
  stepIndex,
69
+ isOverrides,
68
70
  }: ProductCategoriesControlProps) {
69
71
  const { t } = useTranslation("Design");
70
72
  const {
@@ -105,6 +107,7 @@ export function ProductCategoriesControl({
105
107
  const { edit, saveValidField, cancelChanges } = useSortableTreeFunctions({
106
108
  fieldName: productCategoriesFieldName,
107
109
  remove,
110
+ isOverrides,
108
111
  });
109
112
 
110
113
  const productCategories: ProductCategory[] = useWatch({
@@ -129,7 +132,7 @@ export function ProductCategoriesControl({
129
132
  });
130
133
 
131
134
  const handleDragEnd = (event) => {
132
- // @TODO uncomment when will be fix for change sort index
135
+ if (isOverrides) return;
133
136
  const { active, over } = event;
134
137
 
135
138
  if (!active || !over || !active?.id || !over?.id) return;
@@ -266,8 +269,10 @@ export function ProductCategoriesControl({
266
269
  categoryName={value}
267
270
  stepIndex={stepIndex}
268
271
  productCategoryIndex={index}
272
+ isOverride={isOverrides}
269
273
  />
270
274
  }
275
+ isOverride={isOverrides}
271
276
  onDelete={() => remove(index)}
272
277
  validate={() =>
273
278
  trigger(`steps.${stepIndex}.productCategories.${index}`)
@@ -290,6 +295,7 @@ export function ProductCategoriesControl({
290
295
  zones={zones}
291
296
  productCategoryIndex={index}
292
297
  categoryType={productCategory.type}
298
+ isOverrides={isOverrides}
293
299
  />
294
300
  </SortableTree.Item>
295
301
  )}
@@ -299,7 +305,9 @@ export function ProductCategoriesControl({
299
305
  </SortableTree>
300
306
  <CreateProductSetItem
301
307
  title={t("addCategory")}
308
+ isOverride={isOverrides}
302
309
  onClick={() => {
310
+ if (isOverrides) return;
303
311
  setIsSelectCategoryVisible(true);
304
312
  }}
305
313
  />
@@ -308,6 +316,7 @@ export function ProductCategoriesControl({
308
316
  isVisible={isSelectCategoryVisible}
309
317
  onHide={() => setIsSelectCategoryVisible(false)}
310
318
  onCategorySelect={(categoryType) => {
319
+ if (isOverrides) return;
311
320
  append(getCategoryDefaultValue(categoryType, fields.length));
312
321
  setShowCategoryModal(true);
313
322
  if (
@@ -321,7 +330,9 @@ export function ProductCategoriesControl({
321
330
  <>
322
331
  <CreateProductSetItem
323
332
  title={t("editMap")}
333
+ isOverride={isOverrides}
324
334
  onClick={() => {
335
+ if (isOverrides) return;
325
336
  setIsVenueMapSetModalVisible(true);
326
337
  }}
327
338
  className={clsx(
@@ -34,6 +34,7 @@ export interface ProductSetFormValues
34
34
  WithId,
35
35
  ProductSetControlValues {
36
36
  steps: Step[];
37
+ isOverrides?: boolean;
37
38
  }
38
39
 
39
40
  export interface ProductSetFormProps
@@ -50,6 +51,7 @@ export interface ProductSetFormProps
50
51
  providerHasBookingManagement?: ProviderBookingManagementSetting["hasBookingManagement"];
51
52
  zones?: Zone[] | null;
52
53
  isCreateAction?: boolean;
54
+ isOverrides?: boolean;
53
55
  workHours?: WorkHour[];
54
56
  }
55
57
 
@@ -67,6 +69,7 @@ export function ProductSetForm({
67
69
  zones,
68
70
  isCreateAction,
69
71
  workHours,
72
+ isOverrides,
70
73
  ...shared
71
74
  }: ProductSetFormProps) {
72
75
  const { t } = useTranslation("Design");
@@ -84,6 +87,7 @@ export function ProductSetForm({
84
87
  });
85
88
 
86
89
  const { setError, reset } = form;
90
+
87
91
  const formValues = form.watch();
88
92
 
89
93
  const submitHandler = (onSubmit: (values: ProductSetFormValues) => void) => {
@@ -161,6 +165,7 @@ export function ProductSetForm({
161
165
  companyName={companyName}
162
166
  workHours={workHours}
163
167
  providerHasBookingManagement={providerHasBookingManagement}
168
+ isOverrides={isOverrides}
164
169
  />
165
170
  <Row>
166
171
  <Col md={6} sm={12} />