@licklist/design 0.66.0 → 0.66.1-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/date-time-button/DateTimeButton.js +1 -1
  2. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
  3. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
  4. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
  5. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
  6. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
  7. package/dist/product-set/control/DateAndRecurrenceInput.d.ts +1 -1
  8. package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
  9. package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
  10. package/dist/product-set/control/DateInput.js +1 -1
  11. package/dist/product-set/control/ProductSetControl.d.ts +3 -2
  12. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  13. package/dist/product-set/control/ProductSetControl.js +1 -1
  14. package/dist/product-set/form/ProductCategoriesControl.d.ts +3 -1
  15. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  16. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  17. package/dist/product-set/form/ProductSetForm.d.ts +6 -2
  18. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  19. package/dist/product-set/form/ProductSetForm.js +1 -1
  20. package/dist/product-set/form/ProductsControl.d.ts +3 -1
  21. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  22. package/dist/product-set/form/ProductsControl.js +1 -1
  23. package/dist/product-set/form/StepsControl.d.ts +3 -1
  24. package/dist/product-set/form/StepsControl.d.ts.map +1 -1
  25. package/dist/product-set/form/StepsControl.js +1 -1
  26. package/dist/product-set/product/ProductControl.d.ts +1 -0
  27. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  28. package/dist/product-set/product/ProductControl.js +1 -1
  29. package/dist/product-set/step/StepControl.d.ts +2 -1
  30. package/dist/product-set/step/StepControl.d.ts.map +1 -1
  31. package/dist/product-set/step/StepControl.js +1 -1
  32. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  33. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  34. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
  35. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +1 -1
  36. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +3 -1
  37. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  38. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  39. package/dist/recurring-date-picker-input/utils.d.ts +5 -0
  40. package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
  41. package/dist/recurring-date-picker-input/utils.js +1 -1
  42. package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts +1 -1
  43. package/dist/report/ReportRunnerModal/ReportRunnerModal.d.ts.map +1 -1
  44. package/dist/report/ReportRunnerModal/ReportRunnerModal.js +1 -1
  45. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  46. package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
  47. package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
  48. package/dist/sortable-tree/SortableTreeItem.d.ts +1 -2
  49. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  50. package/dist/sortable-tree/SortableTreeItem.js +1 -1
  51. package/dist/styles/date-time-button/DateTimeButton.scss +1 -0
  52. package/dist/styles/sales/BookingResults.scss +1 -1
  53. package/dist/styles/zones/ZoneForm.scss +2 -1
  54. package/dist/zone/form/ZoneForm.d.ts +2 -2
  55. package/dist/zone/form/ZoneForm.d.ts.map +1 -1
  56. package/dist/zone/form/ZoneForm.js +1 -1
  57. package/dist/zone/form/components/ZoneControl.d.ts +2 -2
  58. package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
  59. package/dist/zone/form/components/ZoneControl.js +1 -1
  60. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
  61. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
  62. package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
  63. package/dist/zone/form/utils/dates.d.ts.map +1 -1
  64. package/package.json +3 -5
  65. package/src/date-time-button/DateTimeButton.stories.tsx +2 -1
  66. package/src/date-time-button/DateTimeButton.tsx +7 -5
  67. package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +14 -9
  68. package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +2 -0
  69. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +1 -0
  70. package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -4
  71. package/src/product-set/control/DateInput.tsx +2 -2
  72. package/src/product-set/control/ProductSetControl.tsx +17 -5
  73. package/src/product-set/form/ProductCategoriesControl.tsx +15 -4
  74. package/src/product-set/form/ProductSetForm.tsx +13 -2
  75. package/src/product-set/form/ProductsControl.tsx +93 -77
  76. package/src/product-set/form/StepsControl.tsx +15 -7
  77. package/src/product-set/product/ProductControl.tsx +8 -5
  78. package/src/product-set/step/StepControl.tsx +4 -3
  79. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +4 -18
  80. package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +50 -21
  81. package/src/recurring-date-picker-input/RecurringDatePickerInput.stories.tsx +13 -7
  82. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +12 -1
  83. package/src/recurring-date-picker-input/utils.ts +90 -1
  84. package/src/report/ReportRunnerModal/ReportRunnerModal.stories.tsx +307 -0
  85. package/src/report/ReportRunnerModal/ReportRunnerModal.tsx +24 -14
  86. package/src/sales/booking/results/components/ResultCard.tsx +0 -3
  87. package/src/setting/admin/AdminSettingForm.tsx +2 -2
  88. package/src/sortable-tree/SortableTreeItem.tsx +0 -3
  89. package/src/static/switch/BooleanSwitch.tsx +1 -1
  90. package/src/styles/date-time-button/DateTimeButton.scss +1 -0
  91. package/src/styles/sales/BookingResults.scss +1 -1
  92. package/src/styles/zones/ZoneForm.scss +2 -1
  93. package/src/zone/form/ZoneForm.tsx +3 -2
  94. package/src/zone/form/components/ZoneControl.tsx +3 -3
  95. package/src/zone/form/components/ZoneRecurrencesControl.tsx +7 -5
  96. package/src/zone/form/utils/dates.ts +9 -10
