@licklist/design 0.63.0-dev.0 → 0.63.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 (142) hide show
  1. package/bitbucket-pipelines.yml +8 -0
  2. package/dist/date-time-button/DateTimeButton.js +1 -1
  3. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts +1 -3
  4. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
  5. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +1 -1
  6. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts +1 -3
  7. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
  8. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
  9. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts +1 -3
  10. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
  11. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
  12. package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +1 -1
  13. package/dist/product-set/control/DateAndRecurrenceInput.d.ts +5 -1
  14. package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
  15. package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
  16. package/dist/product-set/control/DateInput.d.ts.map +1 -1
  17. package/dist/product-set/control/DateInput.js +1 -1
  18. package/dist/product-set/control/ProductSetControl.d.ts +3 -4
  19. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  20. package/dist/product-set/form/ProductSetForm.d.ts +1 -4
  21. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  22. package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
  23. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  24. package/dist/product-set/product/ProductControl.js +1 -1
  25. package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +1 -1
  26. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  27. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  28. package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts.map +1 -1
  29. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +1 -3
  30. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  31. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  32. package/dist/recurring-date-picker-input/utils.d.ts +0 -12
  33. package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
  34. package/dist/recurring-date-picker-input/utils.js +1 -1
  35. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  36. package/dist/sales/booking/results/components/ResultCard.js +1 -1
  37. package/dist/sales/coupon/control/CouponFormControl.d.ts +1 -2
  38. package/dist/sales/coupon/control/CouponFormControl.d.ts.map +1 -1
  39. package/dist/sales/coupon/control/CouponFormControl.js +1 -1
  40. package/dist/sales/coupon/form/CouponFrom.d.ts +2 -2
  41. package/dist/sales/coupon/form/CouponFrom.d.ts.map +1 -1
  42. package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
  43. package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
  44. package/dist/setting/dashboard/DashboardSettingForm.d.ts +0 -1
  45. package/dist/setting/dashboard/DashboardSettingForm.d.ts.map +1 -1
  46. package/dist/setting/dashboard/DashboardSettingForm.js +1 -1
  47. package/dist/styles/sales/BookingResults.scss +1 -1
  48. package/dist/typeahead/Typeahead.d.ts +1 -2
  49. package/dist/typeahead/Typeahead.d.ts.map +1 -1
  50. package/dist/typeahead/Typeahead.js +1 -1
  51. package/dist/zone/form/ZoneForm.d.ts +2 -2
  52. package/dist/zone/form/ZoneForm.d.ts.map +1 -1
  53. package/dist/zone/form/ZoneForm.js +1 -1
  54. package/dist/zone/form/components/AvailableTimesControl.d.ts +2 -0
  55. package/dist/zone/form/components/AvailableTimesControl.d.ts.map +1 -1
  56. package/dist/zone/form/components/ZoneControl.d.ts +2 -2
  57. package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
  58. package/dist/zone/form/components/ZoneControl.js +1 -1
  59. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
  60. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
  61. package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
  62. package/dist/zone/form/utils/dates.d.ts.map +1 -1
  63. package/jest.config.js +29 -0
  64. package/package.json +35 -10
  65. package/src/date-time-button/DateTimeButton.stories.tsx +1 -2
  66. package/src/date-time-button/DateTimeButton.tsx +5 -7
  67. package/src/events/edit-event-modal/component/EditEventForm/EditEventForm.tsx +0 -4
  68. package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +8 -10
  69. package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +0 -4
  70. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +6 -6
  71. package/src/product-set/control/DateAndRecurrenceInput.tsx +14 -48
  72. package/src/product-set/control/DateInput.tsx +4 -2
  73. package/src/product-set/control/ProductSetControl.stories.tsx +1 -1
  74. package/src/product-set/control/ProductSetControl.tsx +8 -5
  75. package/src/product-set/form/ProductCategoriesControl.tsx +1 -1
  76. package/src/product-set/form/ProductSetForm.stories.tsx +2 -1
  77. package/src/product-set/form/ProductSetForm.tsx +1 -5
  78. package/src/product-set/hooks/useSortableTreeFunctions.ts +0 -2
  79. package/src/product-set/product/ProductControl.tsx +38 -38
  80. package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +2 -0
  81. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +18 -4
  82. package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +1 -0
  83. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +1 -11
  84. package/src/recurring-date-picker-input/utils.ts +0 -77
  85. package/src/sales/booking/results/BookingResults.stories.tsx +2 -3
  86. package/src/sales/booking/results/components/ResultCard.tsx +5 -2
  87. package/src/sales/coupon/control/CouponFormControl.tsx +51 -28
  88. package/src/sales/coupon/form/CouponFrom.tsx +15 -5
  89. package/src/setting/admin/AdminSettingForm.tsx +2 -2
  90. package/src/setting/dashboard/DashboardSettingForm.tsx +0 -13
  91. package/src/sortable-tree/SortableTreeItem.tsx +1 -1
  92. package/src/static/switch/BooleanSwitch.tsx +1 -1
  93. package/src/styles/sales/BookingResults.scss +1 -1
  94. package/src/typeahead/Typeahead.tsx +3 -16
  95. package/src/zone/form/ZoneForm.tsx +2 -3
  96. package/src/zone/form/components/AvailableTimesControl.tsx +2 -0
  97. package/src/zone/form/components/ZoneControl.tsx +3 -3
  98. package/src/zone/form/components/ZoneRecurrencesControl.tsx +5 -7
  99. package/src/zone/form/utils/dates.ts +10 -9
  100. package/tests/Auth/Authorizer.test.tsx +194 -0
  101. package/tests/Auth/Layout/UserNavDropDown.test.tsx +43 -0
  102. package/tests/Auth/Layout/UserNavDropDownToggle.test.tsx +33 -0
  103. package/tests/Auth/Login/LoginComponent.test.tsx +246 -0
  104. package/tests/Auth/Login/LoginFormComponent.test.tsx +182 -0
  105. package/tests/Auth/Register/RegisterComponent.test.tsx +285 -0
  106. package/tests/Auth/Register/RegisterFormComponent.test.tsx +170 -0
  107. package/tests/Auth/Settings/Dashboard/IpInput.test.tsx +130 -0
  108. package/tests/Auth/Social/SocialCallbackComponent.test.tsx +133 -0
  109. package/tests/Auth/Social/SocialFormComponent.test.tsx +118 -0
  110. package/tests/FileUpload/FileUpload.test.tsx +42 -0
  111. package/tests/Notification/EmailTemplate.test.tsx +82 -0
  112. package/tests/ProductSet/ProductSetPopover.test.tsx +40 -0
  113. package/tests/Report/Report.test.tsx +48 -0
  114. package/tests/Sales/Coupon.test.tsx +51 -0
  115. package/tests/Sales/SalesAndVIews.test.tsx +63 -0
  116. package/tests/SnippetTemplates/SnippetTemplates.test.tsx +56 -0
  117. package/tests/Table/FilterHelperComponent.test.tsx +88 -0
  118. package/tests/Table/PaginationHelperComponent.test.tsx +109 -0
  119. package/tests/Table/PerPageHelperComponent.test.tsx +34 -0
  120. package/tests/Table/TableHelperComponent.test.tsx +295 -0
  121. package/tests/TipTapEditor/TipTapEditor.test.tsx +28 -0
  122. package/tests/__mock__/hooks/useAuthApi.ts +13 -0
  123. package/tests/__mock__/hooks/useAuthMock.ts +13 -0
  124. package/tests/__mock__/hooks/useFormMock.ts +27 -0
  125. package/tests/__mock__/hooks/useNotificationMock.ts +13 -0
  126. package/tests/__mock__/hooks/useQueryMock.ts +16 -0
  127. package/tests/__mock__/hooks/useSocialApiMock.ts +20 -0
  128. package/tests/__mock__/hooks/useTranslationMock.ts +17 -0
  129. package/tests/__mock__/hooks/useUserApiMock.ts +18 -0
  130. package/tests/__mock__/hooks/useUserMock.ts +13 -0
  131. package/tests/__mock__/styleMock.js +1 -0
  132. package/tests/__mock__/windowMock.ts +5 -0
  133. package/tests/packages/react-query.tsx +28 -0
  134. package/tests/setupTests.ts +10 -0
  135. package/dist/product-set/control/utils.d.ts +0 -5
  136. package/dist/product-set/control/utils.d.ts.map +0 -1
  137. package/dist/product-set/control/utils.js +0 -1
  138. package/dist/sales/coupon/utils/index.d.ts +0 -7
  139. package/dist/sales/coupon/utils/index.d.ts.map +0 -1
  140. package/dist/sales/coupon/utils/index.js +0 -1
  141. package/src/product-set/control/utils.ts +0 -25
  142. package/src/sales/coupon/utils/index.ts +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.63.0-dev.0",
