@licklist/design 0.58.4-dev.2 → 0.58.5

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 (131) hide show
  1. package/dist/iframe/event/event-card/IframeEventCard.d.ts +1 -2
  2. package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
  3. package/dist/iframe/event/event-card/IframeEventCard.js +1 -1
  4. package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +1 -1
  5. package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.d.ts.map +1 -1
  6. package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.js +1 -1
  7. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
  8. package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/product-set/card/ProductSetCard.d.ts +1 -2
  11. package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
  12. package/dist/product-set/card/ProductSetCard.js +1 -1
  13. package/dist/product-set/control/ProductSetControl.d.ts +1 -2
  14. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  15. package/dist/product-set/control/ProductSetControl.js +1 -1
  16. package/dist/product-set/control/TutorialGifCard.d.ts +1 -2
  17. package/dist/product-set/control/TutorialGifCard.d.ts.map +1 -1
  18. package/dist/product-set/control/TutorialGifCard.js +1 -1
  19. package/dist/product-set/form/ProductCategoriesControl.d.ts +1 -2
  20. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  21. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  22. package/dist/product-set/form/ProductSetForm.d.ts +2 -7
  23. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  24. package/dist/product-set/form/ProductSetForm.js +1 -1
  25. package/dist/product-set/form/ProductsControl.d.ts +1 -2
  26. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  27. package/dist/product-set/form/ProductsControl.js +1 -1
  28. package/dist/product-set/form/StepsControl.d.ts +1 -2
  29. package/dist/product-set/form/StepsControl.d.ts.map +1 -1
  30. package/dist/product-set/form/StepsControl.js +1 -1
  31. package/dist/product-set/form/SubProductsControl.d.ts +1 -2
  32. package/dist/product-set/form/SubProductsControl.d.ts.map +1 -1
  33. package/dist/product-set/form/SubProductsControl.js +1 -1
  34. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts +1 -2
  35. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
  36. package/dist/product-set/hooks/useSortableTreeFunctions.js +1 -1
  37. package/dist/product-set/item/CreateProductSetItem.d.ts +1 -2
  38. package/dist/product-set/item/CreateProductSetItem.d.ts.map +1 -1
  39. package/dist/product-set/item/CreateProductSetItem.js +1 -1
  40. package/dist/product-set/product/ProductControl.d.ts +1 -2
  41. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  42. package/dist/product-set/product/ProductControl.js +1 -1
  43. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts +2 -4
  44. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +1 -1
  45. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.js +1 -1
  46. package/dist/product-set/product/quantity/ProductQuantityControl.d.ts +0 -1
  47. package/dist/product-set/product/quantity/ProductQuantityControl.d.ts.map +1 -1
  48. package/dist/product-set/product/quantity/ProductQuantityControl.js +1 -1
  49. package/dist/product-set/product-category/ProductCategoryControl.d.ts +1 -2
  50. package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
  51. package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
  52. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +0 -2
  53. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  54. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  55. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  56. package/dist/sortable-list/SortableList.d.ts +1 -2
  57. package/dist/sortable-list/SortableList.d.ts.map +1 -1
  58. package/dist/sortable-list/SortableList.js +1 -1
  59. package/dist/sortable-tree/SortableTreeItem.d.ts +1 -3
  60. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  61. package/dist/sortable-tree/SortableTreeItem.js +1 -1
  62. package/dist/static/manual-date-picker/ManualDatePicker.js +1 -1
  63. package/dist/static/manual-date-picker/constants/index.d.ts +1 -4
  64. package/dist/static/manual-date-picker/constants/index.d.ts.map +1 -1
  65. package/dist/static/manual-date-picker/constants/index.js +1 -1
  66. package/dist/static/manual-date-picker/utils/index.d.ts +0 -4
  67. package/dist/static/manual-date-picker/utils/index.d.ts.map +1 -1
  68. package/dist/static/manual-date-picker/utils/index.js +1 -1
  69. package/dist/styles/availability-indicator/AvailabilityIndicator.scss +0 -10
  70. package/dist/styles/iframe-events/Card.scss +8 -24
  71. package/dist/styles/iframe-events/PoweredBy.scss +2 -2
  72. package/dist/styles/iframe-order-process/IframeOrderProcess.scss +2 -0
  73. package/dist/styles/iframe-page/Page.scss +0 -1
  74. package/dist/styles/iframe-page/PageBody.scss +11 -32
  75. package/dist/styles/iframe-page/PageHeader.scss +39 -41
  76. package/dist/styles/product-set/EditVenueMapSetModal.scss +1 -1
  77. package/dist/styles/sales/BookingResults.scss +1 -1
  78. package/package.json +3 -3
  79. package/src/calendar/Calendar.stories.tsx +2 -9
  80. package/src/iframe/event/event-card/IframeEventCard.stories.tsx +0 -1
  81. package/src/iframe/event/event-card/IframeEventCard.tsx +8 -7
  82. package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +1 -1
  83. package/src/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.tsx +1 -3
  84. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +1 -6
  85. package/src/product-set/card/ProductSetCard.tsx +1 -10
  86. package/src/product-set/control/ProductSetControl.tsx +24 -46
  87. package/src/product-set/control/TutorialGifCard.tsx +3 -11
  88. package/src/product-set/form/ProductCategoriesControl.tsx +1 -12
  89. package/src/product-set/form/ProductSetForm.tsx +1 -10
  90. package/src/product-set/form/ProductsControl.tsx +0 -10
  91. package/src/product-set/form/StepsControl.tsx +2 -8
  92. package/src/product-set/form/SubProductsControl.tsx +0 -3
  93. package/src/product-set/hooks/useSortableTreeFunctions.ts +0 -4
  94. package/src/product-set/item/CreateProductSetItem.tsx +0 -3
  95. package/src/product-set/product/ProductControl.tsx +12 -23
  96. package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +2 -10
  97. package/src/product-set/product/quantity/ProductQuantityControl.tsx +3 -4
  98. package/src/product-set/product-category/ProductCategoryControl.tsx +8 -12
  99. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +1 -4
  100. package/src/sales/booking/results/components/ResultCard.tsx +3 -0
  101. package/src/sortable-list/SortableList.tsx +0 -3
  102. package/src/sortable-tree/SortableTreeItem.tsx +1 -7
  103. package/src/static/manual-date-picker/ManualDatePicker.tsx +3 -3
  104. package/src/static/manual-date-picker/constants/index.ts +2 -6
  105. package/src/static/manual-date-picker/utils/index.ts +0 -11
  106. package/src/static/switch/BooleanSwitch.tsx +1 -1
  107. package/src/styles/availability-indicator/AvailabilityIndicator.scss +0 -10
  108. package/src/styles/iframe-events/Card.scss +8 -24
  109. package/src/styles/iframe-events/PoweredBy.scss +2 -2
  110. package/src/styles/iframe-order-process/IframeOrderProcess.scss +2 -0
  111. package/src/styles/iframe-page/Page.scss +0 -1
  112. package/src/styles/iframe-page/PageBody.scss +11 -32
  113. package/src/styles/iframe-page/PageHeader.scss +39 -41
  114. package/src/styles/product-set/EditVenueMapSetModal.scss +1 -1
  115. package/src/styles/sales/BookingResults.scss +1 -1
  116. package/dist/product-set/control/DateInput.d.ts +0 -17
  117. package/dist/product-set/control/DateInput.d.ts.map +0 -1
  118. package/dist/product-set/control/DateInput.js +0 -1
  119. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts +0 -11
  120. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts.map +0 -1
  121. package/dist/product-set/control/ProductSetRecurrenceOverridesControl.js +0 -1
  122. package/dist/recurring-date-picker-input/DatePickerInput.d.ts +0 -19
  123. package/dist/recurring-date-picker-input/DatePickerInput.d.ts.map +0 -1
  124. package/dist/recurring-date-picker-input/DatePickerInput.js +0 -1
  125. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts +0 -15
  126. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts.map +0 -1
  127. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.js +0 -1
  128. package/src/product-set/control/DateInput.tsx +0 -311
  129. package/src/product-set/control/ProductSetRecurrenceOverridesControl.tsx +0 -63
  130. package/src/recurring-date-picker-input/DatePickerInput.tsx +0 -93
  131. package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +0 -137
