@licklist/design 0.66.1-dev.3 → 0.66.1
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/date-time-button/DateTimeButton.js +1 -1
- 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/iframe/page/components/PageBody/PageBody.d.ts +1 -1
- package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.d.ts +1 -2
- 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/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
- package/dist/product-set/control/DateInput.js +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts +2 -3
- 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 +1 -3
- 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 -6
- 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 +1 -3
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +1 -1
- package/dist/product-set/form/StepsControl.d.ts +1 -3
- package/dist/product-set/form/StepsControl.d.ts.map +1 -1
- package/dist/product-set/form/StepsControl.js +1 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.js +1 -1
- package/dist/product-set/product/ProductControl.d.ts +0 -1
- 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 +1 -2
- package/dist/product-set/step/StepControl.d.ts.map +1 -1
- package/dist/product-set/step/StepControl.js +1 -1
- package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
- package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
- package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +1 -3
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
- package/dist/recurring-date-picker-input/utils.d.ts +0 -5
- package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/utils.js +1 -1
- package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts +1 -1
- package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts.map +1 -1
- package/dist/report/ReportRunnerModal/ReportRunnerModal.js +1 -1
- package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
- package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
- package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts +2 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.js +1 -1
- package/dist/styles/iframe-page/Page.scss +10 -1
- package/dist/styles/sales/BookingResults.scss +1 -1
- package/dist/styles/zones/ZoneForm.scss +1 -2
- package/dist/zone/form/ZoneForm.d.ts +2 -2
- package/dist/zone/form/ZoneForm.d.ts.map +1 -1
- package/dist/zone/form/ZoneForm.js +1 -1
- package/dist/zone/form/components/ZoneControl.d.ts +2 -2
- package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneControl.js +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
- package/dist/zone/form/utils/dates.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/date-time-button/DateTimeButton.stories.tsx +1 -2
- package/src/date-time-button/DateTimeButton.tsx +5 -7
- package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +9 -14
- package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +0 -2
- package/src/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.tsx +2 -8
- package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +0 -1
- package/src/product-set/control/DateAndRecurrenceInput.tsx +4 -3
- package/src/product-set/control/DateInput.tsx +2 -2
- package/src/product-set/control/ProductSetControl.tsx +5 -17
- package/src/product-set/form/ProductCategoriesControl.tsx +4 -16
- package/src/product-set/form/ProductSetForm.tsx +2 -13
- package/src/product-set/form/ProductsControl.tsx +77 -93
- package/src/product-set/form/StepsControl.tsx +7 -15
- package/src/product-set/hooks/useSortableTreeFunctions.ts +1 -0
- package/src/product-set/product/ProductControl.tsx +5 -8
- package/src/product-set/step/StepControl.tsx +3 -4
- package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +18 -4
- package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +21 -50
- package/src/recurring-date-picker-input/RecurringDatePickerInput.stories.tsx +7 -13
- package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +1 -12
- package/src/recurring-date-picker-input/utils.ts +1 -90
- package/src/report/ReportRunnerModal/ReportRunnerModal.tsx +14 -24
- package/src/sales/booking/results/components/ResultCard.tsx +3 -0
- package/src/setting/admin/AdminSettingForm.tsx +2 -2
- package/src/sortable-tree/SortableTreeItem.tsx +3 -0
- package/src/static/switch/BooleanSwitch.tsx +1 -1
- package/src/styles/iframe-page/Page.scss +10 -1
- package/src/styles/sales/BookingResults.scss +1 -1
- package/src/styles/zones/ZoneForm.scss +1 -2
- package/src/zone/form/ZoneForm.tsx +2 -3
- package/src/zone/form/components/ZoneControl.tsx +3 -3
- package/src/zone/form/components/ZoneRecurrencesControl.tsx +5 -7
- package/src/zone/form/utils/dates.ts +10 -9
- package/src/report/ReportRunnerModal/ReportRunnerModal.stories.tsx +0 -307
|
@@ -19,16 +19,9 @@ import { ProductSetFormValues } from "./ProductSetForm";
|
|
|
19
19
|
interface StepsControlProps {
|
|
20
20
|
isLoading: boolean;
|
|
21
21
|
isOverrides?: boolean;
|
|
22
|
-
isEventEditProductSet?: boolean;
|
|
23
|
-
isCreateNewOverrides?: boolean;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export function StepsControl({
|
|
27
|
-
isLoading,
|
|
28
|
-
isOverrides,
|
|
29
|
-
isEventEditProductSet,
|
|
30
|
-
isCreateNewOverrides,
|
|
31
|
-
}: StepsControlProps) {
|
|
24
|
+
export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
32
25
|
const form = useFormContext<ProductSetFormValues>();
|
|
33
26
|
const { t } = useTranslation("Design");
|
|
34
27
|
const [showStepModal, setShowStepModal] = useState(false);
|
|
@@ -75,9 +68,9 @@ export function StepsControl({
|
|
|
75
68
|
<>
|
|
76
69
|
{fields.map((step, index) => {
|
|
77
70
|
const stepFieldName = `steps.${index}` as const;
|
|
71
|
+
|
|
78
72
|
const stepData = getValues(stepFieldName);
|
|
79
|
-
|
|
80
|
-
(isOverrides || isCreateNewOverrides) && !!step.id;
|
|
73
|
+
|
|
81
74
|
return (
|
|
82
75
|
<Controller
|
|
83
76
|
key={`step-${step._id}`}
|
|
@@ -99,9 +92,9 @@ export function StepsControl({
|
|
|
99
92
|
modalLabel={t("addNewStep")}
|
|
100
93
|
modalClass={ProductSetModalClasses.step}
|
|
101
94
|
isNewAdded={showStepModal}
|
|
102
|
-
edit={() => edit(index)}
|
|
95
|
+
edit={() => !isOverrides && edit(index)}
|
|
103
96
|
cancelChanges={() => cancelChanges(index)}
|
|
104
|
-
isOverride={
|
|
97
|
+
isOverride={isOverrides}
|
|
105
98
|
subTitle={
|
|
106
99
|
<div className="product-set-badges-container">
|
|
107
100
|
<div className="product-set-subtitle-dot product-set-subtitle-step-dot" />
|
|
@@ -117,7 +110,6 @@ export function StepsControl({
|
|
|
117
110
|
stepIndex={index}
|
|
118
111
|
stepName={value}
|
|
119
112
|
onStepNameChange={onChange}
|
|
120
|
-
isOverrides={isOverrideStep}
|
|
121
113
|
/>
|
|
122
114
|
}
|
|
123
115
|
onDelete={() => remove(index)}
|
|
@@ -148,8 +140,6 @@ export function StepsControl({
|
|
|
148
140
|
isLoading={isLoading}
|
|
149
141
|
stepIndex={index}
|
|
150
142
|
isOverrides={isOverrides}
|
|
151
|
-
isCreateNewOverrides={isCreateNewOverrides}
|
|
152
|
-
isEventEditProductSet={isEventEditProductSet}
|
|
153
143
|
/>
|
|
154
144
|
</SortableTree.Item>
|
|
155
145
|
)}
|
|
@@ -159,7 +149,9 @@ export function StepsControl({
|
|
|
159
149
|
|
|
160
150
|
<CreateProductSetItem
|
|
161
151
|
title={t("addStep")}
|
|
152
|
+
isOverride={isOverrides}
|
|
162
153
|
onClick={() => {
|
|
154
|
+
if (isOverrides) return;
|
|
163
155
|
append(getDefaultStepsValues());
|
|
164
156
|
setShowStepModal(true);
|
|
165
157
|
if (errors.steps?.type === HookFormService.manualErrorType) {
|
|
@@ -7,17 +7,14 @@ import {
|
|
|
7
7
|
QUANTITY_TYPE_LIST_DTO,
|
|
8
8
|
QUANTITY_TYPE_RECHARGING,
|
|
9
9
|
} from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
|
|
10
|
-
import {
|
|
11
|
-
ProductType,
|
|
12
|
-
PRODUCT_DEfAULT_COLORS,
|
|
13
|
-
} from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
|
|
10
|
+
import { ProductType } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
|
|
14
11
|
import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
|
|
15
|
-
import clsx from "clsx";
|
|
16
12
|
import {
|
|
17
13
|
FieldNamePrefixPath,
|
|
18
14
|
FormValues,
|
|
19
15
|
} from "@licklist/plugins/dist/types/services/Form/hook-form-service";
|
|
20
16
|
import { useId } from "@react-aria/utils";
|
|
17
|
+
import clsx from "clsx";
|
|
21
18
|
import React, {
|
|
22
19
|
ChangeEvent,
|
|
23
20
|
useCallback,
|
|
@@ -39,7 +36,7 @@ import {
|
|
|
39
36
|
} from "react-hook-form";
|
|
40
37
|
import { useTranslation } from "react-i18next";
|
|
41
38
|
import { useImages } from "@licklist/plugins/dist/hooks/Media/useImages";
|
|
42
|
-
|
|
39
|
+
import { PRODUCT_DEfAULT_COLORS } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
|
|
43
40
|
import {
|
|
44
41
|
Image,
|
|
45
42
|
IMAGE_TYPE_IMAGE,
|
|
@@ -89,7 +86,6 @@ export interface ProductControlValues
|
|
|
89
86
|
totalQuantity: number;
|
|
90
87
|
isAvailable: boolean;
|
|
91
88
|
isSoldOut: boolean;
|
|
92
|
-
originalProductId: number | null;
|
|
93
89
|
isUnlimited: boolean;
|
|
94
90
|
isRequired: boolean;
|
|
95
91
|
quantitySelector: number;
|
|
@@ -160,6 +156,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
160
156
|
);
|
|
161
157
|
const capacity = watch(`${fieldNamePrefix}.capacity` as Path<T>);
|
|
162
158
|
const disabledDuration = capacity === "0" || !capacity;
|
|
159
|
+
|
|
163
160
|
const advancedId = useId();
|
|
164
161
|
const nameId = useId();
|
|
165
162
|
|
|
@@ -413,7 +410,7 @@ export function ProductControl<T extends FormValues>({
|
|
|
413
410
|
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
414
411
|
errors
|
|
415
412
|
)}
|
|
416
|
-
disabled={isLoading
|
|
413
|
+
disabled={isLoading}
|
|
417
414
|
defaultValue=""
|
|
418
415
|
>
|
|
419
416
|
<option value="">{t("Design:selectProductGroup")}</option>
|
|
@@ -26,7 +26,6 @@ export interface StepControlProps extends IsDeletableEvent {
|
|
|
26
26
|
stepIndex: number;
|
|
27
27
|
stepName: string;
|
|
28
28
|
onStepNameChange: (args: any) => void;
|
|
29
|
-
isOverrides?: boolean;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
export function StepControl({
|
|
@@ -34,7 +33,6 @@ export function StepControl({
|
|
|
34
33
|
stepIndex,
|
|
35
34
|
stepName,
|
|
36
35
|
onStepNameChange,
|
|
37
|
-
isOverrides = false,
|
|
38
36
|
}: StepControlProps) {
|
|
39
37
|
const { providerHasMap } = useContext(ProductSetLoadingContext);
|
|
40
38
|
const {
|
|
@@ -44,6 +42,7 @@ export function StepControl({
|
|
|
44
42
|
watch,
|
|
45
43
|
} = useFormContext<ProductSetFormValues>();
|
|
46
44
|
const { t } = useTranslation("Design");
|
|
45
|
+
|
|
47
46
|
const fieldName = `steps.${stepIndex}.name` as const;
|
|
48
47
|
const productCategoriesFieldName =
|
|
49
48
|
`steps.${stepIndex}.productCategories` as const;
|
|
@@ -72,7 +71,7 @@ export function StepControl({
|
|
|
72
71
|
fieldName,
|
|
73
72
|
errors
|
|
74
73
|
)}
|
|
75
|
-
disabled={isLoading
|
|
74
|
+
disabled={isLoading}
|
|
76
75
|
/>
|
|
77
76
|
)}
|
|
78
77
|
control={control}
|
|
@@ -115,7 +114,7 @@ export function StepControl({
|
|
|
115
114
|
name={name}
|
|
116
115
|
value={Boolean(value)}
|
|
117
116
|
onChange={onChange}
|
|
118
|
-
disabled={isLoading
|
|
117
|
+
disabled={isLoading}
|
|
119
118
|
/>
|
|
120
119
|
)}
|
|
121
120
|
control={control}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { DateTime } from "luxon";
|
|
1
2
|
import React from "react";
|
|
2
3
|
import { Col, Row } from "react-bootstrap";
|
|
3
4
|
import { useFormContext } from "react-hook-form";
|
|
4
5
|
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { TIME_FORMAT } from "@licklist/core/dist/Config";
|
|
5
7
|
import { WorkingHoursInputValues } from ".";
|
|
6
8
|
import { useWeekdays } from "./utils";
|
|
7
9
|
|
|
@@ -23,10 +25,22 @@ export function WorkingHoursInputDescription() {
|
|
|
23
25
|
<Row key={i}>
|
|
24
26
|
<Col xs="auto">{weekdays[i]}:</Col>
|
|
25
27
|
<Col>
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
{weekday?.end
|
|
29
|
+
? weekday.start
|
|
30
|
+
? t("timeInterval", {
|
|
31
|
+
start: DateTime.fromISO(weekday.start).toFormat(
|
|
32
|
+
TIME_FORMAT
|
|
33
|
+
),
|
|
34
|
+
end: DateTime.fromISO(weekday.start).toFormat(
|
|
35
|
+
TIME_FORMAT
|
|
36
|
+
),
|
|
37
|
+
})
|
|
38
|
+
: t("timeFrom", {
|
|
39
|
+
start: DateTime.fromISO(weekday.start).toFormat(
|
|
40
|
+
TIME_FORMAT
|
|
41
|
+
),
|
|
42
|
+
})
|
|
43
|
+
: null}
|
|
30
44
|
</Col>
|
|
31
45
|
</Row>
|
|
32
46
|
);
|
|
@@ -2,18 +2,8 @@ import React, { useEffect } from "react";
|
|
|
2
2
|
import { DateTime } from "luxon";
|
|
3
3
|
import { Col, Form, Row } from "react-bootstrap";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
useFormContext,
|
|
8
|
-
useWatch,
|
|
9
|
-
Validate,
|
|
10
|
-
} from "react-hook-form";
|
|
11
|
-
import {
|
|
12
|
-
DATE_FORMAT,
|
|
13
|
-
TIME_FORMAT,
|
|
14
|
-
TIME_FULL_FORMAT,
|
|
15
|
-
} from "@licklist/core/dist/Config";
|
|
16
|
-
import { fromFormat } from "@licklist/plugins/dist/utils/dateTime";
|
|
5
|
+
import { RegisterOptions, useFormContext } from "react-hook-form";
|
|
6
|
+
import { DATE_FORMAT } from "@licklist/core/dist/Config";
|
|
17
7
|
import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
|
|
18
8
|
|
|
19
9
|
interface RecurrenceIntervalAndFrequencyInputProps {
|
|
@@ -33,15 +23,6 @@ interface RecurrenceIntervalAndFrequencyInputProps {
|
|
|
33
23
|
>;
|
|
34
24
|
}
|
|
35
25
|
|
|
36
|
-
const fromTimeFormat = fromFormat(TIME_FORMAT);
|
|
37
|
-
const fromTimeFullFormat = fromFormat(TIME_FULL_FORMAT);
|
|
38
|
-
|
|
39
|
-
// default values and entered values are in different formats
|
|
40
|
-
const fromTimeFormats = (time: string) =>
|
|
41
|
-
fromTimeFormat(time).isValid
|
|
42
|
-
? fromTimeFormat(time)
|
|
43
|
-
: fromTimeFullFormat(time);
|
|
44
|
-
|
|
45
26
|
function RecurrenceIntervalAndFrequencyInput({
|
|
46
27
|
disabled = false,
|
|
47
28
|
minDate,
|
|
@@ -55,21 +36,16 @@ function RecurrenceIntervalAndFrequencyInput({
|
|
|
55
36
|
const { t } = useTranslation(["Design", "Notification", "App"]);
|
|
56
37
|
|
|
57
38
|
const {
|
|
39
|
+
getValues,
|
|
58
40
|
formState: { errors },
|
|
59
41
|
register,
|
|
60
42
|
trigger,
|
|
61
|
-
control,
|
|
62
43
|
} = useFormContext<RecurringDatePickerInputValues>();
|
|
63
44
|
|
|
64
|
-
const startDate =
|
|
65
|
-
const endDate =
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const startTime =
|
|
69
|
-
_startTime && fromTimeFormats(_startTime).toFormat(TIME_FORMAT);
|
|
70
|
-
|
|
71
|
-
const _endTime = useWatch({ control, name: "endTime" });
|
|
72
|
-
const endTime = _endTime && fromTimeFormats(_endTime).toFormat(TIME_FORMAT);
|
|
45
|
+
const startDate = getValues("startDate");
|
|
46
|
+
const endDate = getValues("endDate");
|
|
47
|
+
const startTime = getValues("startTime");
|
|
48
|
+
const endTime = getValues("endTime");
|
|
73
49
|
|
|
74
50
|
useEffect(() => {
|
|
75
51
|
if (!startDate || !endDate) {
|
|
@@ -173,27 +149,22 @@ function RecurrenceIntervalAndFrequencyInput({
|
|
|
173
149
|
type="time"
|
|
174
150
|
{...register("endTime", {
|
|
175
151
|
required: false,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (!startTime || !time) {
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
const currentStartTime = DateTime.fromISO(startTime);
|
|
186
|
-
const currentEndTime = DateTime.fromISO(time);
|
|
152
|
+
validate: (time) => {
|
|
153
|
+
if (!startTime || !time) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
const currentStartTime = DateTime.fromISO(startTime);
|
|
157
|
+
const currentEndTime = DateTime.fromISO(time);
|
|
187
158
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
},
|
|
159
|
+
return currentEndTime?.diff(currentStartTime, ["minutes"])
|
|
160
|
+
?.minutes >= 0
|
|
161
|
+
? true
|
|
162
|
+
: `${t(`Validation:fieldLaterDate`, {
|
|
163
|
+
attribute: t("Design:endTimeSmall"),
|
|
164
|
+
min: t("Design:startTimeSmall"),
|
|
165
|
+
})}`;
|
|
196
166
|
},
|
|
167
|
+
...endTimeRules,
|
|
197
168
|
})}
|
|
198
169
|
placeholder="hh:mm"
|
|
199
170
|
defaultValue={endTime}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Meta, Story } from "@storybook/react";
|
|
3
3
|
import { Card } from "react-bootstrap";
|
|
4
|
-
import { DateTime } from "luxon";
|
|
5
|
-
import { DATE_FORMAT, TIME_FORMAT } from "@licklist/core/dist/Config/Date";
|
|
6
4
|
import {
|
|
7
5
|
RecurringDatePickerInput,
|
|
8
6
|
RecurringDatePickerInputProps,
|
|
9
7
|
} from "./RecurringDatePickerInput";
|
|
8
|
+
import { DateTime } from "luxon";
|
|
9
|
+
import { DATE_FORMAT, TIME_FORMAT } from "@licklist/core/dist/Config/Date";
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
title: "RecurringDatePickerInput",
|
|
13
13
|
component: RecurringDatePickerInput,
|
|
14
14
|
} as Meta;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
interface DefaultRecurringDatePickerInputProps
|
|
17
|
+
extends RecurringDatePickerInputProps {}
|
|
18
|
+
|
|
19
|
+
export const Default: Story<DefaultRecurringDatePickerInputProps> = (args) => {
|
|
17
20
|
return (
|
|
18
21
|
<Card style={{ maxWidth: "max-content" }}>
|
|
19
22
|
<Card.Body>
|
|
@@ -22,7 +25,7 @@ export const Default: Story<RecurringDatePickerInputProps> = (args) => {
|
|
|
22
25
|
</Card>
|
|
23
26
|
);
|
|
24
27
|
};
|
|
25
|
-
export const Valid: Story<
|
|
28
|
+
export const Valid: Story<DefaultRecurringDatePickerInputProps> = (args) => {
|
|
26
29
|
return (
|
|
27
30
|
<Card style={{ maxWidth: "max-content" }}>
|
|
28
31
|
<Card.Body>
|
|
@@ -33,15 +36,6 @@ export const Valid: Story<RecurringDatePickerInputProps> = (args) => {
|
|
|
33
36
|
};
|
|
34
37
|
Default.args = {
|
|
35
38
|
onChange: (data) => console.log("onSubmit", data),
|
|
36
|
-
workHours: [
|
|
37
|
-
{ start: "20:00", end: "04:00", day: 0, description: "" },
|
|
38
|
-
{ start: "20:00", end: "04:00", day: 1, description: "" },
|
|
39
|
-
{ start: "20:00", end: "04:00", day: 2, description: "" },
|
|
40
|
-
{ start: "20:00", end: "12:00", day: 3, description: "" },
|
|
41
|
-
{ start: "20:00", end: "23:00", day: 4, description: "" },
|
|
42
|
-
{ start: "08:00", end: "12:00", day: 5, description: "" },
|
|
43
|
-
{ start: "10:00", end: "16:00", day: 6, description: "" },
|
|
44
|
-
],
|
|
45
39
|
};
|
|
46
40
|
Valid.args = {
|
|
47
41
|
onChange: (data) => console.log("onSubmit", data),
|
|
@@ -12,14 +12,9 @@ import {
|
|
|
12
12
|
import { usePreviousValue } from "@licklist/plugins/dist/hooks/Value/usePreviousValue";
|
|
13
13
|
import { FormProvider, useForm } from "react-hook-form";
|
|
14
14
|
import { Form } from "react-bootstrap";
|
|
15
|
-
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
16
15
|
import RecurrenceIntervalAndFrequencyInput from "./RecurrenceIntervalAndFrequencyInput";
|
|
17
16
|
import RecurrenceWeekdaysInput from "./RecurrenceWeekdaysInput";
|
|
18
|
-
import {
|
|
19
|
-
parseAndValidateRRule,
|
|
20
|
-
SupportedFrequency,
|
|
21
|
-
useWorkHoursValidation,
|
|
22
|
-
} from "./utils";
|
|
17
|
+
import { parseAndValidateRRule, SupportedFrequency } from "./utils";
|
|
23
18
|
import { ConfirmModal } from "../modals";
|
|
24
19
|
import { DeleteFieldButton } from "../product-set/elements";
|
|
25
20
|
|
|
@@ -31,7 +26,6 @@ export interface RecurringDatePickerInputProps {
|
|
|
31
26
|
initialFrequency?: Frequency;
|
|
32
27
|
setInitialStartDateAfterSelect?: boolean;
|
|
33
28
|
minDate?: string;
|
|
34
|
-
workHours: WorkHour[] | undefined;
|
|
35
29
|
}
|
|
36
30
|
|
|
37
31
|
export interface RecurringDatePickerInputValues {
|
|
@@ -57,7 +51,6 @@ export function RecurringDatePickerInput({
|
|
|
57
51
|
setInitialStartDateAfterSelect = false,
|
|
58
52
|
children,
|
|
59
53
|
minDate,
|
|
60
|
-
workHours,
|
|
61
54
|
}: PropsWithChildren<RecurringDatePickerInputProps>) {
|
|
62
55
|
const { t } = useTranslation(["Design"]);
|
|
63
56
|
|
|
@@ -91,8 +84,6 @@ export function RecurringDatePickerInput({
|
|
|
91
84
|
byWeekDay,
|
|
92
85
|
});
|
|
93
86
|
|
|
94
|
-
const validator = useWorkHoursValidation(byWeekDay, workHours);
|
|
95
|
-
|
|
96
87
|
const onSubmit = (nextState: RecurringDatePickerInputValues) => {
|
|
97
88
|
const end = getDateTimeObject(endDate, endTime || "23:59:59");
|
|
98
89
|
|
|
@@ -197,8 +188,6 @@ export function RecurringDatePickerInput({
|
|
|
197
188
|
<RecurrenceIntervalAndFrequencyInput
|
|
198
189
|
disabled={disabled}
|
|
199
190
|
minDate={minDate}
|
|
200
|
-
startTimeRules={validator}
|
|
201
|
-
endTimeRules={validator}
|
|
202
191
|
/>
|
|
203
192
|
|
|
204
193
|
{children}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
3
|
-
import { fromFormat } from "@licklist/plugins/dist/utils/dateTime";
|
|
4
|
-
import { DateTime, Interval } from "luxon";
|
|
5
|
-
import { Validate } from "react-hook-form";
|
|
6
|
-
import { useTranslation } from "react-i18next";
|
|
1
|
+
import { DateTime } from "luxon";
|
|
7
2
|
import RRule, { Frequency, Weekday } from "rrule";
|
|
8
3
|
|
|
9
4
|
export const getWeekdayForFrequency = ({
|
|
@@ -16,7 +11,6 @@ export const getWeekdayForFrequency = ({
|
|
|
16
11
|
const parsedDate = DateTime.fromISO(date);
|
|
17
12
|
return new Weekday(
|
|
18
13
|
parsedDate.weekday - 1,
|
|
19
|
-
// eslint-disable-next-line no-nested-ternary
|
|
20
14
|
frequency !== Frequency.MONTHLY
|
|
21
15
|
? undefined
|
|
22
16
|
: parsedDate.day + 7 > parsedDate.daysInMonth
|
|
@@ -115,86 +109,3 @@ export const parseAndValidateRRule = ({
|
|
|
115
109
|
until: options.until,
|
|
116
110
|
} as ParsedRRuleOptions;
|
|
117
111
|
};
|
|
118
|
-
|
|
119
|
-
export const useWorkHoursValidation = (
|
|
120
|
-
byWeekDay: Weekday[] = [],
|
|
121
|
-
workHours: WorkHour[] | undefined
|
|
122
|
-
): {
|
|
123
|
-
validate?: Validate<string>;
|
|
124
|
-
} => {
|
|
125
|
-
const { t } = useTranslation("Validation");
|
|
126
|
-
if (!workHours) return {};
|
|
127
|
-
|
|
128
|
-
const fromTimeFormat = fromFormat(TIME_FORMAT);
|
|
129
|
-
const fromTimeFullFormat = fromFormat(TIME_FULL_FORMAT);
|
|
130
|
-
|
|
131
|
-
// map every day to array of intervals describing workhours for that day
|
|
132
|
-
let intervalsByDay = workHours.map((workhour, index, self) => {
|
|
133
|
-
const res: Interval[] = [];
|
|
134
|
-
|
|
135
|
-
const startTime = fromTimeFormat(workhour.start);
|
|
136
|
-
const endTime = fromTimeFormat(workhour.end);
|
|
137
|
-
|
|
138
|
-
if (endTime > startTime) {
|
|
139
|
-
res.push(Interval.fromDateTimes(startTime, endTime));
|
|
140
|
-
} else {
|
|
141
|
-
// if end is before start, then it means that end is on the next day
|
|
142
|
-
// so count only to the end of current day
|
|
143
|
-
res.push(Interval.fromDateTimes(startTime, startTime.endOf("day")));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const prevIndex = index === 0 ? self.length - 1 : index - 1;
|
|
147
|
-
|
|
148
|
-
const prevStartTime = fromTimeFormat(self[prevIndex].start);
|
|
149
|
-
const prevEndTime = fromTimeFormat(self[prevIndex].end);
|
|
150
|
-
|
|
151
|
-
// if prevStartTime > prevEndTime then it means that prevEndTime is on the current day
|
|
152
|
-
// so we need to add interval from start of current day to prevEndTime
|
|
153
|
-
if (prevStartTime > prevEndTime) {
|
|
154
|
-
res.push(Interval.fromDateTimes(prevEndTime.startOf("day"), prevEndTime));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return res;
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// if length === 0 or length === 7 then all workhours are selected, no need to filter
|
|
161
|
-
if (![0, 7].includes(byWeekDay.length)) {
|
|
162
|
-
intervalsByDay = intervalsByDay.filter((_, index) =>
|
|
163
|
-
byWeekDay.find(({ weekday }) => weekday === index)
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
validate: (_time: string) => {
|
|
169
|
-
// workaround for issue with form values
|
|
170
|
-
// default values and entered values have different formats
|
|
171
|
-
const time = fromTimeFormat(_time).isValid
|
|
172
|
-
? fromTimeFormat(_time)
|
|
173
|
-
: fromTimeFullFormat(_time);
|
|
174
|
-
|
|
175
|
-
const notFittingIntervalsByDay = intervalsByDay.reduce<Interval[][]>(
|
|
176
|
-
(acc, intervalsByDay) => {
|
|
177
|
-
if (!intervalsByDay.some((interval) => interval.contains(time))) {
|
|
178
|
-
acc.push(intervalsByDay);
|
|
179
|
-
}
|
|
180
|
-
return acc;
|
|
181
|
-
},
|
|
182
|
-
[]
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
const notFittingIntervals = notFittingIntervalsByDay
|
|
186
|
-
.flat()
|
|
187
|
-
.filter((interval) => !interval.contains(time));
|
|
188
|
-
|
|
189
|
-
const attribute = notFittingIntervals
|
|
190
|
-
.map((interval) => interval.toFormat("HH:mm"))
|
|
191
|
-
.join(", ");
|
|
192
|
-
|
|
193
|
-
if (notFittingIntervalsByDay.length !== 0) {
|
|
194
|
-
return t("outsideWorkingHours", { attribute }) as string;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return true;
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
};
|
|
@@ -23,7 +23,7 @@ interface ReportField {
|
|
|
23
23
|
title: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
type ReportRunnerModalProps = {
|
|
27
27
|
reportId: Report["id"] | null;
|
|
28
28
|
show: boolean;
|
|
29
29
|
useShowReportFields: (
|
|
@@ -136,38 +136,28 @@ export const ReportRunnerModal = ({
|
|
|
136
136
|
</Button>
|
|
137
137
|
|
|
138
138
|
<form noValidate>
|
|
139
|
-
<div
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
>
|
|
144
|
-
<div className="period-by">
|
|
145
|
-
{PERIOD_BY_TYPES.map((type) => (
|
|
146
|
-
<div key={type}>
|
|
139
|
+
<div className="period-by">
|
|
140
|
+
{PERIOD_BY_TYPES.map((type) => (
|
|
141
|
+
<div key={type}>
|
|
142
|
+
<Form.Group>
|
|
147
143
|
<Form.Check
|
|
148
144
|
inline
|
|
145
|
+
isInvalid={!!errors.periodBy}
|
|
149
146
|
label={t(labelByPeriodType[type])}
|
|
150
147
|
type="radio"
|
|
151
148
|
id={type}
|
|
152
|
-
required
|
|
153
149
|
value={type}
|
|
154
|
-
{...register("periodBy"
|
|
155
|
-
required: `${t("Validation:fieldRequired", {
|
|
156
|
-
attribute: t("Design:period"),
|
|
157
|
-
})}`,
|
|
158
|
-
})}
|
|
150
|
+
{...register("periodBy")}
|
|
159
151
|
/>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
<div className="iframe-event__message-error justify-content-start mb-1">
|
|
165
|
-
{errors.periodBy?.message}
|
|
152
|
+
<Form.Control.Feedback type="invalid">
|
|
153
|
+
{errors.periodBy?.message}
|
|
154
|
+
</Form.Control.Feedback>
|
|
155
|
+
</Form.Group>
|
|
166
156
|
</div>
|
|
167
|
-
)}
|
|
157
|
+
))}
|
|
168
158
|
</div>
|
|
169
159
|
|
|
170
|
-
<div className="controls
|
|
160
|
+
<div className="controls">
|
|
171
161
|
<Form.Group controlId="from-input">
|
|
172
162
|
<Form.Label>{t("Design:from")}</Form.Label>
|
|
173
163
|
<Form.Control
|
|
@@ -178,7 +168,7 @@ export const ReportRunnerModal = ({
|
|
|
178
168
|
required: {
|
|
179
169
|
value: true,
|
|
180
170
|
message: `${t("Validation:fieldRequired", {
|
|
181
|
-
attribute: t("Design:
|
|
171
|
+
attribute: t("Design:to"),
|
|
182
172
|
})}`,
|
|
183
173
|
},
|
|
184
174
|
})}
|
|
@@ -12,6 +12,7 @@ import { TIME_FORMAT } from "@licklist/core/dist/Config";
|
|
|
12
12
|
import * as Config from "@licklist/core/dist/Config";
|
|
13
13
|
import { formatDateStringForEvent } from "@licklist/plugins/dist/utils/formatDate";
|
|
14
14
|
import { getOrderSourceTitle } from "@licklist/plugins/dist/utils/sourceTitle";
|
|
15
|
+
|
|
15
16
|
import Icon from "../../../../static/Icon";
|
|
16
17
|
|
|
17
18
|
export type ResultCardProps = {
|
|
@@ -21,6 +22,8 @@ export type ResultCardProps = {
|
|
|
21
22
|
onCardClick?: (id: number) => void;
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
// @TODO integrate when API will be available
|
|
26
|
+
// activity and staff keys
|
|
24
27
|
export const ResultCard = ({
|
|
25
28
|
order,
|
|
26
29
|
className,
|
|
@@ -11,7 +11,7 @@ import Row from "react-bootstrap/Row";
|
|
|
11
11
|
import Col from "react-bootstrap/Col";
|
|
12
12
|
import { Link } from "react-router-dom";
|
|
13
13
|
import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
|
|
14
|
-
import {
|
|
14
|
+
import { ProviderType } from "@licklist/core/dist/DataMapper/Provider/ProvidableDataMapper";
|
|
15
15
|
import Icon from "../../static/Icon";
|
|
16
16
|
import { PaymentFeeForm, PaymentFeeFormFieldValues } from "./PaymentFeeForm";
|
|
17
17
|
import { Currency } from "../../types/currency";
|
|
@@ -33,7 +33,7 @@ export interface AdminSettingFormProps extends HasPermissionProp {
|
|
|
33
33
|
providerMetadata: {
|
|
34
34
|
country?: string;
|
|
35
35
|
providableId?: number;
|
|
36
|
-
providerType?:
|
|
36
|
+
providerType?: ProviderType;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -53,6 +53,7 @@ export interface SortableTreeItemProps {
|
|
|
53
53
|
};
|
|
54
54
|
setIsExpanded?: () => void;
|
|
55
55
|
isOverride?: boolean;
|
|
56
|
+
isProduct?: boolean;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export function SortableTreeItem({
|
|
@@ -80,6 +81,7 @@ export function SortableTreeItem({
|
|
|
80
81
|
secondaryBadge,
|
|
81
82
|
setIsExpanded,
|
|
82
83
|
isOverride,
|
|
84
|
+
isProduct = false,
|
|
83
85
|
}: SortableTreeItemProps) {
|
|
84
86
|
const [expanded, setExpanded] = useState(isExpanded);
|
|
85
87
|
const [isModalVisible, setIsModalVisible] = useState(isNewAdded);
|
|
@@ -150,6 +152,7 @@ export function SortableTreeItem({
|
|
|
150
152
|
};
|
|
151
153
|
|
|
152
154
|
const onEdit = (e) => {
|
|
155
|
+
if (isOverride && !isProduct) return;
|
|
153
156
|
e.stopPropagation();
|
|
154
157
|
if (edit && !isModalVisible) edit();
|
|
155
158
|
setIsModalVisible(true);
|
|
@@ -23,7 +23,7 @@ export function BooleanSwitch({
|
|
|
23
23
|
const { t } = useTranslation("Design");
|
|
24
24
|
|
|
25
25
|
const options: SelectItem[] = [
|
|
26
|
-
{ id: 1, value: firstValueTitle ??
|
|
26
|
+
{ id: 1, value: firstValueTitle ?? t("yes") },
|
|
27
27
|
{ id: 0, value: secondValueTitle ?? t("no") },
|
|
28
28
|
];
|
|
29
29
|
|