@licklist/design 0.58.6-dev.9 → 0.58.6

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 (243) hide show
  1. package/bitbucket-pipelines.yml +8 -0
  2. package/dist/assets/iframe/calendar.svg +2 -2
  3. package/dist/assets/iframe/calendar.svg.js +1 -1
  4. package/dist/assets/iframe/ticket.svg +2 -2
  5. package/dist/assets/iframe/ticket.svg.js +1 -1
  6. package/dist/calendar/Calendar.d.ts +1 -1
  7. package/dist/calendar/Calendar.d.ts.map +1 -1
  8. package/dist/calendar/Calendar.js +1 -1
  9. package/dist/calendar/components/CalendarButtons/CalendarButtons.js +1 -1
  10. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts +2 -2
  11. package/dist/calendar/components/CalendarDates/CalendarDates.d.ts.map +1 -1
  12. package/dist/calendar/components/CalendarDates/CalendarDates.js +1 -1
  13. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +1 -1
  14. package/dist/events/event-statistic-modal/EventStatisticModal.js +1 -1
  15. package/dist/iframe/event/event-card/IframeEventCard.d.ts +1 -2
  16. package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
  17. package/dist/iframe/event/event-card/IframeEventCard.js +1 -1
  18. package/dist/iframe/event/event-venue-map/IframeEventVenueMap.js +1 -1
  19. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +2 -2
  20. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  21. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
  22. package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.d.ts +2 -4
  23. package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.d.ts.map +1 -1
  24. package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.js +1 -1
  25. package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.d.ts +1 -1
  26. package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.d.ts.map +1 -1
  27. package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.js +1 -1
  28. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.d.ts +2 -4
  29. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.d.ts.map +1 -1
  30. package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.js +1 -1
  31. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +0 -4
  32. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  33. package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.js +1 -1
  34. package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +1 -1
  35. package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.d.ts.map +1 -1
  36. package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.js +1 -1
  37. package/dist/iframe/page/components/PageBody/constants.d.ts +0 -1
  38. package/dist/iframe/page/components/PageBody/constants.d.ts.map +1 -1
  39. package/dist/iframe/page/components/PageBody/constants.js +1 -1
  40. package/dist/iframe/page/components/PageBody/hooks/useResizePageBody.d.ts.map +1 -1
  41. package/dist/iframe/page/components/PageBody/hooks/useResizePageBody.js +1 -1
  42. package/dist/iframe/payment/order-items-table/OrderItemsTable.js +1 -1
  43. package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +1 -1
  44. package/dist/iframe/payment/payment-form/PaymentForm.js +1 -1
  45. package/dist/iframe/payment/payment-page/PaymentPage.d.ts.map +1 -1
  46. package/dist/iframe/payment/payment-page/PaymentPage.js +1 -1
  47. package/dist/iframe/payment/payment-page/PaymentTimer.js +1 -1
  48. package/dist/iframe/payment/payment-status-page/PaymentStatusPage.js +1 -1
  49. package/dist/iframe/ryft/RyftPaymentForm.d.ts.map +1 -1
  50. package/dist/iframe/ryft/RyftPaymentForm.js +1 -1
  51. package/dist/index.js +1 -1
  52. package/dist/product-set/card/ProductSetCard.d.ts +1 -2
  53. package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
  54. package/dist/product-set/card/ProductSetCard.js +1 -1
  55. package/dist/product-set/control/ProductSetControl.d.ts +1 -2
  56. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  57. package/dist/product-set/control/ProductSetControl.js +1 -1
  58. package/dist/product-set/control/TutorialGifCard.d.ts +1 -2
  59. package/dist/product-set/control/TutorialGifCard.d.ts.map +1 -1
  60. package/dist/product-set/control/TutorialGifCard.js +1 -1
  61. package/dist/product-set/form/ProductCategoriesControl.d.ts +1 -2
  62. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  63. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  64. package/dist/product-set/form/ProductSetForm.d.ts +2 -7
  65. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  66. package/dist/product-set/form/ProductSetForm.js +1 -1
  67. package/dist/product-set/form/ProductsControl.d.ts +1 -2
  68. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  69. package/dist/product-set/form/ProductsControl.js +1 -1
  70. package/dist/product-set/form/StepsControl.d.ts +1 -2
  71. package/dist/product-set/form/StepsControl.d.ts.map +1 -1
  72. package/dist/product-set/form/StepsControl.js +1 -1
  73. package/dist/product-set/form/SubProductsControl.d.ts +1 -2
  74. package/dist/product-set/form/SubProductsControl.d.ts.map +1 -1
  75. package/dist/product-set/form/SubProductsControl.js +1 -1
  76. package/dist/product-set/form/VenueMapsControl.js +1 -1
  77. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts +1 -2
  78. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
  79. package/dist/product-set/hooks/useSortableTreeFunctions.js +1 -1
  80. package/dist/product-set/item/CreateProductSetItem.d.ts +1 -2
  81. package/dist/product-set/item/CreateProductSetItem.d.ts.map +1 -1
  82. package/dist/product-set/item/CreateProductSetItem.js +1 -1
  83. package/dist/product-set/product/ProductControl.d.ts +1 -3
  84. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  85. package/dist/product-set/product/ProductControl.js +1 -1
  86. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts +2 -4
  87. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +1 -1
  88. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.js +1 -1
  89. package/dist/product-set/product/quantity/ProductQuantityControl.d.ts +0 -1
  90. package/dist/product-set/product/quantity/ProductQuantityControl.d.ts.map +1 -1
  91. package/dist/product-set/product/quantity/ProductQuantityControl.js +1 -1
  92. package/dist/product-set/product-category/ProductCategoryControl.d.ts +1 -3
  93. package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
  94. package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
  95. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  96. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  97. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +0 -2
  98. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  99. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  100. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  101. package/dist/sales/booking/results/components/ResultCard.js +1 -1
  102. package/dist/sales/notes/NotesTableRow.js +1 -1
  103. package/dist/setting/dashboard/snippets/card/SnippetCard.js +1 -1
  104. package/dist/snippet/snippet-template/control/PropertyControl.d.ts +1 -3
  105. package/dist/snippet/snippet-template/control/PropertyControl.d.ts.map +1 -1
  106. package/dist/snippet/snippet-template/control/PropertyControl.js +1 -1
  107. package/dist/snippet/snippet-template/preview/Preview.js +1 -1
  108. package/dist/sortable-list/SortableList.d.ts +1 -2
  109. package/dist/sortable-list/SortableList.d.ts.map +1 -1
  110. package/dist/sortable-list/SortableList.js +1 -1
  111. package/dist/sortable-tree/SortableTreeItem.d.ts +1 -3
  112. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  113. package/dist/sortable-tree/SortableTreeItem.js +1 -1
  114. package/dist/static/manual-date-picker/ManualDatePicker.js +1 -1
  115. package/dist/static/manual-date-picker/constants/index.d.ts +1 -4
  116. package/dist/static/manual-date-picker/constants/index.d.ts.map +1 -1
  117. package/dist/static/manual-date-picker/constants/index.js +1 -1
  118. package/dist/static/manual-date-picker/utils/index.d.ts +0 -4
  119. package/dist/static/manual-date-picker/utils/index.d.ts.map +1 -1
  120. package/dist/static/manual-date-picker/utils/index.js +1 -1
  121. package/dist/striped-static-table/StripedStaticTable.js +1 -1
  122. package/dist/styles/iframe-events/Card.scss +8 -24
  123. package/dist/styles/iframe-events/PoweredBy.scss +2 -2
  124. package/dist/styles/iframe-order-process/IframeOrderProcess.scss +20 -57
  125. package/dist/styles/iframe-page/Page.scss +0 -1
  126. package/dist/styles/iframe-page/PageBody.scss +12 -34
  127. package/dist/styles/iframe-page/PageHeader.scss +39 -41
  128. package/dist/styles/product-set/EditVenueMapSetModal.scss +1 -1
  129. package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +2 -125
  130. package/dist/styles/sales/BookingResults.scss +1 -1
  131. package/dist/venue-map-sets/form/components/VenueMapImageControl.js +1 -1
  132. package/jest.config.js +29 -0
  133. package/package.json +35 -10
  134. package/src/assets/iframe/calendar.svg +2 -2
  135. package/src/assets/iframe/ticket.svg +2 -2
  136. package/src/calendar/Calendar.stories.tsx +0 -23
  137. package/src/calendar/Calendar.tsx +5 -5
  138. package/src/calendar/components/CalendarDates/CalendarDates.tsx +5 -0
  139. package/src/iframe/event/event-card/IframeEventCard.stories.tsx +0 -1
  140. package/src/iframe/event/event-card/IframeEventCard.tsx +8 -7
  141. package/src/iframe/order-process/components/BookingSummary/BookingSummary.stories.tsx +0 -9
  142. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +7 -58
  143. package/src/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.tsx +0 -8
  144. package/src/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.tsx +4 -4
  145. package/src/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.tsx +10 -63
  146. package/src/iframe/order-process/components/BookingSummary/types/index.ts +0 -4
  147. package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +1 -1
  148. package/src/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.tsx +1 -3
  149. package/src/iframe/page/components/PageBody/constants.ts +0 -2
  150. package/src/iframe/page/components/PageBody/hooks/useResizePageBody.ts +0 -10
  151. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +6 -6
  152. package/src/iframe/payment/payment-page/PaymentPage.stories.tsx +6 -546
  153. package/src/iframe/payment/payment-page/PaymentPage.tsx +29 -38
  154. package/src/iframe/ryft/RyftPaymentForm.tsx +5 -11
  155. package/src/product-set/card/ProductSetCard.tsx +1 -12
  156. package/src/product-set/control/ProductSetControl.tsx +24 -46
  157. package/src/product-set/control/TutorialGifCard.tsx +3 -11
  158. package/src/product-set/form/ProductCategoriesControl.tsx +1 -12
  159. package/src/product-set/form/ProductSetForm.tsx +1 -10
  160. package/src/product-set/form/ProductsControl.tsx +0 -10
  161. package/src/product-set/form/StepsControl.tsx +2 -8
  162. package/src/product-set/form/SubProductsControl.tsx +0 -3
  163. package/src/product-set/hooks/useSortableTreeFunctions.ts +0 -6
  164. package/src/product-set/item/CreateProductSetItem.tsx +0 -3
  165. package/src/product-set/product/ProductControl.tsx +15 -48
  166. package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +2 -8
  167. package/src/product-set/product/quantity/ProductQuantityControl.tsx +3 -4
  168. package/src/product-set/product-category/ProductCategoryControl.tsx +50 -116
  169. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +18 -4
  170. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +1 -4
  171. package/src/sales/booking/results/BookingResults.stories.tsx +2 -3
  172. package/src/sales/booking/results/components/ResultCard.tsx +5 -2
  173. package/src/snippet/snippet-template/control/PropertyControl.tsx +2 -6
  174. package/src/sortable-list/SortableList.tsx +0 -3
  175. package/src/sortable-tree/SortableTreeItem.tsx +0 -6
  176. package/src/static/manual-date-picker/ManualDatePicker.tsx +3 -3
  177. package/src/static/manual-date-picker/constants/index.ts +2 -6
  178. package/src/static/manual-date-picker/utils/index.ts +0 -11
  179. package/src/static/switch/BooleanSwitch.tsx +1 -1
  180. package/src/styles/iframe-events/Card.scss +8 -24
  181. package/src/styles/iframe-events/PoweredBy.scss +2 -2
  182. package/src/styles/iframe-order-process/IframeOrderProcess.scss +20 -57
  183. package/src/styles/iframe-page/Page.scss +0 -1
  184. package/src/styles/iframe-page/PageBody.scss +12 -34
  185. package/src/styles/iframe-page/PageHeader.scss +39 -41
  186. package/src/styles/product-set/EditVenueMapSetModal.scss +1 -1
  187. package/src/styles/ryft-payment-form/RyftPaymentForm.scss +2 -125
  188. package/src/styles/sales/BookingResults.scss +1 -1
  189. package/tests/Auth/Authorizer.test.tsx +194 -0
  190. package/tests/Auth/Layout/UserNavDropDown.test.tsx +43 -0
  191. package/tests/Auth/Layout/UserNavDropDownToggle.test.tsx +33 -0
  192. package/tests/Auth/Login/LoginComponent.test.tsx +246 -0
  193. package/tests/Auth/Login/LoginFormComponent.test.tsx +182 -0
  194. package/tests/Auth/Register/RegisterComponent.test.tsx +285 -0
  195. package/tests/Auth/Register/RegisterFormComponent.test.tsx +170 -0
  196. package/tests/Auth/Settings/Dashboard/IpInput.test.tsx +130 -0
  197. package/tests/Auth/Social/SocialCallbackComponent.test.tsx +133 -0
  198. package/tests/Auth/Social/SocialFormComponent.test.tsx +118 -0
  199. package/tests/FileUpload/FileUpload.test.tsx +42 -0
  200. package/tests/Notification/EmailTemplate.test.tsx +82 -0
  201. package/tests/ProductSet/ProductSetPopover.test.tsx +40 -0
  202. package/tests/Report/Report.test.tsx +48 -0
  203. package/tests/Sales/Coupon.test.tsx +51 -0
  204. package/tests/Sales/SalesAndVIews.test.tsx +63 -0
  205. package/tests/SnippetTemplates/SnippetTemplates.test.tsx +56 -0
  206. package/tests/Table/FilterHelperComponent.test.tsx +88 -0
  207. package/tests/Table/PaginationHelperComponent.test.tsx +109 -0
  208. package/tests/Table/PerPageHelperComponent.test.tsx +34 -0
  209. package/tests/Table/TableHelperComponent.test.tsx +295 -0
  210. package/tests/TipTapEditor/TipTapEditor.test.tsx +28 -0
  211. package/tests/__mock__/hooks/useAuthApi.ts +13 -0
  212. package/tests/__mock__/hooks/useAuthMock.ts +13 -0
  213. package/tests/__mock__/hooks/useFormMock.ts +27 -0
  214. package/tests/__mock__/hooks/useNotificationMock.ts +13 -0
  215. package/tests/__mock__/hooks/useQueryMock.ts +16 -0
  216. package/tests/__mock__/hooks/useSocialApiMock.ts +20 -0
  217. package/tests/__mock__/hooks/useTranslationMock.ts +17 -0
  218. package/tests/__mock__/hooks/useUserApiMock.ts +18 -0
  219. package/tests/__mock__/hooks/useUserMock.ts +13 -0
  220. package/tests/__mock__/styleMock.js +1 -0
  221. package/tests/__mock__/windowMock.ts +5 -0
  222. package/tests/packages/react-query.tsx +28 -0
  223. package/tests/setupTests.ts +10 -0
  224. package/dist/iframe/ryft/utils/ryft-form.d.ts +0 -5
  225. package/dist/iframe/ryft/utils/ryft-form.d.ts.map +0 -1
  226. package/dist/iframe/ryft/utils/ryft-form.js +0 -1
  227. package/dist/product-set/control/DateInput.d.ts +0 -17
  228. package/dist/product-set/control/DateInput.d.ts.map +0 -1
  229. package/dist/product-set/control/DateInput.js +0 -1
  230. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts +0 -11
  231. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts.map +0 -1
  232. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.js +0 -1
  233. package/dist/recurring-date-picker-input/DatePickerInput.d.ts +0 -19
  234. package/dist/recurring-date-picker-input/DatePickerInput.d.ts.map +0 -1
  235. package/dist/recurring-date-picker-input/DatePickerInput.js +0 -1
  236. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts +0 -15
  237. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts.map +0 -1
  238. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.js +0 -1
  239. package/src/iframe/ryft/utils/ryft-form.ts +0 -47
  240. package/src/product-set/control/DateInput.tsx +0 -313
  241. package/src/product-set/control/ProductSetRecurrenceOverridesControl.tsx +0 -63
  242. package/src/recurring-date-picker-input/DatePickerInput.tsx +0 -93
  243. package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +0 -136
