@licklist/design 0.63.3 → 0.65.0-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 (140) hide show
  1. package/bitbucket-pipelines.yml +0 -8
  2. package/dist/date-time-button/DateTimeButton.js +1 -1
  3. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
  4. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
  5. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
  6. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
  7. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
  8. package/dist/iframe/ryft/RyftPaymentForm.d.ts +4 -1
  9. package/dist/iframe/ryft/RyftPaymentForm.d.ts.map +1 -1
  10. package/dist/iframe/ryft/RyftPaymentForm.js +1 -1
  11. package/dist/iframe/ryft/utils/ryft-form.d.ts +5 -2
  12. package/dist/iframe/ryft/utils/ryft-form.d.ts.map +1 -1
  13. package/dist/iframe/ryft/utils/ryft-form.js +1 -1
  14. package/dist/product-set/control/DateAndRecurrenceInput.d.ts +1 -1
  15. package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
  16. package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
  17. package/dist/product-set/control/DateInput.js +1 -1
  18. package/dist/product-set/control/ProductSetControl.d.ts +3 -2
  19. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  20. package/dist/product-set/control/ProductSetControl.js +1 -1
  21. package/dist/product-set/form/ProductCategoriesControl.d.ts +3 -1
  22. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  23. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  24. package/dist/product-set/form/ProductSetForm.d.ts +6 -2
  25. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  26. package/dist/product-set/form/ProductSetForm.js +1 -1
  27. package/dist/product-set/form/ProductsControl.d.ts +3 -1
  28. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  29. package/dist/product-set/form/ProductsControl.js +1 -1
  30. package/dist/product-set/form/StepsControl.d.ts +3 -1
  31. package/dist/product-set/form/StepsControl.d.ts.map +1 -1
  32. package/dist/product-set/form/StepsControl.js +1 -1
  33. package/dist/product-set/product/ProductControl.d.ts +1 -0
  34. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  35. package/dist/product-set/product/ProductControl.js +1 -1
  36. package/dist/product-set/step/StepControl.d.ts +2 -1
  37. package/dist/product-set/step/StepControl.d.ts.map +1 -1
  38. package/dist/product-set/step/StepControl.js +1 -1
  39. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  40. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  41. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
  42. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +1 -1
  43. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +3 -1
  44. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  45. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  46. package/dist/recurring-date-picker-input/utils.d.ts +5 -0
  47. package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
  48. package/dist/recurring-date-picker-input/utils.js +1 -1
  49. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  50. package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
  51. package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
  52. package/dist/sortable-tree/SortableTreeItem.d.ts +1 -2
  53. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  54. package/dist/sortable-tree/SortableTreeItem.js +1 -1
  55. package/dist/styles/date-time-button/DateTimeButton.scss +1 -0
  56. package/dist/styles/iframe-page/PageBody.scss +0 -1
  57. package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +8 -0
  58. package/dist/styles/sales/BookingResults.scss +1 -1
  59. package/dist/styles/zones/ZoneForm.scss +2 -1
  60. package/dist/zone/form/ZoneForm.d.ts +2 -2
  61. package/dist/zone/form/ZoneForm.d.ts.map +1 -1
  62. package/dist/zone/form/ZoneForm.js +1 -1
  63. package/dist/zone/form/components/ZoneControl.d.ts +2 -2
  64. package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
  65. package/dist/zone/form/components/ZoneControl.js +1 -1
  66. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
  67. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
  68. package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
  69. package/dist/zone/form/utils/dates.d.ts.map +1 -1
  70. package/package.json +14 -39
  71. package/src/date-time-button/DateTimeButton.stories.tsx +2 -1
  72. package/src/date-time-button/DateTimeButton.tsx +7 -5
  73. package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +14 -9
  74. package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +2 -0
  75. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +1 -0
  76. package/src/iframe/ryft/RyftPaymentForm.tsx +11 -2
  77. package/src/iframe/ryft/utils/ryft-form.ts +23 -4
  78. package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -4
  79. package/src/product-set/control/DateInput.tsx +2 -2
  80. package/src/product-set/control/ProductSetControl.tsx +17 -5
  81. package/src/product-set/form/ProductCategoriesControl.tsx +15 -4
  82. package/src/product-set/form/ProductSetForm.tsx +13 -2
  83. package/src/product-set/form/ProductsControl.tsx +93 -77
  84. package/src/product-set/form/StepsControl.tsx +15 -7
  85. package/src/product-set/product/ProductControl.tsx +8 -5
  86. package/src/product-set/step/StepControl.tsx +4 -3
  87. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +4 -18
  88. package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +40 -21
  89. package/src/recurring-date-picker-input/RecurringDatePickerInput.stories.tsx +13 -7
  90. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +12 -1
  91. package/src/recurring-date-picker-input/utils.ts +90 -1
  92. package/src/sales/booking/results/components/ResultCard.tsx +0 -3
  93. package/src/setting/admin/AdminSettingForm.tsx +2 -2
  94. package/src/sortable-tree/SortableTreeItem.tsx +0 -3
  95. package/src/static/switch/BooleanSwitch.tsx +1 -1
  96. package/src/styles/date-time-button/DateTimeButton.scss +1 -0
  97. package/src/styles/iframe-page/PageBody.scss +0 -1
  98. package/src/styles/ryft-payment-form/RyftPaymentForm.scss +8 -0
  99. package/src/styles/sales/BookingResults.scss +1 -1
  100. package/src/styles/zones/ZoneForm.scss +2 -1
  101. package/src/zone/form/ZoneForm.tsx +3 -2
  102. package/src/zone/form/components/ZoneControl.tsx +3 -3
  103. package/src/zone/form/components/ZoneRecurrencesControl.tsx +7 -5
  104. package/src/zone/form/utils/dates.ts +9 -10
  105. package/jest.config.js +0 -29
  106. package/tests/Auth/Authorizer.test.tsx +0 -194
  107. package/tests/Auth/Layout/UserNavDropDown.test.tsx +0 -43
  108. package/tests/Auth/Layout/UserNavDropDownToggle.test.tsx +0 -33
  109. package/tests/Auth/Login/LoginComponent.test.tsx +0 -246
  110. package/tests/Auth/Login/LoginFormComponent.test.tsx +0 -182
  111. package/tests/Auth/Register/RegisterComponent.test.tsx +0 -285
  112. package/tests/Auth/Register/RegisterFormComponent.test.tsx +0 -170
  113. package/tests/Auth/Settings/Dashboard/IpInput.test.tsx +0 -130
  114. package/tests/Auth/Social/SocialCallbackComponent.test.tsx +0 -133
  115. package/tests/Auth/Social/SocialFormComponent.test.tsx +0 -118
  116. package/tests/FileUpload/FileUpload.test.tsx +0 -42
  117. package/tests/Notification/EmailTemplate.test.tsx +0 -82
  118. package/tests/ProductSet/ProductSetPopover.test.tsx +0 -40
  119. package/tests/Report/Report.test.tsx +0 -48
  120. package/tests/Sales/Coupon.test.tsx +0 -51
  121. package/tests/Sales/SalesAndVIews.test.tsx +0 -63
  122. package/tests/SnippetTemplates/SnippetTemplates.test.tsx +0 -56
  123. package/tests/Table/FilterHelperComponent.test.tsx +0 -88
  124. package/tests/Table/PaginationHelperComponent.test.tsx +0 -109
  125. package/tests/Table/PerPageHelperComponent.test.tsx +0 -34
  126. package/tests/Table/TableHelperComponent.test.tsx +0 -295
  127. package/tests/TipTapEditor/TipTapEditor.test.tsx +0 -28
  128. package/tests/__mock__/hooks/useAuthApi.ts +0 -13
  129. package/tests/__mock__/hooks/useAuthMock.ts +0 -13
  130. package/tests/__mock__/hooks/useFormMock.ts +0 -27
  131. package/tests/__mock__/hooks/useNotificationMock.ts +0 -13
  132. package/tests/__mock__/hooks/useQueryMock.ts +0 -16
  133. package/tests/__mock__/hooks/useSocialApiMock.ts +0 -20
  134. package/tests/__mock__/hooks/useTranslationMock.ts +0 -17
  135. package/tests/__mock__/hooks/useUserApiMock.ts +0 -18
  136. package/tests/__mock__/hooks/useUserMock.ts +0 -13
  137. package/tests/__mock__/styleMock.js +0 -1
  138. package/tests/__mock__/windowMock.ts +0 -5
  139. package/tests/packages/react-query.tsx +0 -28
  140. package/tests/setupTests.ts +0 -10