3
+ "version": "0.63.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -16,11 +16,14 @@
16
16
  "type-check:watch": "yarn type-check -- --watch",
17
17
  "build": "rollup -c",
18
18
  "watch": "yarn build -- -w",
19
+ "test": "jest --verbose --coverage --watchAll=false",
20
+ "run-test": "jest --verbose --watchAll=false",
19
21
  "lint": "eslint --ext .ts,.tsx .",
20
22
  "lint:fix": "yarn run lint -- --fix",
21
23
  "lint:format": "prettier \"**/*.{md,json,yml,scss}\" --check",
22
24
  "lint:format:fix": "prettier \"**/*.{md,json,yml,scss}\" --write",
23
25
  "prepare": "husky install",
26
+ "test-staged": "CI=true jest --passWithNoTests --findRelatedTests",
24
27
  "tests": "yarn tests-staged",
25
28
  "prettier-write": "prettier --write",
26
29
  "tsc": "bash -c tsc -p tsconfig.json -b"
@@ -50,9 +53,9 @@
50
53
  "@fortawesome/free-brands-svg-icons": "5.15.2",
51
54
  "@fortawesome/free-solid-svg-icons": "5.15.2",
52
55
  "@fortawesome/react-fontawesome": "0.1.9",
53
- "@licklist/core": ">=0.25.1-dev.0 < 0.25.1",
54
- "@licklist/eslint-config": "0.4.5",
55
- "@licklist/plugins": ">=0.28.0-dev.2 < 0.28.0",
56
+ "@licklist/core": "^0.23.1",
57
+ "@licklist/eslint-config": "0.3.4",
58
+ "@licklist/plugins": "^0.27.2",
56
59
  "@mdx-js/react": "1.6.22",