@@ -26,6 +26,7 @@ export interface StepControlProps extends IsDeletableEvent {
26
26
  stepIndex: number;
27
27
  stepName: string;
28
28
  onStepNameChange: (args: any) => void;
29
+ isOverrides?: boolean;
29
30
  }
30
31
 
31
32
  export function StepControl({
@@ -33,6 +34,7 @@ export function StepControl({
33
34
  stepIndex,
34
35
  stepName,
35
36
  onStepNameChange,
37
+ isOverrides = false,
36
38
  }: StepControlProps) {
37
39
  const { providerHasMap } = useContext(ProductSetLoadingContext);
38
40
  const {
@@ -42,7 +44,6 @@ export function StepControl({
42
44
  watch,
43
45
  } = useFormContext<ProductSetFormValues>();
44
46
  const { t } = useTranslation("Design");
45
-
46
47
  const fieldName = `steps.${stepIndex}.name` as const;
47
48
  const productCategoriesFieldName =
48
49
  `steps.${stepIndex}.productCategories` as const;
@@ -71,7 +72,7 @@ export function StepControl({
71
72
  fieldName,
72
73
  errors
73
74
  )}
74
- disabled={isLoading}
75
+ disabled={isLoading || isOverrides}
75
76
  />
76
77
  )}
77
78
  control={control}
@@ -114,7 +115,7 @@ export function StepControl({
114
115
  name={name}
115
116
  value={Boolean(value)}
116
117
  onChange={onChange}
117
- disabled={isLoading}
118
+ disabled={isLoading || isOverrides}
118
119
  />
119
120
  )}
120
121
  control={control}
@@ -1,9 +1,7 @@
1
- import { DateTime } from "luxon";
2
1
  import React from "react";
3
2
  import { Col, Row } from "react-bootstrap";
4
3
  import { useFormContext } from "react-hook-form";
5
4
  import { useTranslation } from "react-i18next";
6
- import { TIME_FORMAT } from "@licklist/core/dist/Config";
7
5
  import { WorkingHoursInputValues } from ".";
8
6
  import { useWeekdays } from "./utils";
9
7
 
@@ -25,22 +23,10 @@ export function WorkingHoursInputDescription() {
25
23
  <Row key={i}>
26
24
  <Col xs="auto">{weekdays[i]}:</Col>
27
25
  <Col>
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}
26
+ {t("timeInterval", {
27
+ start: weekday.start,
28
+ end: weekday.end,
29
+ })}
44
30
  </Col>
45
31
  </Row>
46
32
  );
@@ -2,8 +2,18 @@ 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 { RegisterOptions, useFormContext } from "react-hook-form";
6
- import { DATE_FORMAT } from "@licklist/core/dist/Config";
5
+ import {
6
+ RegisterOptions,
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";
7
17
  import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
8
18
 
9
19
  interface RecurrenceIntervalAndFrequencyInputProps {
@@ -23,6 +33,15 @@ interface RecurrenceIntervalAndFrequencyInputProps {
23
33
  >;
24
34
  }
25
35
 
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
+
26
45
  function RecurrenceIntervalAndFrequencyInput({
27
46
  disabled = false,
28
47
  minDate,
@@ -36,16 +55,21 @@ function RecurrenceIntervalAndFrequencyInput({
36
55
  const { t } = useTranslation(["Design", "Notification", "App"]);
37
56
 
38
57
  const {
39
- getValues,
40
58
  formState: { errors },
41
59
  register,
42
60
  trigger,
61
+ control,
43
62
  } = useFormContext<RecurringDatePickerInputValues>();
44
63
 
45
- const startDate = getValues("startDate");
46
- const endDate = getValues("endDate");
47
- const startTime = getValues("startTime");
48
- const endTime = getValues("endTime");
64
+ const startDate = useWatch({ control, name: "startDate" });
65
+ const endDate = useWatch({ control, name: "endDate" });
66
+
67
+ const _startTime = useWatch({ control, name: "startTime" });
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);
49
73
 
50
74
  useEffect(() => {
51
75
  if (!startDate || !endDate) {
@@ -149,22 +173,27 @@ function RecurrenceIntervalAndFrequencyInput({
149
173
  type="time"
150
174
  {...register("endTime", {
151
175
  required: false,
152
- validate: (time) => {
153
- if (!startTime || !time) {
154
- return true;
155
- }
156
- const currentStartTime = DateTime.fromISO(startTime);
157
- const currentEndTime = DateTime.fromISO(time);
176
+ ...endTimeRules,
177
+ validate: {
178
+ external: endTimeRules?.validate
179
+ ? (endTimeRules?.validate as Validate<string>)
180
+ : () => true,
181
+ time: (time) => {
182
+ if (!startTime || !time) {
183
+ return true;
184
+ }
185
+ const currentStartTime = DateTime.fromISO(startTime);
186
+ const currentEndTime = DateTime.fromISO(time);
158
187
 
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
- })}`;
188
+ return currentEndTime?.diff(currentStartTime, ["minutes"])
189
+ ?.minutes >= 0
190
+ ? true
191
+ : `${t(`Validation:fieldLaterDate`, {
192
+ attribute: t("Design:endTimeSmall"),
193
+ min: t("Design:startTimeSmall"),
194
+ })}`;
195
+ },
166
196
  },
167
- ...endTimeRules,
168
197
  })}
169
198
  placeholder="hh:mm"
170
199
  defaultValue={endTime}
@@ -1,22 +1,19 @@
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";
4
6
  import {
5
7
  RecurringDatePickerInput,
6
8
  RecurringDatePickerInputProps,
7
9
  } 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
- interface DefaultRecurringDatePickerInputProps
17
- extends RecurringDatePickerInputProps {}
18
-
19
- export const Default: Story<DefaultRecurringDatePickerInputProps> = (args) => {
16
+ export const Default: Story<RecurringDatePickerInputProps> = (args) => {
20
17
  return (
21
18
  <Card style={{ maxWidth: "max-content" }}>
22
19
  <Card.Body>
@@ -25,7 +22,7 @@ export const Default: Story<DefaultRecurringDatePickerInputProps> = (args) => {
25
22
  </Card>
26
23
  );
27
24
  };
28
- export const Valid: Story<DefaultRecurringDatePickerInputProps> = (args) => {
25
+ export const Valid: Story<RecurringDatePickerInputProps> = (args) => {
29
26
  return (
30
27
  <Card style={{ maxWidth: "max-content" }}>
31
28
  <Card.Body>
@@ -36,6 +33,15 @@ export const Valid: Story<DefaultRecurringDatePickerInputProps> = (args) => {
36
33
  };
37
34
  Default.args = {
38
35
  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
+ ],
39
45
  };
40
46
  Valid.args = {
41
47
  onChange: (data) => console.log("onSubmit", data),
@@ -12,9 +12,14 @@ 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";
15
16
  import RecurrenceIntervalAndFrequencyInput from "./RecurrenceIntervalAndFrequencyInput";
16
17
  import RecurrenceWeekdaysInput from "./RecurrenceWeekdaysInput";
17
- import { parseAndValidateRRule, SupportedFrequency } from "./utils";
18
+ import {
19
+ parseAndValidateRRule,
20
+ SupportedFrequency,
21
+ useWorkHoursValidation,
22
+ } from "./utils";
18
23
  import { ConfirmModal } from "../modals";
19
24
  import { DeleteFieldButton } from "../product-set/elements";
20
25
 
@@ -26,6 +31,7 @@ export interface RecurringDatePickerInputProps {
26
31
  initialFrequency?: Frequency;
27
32
  setInitialStartDateAfterSelect?: boolean;
28
33
  minDate?: string;
34
+ workHours: WorkHour[] | undefined;
29
35
  }
30
36
 
31
37
  export interface RecurringDatePickerInputValues {
@@ -51,6 +57,7 @@ export function RecurringDatePickerInput({
51
57
  setInitialStartDateAfterSelect = false,
52
58
  children,
53
59
  minDate,
60
+ workHours,
54
61
  }: PropsWithChildren<RecurringDatePickerInputProps>) {
55
62
  const { t } = useTranslation(["Design"]);
56
63
 
@@ -84,6 +91,8 @@ export function RecurringDatePickerInput({
84
91
  byWeekDay,
85
92
  });
86
93
 
94
+ const validator = useWorkHoursValidation(byWeekDay, workHours);
95
+
87
96
  const onSubmit = (nextState: RecurringDatePickerInputValues) => {
88
97
  const end = getDateTimeObject(endDate, endTime || "23:59:59");
89
98
 
@@ -188,6 +197,8 @@ export function RecurringDatePickerInput({
188
197
  <RecurrenceIntervalAndFrequencyInput
189
198
  disabled={disabled}
190
199
  minDate={minDate}
200
+ startTimeRules={validator}
201
+ endTimeRules={validator}
191
202
  />
192
203
 
193
204
  {children}
@@ -1,4 +1,9 @@
1
- import { DateTime } from "luxon";
1
+ import { TIME_FORMAT, TIME_FULL_FORMAT } from "@licklist/core/dist/Config";
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";
2
7
  import RRule, { Frequency, Weekday } from "rrule";
3
8
 
4
9
  export const getWeekdayForFrequency = ({
@@ -11,6 +16,7 @@ export const getWeekdayForFrequency = ({
11
16
  const parsedDate = DateTime.fromISO(date);
12
17
  return new Weekday(
13
18
  parsedDate.weekday - 1,
19
+ // eslint-disable-next-line no-nested-ternary
14
20
  frequency !== Frequency.MONTHLY
15
21
  ? undefined
16
22
  : parsedDate.day + 7 > parsedDate.daysInMonth
@@ -109,3 +115,86 @@ export const parseAndValidateRRule = ({
109
115
  until: options.until,
110
116
  } as ParsedRRuleOptions;
111
117
  };
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
+ };
@@ -0,0 +1,307 @@
1
+ import { Meta, Story } from "@storybook/react";
2
+ import React from "react";
3
+ import { Card } from "react-bootstrap";
4
+ import { ReportRunnerModal, ReportRunnerModalProps } from "./ReportRunnerModal";
5
+
6
+ export default {
7
+ title: "Report/ReportRunnerModal",
8
+ component: ReportRunnerModal,
9
+ } as Meta;
10
+
11
+ export const Default: Story<ReportRunnerModalProps> = (args) => (
12
+ <Card style={{ maxWidth: "max-content" }}>
13
+ <Card.Body>
14
+ <ReportRunnerModal {...args} />
15
+ </Card.Body>
16
+ </Card>
17
+ );
18
+
19
+ Default.args = {
20
+ reportId: 47,
21
+ show: true,
22
+ generate: { isLoading: false },
23
+ download: { isLoading: false },
24
+ useShowReportFields: (type) => ({ data: [], isLoading: false }),
25
+ onHide: () => {},
26
+ onEdit: () => {},
27
+ reports: [
28
+ {
29
+ id: 47,
30
+ providerId: null,
31
+ type: "payments",
32
+ name: "Test 1",
33
+ createdAt: "2024-04-26 08:16:59",
34
+ updatedAt: "2024-04-26 08:16:59",
35
+ deletedAt: null,
36
+ reportFieldValues: [
37
+ {
38
+ id: 580,
39
+ reportId: 47,
40
+ reportFieldId: 16,
41
+ },
42
+ {
43
+ id: 581,
44
+ reportId: 47,
45
+ reportFieldId: 17,
46
+ },
47
+ {
48
+ id: 582,
49
+ reportId: 47,
50
+ reportFieldId: 18,
51
+ },
52
+ {
53
+ id: 583,
54
+ reportId: 47,
55
+ reportFieldId: 19,
56
+ },
57
+ {
58
+ id: 584,
59
+ reportId: 47,
60
+ reportFieldId: 20,
61
+ },
62
+ {
63
+ id: 585,
64
+ reportId: 47,
65
+ reportFieldId: 21,
66
+ },
67
+ {
68
+ id: 586,
69
+ reportId: 47,
70
+ reportFieldId: 22,
71
+ },
72
+ {
73
+ id: 587,
74
+ reportId: 47,
75
+ reportFieldId: 23,
76
+ },
77
+ {
78
+ id: 588,
79
+ reportId: 47,
80
+ reportFieldId: 24,
81
+ },
82
+ {
83
+ id: 589,
84
+ reportId: 47,
85
+ reportFieldId: 26,
86
+ },
87
+ {
88
+ id: 590,
89
+ reportId: 47,
90
+ reportFieldId: 27,
91
+ },
92
+ {
93
+ id: 591,
94
+ reportId: 47,
95
+ reportFieldId: 28,
96
+ },
97
+ {
98
+ id: 592,
99
+ reportId: 47,
100
+ reportFieldId: 40,
101
+ },
102
+ {
103
+ id: 593,
104
+ reportId: 47,
105
+ reportFieldId: 41,
106
+ },
107
+ {
108
+ id: 594,
109
+ reportId: 47,
110
+ reportFieldId: 42,
111
+ },
112
+ ],
113
+ },
114
+ {
115
+ id: 52,
116
+ providerId: null,
117
+ type: "bookings",
118
+ name: "new report",
119
+ createdAt: "2024-04-29 16:05:51",
120
+ updatedAt: "2024-04-29 16:08:39",
121
+ deletedAt: null,
122
+ reportFieldValues: [
123
+ {
124
+ id: 635,
125
+ reportId: 52,
126
+ reportFieldId: 1,
127
+ },
128
+ {
129
+ id: 636,
130
+ reportId: 52,
131
+ reportFieldId: 2,
132
+ },
133
+ {
134
+ id: 637,
135
+ reportId: 52,
136
+ reportFieldId: 3,
137
+ },
138
+ {
139
+ id: 638,
140
+ reportId: 52,
141
+ reportFieldId: 4,
142
+ },
143
+ {
144
+ id: 639,
145
+ reportId: 52,
146
+ reportFieldId: 5,
147
+ },
148
+ {
149
+ id: 640,
150
+ reportId: 52,
151
+ reportFieldId: 6,
152
+ },
153
+ {
154
+ id: 641,
155
+ reportId: 52,
156
+ reportFieldId: 7,
157
+ },
158
+ {
159
+ id: 642,
160
+ reportId: 52,
161
+ reportFieldId: 8,
162
+ },
163
+ {
164
+ id: 643,
165
+ reportId: 52,
166
+ reportFieldId: 9,
167
+ },
168
+ {
169
+ id: 644,
170
+ reportId: 52,
171
+ reportFieldId: 10,
172
+ },
173
+ {
174
+ id: 645,
175
+ reportId: 52,
176
+ reportFieldId: 11,
177
+ },
178
+ {
179
+ id: 646,
180
+ reportId: 52,
181
+ reportFieldId: 12,
182
+ },
183
+ {
184
+ id: 647,
185
+ reportId: 52,
186
+ reportFieldId: 13,
187
+ },
188
+ {
189
+ id: 648,
190
+ reportId: 52,
191
+ reportFieldId: 14,
192
+ },
193
+ {
194
+ id: 649,
195
+ reportId: 52,
196
+ reportFieldId: 15,
197
+ },
198
+ {
199
+ id: 650,
200
+ reportId: 52,
201
+ reportFieldId: 36,
202
+ },
203
+ {
204
+ id: 651,
205
+ reportId: 52,
206
+ reportFieldId: 37,
207
+ },
208
+ {
209
+ id: 652,
210
+ reportId: 52,
211
+ reportFieldId: 38,
212
+ },
213
+ {
214
+ id: 653,
215
+ reportId: 52,
216
+ reportFieldId: 39,
217
+ },
218
+ {
219
+ id: 654,
220
+ reportId: 52,
221
+ reportFieldId: 47,
222
+ },
223
+ {
224
+ id: 655,
225
+ reportId: 52,
226
+ reportFieldId: 48,
227
+ },
228
+ ],
229
+ },
230
+ {
231
+ id: 53,
232
+ providerId: null,
233
+ type: "tickets",
234
+ name: "tickets",
235
+ createdAt: "2024-04-29 16:12:36",
236
+ updatedAt: "2024-04-29 16:12:36",
237
+ deletedAt: null,
238
+ reportFieldValues: [
239
+ {
240
+ id: 656,
241
+ reportId: 53,
242
+ reportFieldId: 29,
243
+ },
244
+ {
245
+ id: 657,
246
+ reportId: 53,
247
+ reportFieldId: 30,
248
+ },
249
+ {
250
+ id: 658,
251
+ reportId: 53,
252
+ reportFieldId: 31,
253
+ },
254
+ {
255
+ id: 659,
256
+ reportId: 53,
257
+ reportFieldId: 32,
258
+ },
259
+ {
260
+ id: 660,
261
+ reportId: 53,
262
+ reportFieldId: 33,
263
+ },
264
+ {
265
+ id: 661,
266
+ reportId: 53,
267
+ reportFieldId: 34,
268
+ },
269
+ {
270
+ id: 662,
271
+ reportId: 53,
272
+ reportFieldId: 35,
273
+ },
274
+ {
275
+ id: 663,
276
+ reportId: 53,
277
+ reportFieldId: 43,
278
+ },
279
+ {
280
+ id: 664,
281
+ reportId: 53,
282
+ reportFieldId: 44,
283
+ },
284
+ {
285
+ id: 665,
286
+ reportId: 53,
287
+ reportFieldId: 45,
288
+ },
289
+ {
290
+ id: 666,
291
+ reportId: 53,
292
+ reportFieldId: 46,
293
+ },
294
+ {
295
+ id: 667,
296
+ reportId: 53,
297
+ reportFieldId: 51,
298
+ },
299
+ {
300
+ id: 668,
301
+ reportId: 53,
302
+ reportFieldId: 52,
303
+ },
304
+ ],
305
+ },
306
+ ],
307
+ };