@@ -1,19 +0,0 @@
1
- import { PropsWithChildren } from "react";
2
- import { Frequency } from "rrule";
3
- import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
4
- export interface RecurringDatePickerInputProps {
5
- disabled?: boolean;
6
- defaultValues?: Partial<RecurringDatePickerInputValues>;
7
- onChange: (state: RecurringDatePickerInputValues) => void;
8
- onDelete: () => void;
9
- initialFrequency?: Frequency;
10
- setInitialStartDateAfterSelect?: boolean;
11
- minDate?: string;
12
- }
13
- export interface DatePickerInputValues {
14
- startDate: string;
15
- startTime: string;
16
- endTime: string;
17
- }
18
- export declare function DatePickerInput({ disabled, onChange, onDelete, defaultValues, children, minDate, }: PropsWithChildren<RecurringDatePickerInputProps>): JSX.Element;
19
- //# sourceMappingURL=DatePickerInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePickerInput.d.ts","sourceRoot":"","sources":["../../src/recurring-date-picker-input/DatePickerInput.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASlC,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAG5E,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACxD,QAAQ,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,CAAC;IAC1D,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,OAAO,GACR,EAAE,iBAAiB,CAAC,6BAA6B,CAAC,eAwDlD"}
@@ -1 +0,0 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),n=e(require("react")),r=require("react-i18next"),i=e(require("react-bootstrap/Button")),a=require("react-bootstrap"),l=require("react-hook-form"),o=require("luxon"),u=require("../modals/confirmation/ConfirmModal.js");require("../modals/dialog/Dialog.js"),require("../modals/dialog/DialogContext.js");var d=require("../product-set/elements/DeleteFieldButton.js"),s=require("@licklist/core/dist/Config/Date"),m=require("./RecurrenceAndFrequencyInput.js");exports.DatePickerInput=function(e){var c,f,v,D=e.disabled,p=void 0!==D&&D,g=e.onChange,q=e.onDelete,b=e.defaultValues,T=e.children,_=e.minDate,E=r.useTranslation(["Design"]).t,F=l.useForm({defaultValues:{startDate:null!==(c=null==b?void 0:b.startDate)&&void 0!==c?c:"",startTime:null!==(f=null==b?void 0:b.startTime)&&void 0!==f?f:"",endTime:null!==(v=null==b?void 0:b.endTime)&&void 0!==v?v:""},mode:"onChange"}),j=F.handleSubmit,x=function(e){var n=(null==e?void 0:e.endTime)?o.DateTime.fromISO(null==e?void 0:e.endTime).toFormat(s.TIME_FULL_FORMAT):"";g(t.__assign(t.__assign({},e),{endTime:n}))};return n.createElement(l.FormProvider,t.__assign({},F),n.createElement(a.Form,{noValidate:!0,onSubmit:function(e){return e.preventDefault(),e.stopPropagation(),j(x)(e)}},n.createElement(m.default,{disabled:p,minDate:_}),T,n.createElement("div",{className:"d-inline-flex align-items-center w-100"},n.createElement(i,{type:"submit"},E("Design:apply")),b&&n.createElement("div",{className:"d-flex justify-content-end delete-btn"},n.createElement(u.ConfirmModal,null,(function(e){return n.createElement(d.DeleteFieldButton,{onDelete:function(){return e(q)}})}))))))};
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- import { RegisterOptions } from "react-hook-form";
3
- interface RecurrenceIntervalAndFrequencyInputProps {
4
- disabled?: boolean;
5
- minDate?: string;
6
- startDateLabel?: string;
7
- startTimeLabel?: string;
8
- endDateLabel?: string;
9
- endTimeLabel?: string;
10
- startTimeRules?: Pick<RegisterOptions, "max" | "min" | "validate" | "required" | "pattern">;
11
- endTimeRules?: Pick<RegisterOptions, "max" | "min" | "validate" | "required" | "pattern">;
12
- }
13
- declare function RecurrenceAndFrequencyInput({ disabled, minDate, startDateLabel, startTimeLabel, endTimeLabel, startTimeRules, endTimeRules, }: RecurrenceIntervalAndFrequencyInputProps): JSX.Element;
14
- export default RecurrenceAndFrequencyInput;
15
- //# sourceMappingURL=RecurrenceAndFrequencyInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RecurrenceAndFrequencyInput.d.ts","sourceRoot":"","sources":["../../src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,eAAe,EAAkB,MAAM,iBAAiB,CAAC;AAGlE,UAAU,wCAAwC;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,IAAI,CACnB,eAAe,EACf,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CACpD,CAAC;IACF,YAAY,CAAC,EAAE,IAAI,CACjB,eAAe,EACf,KAAK,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CACpD,CAAC;CACH;AAED,iBAAS,2BAA2B,CAAC,EACnC,QAAgB,EAChB,OAAO,EACP,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,GACb,EAAE,wCAAwC,eAsG1C;AAED,eAAe,2BAA2B,CAAC"}
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tslib"),a=require("react"),l=(e=a)&&"object"==typeof e&&"default"in e?e.default:e,r=require("react-i18next"),i=require("react-bootstrap"),n=require("react-hook-form"),o=require("luxon");exports.default=function(e){var m,s,u,d=e.disabled,c=void 0!==d&&d,v=e.minDate,f=e.startDateLabel,b=e.startTimeLabel,g=e.endTimeLabel,p=e.startTimeRules,E=e.endTimeRules,T=r.useTranslation(["Design","Notification","App"]).t,F=n.useFormContext(),D=F.getValues,_=F.formState.errors,C=F.register,q=F.trigger,h=D("startDate"),x=D("startTime"),y=D("endTime");return a.useEffect((function(){x&&y&&q("endTime")}),[x]),l.createElement(l.Fragment,null,l.createElement(i.Row,null,l.createElement(i.Col,{xs:12,sm:6},l.createElement(i.Form.Group,null,l.createElement(i.Form.Label,null,null!=f?f:T("Design:fromDate")),l.createElement(i.Form.Control,t.__assign({type:"date"},C("startDate",{required:!0}),{defaultValue:h,className:h&&"date-input-with-value",disabled:c,min:v,isInvalid:Boolean(_.startDate)})),l.createElement(i.Form.Control.Feedback,{type:"invalid"},null===(m=_.startDate)||void 0===m?void 0:m.message)))),l.createElement(i.Row,null,l.createElement(i.Col,{xs:12,sm:6},l.createElement(i.Form.Group,null,l.createElement(i.Form.Label,null,null!=b?b:T("Design:availableFrom")),l.createElement(i.Form.Control,t.__assign({type:"time"},C("startTime",t.__assign({required:!1},p)),{placeholder:"hh:mm",defaultValue:x,disabled:c,isInvalid:Boolean(_.startTime)})),l.createElement(i.Form.Control.Feedback,{type:"invalid"},null===(s=_.startTime)||void 0===s?void 0:s.message))),l.createElement(i.Col,{xs:12,sm:6},l.createElement(i.Form.Group,null,l.createElement(i.Form.Label,null,null!=g?g:T("Design:availableTo")),l.createElement(i.Form.Control,t.__assign({type:"time"},C("endTime",t.__assign({required:!1,validate:function(e){var t;if(!x||!e)return!0;var a=o.DateTime.fromISO(x),l=o.DateTime.fromISO(e);return(null===(t=null==l?void 0:l.diff(a,["minutes"]))||void 0===t?void 0:t.minutes)>=0||"".concat(T("Validation:fieldLaterDate",{attribute:T("Design:endTimeSmall"),min:T("Design:startTimeSmall")}))}},E)),{placeholder:"hh:mm",defaultValue:y,disabled:c,isInvalid:Boolean(_.endTime)})),l.createElement(i.Form.Control.Feedback,{type:"invalid"},null===(u=_.endTime)||void 0===u?void 0:u.message)))))};
@@ -1,311 +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 } from "@licklist/core/dist/Config/Date";
9
- import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
10
- import { TIME_FORMAT } from "@licklist/core/dist/Config/Date";
11
- import { DateTime } from "luxon";
12
- import RRule, { Frequency } from "rrule";
13
- import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
14
-
15
- import { DatePickerInput } from "../../recurring-date-picker-input/DatePickerInput";
16
- import { CONFIRM_MODAL_ACTIONS } from "../../modals/confirmation/ConfirmModal";
17
- import { Icon } from "../../static";
18
-
19
- import {
20
- AvailableTimesControl,
21
- AvailableTimesControlRef,
22
- } from "../../zone/form/components/AvailableTimesControl";
23
- import { RecurringDatePickerInputValues } from "../../recurring-date-picker-input/RecurringDatePickerInput";
24
- import { ProductSetRecurrenceOverridesControl } from "./ProductSetRecurrenceOverridesControl";
25
-
26
-
27
- export interface DateAndRecurrenceInputValues {
28
- menuRecurrences?: Partial<ProductSetRecurrence>[];
29
- }
30
-
31
- interface DateAndRecurrenceInputProps {
32
- isEventEditProductSet?: boolean;
33
- workHours?: WorkHour[];
34
- providerHasBookingManagement: boolean;
35
- isLoading?: boolean;
36
- }
37
-
38
- export const DateInput = ({
39
- isEventEditProductSet,
40
- isLoading,
41
- workHours,
42
- providerHasBookingManagement,
43
- }: DateAndRecurrenceInputProps) => {
44
- const {
45
- control,
46
- register,
47
- formState: { errors },
48
- getValues,
49
- setValue,
50
- clearErrors,
51
- } = useFormContext<DateAndRecurrenceInputValues>();
52
-
53
- const { fields, append, update } = useFieldArray({
54
- name: "menuRecurrences",
55
- control,
56
- keyName: "_id",
57
- });
58
-
59
- const [isDatePopoverVisible, setIsDatePopoverVisible] = useState(false);
60
- const availableTimesFormRef = useRef<AvailableTimesControlRef>();
61
- const [editState, setEditState] = useState<{
62
- index: number;
63
- values: Partial<ProductSetRecurrence>;
64
- }>({
65
- index: null,
66
- values: null,
67
- });
68
- const clearEditState = () => setEditState({ index: null, values: null });
69
-
70
- const popoverRef = useRef<HTMLDivElement>();
71
-
72
- useClickAway(popoverRef, (event) => {
73
- const isModal = CONFIRM_MODAL_ACTIONS.includes(
74
- (event.target as HTMLElement)?.attributes?.getNamedItem("data-id")?.value
75
- );
76
-
77
- if (isModal) {
78
- return;
79
- }
80
-
81
- setIsDatePopoverVisible(false);
82
- clearEditState();
83
- });
84
-
85
- const popoverId = useId()!;
86
-
87
- const handleOnEdit = (next: Partial<ProductSetRecurrence>, index) => {
88
- clearEditState();
89
-
90
- // Hotfix for an issue with Popover close & open actions
91
- setTimeout(() => {
92
- setEditState({ index, values: next });
93
- setIsDatePopoverVisible(() => true);
94
- }, 100);
95
- };
96
-
97
- const { t } = useTranslation("Design");
98
-
99
- // in this method we should fulfill the form with a proper data
100
- const handleRecurringDateChange = async (
101
- next: RecurringDatePickerInputValues
102
- ) => {
103
- const isAvailableTimesFormValid =
104
- await availableTimesFormRef.current?.trigger();
105
-
106
- if (next?.startTime && next?.endTime && isAvailableTimesFormValid) {
107
- const startTime = DateTime.fromISO(next.startTime);
108
- const endTime = DateTime.fromISO(next.endTime);
109
- const { availableTimes } = availableTimesFormRef.current.getValues();
110
- const validAvalilableTimes = availableTimes.every((time) => {
111
- const currentAvailableTime = DateTime.fromFormat(time, TIME_FORMAT);
112
-
113
- return (
114
- currentAvailableTime.diff(startTime, "minutes").minutes >= 0 &&
115
- currentAvailableTime.diff(endTime, "minutes").minutes <= 0
116
- );
117
- });
118
- if (!validAvalilableTimes) {
119
- availableTimesFormRef.current.setError("availableTimes", {
120
- message: t("Validation:fieldTimeBetween", {
121
- attribute: t("Design:startTimesSmall"),
122
- min: startTime.toFormat(TIME_FORMAT),
123
- max: endTime.toFormat(TIME_FORMAT),
124
- }),
125
- });
126
-
127
- return;
128
- }
129
- }
130
-
131
- const rrule = RRule.optionsToString({
132
- dtstart: DateTime.fromISO(next.startDate).toJSDate(),
133
- until: DateTime.fromISO(next.startDate).toJSDate(),
134
- byweekday: [],
135
- freq: Frequency.DAILY,
136
- tzid: TIMEZONE,
137
- }).replace("RRULE:", "");
138
-
139
- const availableTime =
140
- availableTimesFormRef?.current?.getValues()?.availableTimes || null;
141
- const values = {
142
- rrule,
143
- startDate: next.startDate,
144
- endDate: next.startDate,
145
- startTime: next.startTime,
146
- endTime: next.endTime,
147
- availableTimes: availableTime,
148
- } as Partial<ProductSetRecurrence>;
149
-
150
- if (editState.values?.id) {
151
- values.id = editState.values?.id;
152
- }
153
-
154
- if (editState.index !== null) {
155
- update(editState.index, values);
156
- } else {
157
- append(values);
158
- }
159
-
160
- setIsDatePopoverVisible(() => false);
161
- clearEditState();
162
- };
163
-
164
- const handleOnAdd = () => {
165
- if (fields.length >= 1) return;
166
- clearEditState();
167
- setIsDatePopoverVisible((prevValue) => !prevValue);
168
- };
169
-
170
- const handleDelete = () => {
171
- const removeIndex = editState.index;
172
-
173
- setIsDatePopoverVisible(false);
174
- clearEditState();
175
-
176
- setTimeout(() => {
177
- const { menuRecurrences = [] } = getValues();
178
-
179
- // @TODO looks like workaround
180
- // Need recheck other places with remove method.
181
- // or update react-hook-form version.
182
- // Remove method from useFormFieldArray throw
183
- // errors while try to remove element by index.
184
- // So we remove them manually
185
- setValue(
186
- "menuRecurrences",
187
- menuRecurrences.filter(
188
- (_currentMenuRecurrence, index) => index !== removeIndex
189
- )
190
- );
191
- }, 100);
192
- };
193
-
194
- return (
195
- <Form.Group>
196
- <Form.Label>
197
- {t(
198
- isEventEditProductSet
199
- ? "whenOverridesAvailable"
200
- : "productSetAvailable"
201
- )}
202
- </Form.Label>
203
-
204
- <OverlayTrigger
205
- show={isDatePopoverVisible}
206
- overlay={
207
- <Popover id={popoverId} className="rounded">
208
- <Popover.Content className="shadow-lg rounded" ref={popoverRef}>
209
- <DatePickerInput
210
- defaultValues={editState.values}
211
- onChange={handleRecurringDateChange}
212
- onDelete={handleDelete}
213
- >
214
- {providerHasBookingManagement && (
215
- <AvailableTimesControl
216
- workHours={workHours}
217
- isLoading={isLoading}
218
- ref={availableTimesFormRef}
219
- defaultValues={[]}
220
- errorMessage={
221
- errors?.menuRecurrences?.[`${editState?.index}`]
222
- ?.availableTimes?.message
223
- }
224
- clearErrorMessage={() =>
225
- clearErrors(
226
- `menuRecurrences.${editState?.index}.availableTimes`
227
- )
228
- }
229
- />
230
- )}
231
- </DatePickerInput>
232
- </Popover.Content>
233
- </Popover>
234
- }
235
- trigger="click"
236
- placement="bottom"
237
- popperConfig={{ modifiers: [sameWidthPopperModifier] }}
238
- >
239
- <div className="product-set-recurrences">
240
- {fields.map((menuRecurrence, index) => (
241
- <ProductSetRecurrenceOverridesControl
242
- key={menuRecurrence._id}
243
- menuRecurrence={menuRecurrence}
244
- onEdit={() => handleOnEdit(menuRecurrence, index)}
245
- errorMessage={
246
- errors?.menuRecurrences?.[`${index}`]?.availableTimes?.message
247
- }
248
- />
249
- ))}
250
- <div
251
- className="product-set-recurrence-icon-wrapper"
252
- role="button"
253
- tabIndex={0}
254
- onClick={handleOnAdd}
255
- onKeyDown={handleOnAdd}
256
- >
257
- <Icon
258
- type="plus-circle"
259
- height="1rem"
260
- className="product-set-recurrence-icon-add mr-2"
261
- />
262
- {t("addDates")}
263
- </div>
264
-
265
- <Form.Control
266
- type="hidden"
267
- {...register("menuRecurrences", {
268
- required: {
269
- value: true,
270
- message: t("Validation:fieldMinNumber", {
271
- attribute: t("dates"),
272
- min: 1,
273
- }),
274
- },
275
- })}
276
- />
277
-
278
- <div className="manual-form-error">
279
- {errors.menuRecurrences?.message}
280
- </div>
281
- </div>
282
- </OverlayTrigger>
283
- </Form.Group>
284
- );
285
- };
286
-
287
- export const sameWidthPopperModifier: Modifier<
288
- "sameWidth",
289
- Record<string, unknown>
290
- > = {
291
- name: "sameWidth",
292
- enabled: true,
293
- phase: "beforeWrite",
294
- requires: ["computeStyles"],
295
- fn({ state }) {
296
- const style = {
297
- width: `${state.rects.reference.width + 4}px`,
298
- marginLeft: "-2px",
299
- maxWidth: "unset",
300
- };
301
- Object.assign(state.styles.popper, style);
302
- },
303
- effect({ state }) {
304
- const { width } = state.elements.reference.getBoundingClientRect();
305
- const style = {
306
- width: `${width}px`,
307
- maxWidth: "unset",
308
- };
309
- Object.assign(state.elements.popper.style, style);
310
- },
311
- };
@@ -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,137 +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:fromDate")}</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
-
76
- </Row>
77
-
78
- <Row>
79
- <Col xs={12} sm={6}>
80
- <Form.Group>
81
- <Form.Label>
82
- {startTimeLabel ?? t("Design:availableFrom")}
83
- </Form.Label>
84
- <Form.Control
85
- type="time"
86
- {...register("startTime", { required: false, ...startTimeRules })}
87
- placeholder="hh:mm"
88
- defaultValue={startTime}
89
- disabled={disabled}
90
- isInvalid={Boolean(errors.startTime)}
91
- />
92
- <Form.Control.Feedback type="invalid">
93
- {errors.startTime?.message}
94
- </Form.Control.Feedback>
95
- </Form.Group>
96
- </Col>
97
-
98
- <Col xs={12} sm={6}>
99
- <Form.Group>
100
- <Form.Label>{endTimeLabel ?? t("Design:availableTo")}</Form.Label>
101
- <Form.Control
102
- type="time"
103
- {...register("endTime", {
104
- required: false,
105
- validate: (time) => {
106
- if (!startTime || !time) {
107
- return true;
108
- }
109
- const currentStartTime = DateTime.fromISO(startTime);
110
- const currentEndTime = DateTime.fromISO(time);
111
-
112
- return currentEndTime?.diff(currentStartTime, ["minutes"])
113
- ?.minutes >= 0
114
- ? true
115
- : `${t(`Validation:fieldLaterDate`, {
116
- attribute: t("Design:endTimeSmall"),
117
- min: t("Design:startTimeSmall"),
118
- })}`;
119
- },
120
- ...endTimeRules,
121
- })}
122
- placeholder="hh:mm"
123
- defaultValue={endTime}
124
- disabled={disabled}
125
- isInvalid={Boolean(errors.endTime)}
126
- />
127
- <Form.Control.Feedback type="invalid">
128
- {errors.endTime?.message}
129
- </Form.Control.Feedback>
130
- </Form.Group>
131
- </Col>
132
- </Row>
133
- </>
134
- );
135
- }
136
-
137
- export default RecurrenceAndFrequencyInput;