57
60
  "@popperjs/core": "2.11.8",
58
61
  "@react-aria/utils": "3.9.0",
@@ -70,6 +73,10 @@
70
73
  "@svgr/rollup": "5.5.0",
71
74
  "@svgr/webpack": "5.5.0",
72
75
  "@tanstack/react-table": "8.10.6",
76
+ "@testing-library/jest-dom": "5.16.1",
77
+ "@testing-library/react": "11.2.5",
78
+ "@testing-library/react-hooks": "5.1.0",
79
+ "@testing-library/user-event": "13.5.0",
73
80
  "@tiptap/core": "2.0.0-beta.176",
74
81
  "@tiptap/extension-blockquote": "2.0.0-beta.29",
75
82
  "@tiptap/extension-bold": "2.0.0-beta.28",
@@ -92,10 +99,14 @@
92
99
  "@tiptap/react": "2.0.0-beta.109",
93
100
  "@tiptap/suggestion": "2.0.0-beta.92",
94
101
  "@types/babel__core": "7.1.12",
102
+ "@types/enzyme-adapter-react-16": "1.0.6",
103
+ "@types/jest": "26.0.20",
95
104
  "@types/luxon": "1.26.2",
96
105
  "@types/mdx-js__react": "1.5.3",
106
+ "@types/react": "17.0.2",
97
107
  "@types/react-bootstrap": "1.0.1",
98
108
  "@types/react-date-range": "^1.4.4",
109
+ "@types/react-dom": "17.0.1",
99
110
  "@types/react-email-editor": "1.1.7",
100
111
  "@types/react-loader": "2.4.4",
101
112
  "@types/react-phone-number-input": "3.0.6",
@@ -105,6 +116,7 @@
105
116
  "@typescript-eslint/eslint-plugin": "5.8.1",
106
117
  "@typescript-eslint/parser": "5.8.1",
107
118
  "@wojtekmaj/react-daterange-picker": "^4.1.0",
119
+ "babel-jest": "26.6.3",
108
120
  "babel-loader": "8.2.2",
109
121
  "babel-plugin-inline-react-svg": "2.0.1",
110
122
  "bootstrap": "4.6.0",
@@ -116,16 +128,21 @@
116
128
  "emojibase": "6.1.0",
117
129
  "emojibase-data": "7.0.1",
118
130
  "emojibase-regex": "6.0.1",
131
+ "enzyme": "3.11.0",
132
+ "enzyme-adapter-react-16": "1.15.6",
119
133
  "eslint": "7.32.0",
120
134
  "eslint-config-airbnb": "18.2.1",
121
135
  "eslint-config-prettier": "8.3.0",
136
+ "eslint-plugin-jest": "25.3.2",
122
137
  "eslint-plugin-jsx-a11y": "6.5.1",
123
138
  "eslint-plugin-prettier": "4.0.0",
124
139
  "eslint-plugin-react-hooks": "4.2.0",
140
+ "eslint-plugin-testing-library": "5.0.1",
125
141
  "framer-motion": "4.1.17",
126
142
  "history": "5.3.0",
127
143
  "husky": "7.0.4",
128
144
  "i18next": "19.4.5",
145
+ "jest": "26.6.0",
129
146
  "klona": "2.0.4",
130
147
  "konva": "6.0.0",
131
148
  "lint-staged": "11.1.2",
@@ -133,18 +150,18 @@
133
150
  "luxon": "1.26.0",
134
151
  "moment": "2.29.1",
135
152
  "prettier": "2.5.1",
136
- "react": "17.0.2",
153
+ "react": "16.14.0",
137
154
  "react-bootstrap": "1.6.1",
138
155
  "react-color": "2.19.3",
139
156
  "react-copy-to-clipboard": "5.0.3",
