@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
|
@@ -8,12 +8,8 @@ import {
|
|
|
8
8
|
useWatch,
|
|
9
9
|
Validate,
|
|
10
10
|
} from "react-hook-form";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
TIME_FORMAT,
|
|
14
|
-
TIME_FULL_FORMAT,
|
|
15
|
-
} from "@licklist/core/dist/Config";
|
|
16
|
-
import { fromFormat } from "@licklist/plugins/dist/utils/dateTime";
|
|
11
|
+
import { TIME_FORMAT } from "@licklist/core/dist/Config";
|
|
12
|
+
import { fromIso } from "@licklist/core/dist/Services";
|
|
17
13
|
import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
|
|
18
14
|
|
|
19
15
|
interface RecurrenceIntervalAndFrequencyInputProps {
|
|
@@ -31,17 +27,9 @@ interface RecurrenceIntervalAndFrequencyInputProps {
|
|
|
31
27
|
RegisterOptions,
|
|
32
28
|
"max" | "min" | "validate" | "required" | "pattern"
|
|
33
29
|
>;
|
|
30
|
+
timeZone: string;
|
|
34
31
|
}
|
|
35
32
|
|
|
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
33
|
function RecurrenceIntervalAndFrequencyInput({
|
|
46
34
|
disabled = false,
|
|
47
35
|
minDate,
|
|
@@ -51,6 +39,7 @@ function RecurrenceIntervalAndFrequencyInput({
|
|
|
51
39
|
endTimeLabel,
|
|
52
40
|
startTimeRules,
|
|
53
41
|
endTimeRules,
|
|
42
|
+
timeZone,
|
|
54
43
|
}: RecurrenceIntervalAndFrequencyInputProps) {
|
|
55
44
|
const { t } = useTranslation(["Design", "Notification", "App"]);
|
|
56
45
|
|
|
@@ -66,10 +55,10 @@ function RecurrenceIntervalAndFrequencyInput({
|
|
|
66
55
|
|
|
67
56
|
const _startTime = useWatch({ control, name: "startTime" });
|
|
68
57
|
const startTime =
|
|
69
|
-
_startTime &&
|
|
58
|
+
_startTime && fromIso(_startTime, timeZone).toFormat(TIME_FORMAT);
|
|
70
59
|
|
|
71
60
|
const _endTime = useWatch({ control, name: "endTime" });
|
|
72
|
-
const endTime = _endTime &&
|
|
61
|
+
const endTime = _endTime && fromIso(_endTime, timeZone).toFormat(TIME_FORMAT);
|
|
73
62
|
|
|
74
63
|
useEffect(() => {
|
|
75
64
|
if (!startDate || !endDate) {
|
|
@@ -119,11 +108,8 @@ function RecurrenceIntervalAndFrequencyInput({
|
|
|
119
108
|
if (!startDate || !date) {
|
|
120
109
|
return true;
|
|
121
110
|
}
|
|
122
|
-
const currentStartDate =
|
|
123
|
-
|
|
124
|
-
DATE_FORMAT,
|
|
125
|
-
);
|
|
126
|
-
const currentEndDate = DateTime.fromFormat(date, DATE_FORMAT);
|
|
111
|
+
const currentStartDate = fromIso(startDate, timeZone);
|
|
112
|
+
const currentEndDate = fromIso(date, timeZone);
|
|
127
113
|
return currentEndDate.diff(currentStartDate, ["days"]).days >=
|
|
128
114
|
0
|
|
129
115
|
? true
|
|
@@ -2,7 +2,7 @@ import { useEffect, useMemo, PropsWithChildren } from "react";
|
|
|
2
2
|
import RRule, { Frequency, Weekday } from "rrule";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
4
|
import Button from "react-bootstrap/Button";
|
|
5
|
-
import { DateTime, Interval } from "luxon";
|
|
5
|
+
import { DateTime, Interval, WeekdayNumbers } from "luxon";
|
|
6
6
|
import { useIntl } from "react-intl";
|
|
7
7
|
import {
|
|
8
8
|
DATE_TIME_FORMAT,
|
|
@@ -32,6 +32,7 @@ export interface RecurringDatePickerInputProps {
|
|
|
32
32
|
setInitialStartDateAfterSelect?: boolean;
|
|
33
33
|
minDate?: string;
|
|
34
34
|
workHours: WorkHour[] | undefined;
|
|
35
|
+
timeZone: string;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export interface RecurringDatePickerInputValues {
|
|
@@ -58,6 +59,7 @@ export function RecurringDatePickerInput({
|
|
|
58
59
|
children,
|
|
59
60
|
minDate,
|
|
60
61
|
workHours,
|
|
62
|
+
timeZone,
|
|
61
63
|
}: PropsWithChildren<RecurringDatePickerInputProps>) {
|
|
62
64
|
const { t } = useTranslation(["Design"]);
|
|
63
65
|
|
|
@@ -91,7 +93,7 @@ export function RecurringDatePickerInput({
|
|
|
91
93
|
byWeekDay,
|
|
92
94
|
});
|
|
93
95
|
|
|
94
|
-
const validator = useWorkHoursValidation(byWeekDay, workHours);
|
|
96
|
+
const validator = useWorkHoursValidation(byWeekDay, workHours, timeZone);
|
|
95
97
|
|
|
96
98
|
const onSubmit = (nextState: RecurringDatePickerInputValues) => {
|
|
97
99
|
const end = getDateTimeObject(endDate, endTime || "23:59:59");
|
|
@@ -158,7 +160,7 @@ export function RecurringDatePickerInput({
|
|
|
158
160
|
// Luxon use standard ISO calendar but in that case
|
|
159
161
|
// first weekday from weekdays array start from 0 index.
|
|
160
162
|
// We need to add 1 to it to show correct data
|
|
161
|
-
const currentWeekDay = byWeekDay[0]?.weekday + 1;
|
|
163
|
+
const currentWeekDay = (byWeekDay[0]?.weekday + 1) as WeekdayNumbers;
|
|
162
164
|
|
|
163
165
|
const currentDate = DateTime.local();
|
|
164
166
|
|
|
@@ -199,6 +201,7 @@ export function RecurringDatePickerInput({
|
|
|
199
201
|
minDate={minDate}
|
|
200
202
|
startTimeRules={validator}
|
|
201
203
|
endTimeRules={validator}
|
|
204
|
+
timeZone={timeZone}
|
|
202
205
|
/>
|
|
203
206
|
|
|
204
207
|
{children}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { TIME_FORMAT, TIME_FULL_FORMAT } from "@licklist/core/dist/Config";
|
|
2
1
|
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
3
|
-
import {
|
|
2
|
+
import { fromIso } from "@licklist/core/dist/Services";
|
|
4
3
|
import { DateTime, Interval } from "luxon";
|
|
5
4
|
import { Validate } from "react-hook-form";
|
|
6
5
|
import { useTranslation } from "react-i18next";
|
|
@@ -119,6 +118,7 @@ export const parseAndValidateRRule = ({
|
|
|
119
118
|
export const useWorkHoursValidation = (
|
|
120
119
|
byWeekDay: Weekday[] = [],
|
|
121
120
|
workHours: WorkHour[] | undefined,
|
|
121
|
+
timeZone: string,
|
|
122
122
|
): {
|
|
123
123
|
/* @ts-expect-error 2314 */
|
|
124
124
|
validate?: Validate<string>;
|
|
@@ -126,15 +126,12 @@ export const useWorkHoursValidation = (
|
|
|
126
126
|
const { t } = useTranslation("Validation");
|
|
127
127
|
if (!workHours) return {};
|
|
128
128
|
|
|
129
|
-
const fromTimeFormat = fromFormat(TIME_FORMAT);
|
|
130
|
-
const fromTimeFullFormat = fromFormat(TIME_FULL_FORMAT);
|
|
131
|
-
|
|
132
129
|
// map every day to array of intervals describing workhours for that day
|
|
133
130
|
let intervalsByDay = workHours.map((workhour, index, self) => {
|
|
134
131
|
const res: Interval[] = [];
|
|
135
132
|
|
|
136
|
-
const startTime =
|
|
137
|
-
const endTime =
|
|
133
|
+
const startTime = fromIso(workhour.start, timeZone);
|
|
134
|
+
const endTime = fromIso(workhour.end, timeZone);
|
|
138
135
|
|
|
139
136
|
if (endTime > startTime) {
|
|
140
137
|
res.push(Interval.fromDateTimes(startTime, endTime));
|
|
@@ -146,8 +143,8 @@ export const useWorkHoursValidation = (
|
|
|
146
143
|
|
|
147
144
|
const prevIndex = index === 0 ? self.length - 1 : index - 1;
|
|
148
145
|
|
|
149
|
-
const prevStartTime =
|
|
150
|
-
const prevEndTime =
|
|
146
|
+
const prevStartTime = fromIso(self[prevIndex].start, timeZone);
|
|
147
|
+
const prevEndTime = fromIso(self[prevIndex].end, timeZone);
|
|
151
148
|
|
|
152
149
|
// if prevStartTime > prevEndTime then it means that prevEndTime is on the current day
|
|
153
150
|
// so we need to add interval from start of current day to prevEndTime
|
|
@@ -169,9 +166,7 @@ export const useWorkHoursValidation = (
|
|
|
169
166
|
validate: (_time: string) => {
|
|
170
167
|
// workaround for issue with form values
|
|
171
168
|
// default values and entered values have different formats
|
|
172
|
-
const time =
|
|
173
|
-
? fromTimeFormat(_time)
|
|
174
|
-
: fromTimeFullFormat(_time);
|
|
169
|
+
const time = fromIso(_time, timeZone);
|
|
175
170
|
|
|
176
171
|
const notFittingIntervalsByDay = intervalsByDay.reduce<Interval[][]>(
|
|
177
172
|
(acc, intervalsByDay) => {
|
|
@@ -12,10 +12,13 @@ export interface TypeaheadProps {
|
|
|
12
12
|
placeholder: string;
|
|
13
13
|
isRequired?: boolean;
|
|
14
14
|
name: string;
|
|
15
|
+
value?: TypeaheadOptions;
|
|
15
16
|
isMultipleChoise?: boolean;
|
|
16
17
|
noOptionsMessage: string;
|
|
17
18
|
isInvalid?: boolean;
|
|
18
19
|
isCouponForm?: boolean;
|
|
20
|
+
containerStyles?: CSSObjectWithLabel;
|
|
21
|
+
onChangeValue?: (value: TypeaheadOptions) => void;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
function Typeahead({
|
|
@@ -24,6 +27,9 @@ function Typeahead({
|
|
|
24
27
|
isRequired = false,
|
|
25
28
|
isMultipleChoise,
|
|
26
29
|
name = "",
|
|
30
|
+
value,
|
|
31
|
+
onChangeValue,
|
|
32
|
+
containerStyles,
|
|
27
33
|
isCouponForm = false,
|
|
28
34
|
noOptionsMessage = "",
|
|
29
35
|
isInvalid,
|
|
@@ -53,15 +59,23 @@ function Typeahead({
|
|
|
53
59
|
render={({ field }) => (
|
|
54
60
|
<Select
|
|
55
61
|
placeholder={placeholder}
|
|
56
|
-
value={field.value}
|
|
62
|
+
value={value ?? field.value}
|
|
57
63
|
isMulti={isMultipleChoise}
|
|
58
64
|
styles={{
|
|
65
|
+
container: (base) => ({
|
|
66
|
+
...base,
|
|
67
|
+
...containerStyles,
|
|
68
|
+
}),
|
|
59
69
|
control: (base) => ({
|
|
60
70
|
...base,
|
|
61
71
|
...getStyle(),
|
|
62
72
|
}),
|
|
63
73
|
}}
|
|
64
74
|
onChange={(value) => {
|
|
75
|
+
if (onChangeValue) {
|
|
76
|
+
onChangeValue(value);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
65
79
|
field.onChange(value);
|
|
66
80
|
}}
|
|
67
81
|
options={options}
|
|
@@ -14,6 +14,7 @@ export type ZoneFormProps = {
|
|
|
14
14
|
serverErrors?: ServerError;
|
|
15
15
|
isLoading?: boolean;
|
|
16
16
|
workHours: WorkHour[] | undefined;
|
|
17
|
+
timeZone: string;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export type ZoneFormValues = Partial<Zone> & {
|
|
@@ -26,6 +27,7 @@ export const ZoneForm = ({
|
|
|
26
27
|
serverErrors,
|
|
27
28
|
isLoading = false,
|
|
28
29
|
workHours,
|
|
30
|
+
timeZone,
|
|
29
31
|
}: ZoneFormProps) => {
|
|
30
32
|
const { t } = useTranslation("Design");
|
|
31
33
|
const form = useForm<ZoneFormValues>({
|
|
@@ -55,7 +57,11 @@ export const ZoneForm = ({
|
|
|
55
57
|
return (
|
|
56
58
|
<FormProvider {...form}>
|
|
57
59
|
<Form onSubmit={handleSubmit(onFormSubmit)}>
|
|
58
|
-
<ZoneControl
|
|
60
|
+
<ZoneControl
|
|
61
|
+
isLoading={isLoading}
|
|
62
|
+
workHours={workHours}
|
|
63
|
+
timeZone={timeZone}
|
|
64
|
+
/>
|
|
59
65
|
<Row>
|
|
60
66
|
<Col md={6} sm={12} />
|
|
61
67
|
<Col
|
|
@@ -11,14 +11,19 @@ import { GameDurationControl } from "./GameDurationControl";
|
|
|
11
11
|
export type ZoneControlProps = {
|
|
12
12
|
isLoading: boolean;
|
|
13
13
|
workHours: WorkHour[] | undefined;
|
|
14
|
+
timeZone: string;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
export const ZoneControl = ({
|
|
17
|
+
export const ZoneControl = ({
|
|
18
|
+
isLoading,
|
|
19
|
+
workHours,
|
|
20
|
+
timeZone,
|
|
21
|
+
}: ZoneControlProps) => {
|
|
17
22
|
return (
|
|
18
23
|
<Row>
|
|
19
24
|
<Col md={6} sm={12} className="pr-5">
|
|
20
25
|
<NameControl isLoading={isLoading} />
|
|
21
|
-
<ZoneRecurrencesControl workHours={workHours} />
|
|
26
|
+
<ZoneRecurrencesControl workHours={workHours} timeZone={timeZone} />
|
|
22
27
|
<hr />
|
|
23
28
|
<Row>
|
|
24
29
|
<Col md={6} sm={6}>
|
|
@@ -27,10 +27,12 @@ export interface DateAndRecurrenceInputValues {
|
|
|
27
27
|
|
|
28
28
|
type ZoneRecurrenceControlProps = {
|
|
29
29
|
workHours: WorkHour[] | undefined;
|
|
30
|
+
timeZone: string;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
export const ZoneRecurrencesControl = ({
|
|
33
34
|
workHours,
|
|
35
|
+
timeZone,
|
|
34
36
|
}: ZoneRecurrenceControlProps) => {
|
|
35
37
|
const {
|
|
36
38
|
control,
|
|
@@ -168,6 +170,7 @@ export const ZoneRecurrencesControl = ({
|
|
|
168
170
|
onDelete={handleDelete}
|
|
169
171
|
setInitialStartDateAfterSelect
|
|
170
172
|
workHours={workHours}
|
|
173
|
+
timeZone={timeZone}
|
|
171
174
|
/>
|
|
172
175
|
</Popover.Content>
|
|
173
176
|
</Popover>
|