@@ -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
+ };
@@ -12,7 +12,6 @@ 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
-
16
15
  import Icon from "../../../../static/Icon";
17
16
 
18
17
  export type ResultCardProps = {
@@ -22,8 +21,6 @@ export type ResultCardProps = {
22
21
  onCardClick?: (id: number) => void;
23
22
  };
24
23
 
25
- // @TODO integrate when API will be available
26
- // activity and staff keys
27
24
  export const ResultCard = ({
28
25
  order,
29
26
  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 { ProviderType } from "@licklist/core/dist/DataMapper/Provider/ProvidableDataMapper";
14
+ import { ProvidableType } 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?: ProviderType;
36
+ providerType?: ProvidableType;
37
37
  };
38
38
  }
39
39
 
@@ -53,7 +53,6 @@ export interface SortableTreeItemProps {
53
53
  };
54
54
  setIsExpanded?: () => void;
55
55
  isOverride?: boolean;
56
- isProduct?: boolean;
57
56
  }
58
57
 
59
58
  export function SortableTreeItem({
@@ -81,7 +80,6 @@ export function SortableTreeItem({
81
80
  secondaryBadge,
82
81
  setIsExpanded,
83
82
  isOverride,
84
- isProduct = false,
85
83
  }: SortableTreeItemProps) {
86
84
  const [expanded, setExpanded] = useState(isExpanded);
87
85
  const [isModalVisible, setIsModalVisible] = useState(isNewAdded);
@@ -152,7 +150,6 @@ export function SortableTreeItem({
152
150
  };
153
151
 
154
152
  const onEdit = (e) => {
155
- if (isOverride && !isProduct) return;
156
153
  e.stopPropagation();
157
154
  if (edit && !isModalVisible) edit();
158
155
  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 ?? t("yes") },
26
+ { id: 1, value: firstValueTitle ?? t("yes") },
27
27
  { id: 0, value: secondValueTitle ?? t("no") },
28
28
  ];
29
29
 
@@ -81,6 +81,7 @@
81
81
  min-width: 5.3rem;
82
82
  max-width: 5.3rem;
83
83
  min-height: 2.75rem;
84
+ border: 2px solid $snippet-calendar-disabled-button-border-color;
84
85
  }
85
86
 
86
87
  &.calendar-view {
@@ -65,7 +65,6 @@
65
65
  }
66
66
 
67
67
  @include media-breakpoint-down(sm) {
68
- height: 100%;
69
68
  max-height: calc(100svh - 30rem);
70
69
  }
71
70
 
@@ -135,6 +135,14 @@
135
135
  margin-bottom: 0.5rem;
136
136
  }
137
137
  }