140
157
  "react-date-range": "^1.4.0",
141
- "react-dom": "17.0.2",
158
+ "react-dom": "16.14.0",
142
159
  "react-email-editor": "1.6.1",
143
160
  "react-highlighter": "0.4.3",
144
161
  "react-hook-form": "7.13.0",
145
162
  "react-i18next": "11.8.8",
146
163
  "react-intl": "5.15.8",
147
- "react-konva": "^17.0.2-6",
164
+ "react-konva": "16.13.0-6",
148
165
  "react-loader": "2.4.7",
149
166
  "react-loading-skeleton": "^3.3.1",
150
167
  "react-overlays": "4.1.1",
@@ -169,6 +186,7 @@
169
186
  "sass": "1.32.8",
170
187
  "sass-loader": "10.1.1",
171
188
  "style-loader": "2.0.0",
189
+ "ts-jest": "26.5.2",
172
190
  "twemoji-parser": "14.0.0",
173
191
  "typescript": "4.9.5",
174
192
  "url-loader": "4.1.1",
@@ -176,17 +194,24 @@
176
194
  },
177
195
  "resolutions": {
178
196
  "@types/react": "17.0.2",
179
- "@types/react-dom": "17.0.2"
197
+ "@types/react-dom": "17.0.1"
198
+ },
199
+ "jest": {
200
+ "setupFilesAfterEnv": [
201
+ "./jest.config.js"
202
+ ],
203
+ "snapshotSerializers": [
204
+ "enzyme-to-json/serializer"
205
+ ]
180
206
  },
181
207
  "lint-staged": {
182
208
  "*.{ts,tsx}": [
209
+ "yarn test-staged",
183
210
  "yarn prettier-write",
184
211
  "yarn lint:fix"
185
212
  ]
186
213
  },
187
214
  "devDependencies": {
188
- "@types/react": "17.0.2",
189
- "@types/react-dom": "17.0.2",
190
215
  "identity-obj-proxy": "^3.0.0"
191
216
  },