@@ -1,313 +0,0 @@
1
- import React, { useRef, useState } from "react";
2
- import { Modifier } from "@popperjs/core";
3
- import { useId } from "@react-aria/utils";
4
- import { Form, OverlayTrigger, Popover } from "react-bootstrap";
5
- import { useFieldArray, useFormContext } from "react-hook-form";
6
- import { useTranslation } from "react-i18next";
7
- import { useClickAway } from "react-use";
8
- import { TIMEZONE, TIME_FORMAT } from "@licklist/core/dist/Config/Date";
9
- import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
10
- import { DateTime } from "luxon";
11
- import RRule, { Frequency } from "rrule";
12
- import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
13
-
14
- import { DatePickerInput } from "../../recurring-date-picker-input/DatePickerInput";
15
- import { CONFIRM_MODAL_ACTIONS } from "../../modals/confirmation/ConfirmModal";
16
- import { Icon } from "../../static";
17
-
18
- import {
19
- AvailableTimesControl,
20
- AvailableTimesControlRef,
21
- } from "../../zone/form/components/AvailableTimesControl";
22
- import {
23
- RecurringDatePickerInputValues,
24
- getDateTimeObject,
25
- } from "../../recurring-date-picker-input/RecurringDatePickerInput";
26
- import { ProductSetRecurrenceOverridesControl } from "./ProductSetRecurrenceOverridesControl";
27
-
28
- export interface DateAndRecurrenceInputValues {
29
- menuRecurrences?: Partial<ProductSetRecurrence>[];
30
- }
31
-
32
- interface DateAndRecurrenceInputProps {
33
- isEventEditProductSet?: boolean;
34
- workHours?: WorkHour[];
35
- providerHasBookingManagement: boolean;
36
- isLoading?: boolean;
37
- }
38
-
39
- export const DateInput = ({
40
- isEventEditProductSet,
41
- isLoading,
42
- workHours,
43
- providerHasBookingManagement,
44
- }: DateAndRecurrenceInputProps) => {
45
- const {
46
- control,
47
- register,
48
- formState: { errors },
49
- getValues,
50
- setValue,
51
- clearErrors,
52
- } = useFormContext<DateAndRecurrenceInputValues>();
53
-
54
- const { fields, append, update } = useFieldArray({
55
- name: "menuRecurrences",
56
- control,
57
- keyName: "_id",
58
- });
59
-
60
- const [isDatePopoverVisible, setIsDatePopoverVisible] = useState(false);
61
- const availableTimesFormRef = useRef<AvailableTimesControlRef>();
62
- const [editState, setEditState] = useState<{
63
- index: number;
64
- values: Partial<ProductSetRecurrence>;
65
- }>({
66
- index: null,
67
- values: null,
68
- });
69
- const clearEditState = () => setEditState({ index: null, values: null });
70
-
71
- const popoverRef = useRef<HTMLDivElement>();
72
-
73
- useClickAway(popoverRef, (event) => {
74
- const isModal = CONFIRM_MODAL_ACTIONS.includes(
75
- (event.target as HTMLElement)?.attributes?.getNamedItem("data-id")?.value
76
- );
77
-
78
- if (isModal) {
79
- return;
80
- }
81
-
82
- setIsDatePopoverVisible(false);
83
- clearEditState();
84
- });
85
-
86
- const popoverId = useId()!;
87
-
88
- const handleOnEdit = (next: Partial<ProductSetRecurrence>, index) => {
89
- clearEditState();
90
-
91
- // Hotfix for an issue with Popover close & open actions
92
- setTimeout(() => {
93
- setEditState({ index, values: next });
94
- setIsDatePopoverVisible(() => true);
95
- }, 100);
96
- };
97
-
98
- const { t } = useTranslation("Design");
99
-
100
- // in this method we should fulfill the form with a proper data
101
- const handleRecurringDateChange = async (
102
- next: RecurringDatePickerInputValues
103
- ) => {
104
- const isAvailableTimesFormValid =
105
- await availableTimesFormRef.current?.trigger();
106
-
107
- if (next?.startTime && next?.endTime && isAvailableTimesFormValid) {
108
- const startTime = DateTime.fromISO(next.startTime);
109
- const endTime = DateTime.fromISO(next.endTime);
110
- const { availableTimes } = availableTimesFormRef.current.getValues();
111
- const validAvalilableTimes = availableTimes.every((time) => {
112
- const currentAvailableTime = DateTime.fromFormat(time, TIME_FORMAT);
113
-
114
- return (
115
- currentAvailableTime.diff(startTime, "minutes").minutes >= 0 &&
116
- currentAvailableTime.diff(endTime, "minutes").minutes <= 0
117
- );
118
- });
119
- if (!validAvalilableTimes) {
120
- availableTimesFormRef.current.setError("availableTimes", {
121
- message: t("Validation:fieldTimeBetween", {
122
- attribute: t("Design:startTimesSmall"),
123
- min: startTime.toFormat(TIME_FORMAT),
124
- max: endTime.toFormat(TIME_FORMAT),
125
- }),
126
- });
127
-
128
- return;
129
- }
130
- }
131
- const start = getDateTimeObject(next.startDate, next.endTime || "23:59:59");
132
-
133
- const rrule = RRule.optionsToString({
134
- until: (start as DateTime).toJSDate(),
135
- byweekday: [],
136
- freq: Frequency.DAILY,
137
- tzid: TIMEZONE,
138
- interval: 1,
139
- }).replace("RRULE:", "");
140
-
141
- const availableTime =
142
- availableTimesFormRef?.current?.getValues()?.availableTimes || null;
143
- const values = {
144
- rrule,
145
- startDate: next.startDate,
146
- endDate: next.startDate,
147
- startTime: next.startTime,
148
- endTime: next.endTime,
149
- availableTimes: availableTime,
150
- } as Partial<ProductSetRecurrence>;
151
-
152
- if (editState.values?.id) {
153
- values.id = editState.values?.id;
154
- }
155
-
156
- if (editState.index !== null) {
157
- update(editState.index, values);
158
- } else {
159
- append(values);
160
- }
161
-
162
- setIsDatePopoverVisible(() => false);
163
- clearEditState();
164
- };
165
-
166
- const handleOnAdd = () => {
167
- if (fields.length >= 1) return;
168
- clearEditState();
169
- setIsDatePopoverVisible((prevValue) => !prevValue);
170
- };
171
-
172
- const handleDelete = () => {
173
- const removeIndex = editState.index;
174
-
175
- setIsDatePopoverVisible(false);
176
- clearEditState();
177
-
178
- setTimeout(() => {
179
- const { menuRecurrences = [] } = getValues();
180
-
181
- // @TODO looks like workaround
182
- // Need recheck other places with remove method.
183
- // or update react-hook-form version.
184
- // Remove method from useFormFieldArray throw
185
- // errors while try to remove element by index.
186
- // So we remove them manually
187
- setValue(
188
- "menuRecurrences",
189
- menuRecurrences.filter(
190
- (_currentMenuRecurrence, index) => index !== removeIndex
191
- )
192
- );
193
- }, 100);
194
- };
195
-
196
- return (
197
- <Form.Group>
198
- <Form.Label>
199
- {t(
200
- isEventEditProductSet
201
- ? "whenOverridesAvailable"
202
- : "productSetAvailable"
203
- )}
204
- </Form.Label>
205
-
206
- <OverlayTrigger
207
- show={isDatePopoverVisible}
208
- overlay={
209
- <Popover id={popoverId} className="rounded">
210
- <Popover.Content className="shadow-lg rounded" ref={popoverRef}>
211
- <DatePickerInput
212
- defaultValues={editState.values}
213
- onChange={handleRecurringDateChange}
214
- onDelete={handleDelete}
215
- >
216
- {providerHasBookingManagement && (
217
- <AvailableTimesControl
218
- workHours={workHours}
219
- isLoading={isLoading}
220
- ref={availableTimesFormRef}
221
- defaultValues={[]}
222
- errorMessage={
223
- errors?.menuRecurrences?.[`${editState?.index}`]
224
- ?.availableTimes?.message
225
- }
226
- clearErrorMessage={() =>
227
- clearErrors(
228
- `menuRecurrences.${editState?.index}.availableTimes`
229
- )
230
- }
231
- />
232
- )}
233
- </DatePickerInput>
234
- </Popover.Content>
235
- </Popover>
236
- }
237
- trigger="click"
238
- placement="bottom"
239
- popperConfig={{ modifiers: [sameWidthPopperModifier] }}
240
- >
241
- <div className="product-set-recurrences">
242
- {fields.map((menuRecurrence, index) => (
243
- <ProductSetRecurrenceOverridesControl
244
- key={menuRecurrence._id}
245
- menuRecurrence={menuRecurrence}
246
- onEdit={() => handleOnEdit(menuRecurrence, index)}
247
- errorMessage={
248
- errors?.menuRecurrences?.[`${index}`]?.availableTimes?.message
249
- }
250
- />
251
- ))}
252
- <div
253
- className="product-set-recurrence-icon-wrapper"
254
- role="button"
255
- tabIndex={0}
256
- onClick={handleOnAdd}
257
- onKeyDown={handleOnAdd}
258
- >
259
- <Icon
260
- type="plus-circle"
261
- height="1rem"
262
- className="product-set-recurrence-icon-add mr-2"
263
- />
264
- {t("addDates")}
265
- </div>
266
-
267
- <Form.Control
268
- type="hidden"
269
- {...register("menuRecurrences", {
270
- required: {
271
- value: true,
272
- message: t("Validation:fieldMinNumber", {
273
- attribute: t("dates"),
274
- min: 1,
275
- }),
276
- },
277
- })}
278
- />
279
-
280
- <div className="manual-form-error">
281
- {errors.menuRecurrences?.message}
282
- </div>
283
- </div>
284
- </OverlayTrigger>
285
- </Form.Group>
286
- );
287
- };
288
-
289
- export const sameWidthPopperModifier: Modifier<
290
- "sameWidth",
291
- Record<string, unknown>
292
- > = {
293
- name: "sameWidth",
294
- enabled: true,
295
- phase: "beforeWrite",
296
- requires: ["computeStyles"],
297
- fn({ state }) {
298
- const style = {
299
- width: `${state.rects.reference.width + 4}px`,
300
- marginLeft: "-2px",
301
- maxWidth: "unset",
302
- };
303
- Object.assign(state.styles.popper, style);
304
- },
305
- effect({ state }) {
306
- const { width } = state.elements.reference.getBoundingClientRect();
307
- const style = {
308
- width: `${width}px`,
309
- maxWidth: "unset",
310
- };
311
- Object.assign(state.elements.popper.style, style);
312
- },
313
- };
@@ -1,63 +0,0 @@
1
- import React from "react";
2
- import { useIntl } from "react-intl";
3
- import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
4
-
5
- import { Icon } from "../../static";
6
-
7
- export interface ProductSetRecurrenceControlProps {
8
- menuRecurrence?: { _id: string } & Partial<ProductSetRecurrence>;
9
- onEdit?: (onEdit: Partial<ProductSetRecurrence>) => void;
10
- errorMessage?: string;
11
- }
12
-
13
- export const ProductSetRecurrenceOverridesControl = ({
14
- menuRecurrence,
15
- onEdit,
16
- errorMessage,
17
- }: ProductSetRecurrenceControlProps) => {
18
- const { formatDate } = useIntl();
19
-
20
- return (
21
- <div className="sortable-tree-root flex-column" role="button" tabIndex={0}>
22
- <div
23
- key={menuRecurrence.rrule}
24
- className="product-set-recurrence d-flex flex-column mr-0 mb-3 p-3 px-4 flex-grow-1"
25
- >
26
- <span className="d-flex flex-row align-items-center">
27
- <Icon
28
- type="calendar"
29
- height="1rem"
30
- className="product-set-recurrence-icon-calendar"
31
- />
32
- <span className="product-set-recurrence-title d-flex flex-grow-1">
33
- {formatDate(menuRecurrence.startDate, {
34
- dateStyle: "medium",
35
- })}{" "}
36
- </span>
37
-
38
- <div
39
- className="d-inline-flex"
40
- role="button"
41
- tabIndex={0}
42
- onClick={() => onEdit(menuRecurrence)}
43
- onKeyDown={() => onEdit(menuRecurrence)}
44
- >
45
- <Icon
46
- type="ellipsis-h"
47
- height="1rem"
48
- className="product-set-recurrence-icon-more"
49
- />
50
- </div>
51
- </span>
52
- <span className="product-set-recurrence-description">
53
- {formatDate(menuRecurrence.startDate, {
54
- dateStyle: "medium",
55
- })}{" "}
56
- </span>
57
- </div>
58
- <div className={`manual-form-error ${!errorMessage && "d-none"}`}>
59
- {errorMessage}
60
- </div>
61
- </div>
62
- );
63
- };
@@ -1,93 +0,0 @@
1
- import React, { PropsWithChildren } from "react";
2
- import { Frequency } from "rrule";
3
- import { useTranslation } from "react-i18next";
4
- import Button from "react-bootstrap/Button";
5
- import { DateTime } from "luxon";
6
- import { TIME_FULL_FORMAT } from "@licklist/core/dist/Config/Date";
7
- import { FormProvider, useForm } from "react-hook-form";
8
- import { Form } from "react-bootstrap";
9
- import { ConfirmModal } from "../modals";
10
- import { DeleteFieldButton } from "../product-set/elements";
11
- import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
12
- import RecurrenceAndFrequencyInput from "./RecurrenceAndFrequencyInput";
13
-
14
- export interface RecurringDatePickerInputProps {
15
- disabled?: boolean;
16
- defaultValues?: Partial<RecurringDatePickerInputValues>;
17
- onChange: (state: RecurringDatePickerInputValues) => void;
18
- onDelete: () => void;
19
- initialFrequency?: Frequency;
20
- setInitialStartDateAfterSelect?: boolean;
21
- minDate?: string;
22
- }
23
-
24
- export interface DatePickerInputValues {
25
- startDate: string;
26
- startTime: string;
27
- endTime: string;
28
- }
29
-
30
- export function DatePickerInput({
31
- disabled = false,
32
- onChange,
33
- onDelete,
34
- defaultValues,
35
- children,
36
- minDate,
37
- }: PropsWithChildren<RecurringDatePickerInputProps>) {
38
- const { t } = useTranslation(["Design"]);
39
-
40
- const form = useForm<DatePickerInputValues>({
41
- defaultValues: {
42
- startDate: defaultValues?.startDate ?? "",
43
- startTime: defaultValues?.startTime ?? "",
44
- endTime: defaultValues?.endTime ?? "",
45
- },
46
- mode: "onChange",
47
- });
48
-
49
- const { handleSubmit } = form;
50
-
51
- const onSubmit = (nextState: RecurringDatePickerInputValues) => {
52
- const endTimeNextState = nextState?.endTime
53
- ? DateTime.fromISO(nextState?.endTime).toFormat(TIME_FULL_FORMAT)
54
- : "";
55
-
56
- onChange({
57
- ...nextState,
58
- endTime: endTimeNextState,
59
- });
60
- };
61
-
62
- return (
63
- <FormProvider {...form}>
64
- <Form
65
- noValidate
66
- onSubmit={(event) => {
67
- // prevents parent form submitting
68
- event.preventDefault();
69
- event.stopPropagation();
70
- return handleSubmit(onSubmit)(event);
71
- }}
72
- >
73
- <RecurrenceAndFrequencyInput disabled={disabled} minDate={minDate} />
74
-
75
- {children}
76
-
77
- <div className="d-inline-flex align-items-center w-100">
78
- <Button type="submit">{t("Design:apply")}</Button>
79
-
80
- {defaultValues && (
81
- <div className="d-flex justify-content-end delete-btn">
82
- <ConfirmModal>
83
- {(confirm) => (
84
- <DeleteFieldButton onDelete={() => confirm(onDelete)} />
85
- )}
86
- </ConfirmModal>
87
- </div>
88
- )}
89
- </div>
90
- </Form>
91
- </FormProvider>
92
- );
93
- }
@@ -1,136 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { DateTime } from "luxon";
3
- import { Col, Form, Row } from "react-bootstrap";
4
- import { useTranslation } from "react-i18next";
5
- import { RegisterOptions, useFormContext } from "react-hook-form";
6
- import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
7
-
8
- interface RecurrenceIntervalAndFrequencyInputProps {
9
- disabled?: boolean;
10
- minDate?: string;
11
- startDateLabel?: string;
12
- startTimeLabel?: string;
13
- endDateLabel?: string;
14
- endTimeLabel?: string;
15
- startTimeRules?: Pick<
16
- RegisterOptions,
17
- "max" | "min" | "validate" | "required" | "pattern"
18
- >;
19
- endTimeRules?: Pick<
20
- RegisterOptions,
21
- "max" | "min" | "validate" | "required" | "pattern"
22
- >;
23
- }
24
-
25
- function RecurrenceAndFrequencyInput({
26
- disabled = false,
27
- minDate,
28
- startDateLabel,
29
- startTimeLabel,
30
- endTimeLabel,
31
- startTimeRules,
32
- endTimeRules,
33
- }: RecurrenceIntervalAndFrequencyInputProps) {
34
- const { t } = useTranslation(["Design", "Notification", "App"]);
35
-
36
- const {
37
- getValues,
38
- formState: { errors },
39
- register,
40
- trigger,
41
- } = useFormContext<RecurringDatePickerInputValues>();
42
-
43
- const startDate = getValues("startDate");
44
- const startTime = getValues("startTime");
45
- const endTime = getValues("endTime");
46
-
47
- useEffect(() => {
48
- if (!startTime || !endTime) {
49
- return;
50
- }
51
- trigger("endTime");
52
- // eslint-disable-next-line react-hooks/exhaustive-deps
53
- }, [startTime]);
54
-
55
- return (
56
- <>
57
- <Row>
58
- <Col xs={12} sm={6}>
59
- <Form.Group>
60
- <Form.Label>{startDateLabel ?? t("Design:date")}</Form.Label>
61
- <Form.Control
62
- type="date"
63
- {...register("startDate", { required: true })}
64
- defaultValue={startDate}
65
- className={startDate && "date-input-with-value"}
66
- disabled={disabled}
67
- min={minDate}
68
- isInvalid={Boolean(errors.startDate)}
69
- />
70
- <Form.Control.Feedback type="invalid">
71
- {errors.startDate?.message}
72
- </Form.Control.Feedback>
73
- </Form.Group>
74
- </Col>
75
- </Row>
76
-
77
- <Row>
78
- <Col xs={12} sm={6}>
79
- <Form.Group>
80
- <Form.Label>
81
- {startTimeLabel ?? t("Design:availableFrom")}
82
- </Form.Label>
83
- <Form.Control
84
- type="time"
85
- {...register("startTime", { required: false, ...startTimeRules })}
86
- placeholder="hh:mm"
87
- defaultValue={startTime}
88
- disabled={disabled}
89
- isInvalid={Boolean(errors.startTime)}
90
- />
91
- <Form.Control.Feedback type="invalid">
92
- {errors.startTime?.message}
93
- </Form.Control.Feedback>
94
- </Form.Group>
95
- </Col>
96
-
97
- <Col xs={12} sm={6}>
98
- <Form.Group>
99
- <Form.Label>{endTimeLabel ?? t("Design:availableTo")}</Form.Label>
100
- <Form.Control
101
- type="time"
102
- {...register("endTime", {
103
- required: false,
104
- validate: (time) => {
105
- if (!startTime || !time) {
106
- return true;
107
- }
108
- const currentStartTime = DateTime.fromISO(startTime);
109
- const currentEndTime = DateTime.fromISO(time);
110
-
111
- return currentEndTime?.diff(currentStartTime, ["minutes"])
112
- ?.minutes >= 0
113
- ? true
114
- : `${t(`Validation:fieldLaterDate`, {
115
- attribute: t("Design:endTimeSmall"),
116
- min: t("Design:startTimeSmall"),
117
- })}`;
118
- },
119
- ...endTimeRules,
120
- })}
121
- placeholder="hh:mm"
122
- defaultValue={endTime}
123
- disabled={disabled}
124
- isInvalid={Boolean(errors.endTime)}
125
- />
126
- <Form.Control.Feedback type="invalid">
127
- {errors.endTime?.message}
128
- </Form.Control.Feedback>
129
- </Form.Group>
130
- </Col>
131
- </Row>
132
- </>
133
- );
134
- }
135
-
136
- export default RecurrenceAndFrequencyInput;