138
+ .ryft-pay-grid {
139
+ display: flex;
140
+ flex-direction: column;
141
+ .apple-pay-button {
142
+ height: 2.5rem;
143
+ margin-top: 1rem;
144
+ }
145
+ }
138
146
  .mobile-pay-title {
139
147
  display: block;
140
148
  font-weight: 600;
@@ -5,7 +5,7 @@
5
5
  flex-wrap: wrap;
6
6
 
7
7
  .result-card {
8
- height: 14.25rem;
8
+ height: 14rem;
9
9
  border: 1px solid $gray-400;
10
10
  max-width: calc(50% - 0.75rem);
11
11
  flex: 0 0 calc(50% - 0.75rem);
@@ -1,4 +1,5 @@
1
1
  .zone-available-times {
2
+ overscroll-behavior: contain;
2
3
  display: flex;
3
4
  flex-wrap: wrap;
4
5
  gap: 1.5rem;
@@ -7,4 +8,4 @@
7
8
  justify-content: start;
8
9
  width: 95%;
9
10
  overflow: scroll;
10
- }
11
+ }
@@ -13,7 +13,7 @@ export type ZoneFormProps = {
13
13
  onSubmit: (values: Partial<Zone>) => void;
14
14
  serverErrors?: ServerError;
15
15
  isLoading?: boolean;
16
- workHours?: WorkHour[];
16
+ workHours: WorkHour[] | undefined;
17
17
  };
18
18
 
19
19
  export type ZoneFormValues = Partial<Zone> & {
@@ -25,6 +25,7 @@ export const ZoneForm = ({
25
25
  onSubmit,
26
26
  serverErrors,
27
27
  isLoading = false,
28
+ workHours,
28
29
  }: ZoneFormProps) => {
29
30
  const { t } = useTranslation("Design");
30
31
  const form = useForm<ZoneFormValues>({
@@ -54,7 +55,7 @@ export const ZoneForm = ({
54
55
  return (
55
56
  <FormProvider {...form}>
56
57
  <Form onSubmit={handleSubmit(onFormSubmit)}>
57
- <ZoneControl isLoading={isLoading} />
58
+ <ZoneControl isLoading={isLoading} workHours={workHours} />
58
59
  <Row>
59
60
  <Col md={6} sm={12} />
60
61
  <Col
@@ -11,15 +11,15 @@ import { GameDurationControl } from "./GameDurationControl";
11
11
 
12
12
  export type ZoneControlProps = {
13
13
  isLoading: boolean;
14
- workHours?: WorkHour[];
14
+ workHours: WorkHour[] | undefined;
15
15
  };
16
16
 
17
- export const ZoneControl = ({ isLoading }: ZoneControlProps) => {
17
+ export const ZoneControl = ({ isLoading, workHours }: ZoneControlProps) => {
18
18
  return (
19
19
  <Row>
20
20
  <Col md={6} sm={12} className="pr-5">
21
21
  <NameControl isLoading={isLoading} />
22
- <ZoneRecurrencesControl />
22
+ <ZoneRecurrencesControl workHours={workHours} />
23
23
  <hr />
24
24
  <Row>
25
25
  <Col md={6} sm={6}>
@@ -25,12 +25,13 @@ export interface DateAndRecurrenceInputValues {
25
25
  zoneRecurrences?: Partial<ZoneRecurrence>[];
26
26
  }
27
27
 
28
- export type ZoneRecurrenceControlProps = {
29
- workHours?: WorkHour[];
30
- isLoading?: boolean;
28
+ type ZoneRecurrenceControlProps = {
29
+ workHours: WorkHour[] | undefined;
31
30
  };
32
31
 
33
- export const ZoneRecurrencesControl = () => {
32
+ export const ZoneRecurrencesControl = ({
33
+ workHours,
34
+ }: ZoneRecurrenceControlProps) => {
34
35
  const {
35
36
  control,
36
37
  register,
@@ -69,7 +70,7 @@ export const ZoneRecurrencesControl = () => {
69
70
  clearEditState();
70
71
  });
71
72
 
72
- const popoverId = useId()!;
73
+ const popoverId = useId();
73
74
 
74
75
  const { t } = useTranslation(["Design", "Validation"]);
75
76
 
@@ -166,6 +167,7 @@ export const ZoneRecurrencesControl = () => {
166
167
  onChange={handleRecurringDateChange}
167
168
  onDelete={handleDelete}
168
169
  setInitialStartDateAfterSelect
170
+ workHours={workHours}
169
171
  />
170
172
  </Popover.Content>
171
173
  </Popover>
@@ -53,18 +53,17 @@ export const getCheckboxesByWorkHours = (workHours?: WorkHour[]) => {
53
53
  if (!workHours || !workHours.length)
54
54
  return getTimeCheckboxRanges(DEFAULT_START_DAY_TIME, DEFAULT_END_DAY_TIME);
55
55
 
56
- const providerWorkHoursByWeek = workHours.reduce(
57
- (workHoursNextArray: { start: string; end: string }[], currentWorkHour) => {
58
- const { start, end } = currentWorkHour;
56
+ const providerWorkHoursByWeek = workHours.reduce<
57
+ { start: string; end: string }[]
58
+ >((workHoursNextArray, currentWorkHour) => {
59
+ const { start, end } = currentWorkHour;
59
60
 
60
- if (start && end) {
61
- return [...workHoursNextArray, { start, end }];
62
- }
61
+ if (start && end) {
62
+ return [...workHoursNextArray, { start, end }];
63
+ }
63
64
 
64
- return workHoursNextArray;
65
- },
66
- []
67
- );
65
+ return workHoursNextArray;
66
+ }, []);
68
67
 
69
68
  // If venue has filled only 1 work day from wee
70
69
  // For another days we use default 00:00 and 23:59
package/jest.config.js DELETED
@@ -1,29 +0,0 @@
1
- // For a detailed explanation regarding each configuration property, visit:
2
- // https://jestjs.io/docs/en/configuration.html
3
-
4
- module.exports = {
5
- modulePathIgnorePatterns: ["/dist/"],
6
- roots: ["<rootDir>/src", "<rootDir>/tests"],
7
- globals: {
8
- "ts-jest": {
9
- isolatedModules: true,
10
- babelConfig: {
11
- presets: ["@babel/preset-env", "@babel/preset-react"],
12
- },
13
- },
14
- },
15
- transform: {
16
- "^.+\\.(t|j)sx?$": "ts-jest",
17
- },
18
- transformIgnorePatterns: [
19
- "node_modules/(?!(redux-persist)/)",
20
- "node_modules/(?!(@licklist)/)",
21
- ],
22
- testRegex: ["(\\/tests\\/.*.(test|spec))\\.tsx?$"],
23
- moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
24
- setupFilesAfterEnv: ["<rootDir>/tests/setupTests.ts"],
25
- moduleNameMapper: {
26
- "^.+\\.(css|scss|sass|less)$": "<rootDir>/tests/__mock__/styleMock.js",
27
- ".+\\.(svg|png|jpg)$": "identity-obj-proxy",
28
- },
29
- };
@@ -1,194 +0,0 @@
1
- import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
2
- import { mount, shallow } from "enzyme";
3
- import * as React from "react";
4
- import { act } from "react-dom/test-utils";
5
- import { QueryClientProvider } from "react-query";
6
- import { Authorizer } from "../../src/auth/Authorizer";
7
- import useAuthMock from "../__mock__/hooks/useAuthMock";
8
- import useUserMock from "../__mock__/hooks/useUserMock";
9
- import useAuthApi from "../__mock__/hooks/useAuthApi";
10
- import { queryClient } from "../packages/react-query";
11
-
12
- jest.mock("react-i18next", () => ({
13
- Trans: jest.fn().mockReturnValue("test"),
14
- useTranslation: () => ({
15
- t: jest.fn((arg) => arg),
16
- }),
17
- }));
18
- jest.mock("@licklist/plugins/dist/context/user/hooks/useAuth");
19
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
20
- jest.mock("@licklist/plugins/dist/hooks/Api/useAuthApi");
21
-
22
- const DEFAULT_PROFILE_RESPONSE = {
23
- useProfile: () => ({
24
- isLoading: false,
25
- isFetching: false,
26
- isError: false,
27
- data: { access_token: "test" },
28
- }),
29
- };
30
-
31
- const DEFAULT_PROFILE_LOADING_RESPONSE = {
32
- useProfile: () => ({
33
- isLoading: true,
34
- isFetching: false,
35
- isError: false,
36
- data: { access_token: "test" },
37
- }),
38
- };
39
-
40
- describe("Authorizer", () => {
41
- it("should be rendered without issues", () => {
42
- useAuthMock({
43
- secrets: null,
44
- });
45
- useUserMock({
46
- profile: null,
47
- });
48
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
49
-
50
- const component = shallow(
51
- <QueryClientProvider client={queryClient}>
52
- <Authorizer />
53
- </QueryClientProvider>
54
- );
55
-
56
- expect(component.exists()).toBeTruthy();
57
- });
58
-
59
- it("should render children if authorized", () => {
60
- let component: any;
61
-
62
- useAuthMock({
63
- secrets: "not-null",
64
- });
65
- useUserMock({
66
- profile: "not-null",
67
- });
68
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
69
-
70
- RouteService.getCurrentPage = jest.fn();
71
- RouteService.getCurrentRoute = jest.fn();
72
- RouteService.cleanRedirect = jest.fn();
73
-
74
- act(() => {
75
- component = mount(
76
- <QueryClientProvider client={queryClient}>
77
- <Authorizer>
78
- <p>test</p>
79
- </Authorizer>
80
- </QueryClientProvider>
81
- );
82
- });
83
-
84
- component.update();
85
-
86
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(0);
87
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(0);
88
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(0);
89
- expect(component.exists()).toBeTruthy();
90
- expect(component.find("BlockLoader").exists()).toBeTruthy();
91
- });
92
-
93
- it("should render children if current page is login", () => {
94
- let component: any;
95
-
96
- useAuthMock({
97
- secrets: null,
98
- });
99
- useUserMock({
100
- profile: null,
101
- });
102
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
103
-
104
- RouteService.getCurrentPage = jest.fn().mockReturnValue("/login");
105
- RouteService.getCurrentRoute = jest.fn();
106
- RouteService.cleanRedirect = jest.fn();
107
-
108
- act(() => {
109
- component = mount(
110
- <QueryClientProvider client={queryClient}>
111
- <Authorizer>
112
- <p>test</p>
113
- </Authorizer>
114
- </QueryClientProvider>
115
- );
116
- });
117
-
118
- component.update();
119
-
120
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(0);
121
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(0);
122
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(0);
123
- expect(component.exists()).toBeTruthy();
124
- expect(component.find("BlockLoader").exists()).toBeTruthy();
125
- });
126
-
127
- it("should NOT render children if profile is loading or fetching", () => {
128
- let component: any;
129
-
130
- useAuthMock({
131
- secrets: null,
132
- });
133
- useUserMock({
134
- profile: null,
135
- });
136
- useAuthApi(DEFAULT_PROFILE_LOADING_RESPONSE);
137
-
138
- RouteService.getCurrentPage = jest.fn();
139
- RouteService.getCurrentRoute = jest.fn();
140
- RouteService.cleanRedirect = jest.fn();
141
-
142
- act(() => {
143
- component = mount(
144
- <QueryClientProvider client={queryClient}>
145
- <Authorizer>
146
- <p>test</p>
147
- </Authorizer>
148
- </QueryClientProvider>
149
- );
150
- });
151
-
152
- component.update();
153
-
154
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(0);
155
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(0);
156
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(0);
157
- expect(component.exists()).toBeTruthy();
158
- expect(component.find("BlockLoader").exists()).toBeTruthy();
159
- });
160
-
161
- it("should NOT render children if unauthorized and current page is not login", () => {
162
- let component: any;
163
-
164
- useAuthMock({
165
- secrets: null,
166
- });
167
- useUserMock({
168
- profile: null,
169
- });
170
- useAuthApi(DEFAULT_PROFILE_RESPONSE);
171
-
172
- RouteService.getCurrentPage = jest.fn();
173
- RouteService.getCurrentRoute = jest.fn();
174
- RouteService.cleanRedirect = jest.fn();
175
-
176
- act(() => {
177
- component = mount(
178
- <QueryClientProvider client={queryClient}>
179
- <Authorizer>
180
- <p>test</p>
181
- </Authorizer>
182
- </QueryClientProvider>
183
- );
184
- });
185
-
186
- component.update();
187
-
188
- expect(RouteService.getCurrentPage).toHaveBeenCalledTimes(3);
189
- expect(RouteService.getCurrentRoute).toHaveBeenCalledTimes(1);
190
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(1);
191
- expect(component.exists()).toBeTruthy();
192
- expect(component.find("BlockLoader").exists()).toBeTruthy();
193
- });
194
- });
@@ -1,43 +0,0 @@
1
- import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
2
- import { mount, shallow } from "enzyme";
3
- import * as React from "react";
4
- import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
5
- import useUserMock from "../../__mock__/hooks/useUserMock";
6
- import { UserNavDropDown } from "../../../src/auth/Layout/UserNavDropDown";
7
-
8
- jest.mock("react-i18next");
9
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
10
-
11
- describe("UserNavDropDown", () => {
12
- it("should be rendered without issues", () => {
13
- useTranslationMock({
14
- t: jest.fn(),
15
- });
16
- useUserMock({
17
- profile: null,
18
- });
19
-
20
- const component = shallow(<UserNavDropDown />);
21
-
22
- expect(component.exists()).toBeTruthy();
23
- });
24
-
25
- it("should logout on click", () => {
26
- useTranslationMock({
27
- t: jest.fn(),
28
- });
29
- useUserMock({
30
- logout: jest.fn(),
31
- });
32
-
33
- RouteService.redirectTo = jest.fn();
34
-
35
- const component = mount(<UserNavDropDown />);
36
-
37
- expect(component.exists()).toBeTruthy();
38
-
39
- component.children().prop("onClick")();
40
-
41
- expect(RouteService.redirectTo).toHaveBeenCalledTimes(1);
42
- });
43
- });
@@ -1,33 +0,0 @@
1
- import { IUser } from "@licklist/plugins/dist/types/context/user/IUser";
2
- import { shallow } from "enzyme";
3
- import * as React from "react";
4
- import { UserNavDropDownToggle } from "../../../src/auth/Layout/UserNavDropDownToggle";
5
- import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
6
-
7
- jest.mock("react-i18next");
8
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
9
-
10
- const user: IUser = {
11
- id: 1,
12
- first_name: "first_name",
13
- last_name: "last_name",
14
- email: "email",
15
- user_roles: [],
16
- user_detail: {
17
- postcode: "",
18
- birthday: "",
19
- phone: "",
20
- },
21
- };
22
-
23
- describe("UserNavDropDownToggle", () => {
24
- it("should be rendered without issues", () => {
25
- useTranslationMock({
26
- t: jest.fn(),
27
- });
28
-
29
- const component = shallow(<UserNavDropDownToggle user={user} />);
30
-
31
- expect(component.exists()).toBeTruthy();
32
- });
33
- });