192
217
  "volta": {
@@ -8,7 +8,7 @@ export default {
8
8
  component: DateTimeButton,
9
9
  } as Meta;
10
10
 
11
- const date = DateTime.now().plus({ hour: 1 });
11
+ const date = DateTime.now();
12
12
 
13
13
  export const Default: Story<DateTimeButtonProps> = (args) => {
14
14
  return <DateTimeButton {...args} />;
@@ -19,7 +19,6 @@ Default.args = {
19
19
  isSelected: false,
20
20
  isDisabled: false,
21
21
  onSelect: () => null,
22
- shouldCalculateResources: false,
23
22
  };
24
23
 
25
24
  export const Selected: Story<DateTimeButtonProps> = (args) => {
@@ -46,7 +46,7 @@ export const DateTimeButton = ({
46
46
 
47
47
  const isTimeVariant = variant === Variant.time;
48
48
 
49
- const isPast = variant === Variant.time ? isPastTime(date) : isPastDate(date);
49
+ const isTimeInPast = isTimeVariant && isDateInPast(date);
50
50
 
51
51
  const noResources =
52
52
  shouldCalculateResources &&
@@ -55,7 +55,7 @@ export const DateTimeButton = ({
55
55
  !has(resources, "bookedResources") ||
56
56
  !has(resources, "totalResources"));
57
57
 
58
- const isDisabled = _isDisabled || isSoldOut || isPast || noResources;
58
+ const isDisabled = _isDisabled || isSoldOut || isTimeInPast || noResources;
59
59
 
60
60
  return (
61
61
  <button
@@ -85,7 +85,7 @@ export const DateTimeButton = ({
85
85
  {showResources && resources && (
86
86
  <AvailabilityIndicator
87
87
  resources={resources}
88
- isUnavailable={_isDisabled || isPast}
88
+ isUnavailable={_isDisabled || isTimeInPast}
89
89
  isSoldOut={isSoldOut}
90
90
  />
91
91
  )}
@@ -93,7 +93,5 @@ export const DateTimeButton = ({
93
93
  );
94
94
  };
95
95
 
96
- const isPastTime = (date: DateTime): boolean => DateTime.now() > date;
97
-
98
- const isPastDate = (date: DateTime): boolean =>
99
- DateTime.now() > date.set({ hour: 23, minute: 59, second: 59 });
96
+ const isDateInPast = (date: DateTime): boolean =>
97
+ date.toUTC() <= DateTime.now().toUTC();
@@ -19,7 +19,6 @@ import { scrollToError } from "@licklist/plugins/dist/utils/ScrollUtils";
19
19
  import { getFirstErrorKey } from "@licklist/plugins/dist/utils/FormValues";
20
20
 
21
21
  import { ProductSet } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
22
- import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
23
22
  import { CategoryGroup } from "../../../../types/categories";
24
23
  import { SaleDeadline } from "../SaleDeadline/SaleDeadline";
25
24
  import {
@@ -65,7 +64,6 @@ export interface EditEventFormProps extends HasPermissionProp {
65
64
  createProductSet: (props: EditEventFormValues) => void;
66
65
  setEditProductSetId: (value: string) => void;
67
66
  isExternalPaymentLinkEnabled?: boolean;
68
- workHours: WorkHour[] | undefined;
69
67
  }
70
68
 
71
69
  const eventImageTypes = {
@@ -85,7 +83,6 @@ export const EditEventForm = ({
85
83
  createProductSet,
86
84
  setEditProductSetId,
87
85
  isExternalPaymentLinkEnabled,
88
- workHours,
89
86
  }: EditEventFormProps) => {
90
87
  const { t } = useTranslation(["Design", "Validation"]);
91
88
 
@@ -406,7 +403,6 @@ export const EditEventForm = ({
406
403
  setEditProductSetId={setEditProductSetId}
407
404
  setShowEditProductSet={setShowEditProductSet}
408
405
  showEditProductSet={showEditProductSet}
409
- workHours={workHours}
410
406
  />
411
407
 
412
408
  {hasPermission && !showEditProductSet && (
@@ -5,7 +5,6 @@ import { useId } from "@react-aria/utils";
5
5
  import { Controller, useFormContext } from "react-hook-form";
6
6
  import { HasPermissionProp } from "@licklist/plugins/dist/types/permission/Permission";
7
7
  import { ProductSet } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
8
- import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
9
8
  import { ConfirmModal } from "../../../../modals/confirmation/ConfirmModal";
10
9
  import { EditEventFormValues } from "../EditEventForm/EditEventForm";
11
10
  import { EditEventProductSet } from "./component/EditEventProductSet";
@@ -16,7 +15,6 @@ interface SelectEventProductSetProps extends HasPermissionProp {
16
15
  setShowEditProductSet: (value: boolean) => void;
17
16
  createProductSet: (props: EditEventFormValues) => void;
18
17
  setEditProductSetId: (value: string) => void;
19
- workHours: WorkHour[] | undefined;
20
18
  }
21
19
 
22
20
  export const SelectEventProductSet = ({
@@ -25,7 +23,6 @@ export const SelectEventProductSet = ({
25
23
  setEditProductSetId,
26
24
  showEditProductSet,
27
25
  setShowEditProductSet,
28
- workHours,
29
26
  }: SelectEventProductSetProps) => {
30
27
  const { t } = useTranslation(["Design"]);
31
28
  const form = useFormContext<EditEventFormValues>();
@@ -202,13 +199,14 @@ export const SelectEventProductSet = ({
202
199
  </Form.Group>
203
200
  </div>
204
201
  {showEditProductSet && productSetId && (
205
- <EditEventProductSet
206
- onSubmit={onSubmit}
207
- defaultValues={
208
- productSetId === editedProductSet?.id && editedProductSet
209
- }
210
- workHours={workHours}
211
- />
202
+ <>
203
+ <EditEventProductSet
204
+ onSubmit={onSubmit}
205
+ defaultValues={
206
+ productSetId === editedProductSet?.id && editedProductSet
207
+ }
208
+ />
209
+ </>
212
210
  )}
213
211
  </>
214
212
  );
@@ -5,7 +5,6 @@ import { isEqual } from "lodash";
5
5
  import { useParams } from "react-router-dom";
6
6
  import { useEventEditProductSetContext } from "@licklist/plugins/dist/context/event/EventEditProductSetContext";
7
7
  import { useTranslation } from "react-i18next";
8
- import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
9
8
  import { BlockLoader } from "../../../../../static/loader/BlockLoader";
10
9
  import { ProductSetControl } from "../../../../../product-set";
11
10
  import { ProductSetContextProvider } from "../../../../../product-set/form/context";
@@ -23,13 +22,11 @@ export interface EventDates {
23
22
  interface EditEventProductSetProps {
24
23
  onSubmit: (value: EditEventFormValues["editedProductSet"]) => void;
25
24
  defaultValues?: EditEventFormValues["editedProductSet"];
26
- workHours: WorkHour[] | undefined;
27
25
  }
28
26
 
29
27
  export const EditEventProductSet = ({
30
28
  onSubmit,
31
29
  defaultValues,
32
- workHours,
33
30
  }: EditEventProductSetProps) => {
34
31
  const { companyId } = useParams<{
35
32
  companyId: string;
@@ -127,7 +124,6 @@ export const EditEventProductSet = ({
127
124
  companyName={selectedCompany?.title}
128
125
  fee={feeInPercent}
129
126
  isEventEditProductSet
130
- workHours={workHours}
131
127
  />
132
128
  <Button
133
129
  disabled={isLoading}
@@ -63,7 +63,7 @@ const processedPaymentSummary = ({
63
63
  const total = calculateTotalPrice(order, externalPaymentDetail);
64
64
 
65
65
  const totalDiscount = calculateTotalDiscount(order.payments);
66
-
66
+ const totalWithDiscount = total - Number(totalDiscount);
67
67
  let summaryItems: SummaryItem[] = [
68
68
  {
69
69
  translateKey: AMOUNT_TOTAL,
@@ -74,7 +74,7 @@ const processedPaymentSummary = ({
74
74
  if (totalDiscount) {
75
75
  summaryItems.push({
76
76
  translateKey: AMOUNT_WITH_DISCOUNT,
77
- price: order.totalToPayAmount,
77
+ price: totalWithDiscount < 0 ? 0 : totalWithDiscount,
78
78
  });
79
79
  }
80
80
 
@@ -84,17 +84,17 @@ const processedPaymentSummary = ({
84
84
 
85
85
  summaryItems.push({
86
86
  translateKey: TOTAL_PAID,
87
- price: order.paidAmount,
87
+ price: totalWithDiscount <= 0 ? 0 : order.totalAmount,
88
88
  });
89
- if (order.totalToPayAmount <= 0) {
89
+ if (totalWithDiscount <= 0) {
90
90
  return summaryItems;
91
91
  }
92
92
  summaryItems = [...summaryItems, ...externalPaymentDetail];
93
93
 
94
- if (order.remainingToPay) {
94
+ if (totalWithDiscount > order.totalAmount) {
95
95
  summaryItems.push({
96
96
  translateKey: REMAINING_TO_PAY,
97
- price: order.remainingToPay,
97
+ price: totalWithDiscount - order.totalAmount,
98
98
  });
99
99
  }
100
100
  return summaryItems;
@@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
2
2
  import { Modifier } from "@popperjs/core";
3
3
  import { useId } from "@react-aria/utils";
4
4
  import { Form, OverlayTrigger, Popover } from "react-bootstrap";
5
- import { useFieldArray, useFormContext, useWatch } from "react-hook-form";
5
+ import { useFieldArray, useFormContext } from "react-hook-form";
6
6
  import { useTranslation } from "react-i18next";
7
7
  import { useClickAway } from "react-use";
8
8
  import { DateTime } from "luxon";
@@ -14,6 +14,7 @@ import {
14
14
  SortableContext,
15
15
  verticalListSortingStrategy,
16
16
  } from "@dnd-kit/sortable";
17
+
17
18
  import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
18
19
  import { CONFIRM_MODAL_ACTIONS } from "../../modals/confirmation/ConfirmModal";
19
20
  import { Icon } from "../../static";
@@ -26,15 +27,16 @@ import {
26
27
  AvailableTimesControl,
27
28
  AvailableTimesControlRef,
28
29
  } from "../../zone/form/components/AvailableTimesControl";
29
- import { ProductSetControlValues } from "..";
30
- import {
31
- getProductWithSmallestDuration,
32
- getLatestAvailableDateTime,
33
- } from "./utils";
30
+
31
+ // eslint-disable-next-line max-len
32
+
33
+ export interface DateAndRecurrenceInputValues {
34
+ menuRecurrences?: Partial<ProductSetRecurrence>[];
35
+ }
34
36
 
35
37
  interface DateAndRecurrenceInputProps {
36
38
  isEventEditProductSet?: boolean;
37
- workHours: WorkHour[] | undefined;
39
+ workHours?: WorkHour[];
38
40
  providerHasBookingManagement: boolean;
39
41
  isLoading?: boolean;
40
42
  }
@@ -52,9 +54,7 @@ export const DateAndRecurrenceInput = ({
52
54
  getValues,
53
55
  setValue,
54
56
  clearErrors,
55
- } = useFormContext<ProductSetControlValues>();
56
-
57
- const steps = useWatch({ control, name: "steps" });
57
+ } = useFormContext<DateAndRecurrenceInputValues>();
58
58
 
59
59
  const [availableTimes, setAvailableTimes] = useState<string[]>([]);
60
60
  const availableTimesFormRef = useRef<AvailableTimesControlRef>();
@@ -90,7 +90,7 @@ export const DateAndRecurrenceInput = ({
90
90
  clearEditState();
91
91
  });
92
92
 
93
- const popoverId = useId();
93
+ const popoverId = useId()!;
94
94
 
95
95
  const { t } = useTranslation("Design");
96
96
 
@@ -101,13 +101,11 @@ export const DateAndRecurrenceInput = ({
101
101
  const isAvailableTimesFormValid =
102
102
  await availableTimesFormRef.current?.trigger();
103
103
 
104
- const { availableTimes } = availableTimesFormRef.current.getValues();
105
-
106
104
  if (next?.startTime && next?.endTime && isAvailableTimesFormValid) {
107
105
  const startTime = DateTime.fromISO(next.startTime);
108
106
  const endTime = DateTime.fromISO(next.endTime);
109
-
110
- const areAvailableTimesValid = availableTimes.every((time) => {
107
+ const { availableTimes } = availableTimesFormRef.current.getValues();
108
+ const validAvalilableTimes = availableTimes.every((time) => {
111
109
  const currentAvailableTime = DateTime.fromFormat(time, TIME_FORMAT);
112
110
 
113
111
  return (
@@ -115,8 +113,7 @@ export const DateAndRecurrenceInput = ({
115
113
  currentAvailableTime.diff(endTime, "minutes").minutes <= 0
116
114
  );
117
115
  });
118
-
119
- if (!areAvailableTimesValid) {
116
+ if (!validAvalilableTimes) {
120
117
  availableTimesFormRef.current.setError("availableTimes", {
121
118
  message: t("Validation:fieldTimeBetween", {
122
119
  attribute: t("Design:startTimesSmall"),
@@ -129,36 +126,6 @@ export const DateAndRecurrenceInput = ({
129
126
  }
130
127
  }
131
128
 
132
- // this check is required to prevent user from adding available time
133
- // less than the lowest duration product, e.g. if lowest duration product
134
- // is 1 hour and user tries to add time 15 minutes before end time,
135
- // such time can never be booked
136
- const lowestDurationProduct = getProductWithSmallestDuration(steps);
137
-
138
- if (lowestDurationProduct) {
139
- const endTime = next?.endTime
140
- ? DateTime.fromFormat(next?.endTime, TIME_FORMAT)
141
- : // this is to allow user to add 23:00 if end is at 23:59
142
- DateTime.fromFormat("23:59", TIME_FORMAT).plus({ minutes: 1 });
143
-
144
- const latestAvailableTime = getLatestAvailableDateTime(availableTimes);
145
-
146
- const latestAllowedTime = endTime.minus({
147
- minutes: lowestDurationProduct.duration,
148
- });
149
-
150
- if (latestAvailableTime > latestAllowedTime) {
151
- availableTimesFormRef.current.setError("availableTimes", {
152
- message: t("Validation:fieldTimeBefore", {
153
- attribute: t("Design:timeLowercase"),
154
- time: latestAllowedTime.toFormat(TIME_FORMAT),
155
- }),
156
- });
157
-
158
- return;
159
- }
160
- }
161
-
162
129
  const availableTime =
163
130
  availableTimesFormRef?.current?.getValues()?.availableTimes || null;
164
131
 
@@ -261,7 +228,6 @@ export const DateAndRecurrenceInput = ({
261
228
  defaultValues={editState.values}
262
229
  onChange={handleRecurringDateChange}
263
230
  onDelete={handleDelete}
264
- workHours={workHours}
265
231
  >
266
232
  {providerHasBookingManagement && (
267
233
  <AvailableTimesControl
@@ -5,8 +5,9 @@ import { Form, OverlayTrigger, Popover } from "react-bootstrap";
5
5
  import { useFieldArray, useFormContext } from "react-hook-form";
6
6
  import { useTranslation } from "react-i18next";
7
7
  import { useClickAway } from "react-use";
8
- import { UTC_TIMEZONE, TIME_FORMAT } from "@licklist/core/dist/Config/Date";
8
+ import { TIMEZONE } from "@licklist/core/dist/Config/Date";
9
9
  import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
10
+ import { TIME_FORMAT } from "@licklist/core/dist/Config/Date";
10
11
  import { DateTime } from "luxon";
11
12
  import RRule, { Frequency } from "rrule";
12
13
  import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
@@ -26,6 +27,7 @@ import {
26
27
  import { ProductSetRecurrenceOverridesControl } from "./ProductSetRecurrenceOverridesControl";
27
28
  import { MAX_QUANTITY_RECURRENCE_DATE_IN_OVERRIDE } from "../product/constants";
28
29
 
30
+
29
31
  export interface DateAndRecurrenceInputValues {
30
32
  menuRecurrences?: Partial<ProductSetRecurrence>[];
31
33
  }
@@ -136,7 +138,7 @@ export const DateInput = ({
136
138
  until: (start as DateTime).toJSDate(),
137
139
  byweekday: [],
138
140
  freq: Frequency.DAILY,
139
- tzid: UTC_TIMEZONE,
141
+ tzid: TIMEZONE,
140
142
  interval: 1,
141
143
  }).replace("RRULE:", "");
142
144
 
@@ -2,12 +2,12 @@ import { Meta, Story } from "@storybook/react";
2
2
  import React from "react";
3
3
  import Form from "react-bootstrap/Form";
4
4
  import { FormProvider, useForm } from "react-hook-form";
5
- import { OPERATIONAL_COST_CUSTOMER } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
6
5
  import {
7
6
  ProductSetControl,
8
7
  ProductSetControlProps,
9
8
  ProductSetControlValues,
10
9
  } from "./ProductSetControl";
10
+ import { OPERATIONAL_COST_CUSTOMER } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
11
11
 
12
12
  export default {
13
13
  title: "Product Set/Control",
@@ -22,10 +22,14 @@ import { SmsTemplate } from "@licklist/core/dist/DataMapper/Notification/SmsTemp
22
22
  import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
23
23
  import { ruleForUrlWithProtocol } from "@licklist/plugins/dist/validation/Rules/urlRule";
24
24
  import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
25
- import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
26
25
  import { WarningMessage } from "../../static";
27
26
  import { SelectItem } from "../../types/generic/SelectItem";
28
- import { DateAndRecurrenceInput } from "./DateAndRecurrenceInput";
27
+ import {
28
+ DateAndRecurrenceInput,
29
+ // TODO: Show Date Component, when reccurent date bugs are fixed
30
+ // DateAndRecurrenceInput,
31
+ DateAndRecurrenceInputValues,
32
+ } from "./DateAndRecurrenceInput";
29
33
  import TutorialGifCard from "./TutorialGifCard";
30
34
  import { Step } from "../types";
31
35
  import { StepsControl } from "../form/StepsControl";
@@ -49,7 +53,7 @@ export interface TemplateItem {
49
53
  label: string;
50
54
  }
51
55
 
52
- export interface ProductSetControlValues {
56
+ export interface ProductSetControlValues extends DateAndRecurrenceInputValues {
53
57
  name: string;
54
58
  type: ProductSetType;
55
59
  termsAndConditions: string;
@@ -61,7 +65,6 @@ export interface ProductSetControlValues {
61
65
  steps: Step[];
62
66
  emailTemplates?: TemplateItem[];
63
67
  smsTemplates?: TemplateItem[];
64
- menuRecurrences?: Partial<ProductSetRecurrence>[];
65
68
  }
66
69
 
67
70
  export interface ProductSetControlShared {
@@ -82,7 +85,7 @@ export interface ProductSetControlProps {
82
85
  fieldSets?: FieldSet[];
83
86
  showEmailTemplate?: boolean;
84
87
  showSmsTemplate?: boolean;
85
- workHours: WorkHour[] | undefined;
88
+ workHours?: WorkHour[];
86
89
  providerHasBookingManagement?: boolean;
87
90
  isOverrides?: boolean;
88
91
  }
@@ -307,7 +307,7 @@ export function ProductCategoriesControl({
307
307
  title={t("addCategory")}
308
308
  isOverride={isOverrides}
309
309
  onClick={() => {
310
- if (isOverrides) return;
310
+ if (isOverrides) return;
311
311
  setIsSelectCategoryVisible(true);
312
312
  }}
313
313
  />
@@ -63,9 +63,9 @@ Default.args = {
63
63
  sort: 100,
64
64
  type: "standard",
65
65
  updatedAt: "2023-05-08T15:55:28.000+03:00",
66
- defaultDuration: 30,
67
66
  zoneRecurrences: [
68
67
  {
68
+ availableTimes: ["10:05", "10:25", "10:45"],
69
69
  endDate: "2022-02-22",
70
70
  endTime: "22:00:00",
71
71
  id: 1,
@@ -90,6 +90,7 @@ Default.args = {
90
90
  updatedAt: "2023-05-08T15:55:28.000+03:00",
91
91
  zoneRecurrences: [
92
92
  {
93
+ availableTimes: ["10:05", "10:25", "10:45"],
93
94
  endDate: "2022-02-22",
94
95
  endTime: "22:00:00",
95
96
  id: 1,
@@ -26,16 +26,12 @@ import { checkAvailableTimesErrors, getFilteredTemplates } from "../utils";
26
26
  export interface WithIsLoading {
27
27
  isLoading: boolean;
28
28
  }
29
- export interface WithIdOptional {
30
- id?: number;
31
- }
32
-
33
29
  export interface WithId {
34
30
  id: number;
35
31
  }
36
32
  export interface ProductSetFormValues
37
33
  extends FormValues,
38
- WithIdOptional,
34
+ WithId,
39
35
  ProductSetControlValues {
40
36
  steps: Step[];
41
37
  isOverrides?: boolean;
@@ -24,10 +24,8 @@ export const useSortableTreeFunctions = ({
24
24
  const cancelChanges = (index: number) => {
25
25
  if (isOverrides) return;
26
26
  if (!previousValue) {
27
- // eslint-disable-next-line consistent-return
28
27
  return remove(index);
29
28
  }
30
- // eslint-disable-next-line consistent-return
31
29
  return setValue(`${fieldName}.${index}` as const, previousValue);
32
30
  };
33
31