@licklist/design 0.67.3-dev.0 → 0.67.3-dev.2
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/EditEventForm/EditEventForm.d.ts +2 -1
- package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +2 -3
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts +2 -2
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +27 -26
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts +2 -2
- 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 +3 -3
- package/dist/index.js +1 -0
- package/dist/modals/confirmation/ConfirmModal.d.ts +3 -1
- package/dist/modals/confirmation/ConfirmModal.d.ts.map +1 -1
- package/dist/modals/confirmation/ConfirmModal.js +172 -8
- package/dist/product-set/card/ProductSetCard.d.ts +6 -2
- package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
- package/dist/product-set/card/ProductSetCard.js +30 -11
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts +2 -1
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.js +2 -1
- package/dist/product-set/control/ProductSetControl.d.ts +1 -2
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +4 -16
- 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 +5 -3
- package/dist/product-set/form/ProductSetNameControl.d.ts +6 -0
- package/dist/product-set/form/ProductSetNameControl.d.ts.map +1 -0
- package/dist/product-set/form/ProductSetNameControl.js +35 -0
- package/dist/product-set/form/index.d.ts +1 -0
- package/dist/product-set/form/index.d.ts.map +1 -1
- package/dist/product-set/utils/index.d.ts +7 -0
- package/dist/product-set/utils/index.d.ts.map +1 -1
- package/dist/product-set/utils/index.js +10 -1
- package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts +2 -1
- package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +7 -13
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +2 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +4 -3
- package/dist/recurring-date-picker-input/utils.d.ts +1 -1
- package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/utils.js +7 -10
- package/dist/typeahead/Typeahead.d.ts +5 -1
- package/dist/typeahead/Typeahead.d.ts.map +1 -1
- package/dist/typeahead/Typeahead.js +9 -2
- package/dist/zone/form/ZoneForm.d.ts +2 -1
- package/dist/zone/form/ZoneForm.d.ts.map +1 -1
- package/dist/zone/form/ZoneForm.js +3 -2
- package/dist/zone/form/components/ZoneControl.d.ts +2 -1
- package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneControl.js +3 -2
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +2 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.js +3 -2
- package/package.json +4 -4
- package/src/events/edit-event-modal/component/EditEventForm/EditEventForm.tsx +3 -2
- package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +35 -37
- package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +3 -3
- package/src/modals/confirmation/ConfirmModal.tsx +19 -3
- package/src/product-set/card/ProductSetCard.tsx +47 -8
- package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -0
- package/src/product-set/control/ProductSetControl.tsx +1 -14
- package/src/product-set/form/ProductSetForm.tsx +3 -0
- package/src/product-set/form/ProductSetNameControl.tsx +27 -0
- package/src/product-set/form/index.ts +1 -0
- package/src/product-set/utils/index.ts +11 -0
- package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +8 -22
- package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +6 -3
- package/src/recurring-date-picker-input/utils.ts +7 -12
- package/src/typeahead/Typeahead.tsx +15 -1
- package/src/zone/form/ZoneForm.tsx +7 -1
- package/src/zone/form/components/ZoneControl.tsx +7 -2
- package/src/zone/form/components/ZoneRecurrencesControl.tsx +3 -0
- package/yarn.lock +161 -141
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoneRecurrencesControl.d.ts","sourceRoot":"","sources":["../../../../src/zone/form/components/ZoneRecurrencesControl.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAMlG,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAWtF,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;CAC7C;AAED,KAAK,0BAA0B,GAAG;IAChC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ZoneRecurrencesControl.d.ts","sourceRoot":"","sources":["../../../../src/zone/form/components/ZoneRecurrencesControl.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAMlG,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAWtF,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;CAC7C;AAED,KAAK,0BAA0B,GAAG;IAChC,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,sBAAsB,6BAGhC,0BAA0B,4CAoM5B,CAAC"}
|
|
@@ -212,7 +212,7 @@ function _ts_generator(thisArg, body) {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
var ZoneRecurrencesControl = function(param) {
|
|
215
|
-
var workHours = param.workHours;
|
|
215
|
+
var workHours = param.workHours, timeZone = param.timeZone;
|
|
216
216
|
var _errors_zoneRecurrences;
|
|
217
217
|
var _useFormContext = useFormContext(), control = _useFormContext.control, register = _useFormContext.register, errors = _useFormContext.formState.errors, getValues = _useFormContext.getValues, setValue = _useFormContext.setValue, clearErrors = _useFormContext.clearErrors;
|
|
218
218
|
var _useFieldArray = useFieldArray({
|
|
@@ -350,7 +350,8 @@ var ZoneRecurrencesControl = function(param) {
|
|
|
350
350
|
onChange: handleRecurringDateChange,
|
|
351
351
|
onDelete: handleDelete,
|
|
352
352
|
setInitialStartDateAfterSelect: true,
|
|
353
|
-
workHours: workHours
|
|
353
|
+
workHours: workHours,
|
|
354
|
+
timeZone: timeZone
|
|
354
355
|
})
|
|
355
356
|
})
|
|
356
357
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@licklist/design",
|
|
3
|
-
"version": "0.67.3-dev.
|
|
3
|
+
"version": "0.67.3-dev.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
]
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@licklist/core": "0.29.1-dev.
|
|
45
|
+
"@licklist/core": "0.29.1-dev.3",
|
|
46
46
|
"@licklist/eslint-config": "0.5.5",
|
|
47
47
|
"@licklist/plugins": "0.32.0-dev.3",
|
|
48
48
|
"lodash": "4.17.21",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@dnd-kit/utilities": "2.0.0",
|
|
62
62
|
"@fortawesome/fontawesome-svg-core": "1.2.34",
|
|
63
63
|
"@fortawesome/free-solid-svg-icons": "5.15.2",
|
|
64
|
-
"@licklist/core": "0.29.1-dev.
|
|
64
|
+
"@licklist/core": "0.29.1-dev.3",
|
|
65
65
|
"@licklist/eslint-config": "0.5.5",
|
|
66
66
|
"@licklist/plugins": "0.32.0-dev.3",
|
|
67
67
|
"@mdx-js/react": "1.6.22",
|
|
@@ -201,4 +201,4 @@
|
|
|
201
201
|
"yarn": "4.4.0"
|
|
202
202
|
},
|
|
203
203
|
"stableVersion": "0.66.7-dev.5"
|
|
204
|
-
}
|
|
204
|
+
}
|
|
@@ -64,6 +64,7 @@ export interface EditEventFormProps extends HasPermissionProp {
|
|
|
64
64
|
createProductSet: (props: EditEventFormValues) => void;
|
|
65
65
|
setEditProductSetId: (value: string) => void;
|
|
66
66
|
isExternalPaymentLinkEnabled?: boolean;
|
|
67
|
+
timeZone: string;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
const eventImageTypes = {
|
|
@@ -83,6 +84,7 @@ export const EditEventForm = ({
|
|
|
83
84
|
createProductSet,
|
|
84
85
|
setEditProductSetId,
|
|
85
86
|
isExternalPaymentLinkEnabled,
|
|
87
|
+
timeZone,
|
|
86
88
|
}: EditEventFormProps) => {
|
|
87
89
|
const { t } = useTranslation(["Design", "Validation"]);
|
|
88
90
|
|
|
@@ -122,7 +124,6 @@ export const EditEventForm = ({
|
|
|
122
124
|
const visible = watch("visible");
|
|
123
125
|
const editedProductSet = watch("editedProductSet");
|
|
124
126
|
const productSetId = watch("productSetId");
|
|
125
|
-
const occurrenceStartAtDate = watch("start");
|
|
126
127
|
|
|
127
128
|
const {
|
|
128
129
|
images,
|
|
@@ -404,7 +405,7 @@ export const EditEventForm = ({
|
|
|
404
405
|
setEditProductSetId={setEditProductSetId}
|
|
405
406
|
setShowEditProductSet={setShowEditProductSet}
|
|
406
407
|
showEditProductSet={showEditProductSet}
|
|
407
|
-
|
|
408
|
+
timeZone={timeZone}
|
|
408
409
|
/>
|
|
409
410
|
|
|
410
411
|
{hasPermission && !showEditProductSet && (
|
package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx
CHANGED
|
@@ -5,9 +5,11 @@ import { useId } from "@react-aria/utils";
|
|
|
5
5
|
import { Controller, useFormContext } from "react-hook-form";
|
|
6
6
|
import { HasPermissionProp } from "@licklist/plugins/dist/types/permission/Permission";
|
|
7
7
|
import { ProductSet } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
|
|
8
|
+
import { getTypeHeadItemsFromMenus } from "../../../../product-set/utils";
|
|
8
9
|
import { ConfirmModal } from "../../../../modals/confirmation/ConfirmModal";
|
|
9
10
|
import { EditEventFormValues } from "../EditEventForm/EditEventForm";
|
|
10
11
|
import { EditEventProductSet } from "./component/EditEventProductSet";
|
|
12
|
+
import { Typeahead } from "../../../../typeahead";
|
|
11
13
|
|
|
12
14
|
interface SelectEventProductSetProps extends HasPermissionProp {
|
|
13
15
|
productSets?: ProductSet[];
|
|
@@ -15,7 +17,7 @@ interface SelectEventProductSetProps extends HasPermissionProp {
|
|
|
15
17
|
setShowEditProductSet: (value: boolean) => void;
|
|
16
18
|
createProductSet: (props: EditEventFormValues) => void;
|
|
17
19
|
setEditProductSetId: (value: string) => void;
|
|
18
|
-
|
|
20
|
+
timeZone: string;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export const SelectEventProductSet = ({
|
|
@@ -24,7 +26,7 @@ export const SelectEventProductSet = ({
|
|
|
24
26
|
setEditProductSetId,
|
|
25
27
|
showEditProductSet,
|
|
26
28
|
setShowEditProductSet,
|
|
27
|
-
|
|
29
|
+
timeZone,
|
|
28
30
|
}: SelectEventProductSetProps) => {
|
|
29
31
|
const { t } = useTranslation(["Design"]);
|
|
30
32
|
const form = useFormContext<EditEventFormValues>();
|
|
@@ -42,6 +44,21 @@ export const SelectEventProductSet = ({
|
|
|
42
44
|
const productSetId = watch("productSetId");
|
|
43
45
|
const editedProductSet = watch("editedProductSet");
|
|
44
46
|
|
|
47
|
+
const typeheadValues = getTypeHeadItemsFromMenus(
|
|
48
|
+
editedProductSet
|
|
49
|
+
? productSets.map((productSet) => {
|
|
50
|
+
if (productSet.id === editedProductSet.id) {
|
|
51
|
+
return editedProductSet;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return productSet;
|
|
55
|
+
})
|
|
56
|
+
: productSets,
|
|
57
|
+
);
|
|
58
|
+
const selectedProductSetTypeheadValue = productSetId
|
|
59
|
+
? typeheadValues?.find((typeheadValue) => typeheadValue.id === productSetId)
|
|
60
|
+
: undefined;
|
|
61
|
+
|
|
45
62
|
const onEditProductSet = useCallback(
|
|
46
63
|
() => {
|
|
47
64
|
setEditProductSetId(String(productSetId));
|
|
@@ -95,6 +112,7 @@ export const SelectEventProductSet = ({
|
|
|
95
112
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
113
|
const onSubmit = (value: EditEventFormValues["editedProductSet"]) => {
|
|
97
114
|
setShowEditProductSet(false);
|
|
115
|
+
setValue("productSetId", value.id);
|
|
98
116
|
setValue("editedProductSet", value);
|
|
99
117
|
};
|
|
100
118
|
|
|
@@ -110,49 +128,29 @@ export const SelectEventProductSet = ({
|
|
|
110
128
|
<Controller
|
|
111
129
|
control={control}
|
|
112
130
|
name="productSetId"
|
|
113
|
-
render={(
|
|
114
|
-
const fieldValue = String(field.value);
|
|
131
|
+
render={() => {
|
|
115
132
|
return (
|
|
116
133
|
<>
|
|
117
134
|
<div className="d-flex align-items-center flex-row w-100">
|
|
118
135
|
<ConfirmModal>
|
|
119
136
|
{(confirm) => {
|
|
120
137
|
return (
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
<Typeahead
|
|
139
|
+
name="productSetId"
|
|
140
|
+
value={selectedProductSetTypeheadValue}
|
|
141
|
+
containerStyles={{ width: "100%" }}
|
|
142
|
+
onChangeValue={(typeheadValue) => {
|
|
124
143
|
onChangeProductSet(
|
|
125
|
-
Number(
|
|
144
|
+
Number(typeheadValue.id),
|
|
126
145
|
confirm,
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
isInvalid={Boolean(errors.productSetId)}
|
|
130
|
-
value={fieldValue}
|
|
131
|
-
>
|
|
132
|
-
<option value="" hidden>
|
|
133
|
-
{t("Design:chooseProductSet")}
|
|
134
|
-
</option>
|
|
135
|
-
{productSets?.map((productSet) => {
|
|
136
|
-
const isCurrentEditedProductSet =
|
|
137
|
-
editedProductSet &&
|
|
138
|
-
editedProductSet?.id === productSet?.id;
|
|
139
|
-
return (
|
|
140
|
-
<option
|
|
141
|
-
key={productSet.id}
|
|
142
|
-
value={productSet.id}
|
|
143
|
-
>
|
|
144
|
-
{isCurrentEditedProductSet ||
|
|
145
|
-
productSet.isOverride
|
|
146
|
-
? `[${t("edited")}] ${
|
|
147
|
-
isCurrentEditedProductSet
|
|
148
|
-
? editedProductSet?.name
|
|
149
|
-
: productSet.name
|
|
150
|
-
}`
|
|
151
|
-
: productSet.name}
|
|
152
|
-
</option>
|
|
153
146
|
);
|
|
154
|
-
}
|
|
155
|
-
|
|
147
|
+
}}
|
|
148
|
+
options={typeheadValues}
|
|
149
|
+
placeholder={t("Design:choose")}
|
|
150
|
+
noOptionsMessage={t(
|
|
151
|
+
"Design:noAvailableProductSets",
|
|
152
|
+
)}
|
|
153
|
+
/>
|
|
156
154
|
);
|
|
157
155
|
}}
|
|
158
156
|
</ConfirmModal>
|
|
@@ -211,10 +209,10 @@ export const SelectEventProductSet = ({
|
|
|
211
209
|
{showEditProductSet && productSetId && (
|
|
212
210
|
<EditEventProductSet
|
|
213
211
|
onSubmit={onSubmit}
|
|
214
|
-
occurrenceStartAtDate={occurrenceStartAtDate}
|
|
215
212
|
defaultValues={
|
|
216
213
|
productSetId === editedProductSet?.id && editedProductSet
|
|
217
214
|
}
|
|
215
|
+
timeZone={timeZone}
|
|
218
216
|
/>
|
|
219
217
|
)}
|
|
220
218
|
</>
|
|
@@ -22,13 +22,13 @@ export interface EventDates {
|
|
|
22
22
|
interface EditEventProductSetProps {
|
|
23
23
|
onSubmit: (value: EditEventFormValues["editedProductSet"]) => void;
|
|
24
24
|
defaultValues?: EditEventFormValues["editedProductSet"];
|
|
25
|
-
|
|
25
|
+
timeZone: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const EditEventProductSet = ({
|
|
29
29
|
onSubmit,
|
|
30
30
|
defaultValues,
|
|
31
|
-
|
|
31
|
+
timeZone,
|
|
32
32
|
}: EditEventProductSetProps) => {
|
|
33
33
|
const { companyId } = useParams<{
|
|
34
34
|
companyId: string;
|
|
@@ -127,8 +127,8 @@ export const EditEventProductSet = ({
|
|
|
127
127
|
fee={feeInPercent}
|
|
128
128
|
isEventEditProductSet
|
|
129
129
|
isOverrides
|
|
130
|
-
occurrenceStartAtDate={occurrenceStartAtDate}
|
|
131
130
|
workHours={undefined}
|
|
131
|
+
timeZone={timeZone}
|
|
132
132
|
/>
|
|
133
133
|
<Button
|
|
134
134
|
disabled={isLoading}
|
|
@@ -20,6 +20,9 @@ export type ConfirmModalTypes =
|
|
|
20
20
|
export interface ConfirmModalProps {
|
|
21
21
|
type?: ConfirmModalTypes;
|
|
22
22
|
children?: (confirm: (action: ConfirmAction) => void) => ReactNode;
|
|
23
|
+
// confirm function memoize the callback function. It's an alternative function
|
|
24
|
+
confirmationHandler?: () => Promise<boolean | undefined>;
|
|
25
|
+
disabledButtons?: boolean;
|
|
23
26
|
title?: string;
|
|
24
27
|
content?: string | ReactNode;
|
|
25
28
|
onClose?: () => void;
|
|
@@ -37,7 +40,9 @@ export function ConfirmModal({
|
|
|
37
40
|
type = "default",
|
|
38
41
|
children,
|
|
39
42
|
onClose,
|
|
43
|
+
confirmationHandler,
|
|
40
44
|
title,
|
|
45
|
+
disabledButtons,
|
|
41
46
|
content,
|
|
42
47
|
hideButtons = false,
|
|
43
48
|
}: ConfirmModalProps) {
|
|
@@ -52,10 +57,16 @@ export function ConfirmModal({
|
|
|
52
57
|
setIsOpen(() => true);
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
const handleConfirmation = (e) => {
|
|
60
|
+
const handleConfirmation = async (e) => {
|
|
56
61
|
e.stopPropagation();
|
|
57
|
-
if (!actionRef.current) return;
|
|
58
|
-
|
|
62
|
+
if (!actionRef.current && !confirmationHandler) return;
|
|
63
|
+
if (confirmationHandler) {
|
|
64
|
+
const res = await confirmationHandler();
|
|
65
|
+
if (res) {
|
|
66
|
+
setIsOpen(() => false);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
59
70
|
actionRef.current();
|
|
60
71
|
setIsOpen(() => false);
|
|
61
72
|
};
|
|
@@ -88,6 +99,7 @@ export function ConfirmModal({
|
|
|
88
99
|
<Button
|
|
89
100
|
variant="danger"
|
|
90
101
|
className="btn-sm rounded"
|
|
102
|
+
disabled={disabledButtons}
|
|
91
103
|
onClick={handleClose}
|
|
92
104
|
data-id={CONFIRM_MODAL_ACTION_DECLINE}
|
|
93
105
|
>
|
|
@@ -105,12 +117,14 @@ export function ConfirmModal({
|
|
|
105
117
|
variant="outline"
|
|
106
118
|
className="cancel-button"
|
|
107
119
|
onClick={handleClose}
|
|
120
|
+
disabled={disabledButtons}
|
|
108
121
|
data-id={CONFIRM_MODAL_ACTION_DECLINE}
|
|
109
122
|
>
|
|
110
123
|
{t("cancel")}
|
|
111
124
|
</Button>
|
|
112
125
|
<Button
|
|
113
126
|
variant="danger"
|
|
127
|
+
disabled={disabledButtons}
|
|
114
128
|
onClick={handleConfirmation}
|
|
115
129
|
data-id={CONFIRM_MODAL_ACTION_CONFIRM}
|
|
116
130
|
>
|
|
@@ -121,6 +135,7 @@ export function ConfirmModal({
|
|
|
121
135
|
<>
|
|
122
136
|
<Button
|
|
123
137
|
variant="danger"
|
|
138
|
+
disabled={disabledButtons}
|
|
124
139
|
onClick={handleClose}
|
|
125
140
|
data-id={CONFIRM_MODAL_ACTION_DECLINE}
|
|
126
141
|
>
|
|
@@ -128,6 +143,7 @@ export function ConfirmModal({
|
|
|
128
143
|
</Button>
|
|
129
144
|
<Button
|
|
130
145
|
variant="success"
|
|
146
|
+
disabled={disabledButtons}
|
|
131
147
|
onClick={handleConfirmation}
|
|
132
148
|
data-id={CONFIRM_MODAL_ACTION_CONFIRM}
|
|
133
149
|
>
|
|
@@ -9,15 +9,20 @@ import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
|
|
|
9
9
|
import { FaEllipsisH, FaEye, FaTrashAlt } from "react-icons/fa";
|
|
10
10
|
import { ConfirmModal } from "../../modals";
|
|
11
11
|
import { MenuButton } from "../../table/MenuButton";
|
|
12
|
+
import { ProductSetNameControl } from "../form/ProductSetNameControl";
|
|
12
13
|
|
|
13
14
|
export interface ProductSetCardProps extends HasPermissionProp {
|
|
14
15
|
name: string;
|
|
15
16
|
rrule?: string;
|
|
16
17
|
href: string;
|
|
17
|
-
|
|
18
|
+
duplicateProductSetName: string;
|
|
19
|
+
onChangeDuplicateProductSetName: (value: string) => void;
|
|
20
|
+
onCopy: () => Promise<boolean | undefined>;
|
|
18
21
|
onRemove: () => void;
|
|
22
|
+
isLoading?: boolean;
|
|
19
23
|
className?: string;
|
|
20
24
|
override?: number;
|
|
25
|
+
duplicateProductSetError?: string;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
export function ProductSetCard({
|
|
@@ -26,6 +31,10 @@ export function ProductSetCard({
|
|
|
26
31
|
href,
|
|
27
32
|
onCopy,
|
|
28
33
|
onRemove,
|
|
34
|
+
onChangeDuplicateProductSetName,
|
|
35
|
+
duplicateProductSetName,
|
|
36
|
+
duplicateProductSetError,
|
|
37
|
+
isLoading,
|
|
29
38
|
className = "",
|
|
30
39
|
hasPermission = true,
|
|
31
40
|
override = 0,
|
|
@@ -35,19 +44,23 @@ export function ProductSetCard({
|
|
|
35
44
|
const productSetCardClasses = `product-set-card ${className}`;
|
|
36
45
|
const [isOverlayVisibile, setIsOverlayVisible] = useState(false);
|
|
37
46
|
|
|
47
|
+
const onCardClick = () => {
|
|
48
|
+
RouteService.redirectTo(href);
|
|
49
|
+
};
|
|
38
50
|
return (
|
|
51
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
39
52
|
<div
|
|
40
53
|
role="button"
|
|
41
54
|
tabIndex={0}
|
|
42
55
|
className="border-0 product-set-card-wrapper w-100 pb-0"
|
|
43
|
-
onClick={
|
|
44
|
-
onKeyUp={() => RouteService.redirectTo(href)}
|
|
56
|
+
onClick={onCardClick}
|
|
45
57
|
>
|
|
46
58
|
<div className={productSetCardClasses}>
|
|
47
59
|
<div className="product-set-card-link">
|
|
48
60
|
<div className="d-flex flex-column">
|
|
49
61
|
<div>
|
|
50
|
-
{name}
|
|
62
|
+
{name}
|
|
63
|
+
{rrule && `(${RRule.fromString(rrule).toText()})`}
|
|
51
64
|
</div>
|
|
52
65
|
{!!override && (
|
|
53
66
|
<div className="h6 bold ml-1">
|
|
@@ -79,14 +92,33 @@ export function ProductSetCard({
|
|
|
79
92
|
>
|
|
80
93
|
{hasPermission && (
|
|
81
94
|
<>
|
|
82
|
-
<ListGroup.Item
|
|
95
|
+
<ListGroup.Item
|
|
96
|
+
action
|
|
97
|
+
as="div"
|
|
98
|
+
role="button"
|
|
99
|
+
tabIndex={0}
|
|
100
|
+
onClick={(e) => e.stopPropagation()}
|
|
101
|
+
>
|
|
83
102
|
{Boolean(onCopy) && (
|
|
84
|
-
<ConfirmModal
|
|
103
|
+
<ConfirmModal
|
|
104
|
+
// confirm function memoize the callback function and it leads to bugs
|
|
105
|
+
confirmationHandler={onCopy}
|
|
106
|
+
disabledButtons={isLoading}
|
|
107
|
+
content={
|
|
108
|
+
<ProductSetNameControl
|
|
109
|
+
value={duplicateProductSetName}
|
|
110
|
+
onChange={onChangeDuplicateProductSetName}
|
|
111
|
+
error={duplicateProductSetError}
|
|
112
|
+
/>
|
|
113
|
+
}
|
|
114
|
+
>
|
|
85
115
|
{(confirm) => (
|
|
86
116
|
<MenuButton
|
|
87
117
|
onClick={() => {
|
|
88
118
|
setIsOverlayVisible(false);
|
|
89
|
-
|
|
119
|
+
onChangeDuplicateProductSetName(name);
|
|
120
|
+
// confirm function memoize the callback function and it leads to bugs
|
|
121
|
+
confirm(() => {});
|
|
90
122
|
}}
|
|
91
123
|
name={t("duplicate")}
|
|
92
124
|
className="product-set-card-menu-item-text"
|
|
@@ -95,7 +127,14 @@ export function ProductSetCard({
|
|
|
95
127
|
</ConfirmModal>
|
|
96
128
|
)}
|
|
97
129
|
</ListGroup.Item>
|
|
98
|
-
<ListGroup.Item
|
|
130
|
+
<ListGroup.Item
|
|
131
|
+
action
|
|
132
|
+
className="text-danger"
|
|
133
|
+
as="div"
|
|
134
|
+
role="button"
|
|
135
|
+
tabIndex={0}
|
|
136
|
+
onClick={(e) => e.stopPropagation()}
|
|
137
|
+
>
|
|
99
138
|
{Boolean(onRemove) && (
|
|
100
139
|
<ConfirmModal>
|
|
101
140
|
{(confirm) => (
|
|
@@ -37,6 +37,7 @@ interface DateAndRecurrenceInputProps {
|
|
|
37
37
|
workHours: WorkHour[] | undefined;
|
|
38
38
|
providerHasBookingManagement: boolean;
|
|
39
39
|
isLoading?: boolean;
|
|
40
|
+
timeZone: string;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
export const DateAndRecurrenceInput = ({
|
|
@@ -44,6 +45,7 @@ export const DateAndRecurrenceInput = ({
|
|
|
44
45
|
providerHasBookingManagement,
|
|
45
46
|
workHours,
|
|
46
47
|
isLoading,
|
|
48
|
+
timeZone,
|
|
47
49
|
}: DateAndRecurrenceInputProps) => {
|
|
48
50
|
const {
|
|
49
51
|
control,
|
|
@@ -227,6 +229,7 @@ export const DateAndRecurrenceInput = ({
|
|
|
227
229
|
onChange={handleRecurringDateChange}
|
|
228
230
|
onDelete={handleDelete}
|
|
229
231
|
workHours={workHours}
|
|
232
|
+
timeZone={timeZone}
|
|
230
233
|
>
|
|
231
234
|
{providerHasBookingManagement && (
|
|
232
235
|
<AvailableTimesControl
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
1
|
import { Col, Form, Row } from "react-bootstrap";
|
|
3
2
|
import { Controller, useFormContext } from "react-hook-form";
|
|
4
3
|
import { useTranslation } from "react-i18next";
|
|
5
4
|
import clsx from "clsx";
|
|
6
|
-
import { DateTime } from "luxon";
|
|
7
5
|
import {
|
|
8
6
|
OPERATIONAL_COST_CUSTOMER,
|
|
9
7
|
OPERATIONAL_COST_PROVIDER,
|
|
@@ -16,7 +14,6 @@ import {
|
|
|
16
14
|
RELY_ON_PEOPLE_TYPES,
|
|
17
15
|
RelyOnPeopleType,
|
|
18
16
|
} from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
|
|
19
|
-
import { DATE_MONTH_LOCALE_FORMAT } from "@licklist/core/dist/Config";
|
|
20
17
|
import { useId } from "@react-aria/utils";
|
|
21
18
|
import { FieldSet } from "@licklist/core/dist/DataMapper/Order/FieldSetDataMapper";
|
|
22
19
|
import { EmailTemplate } from "@licklist/core/dist/DataMapper/Notification/EmailTemplateDataMapper";
|
|
@@ -91,7 +88,6 @@ export interface ProductSetControlProps {
|
|
|
91
88
|
workHours: WorkHour[] | undefined;
|
|
92
89
|
providerHasBookingManagement?: boolean;
|
|
93
90
|
isOverrides?: boolean;
|
|
94
|
-
occurrenceStartAtDate?: string;
|
|
95
91
|
isCreateNewOverrides?: boolean;
|
|
96
92
|
}
|
|
97
93
|
|
|
@@ -109,7 +105,6 @@ export function ProductSetControl({
|
|
|
109
105
|
workHours,
|
|
110
106
|
providerHasBookingManagement = false,
|
|
111
107
|
isOverrides = false,
|
|
112
|
-
occurrenceStartAtDate,
|
|
113
108
|
isCreateNewOverrides = false,
|
|
114
109
|
}: ProductSetControlProps) {
|
|
115
110
|
const { t } = useTranslation(["Design", "Validation", "Notification"]);
|
|
@@ -119,12 +114,10 @@ export function ProductSetControl({
|
|
|
119
114
|
formState: { errors },
|
|
120
115
|
watch,
|
|
121
116
|
setError,
|
|
122
|
-
setValue,
|
|
123
117
|
clearErrors,
|
|
124
118
|
} = useFormContext<ProductSetControlValues>();
|
|
125
119
|
|
|
126
120
|
const steps = watch("steps");
|
|
127
|
-
const productSetName = watch("name");
|
|
128
121
|
|
|
129
122
|
const nameId = useId();
|
|
130
123
|
const termsAndConditionsId = useId();
|
|
@@ -138,13 +131,6 @@ export function ProductSetControl({
|
|
|
138
131
|
productCategories?.some((category) => checkIfZoneCategory(category?.type)),
|
|
139
132
|
);
|
|
140
133
|
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
if (!occurrenceStartAtDate) return;
|
|
143
|
-
const eventStartDate = DateTime.fromISO(occurrenceStartAtDate);
|
|
144
|
-
const eventStart = eventStartDate.toFormat(DATE_MONTH_LOCALE_FORMAT);
|
|
145
|
-
setValue("name", `${productSetName} (${eventStart})`);
|
|
146
|
-
}, [setValue, occurrenceStartAtDate]);
|
|
147
|
-
|
|
148
134
|
return (
|
|
149
135
|
<Row
|
|
150
136
|
className={`product-set-form ${
|
|
@@ -200,6 +186,7 @@ export function ProductSetControl({
|
|
|
200
186
|
workHours={isZoneAdded ? workHours : undefined}
|
|
201
187
|
isLoading={isLoading}
|
|
202
188
|
providerHasBookingManagement={providerHasBookingManagement}
|
|
189
|
+
timeZone={timeZone}
|
|
203
190
|
/>
|
|
204
191
|
)}
|
|
205
192
|
</>
|
|
@@ -59,6 +59,7 @@ export interface ProductSetFormProps
|
|
|
59
59
|
isOverrides?: boolean;
|
|
60
60
|
workHours?: WorkHour[];
|
|
61
61
|
isCreateNewOverrides?: boolean;
|
|
62
|
+
timeZone: string;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export function ProductSetForm({
|
|
@@ -77,6 +78,7 @@ export function ProductSetForm({
|
|
|
77
78
|
workHours,
|
|
78
79
|
isOverrides,
|
|
79
80
|
isCreateNewOverrides,
|
|
81
|
+
timeZone,
|
|
80
82
|
...shared
|
|
81
83
|
}: ProductSetFormProps) {
|
|
82
84
|
const { t } = useTranslation("Design");
|
|
@@ -194,6 +196,7 @@ export function ProductSetForm({
|
|
|
194
196
|
providerHasBookingManagement={providerHasBookingManagement}
|
|
195
197
|
isOverrides={isOverrides}
|
|
196
198
|
isCreateNewOverrides={isCreateNewOverrides}
|
|
199
|
+
timeZone={timeZone}
|
|
197
200
|
/>
|
|
198
201
|
<Row>
|
|
199
202
|
<Col md={6} sm={12} />
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Form } from "react-bootstrap";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
|
|
4
|
+
export const ProductSetNameControl = ({
|
|
5
|
+
value,
|
|
6
|
+
onChange,
|
|
7
|
+
error,
|
|
8
|
+
}: {
|
|
9
|
+
value: string;
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
error?: string;
|
|
12
|
+
}) => {
|
|
13
|
+
const { t } = useTranslation(["Design"]);
|
|
14
|
+
return (
|
|
15
|
+
<Form.Group>
|
|
16
|
+
<Form.Label>{t("Design:ProductSetName")}*</Form.Label>
|
|
17
|
+
<Form.Control
|
|
18
|
+
value={value}
|
|
19
|
+
maxLength={255}
|
|
20
|
+
onChange={(e) => onChange(e.target.value)}
|
|
21
|
+
placeholder={t("Design:placeholderProductSetName")}
|
|
22
|
+
isInvalid={Boolean(error)}
|
|
23
|
+
/>
|
|
24
|
+
<Form.Control.Feedback type="invalid">{error}</Form.Control.Feedback>
|
|
25
|
+
</Form.Group>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -3,6 +3,7 @@ import { SmsTemplate } from "@licklist/core/dist/DataMapper/Notification/SmsTemp
|
|
|
3
3
|
import { TFunction } from "react-i18next";
|
|
4
4
|
import { UseFormSetError } from "react-hook-form";
|
|
5
5
|
import { checkIfZoneCategory } from "@licklist/plugins";
|
|
6
|
+
import { ProductSet } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
|
|
6
7
|
import { TemplateItem } from "../control/ProductSetControl";
|
|
7
8
|
import { ProductSetFormValues } from "../form/ProductSetForm";
|
|
8
9
|
|
|
@@ -12,6 +13,11 @@ interface CheckAvailableTimesErrors {
|
|
|
12
13
|
t: TFunction;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
export interface MenuTypeheadItem {
|
|
17
|
+
id: number;
|
|
18
|
+
label: string;
|
|
19
|
+
value: number;
|
|
20
|
+
}
|
|
15
21
|
export const moveArrayElements = <T>(
|
|
16
22
|
array: T[],
|
|
17
23
|
prevIndex: number,
|
|
@@ -84,3 +90,8 @@ export const checkAvailableTimesErrors = ({
|
|
|
84
90
|
});
|
|
85
91
|
return hasError;
|
|
86
92
|
};
|
|
93
|
+
|
|
94
|
+
export const getTypeHeadItemsFromMenus = (
|
|
95
|
+
menus?: (ProductSet | ProductSetFormValues)[],
|
|
96
|
+
): MenuTypeheadItem[] =>
|
|
97
|
+
menus?.map((menu) => ({ id: menu.id, value: menu.id, label: menu.name }));
|