@licklist/design 0.44.486-dev.1 → 0.44.486-dev.11

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 (68) hide show
  1. package/dist/collapsible-input-group/CollapsibleInputGroup.js +1 -1
  2. package/dist/date-time-button/DateTimeButton.js +1 -1
  3. package/dist/iframe/event/event-calendar/EventCalendar.d.ts +5 -3
  4. package/dist/iframe/event/event-calendar/EventCalendar.d.ts.map +1 -1
  5. package/dist/iframe/event/event-calendar/EventCalendar.js +1 -1
  6. package/dist/iframe/event/event-calendar/components/CalendarDate/CalendarDate.d.ts +3 -2
  7. package/dist/iframe/event/event-calendar/components/CalendarDate/CalendarDate.d.ts.map +1 -1
  8. package/dist/iframe/event/event-calendar/components/CalendarDate/CalendarDate.js +1 -1
  9. package/dist/iframe/event/event-calendar/components/CalendarDates/CalendarDates.d.ts +5 -3
  10. package/dist/iframe/event/event-calendar/components/CalendarDates/CalendarDates.d.ts.map +1 -1
  11. package/dist/iframe/event/event-calendar/components/CalendarDates/CalendarDates.js +1 -1
  12. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +1 -1
  13. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
  14. package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
  15. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +1 -0
  16. package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
  17. package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.d.ts +1 -1
  18. package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.d.ts.map +1 -1
  19. package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.js +1 -1
  20. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts +3 -2
  21. package/dist/iframe/order-process/components/utils/useCategoryVerification.d.ts.map +1 -1
  22. package/dist/iframe/order-process/components/utils/useCategoryVerification.js +1 -1
  23. package/dist/iframe/payment/order-items-table/hooks/useTableData.d.ts.map +1 -1
  24. package/dist/iframe/payment/order-items-table/hooks/useTableData.js +1 -1
  25. package/dist/iframe/payment/order-items-table/types/index.d.ts +7 -1
  26. package/dist/iframe/payment/order-items-table/types/index.d.ts.map +1 -1
  27. package/dist/iframe/payment/order-items-table/types/index.js +1 -0
  28. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts +3 -0
  29. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -0
  30. package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +1 -0
  31. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  32. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  33. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
  34. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +1 -1
  35. package/dist/static/CountryCodeSelect.d.ts.map +1 -1
  36. package/dist/static/CountryCodeSelect.js +1 -1
  37. package/dist/styles/iframe-events/Calendar.scss +14 -14
  38. package/dist/styles/iframe-page/PageBody.scss +3 -2
  39. package/dist/styles/resources-blocking/_index.scss +5 -0
  40. package/dist/zone/form/components/AvailableTimesControl.d.ts.map +1 -1
  41. package/dist/zone/form/components/AvailableTimesControl.js +1 -1
  42. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
  43. package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
  44. package/dist/zone/form/utils/dates.d.ts.map +1 -1
  45. package/dist/zone/form/utils/dates.js +1 -1
  46. package/package.json +1 -1
  47. package/src/collapsible-input-group/CollapsibleInputGroup.tsx +1 -1
  48. package/src/date-time-button/DateTimeButton.tsx +1 -1
  49. package/src/iframe/event/event-calendar/EventCalendar.stories.tsx +20 -21
  50. package/src/iframe/event/event-calendar/EventCalendar.tsx +10 -3
  51. package/src/iframe/event/event-calendar/components/CalendarDate/CalendarDate.tsx +10 -2
  52. package/src/iframe/event/event-calendar/components/CalendarDates/CalendarDates.tsx +6 -2
  53. package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +2 -0
  54. package/src/iframe/order-process/components/BookingSummary/types/index.ts +1 -0
  55. package/src/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.tsx +2 -2
  56. package/src/iframe/order-process/components/utils/useCategoryVerification.ts +28 -29
  57. package/src/iframe/payment/order-items-table/hooks/useTableData.tsx +11 -99
  58. package/src/iframe/payment/order-items-table/types/index.ts +18 -1
  59. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +118 -0
  60. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +10 -8
  61. package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +13 -9
  62. package/src/static/CountryCodeSelect.tsx +3 -5
  63. package/src/styles/iframe-events/Calendar.scss +14 -14
  64. package/src/styles/iframe-page/PageBody.scss +3 -2
  65. package/src/styles/resources-blocking/_index.scss +5 -0
  66. package/src/zone/form/components/AvailableTimesControl.tsx +4 -9
  67. package/src/zone/form/components/ZoneRecurrencesControl.tsx +25 -32
  68. package/src/zone/form/utils/dates.ts +29 -36
@@ -59,7 +59,7 @@ export const DateTimeButton = <T extends DateTime | string>({
59
59
  />
60
60
  )}
61
61
 
62
- {price && <div className="price">{price}</div>}
62
+ {price && !isDisabled && <div className="price">{price}</div>}
63
63
 
64
64
  {/* TODO uncomment when adding availability */}
65
65
  {/* {info && (
@@ -1,37 +1,36 @@
1
1
  import React from "react";
2
2
  import { DateTime } from "luxon";
3
3
  import { Meta, Story } from "@storybook/react";
4
- import { boolean } from "@storybook/addon-knobs";
5
- import { EventCalendarProvider } from "@licklist/plugins/dist/context/event/EventCalendarContext";
6
- import { EventCalendar } from "./EventCalendar";
4
+ import {
5
+ EventCalendarProvider,
6
+ getMonthCalendarDates,
7
+ } from "@licklist/plugins/dist/context/event/EventCalendarContext";
8
+ import { EventCalendar, EventCalendarProps } from "./EventCalendar";
7
9
 
8
10
  export default {
9
11
  title: "Iframe/Event/Calendar",
10
12
  component: EventCalendar,
11
13
  } as Meta;
12
14
 
13
- export const Default: Story<any> = (args) => {
14
- const now = DateTime.now().set({
15
- hour: 0,
16
- second: 0,
17
- millisecond: 0,
18
- minute: 0,
19
- });
20
- const disabledDates = [now.minus({ day: 2 }), now, now.plus({ day: 2 })];
21
-
22
- const isLoading = boolean("isLoading", false);
23
-
15
+ export const Default: Story<EventCalendarProps> = (args) => {
24
16
  return (
25
- <EventCalendarProvider>
17
+ <EventCalendarProvider getCalendarDates={getMonthCalendarDates}>
26
18
  <div style={{ backgroundColor: "white" }}>
27
- <EventCalendar
28
- {...args}
29
- disabledDates={disabledDates}
30
- isLoading={isLoading}
31
- />
19
+ <EventCalendar {...args} />
32
20
  </div>
33
21
  </EventCalendarProvider>
34
22
  );
35
23
  };
36
24
 
37
- Default.args = {};
25
+ const now = DateTime.now().set({
26
+ hour: 0,
27
+ second: 0,
28
+ millisecond: 0,
29
+ minute: 0,
30
+ });
31
+
32
+ Default.args = {
33
+ disabledDates: [now.minus({ day: 2 }), now, now.plus({ day: 2 })],
34
+ isLoading: false,
35
+ fromPrice: "from £10",
36
+ };
@@ -1,19 +1,26 @@
1
- import React from "react";
1
+ import React, { ReactElement } from "react";
2
2
  import { CalendarButtons } from "./components/CalendarButtons";
3
3
  import { CalendarDates } from "./components/CalendarDates";
4
4
  import { CalendarBaseProps } from "./types";
5
5
 
6
- export type EventCalendarProps = CalendarBaseProps;
6
+ export type EventCalendarProps = CalendarBaseProps & {
7
+ fromPrice?: string | ReactElement | null;
8
+ };
7
9
 
8
10
  export const EventCalendar = ({
9
11
  disabledDates = [],
10
12
  isLoading = false,
13
+ fromPrice,
11
14
  }: EventCalendarProps) => {
12
15
  return (
13
16
  <div className="calendar-wrapper">
14
17
  <div className="calendar">
15
18
  <CalendarButtons disabledDates={disabledDates} isLoading={isLoading} />
16
- <CalendarDates disabledDates={disabledDates} isLoading={isLoading} />
19
+ <CalendarDates
20
+ disabledDates={disabledDates}
21
+ isLoading={isLoading}
22
+ fromPrice={fromPrice}
23
+ />
17
24
  </div>
18
25
  </div>
19
26
  );
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { ReactElement } from "react";
2
2
  import { Button } from "react-bootstrap";
3
3
  import { DateTime } from "luxon";
4
4
  import clsx from "clsx";
@@ -9,6 +9,7 @@ export type CalendarDateProps = {
9
9
  selectedDate?: DateTime;
10
10
  setSelectedDate: (date: DateTime) => void;
11
11
  isDisabled?: boolean;
12
+ fromPrice?: string | ReactElement | null;
12
13
  };
13
14
 
14
15
  export const CalendarDate = ({
@@ -17,6 +18,7 @@ export const CalendarDate = ({
17
18
  selectedDate,
18
19
  setSelectedDate,
19
20
  isDisabled = false,
21
+ fromPrice,
20
22
  }: CalendarDateProps) => {
21
23
  const onClick = () => {
22
24
  if (isDisabled) return;
@@ -37,7 +39,13 @@ export const CalendarDate = ({
37
39
  )}
38
40
  onClick={onClick}
39
41
  >
40
- {currentDate.day}
42
+ <div>{currentDate.day}</div>
43
+
44
+ {typeof fromPrice === "string" ? (
45
+ <div>{fromPrice}</div>
46
+ ) : (
47
+ <>{fromPrice}</>
48
+ )}
41
49
  </Button>
42
50
  );
43
51
  };
@@ -1,4 +1,4 @@
1
- import React, { useContext, useMemo } from "react";
1
+ import React, { ReactElement, useContext, useMemo } from "react";
2
2
  import { DateTime } from "luxon";
3
3
  import { EventCalendarContext } from "@licklist/plugins/dist/context/event/EventCalendarContext";
4
4
  import { CalendarWeekdays } from "../CalendarWeekdays";
@@ -6,11 +6,14 @@ import { CalendarDate } from "../CalendarDate";
6
6
  import { CalendarBaseProps } from "../../types";
7
7
  import { isSelectedDateDisabled } from "../../utils";
8
8
 
9
- export type CalendarDatesProps = CalendarBaseProps;
9
+ export type CalendarDatesProps = CalendarBaseProps & {
10
+ fromPrice?: string | ReactElement | null;
11
+ };
10
12
 
11
13
  export const CalendarDates = ({
12
14
  disabledDates = [],
13
15
  isLoading = false,
16
+ fromPrice,
14
17
  }: CalendarDatesProps) => {
15
18
  const { calendarDates, initialDate, selectedDate, setSelectedDate } =
16
19
  useContext(EventCalendarContext);
@@ -52,6 +55,7 @@ export const CalendarDates = ({
52
55
  selectedDate={selectedDate}
53
56
  setSelectedDate={setSelectedDate}
54
57
  isDisabled={isDisabled}
58
+ fromPrice={fromPrice}
55
59
  />
56
60
  );
57
61
  })}
@@ -11,6 +11,7 @@ import { BookingSummaryAccordion } from "./components/BookingSummaryAccordion";
11
11
 
12
12
  export const BookingSummary = ({
13
13
  date,
14
+ time,
14
15
  menuSteps,
15
16
  formValues,
16
17
  isNotShownPeopleAmount,
@@ -47,6 +48,7 @@ export const BookingSummary = ({
47
48
  <div className="event-info">
48
49
  <p className="m-0 title event-name">{eventName}</p>
49
50
  <p className="m-0">{date}</p>
51
+ {time && <p className="m-0">{time}</p>}
50
52
  </div>
51
53
  <hr />
52
54
 
@@ -6,6 +6,7 @@ export const ACCORDION_KEY = "booking-summary";
6
6
 
7
7
  export type BookingSummaryProps = {
8
8
  date: string;
9
+ time?: string;
9
10
  menuSteps?: MenuStep[];
10
11
  formValues?: {
11
12
  [key: string]: Order;
@@ -20,8 +20,8 @@ import { Step } from "@licklist/core/dist/DataMapper/Product/StepDataMapper";
20
20
  import { useTranslation } from "react-i18next";
21
21
  import { Product } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
22
22
  import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
23
+ import { MenuStep } from "@licklist/plugins/dist/types/context/sale/menuSteps";
23
24
  import { Category } from "./components/Category";
24
- import { MenuStep } from "../../../../types";
25
25
  import { STEP_FORM_ID } from "../../constants";
26
26
  import { ErrorModal } from "../ErrorModal/ErrorModal";
27
27
  import { PageBody } from "../../../page/components/PageBody";
@@ -117,7 +117,7 @@ export const CalendarStepsForm = forwardRef<
117
117
  );
118
118
  return;
119
119
  }
120
- const categoryError = verifyCategoryItems(values, step);
120
+ const categoryError = verifyCategoryItems(values, step.productCategories);
121
121
 
122
122
  if (categoryError) {
123
123
  setStepFormError(categoryError.message);
@@ -1,5 +1,6 @@
1
+ import { ProductCategory } from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
1
2
  import { useTranslation } from "react-i18next";
2
- import { MenuStep, Order } from "src/types";
3
+ import { Order } from "src/types";
3
4
 
4
5
  interface CategoryError {
5
6
  message: string;
@@ -12,41 +13,39 @@ export const useCategoryVerification = () => {
12
13
 
13
14
  return (
14
15
  values: Record<Order["id"], Order>,
15
- step: MenuStep
16
+ productCategories?: ProductCategory[]
16
17
  ): CategoryError | void => {
17
- let errorMessage;
18
+ let errorMessage: { id: number; message: string } | void;
18
19
 
19
20
  const productArray = Object.values(values).filter(
20
21
  (product) => product?.quantity > 0
21
22
  );
22
23
 
23
- step?.productCategories.forEach(
24
- ({ minSubItems, maxSubItems, id, name }) => {
25
- if (!minSubItems && !maxSubItems) return;
26
-
27
- const categoryProductsQuantity = productArray.filter(
28
- (product) => product?.productsCategoryId === id
29
- ).length;
30
-
31
- if (minSubItems && categoryProductsQuantity < minSubItems) {
32
- const message = t("Validation:fieldMinNumber", {
33
- min: minSubItems,
34
- attribute: `number of products in the ${name} category`,
35
- });
36
- errorMessage = { id, message };
37
-
38
- return;
39
- }
40
-
41
- if (maxSubItems && categoryProductsQuantity > maxSubItems) {
42
- const message = t("Validation:fieldMaxNumber", {
43
- max: maxSubItems,
44
- attribute: `number of products in the ${name} category`,
45
- });
46
- errorMessage = { id, message };
47
- }
24
+ productCategories.forEach(({ minSubItems, maxSubItems, id, name }) => {
25
+ if (!minSubItems && !maxSubItems) return;
26
+
27
+ const categoryProductsQuantity = productArray.filter(
28
+ (product) => product?.productsCategoryId === id
29
+ ).length;
30
+
31
+ if (minSubItems && categoryProductsQuantity < minSubItems) {
32
+ const message = t("Validation:fieldMinNumber", {
33
+ min: minSubItems,
34
+ attribute: `number of products in the ${name} category`,
35
+ });
36
+ errorMessage = { id, message };
37
+
38
+ return;
48
39
  }
49
- );
40
+
41
+ if (maxSubItems && categoryProductsQuantity > maxSubItems) {
42
+ const message = t("Validation:fieldMaxNumber", {
43
+ max: maxSubItems,
44
+ attribute: `number of products in the ${name} category`,
45
+ });
46
+ errorMessage = { id, message };
47
+ }
48
+ });
50
49
 
51
50
  return errorMessage;
52
51
  };
@@ -9,15 +9,9 @@ import {
9
9
  PAYMENT_TYPE_NET_PROFIT,
10
10
  } from "@licklist/core/dist/DataMapper/Order/PaymentDataMapper";
11
11
  import { StaticTableData } from "../../../../table";
12
- import {
13
- getProductQuantityAndPrice,
14
- calculateTotalDiscount,
15
- calculateTotalPrice,
16
- getPaymentValueByType,
17
- getExternalPaymentDetail,
18
- getTotalSumByCategory,
19
- } from "../utils";
12
+ import { getProductQuantityAndPrice, getTotalSumByCategory } from "../utils";
20
13
  import { OrderItemsTableProps, SummaryItem } from "../types";
14
+ import { getOrderSummaryItems } from "../utils/paymentSummary";
21
15
 
22
16
  const CURRENCY_DEFAULT = "GBP";
23
17
  export const PAYMENT_TYPE_TRANSLATE_KEYS = {
@@ -114,9 +108,7 @@ export const useTableData = ({
114
108
  );
115
109
  };
116
110
 
117
- const renderSummaryItems = (
118
- summaryItems: { translateKey: string; price: number }[]
119
- ) => {
111
+ const renderSummaryItems = (summaryItems: SummaryItem[]) => {
120
112
  return summaryItems.map(({ translateKey, price }) => {
121
113
  return {
122
114
  key: uniqueId(`summary-info-${translateKey}`),
@@ -127,93 +119,6 @@ export const useTableData = ({
127
119
  });
128
120
  };
129
121
 
130
- const paymentNotProcessedSummary = () => {
131
- const externalPaymentDetail = paymentDetail
132
- ? getExternalPaymentDetail(paymentDetail)
133
- : undefined;
134
-
135
- const total = calculateTotalPrice(order, externalPaymentDetail);
136
-
137
- const summaryItems: SummaryItem[] = [
138
- {
139
- translateKey: "amountTotal",
140
- price: total,
141
- },
142
- ];
143
-
144
- if (externalDiscount) {
145
- summaryItems.push({
146
- price: externalDiscount,
147
- translateKey: "amountWithDiscount",
148
- });
149
- }
150
-
151
- if (externalPaymentDetail) {
152
- return [...summaryItems, ...getExternalPaymentDetail(paymentDetail)];
153
- }
154
-
155
- return summaryItems;
156
- };
157
-
158
- const processedPaymentSummary = () => {
159
- const externalPaymentDetail =
160
- paymentDetail && !order.payments.length
161
- ? getExternalPaymentDetail(paymentDetail)
162
- : Object.keys(PAYMENT_TYPE_TRANSLATE_KEYS).map((key) => {
163
- return {
164
- translateKey: PAYMENT_TYPE_TRANSLATE_KEYS[key],
165
- price: getPaymentValueByType(order.payments, key),
166
- };
167
- });
168
-
169
- const total = calculateTotalPrice(order, externalPaymentDetail);
170
-
171
- const totalDiscount = calculateTotalDiscount(order.payments);
172
- const totalWithDiscount = total - Number(totalDiscount);
173
- let summaryItems: SummaryItem[] = [
174
- {
175
- translateKey: "amountTotal",
176
- price: total,
177
- },
178
- ];
179
-
180
- if (totalDiscount) {
181
- summaryItems.push({
182
- translateKey: "amountWithDiscount",
183
- price: totalWithDiscount < 0 ? 0 : totalWithDiscount,
184
- });
185
- }
186
-
187
- if (paymentDetail && !order.payments.length) {
188
- return [...summaryItems, ...externalPaymentDetail];
189
- }
190
-
191
- summaryItems.push({
192
- translateKey: "totalPaid",
193
- price: totalWithDiscount <= 0 ? 0 : order.totalAmount,
194
- });
195
- if (totalWithDiscount <= 0) {
196
- return summaryItems;
197
- }
198
- summaryItems = [...summaryItems, ...externalPaymentDetail];
199
-
200
- if (totalWithDiscount > order.totalAmount) {
201
- summaryItems.push({
202
- translateKey: "remainingToPay",
203
- price: totalWithDiscount - order.totalAmount,
204
- });
205
- }
206
- return summaryItems;
207
- };
208
-
209
- const getOrderSummaryItems = () => {
210
- if (!isPaymentProcessed) {
211
- return paymentNotProcessedSummary();
212
- }
213
-
214
- return processedPaymentSummary();
215
- };
216
-
217
122
  const data = useMemo(
218
123
  () => {
219
124
  if (!order) {
@@ -222,7 +127,14 @@ export const useTableData = ({
222
127
 
223
128
  return [
224
129
  ...renderProductsContent(),
225
- ...renderSummaryItems(getOrderSummaryItems()),
130
+ ...renderSummaryItems(
131
+ getOrderSummaryItems({
132
+ order,
133
+ paymentDetail,
134
+ isPaymentProcessed,
135
+ externalDiscount,
136
+ })
137
+ ),
226
138
  ];
227
139
  },
228
140
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1,7 +1,24 @@
1
1
  import { Order } from "@licklist/core/dist/DataMapper/Order/OrderDataMapper";
2
2
  import { PaymentDetail } from "@licklist/core/dist/DataMapper/Order/PaymentDetailDataMapper";
3
3
 
4
- export type SummaryItem = { translateKey: string; price: number };
4
+ export const AMOUNT_TOTAL = "amountTotal";
5
+ export const AMOUNT_WITH_DISCOUNT = "amountWithDiscount";
6
+ export const TOTAL_PAID = "totalPaid";
7
+ export const REMAINING_TO_PAY = "remainingToPay";
8
+
9
+ export const SUMMARY_TRANSLATE_KEYS = [
10
+ AMOUNT_TOTAL,
11
+ AMOUNT_WITH_DISCOUNT,
12
+ TOTAL_PAID,
13
+ REMAINING_TO_PAY,
14
+ ];
15
+
16
+ export type SUMMARY_TRANSLATE_KEY = typeof SUMMARY_TRANSLATE_KEYS[number];
17
+
18
+ export type SummaryItem = {
19
+ translateKey: SUMMARY_TRANSLATE_KEY;
20
+ price: number;
21
+ };
5
22
 
6
23
  export type OrderItemsTableProps = {
7
24
  order?: Order;
@@ -0,0 +1,118 @@
1
+ import { PAYMENT_TYPE_TRANSLATE_KEYS } from "../hooks/useTableData";
2
+ import {
3
+ AMOUNT_TOTAL,
4
+ AMOUNT_WITH_DISCOUNT,
5
+ OrderItemsTableProps,
6
+ REMAINING_TO_PAY,
7
+ SummaryItem,
8
+ TOTAL_PAID,
9
+ } from "../types";
10
+ import {
11
+ calculateTotalDiscount,
12
+ calculateTotalPrice,
13
+ getExternalPaymentDetail,
14
+ getPaymentValueByType,
15
+ } from "./index";
16
+
17
+ const paymentNotProcessedSummary = ({
18
+ order,
19
+ externalDiscount,
20
+ paymentDetail,
21
+ }: OrderItemsTableProps) => {
22
+ const externalPaymentDetail = paymentDetail
23
+ ? getExternalPaymentDetail(paymentDetail)
24
+ : undefined;
25
+
26
+ const total = calculateTotalPrice(order, externalPaymentDetail);
27
+
28
+ const summaryItems: SummaryItem[] = [
29
+ {
30
+ translateKey: AMOUNT_TOTAL,
31
+ price: total,
32
+ },
33
+ ];
34
+
35
+ if (externalDiscount) {
36
+ summaryItems.push({
37
+ price: externalDiscount,
38
+ translateKey: AMOUNT_WITH_DISCOUNT,
39
+ });
40
+ }
41
+
42
+ if (externalPaymentDetail) {
43
+ return [...summaryItems, ...getExternalPaymentDetail(paymentDetail)];
44
+ }
45
+
46
+ return summaryItems;
47
+ };
48
+
49
+ const processedPaymentSummary = ({
50
+ order,
51
+ paymentDetail,
52
+ }: OrderItemsTableProps) => {
53
+ const externalPaymentDetail =
54
+ paymentDetail && !order.payments.length
55
+ ? getExternalPaymentDetail(paymentDetail)
56
+ : Object.keys(PAYMENT_TYPE_TRANSLATE_KEYS).map((key) => {
57
+ return {
58
+ translateKey: PAYMENT_TYPE_TRANSLATE_KEYS[key],
59
+ price: getPaymentValueByType(order.payments, key),
60
+ };
61
+ });
62
+
63
+ const total = calculateTotalPrice(order, externalPaymentDetail);
64
+
65
+ const totalDiscount = calculateTotalDiscount(order.payments);
66
+ const totalWithDiscount = total - Number(totalDiscount);
67
+ let summaryItems: SummaryItem[] = [
68
+ {
69
+ translateKey: AMOUNT_TOTAL,
70
+ price: total,
71
+ },
72
+ ];
73
+
74
+ if (totalDiscount) {
75
+ summaryItems.push({
76
+ translateKey: AMOUNT_WITH_DISCOUNT,
77
+ price: totalWithDiscount < 0 ? 0 : totalWithDiscount,
78
+ });
79
+ }
80
+
81
+ if (paymentDetail && !order.payments.length) {
82
+ return [...summaryItems, ...externalPaymentDetail];
83
+ }
84
+
85
+ summaryItems.push({
86
+ translateKey: TOTAL_PAID,
87
+ price: totalWithDiscount <= 0 ? 0 : order.totalAmount,
88
+ });
89
+ if (totalWithDiscount <= 0) {
90
+ return summaryItems;
91
+ }
92
+ summaryItems = [...summaryItems, ...externalPaymentDetail];
93
+
94
+ if (totalWithDiscount > order.totalAmount) {
95
+ summaryItems.push({
96
+ translateKey: REMAINING_TO_PAY,
97
+ price: totalWithDiscount - order.totalAmount,
98
+ });
99
+ }
100
+ return summaryItems;
101
+ };
102
+
103
+ export const getOrderSummaryItems = ({
104
+ order,
105
+ externalDiscount,
106
+ paymentDetail,
107
+ isPaymentProcessed,
108
+ }: OrderItemsTableProps): SummaryItem[] => {
109
+ if (!isPaymentProcessed) {
110
+ return paymentNotProcessedSummary({
111
+ order,
112
+ externalDiscount,
113
+ paymentDetail,
114
+ });
115
+ }
116
+
117
+ return processedPaymentSummary({ order, paymentDetail });
118
+ };
@@ -3,7 +3,7 @@ import React from "react";
3
3
  import { Col, Row } from "react-bootstrap";
4
4
  import { useFormContext } from "react-hook-form";
5
5
  import { useTranslation } from "react-i18next";
6
- import { useIntl } from "react-intl";
6
+ import { TIME_FORMAT } from "@licklist/core/dist/Config";
7
7
  import { WorkingHoursInputValues } from ".";
8
8
  import { useWeekdays } from "./utils";
9
9
 
@@ -12,7 +12,9 @@ export function WorkingHoursInputDescription() {
12
12
  const values = watch("workingHours");
13
13
  const weekdays = useWeekdays("short");
14
14
  const { t } = useTranslation("Design");
15
- const { formatTime } = useIntl();
15
+
16
+ if (!values) return null;
17
+
16
18
  return (
17
19
  <>
18
20
  {Array.from({ length: weekdays.length }, (_, i) => i)
@@ -26,16 +28,16 @@ export function WorkingHoursInputDescription() {
26
28
  {weekday?.end
27
29
  ? weekday.start
28
30
  ? t("timeInterval", {
29
- start: formatTime(
30
- DateTime.fromISO(weekday.start).toJSDate()
31
+ start: DateTime.fromISO(weekday.start).toFormat(
32
+ TIME_FORMAT
31
33
  ),
32
- end: formatTime(
33
- DateTime.fromISO(weekday.end).toJSDate()
34
+ end: DateTime.fromISO(weekday.start).toFormat(
35
+ TIME_FORMAT
34
36
  ),
35
37
  })
36
38
  : t("timeFrom", {
37
- start: formatTime(
38
- DateTime.fromISO(weekday.start).toJSDate()
39
+ start: DateTime.fromISO(weekday.start).toFormat(
40
+ TIME_FORMAT
39
41
  ),
40
42
  })
41
43
  : null}
@@ -3,7 +3,7 @@ import { DateTime } from "luxon";
3
3
  import { Col, Form, Row } from "react-bootstrap";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import { useFormContext } from "react-hook-form";
6
- import { DATE_FORMAT, TIME_FORMAT } from "@licklist/core/dist/Config";
6
+ import { DATE_FORMAT } from "@licklist/core/dist/Config";
7
7
  import { RecurringDatePickerInputValues } from "./RecurringDatePickerInput";
8
8
 
9
9
  interface RecurrenceIntervalAndFrequencyInputProps {
@@ -30,6 +30,7 @@ function RecurrenceIntervalAndFrequencyInput({
30
30
  formState: { errors },
31
31
  register,
32
32
  trigger,
33
+ setValue,
33
34
  } = useFormContext<RecurringDatePickerInputValues>();
34
35
 
35
36
  const startDate = getValues("startDate");
@@ -109,7 +110,7 @@ function RecurrenceIntervalAndFrequencyInput({
109
110
  </Col>
110
111
  </Row>
111
112
 
112
- <Row className="align-items-center">
113
+ <Row>
113
114
  <Col xs={12} sm={6}>
114
115
  <Form.Group>
115
116
  <Form.Label>
@@ -118,6 +119,9 @@ function RecurrenceIntervalAndFrequencyInput({
118
119
  <Form.Control
119
120
  type="time"
120
121
  {...register("startTime", { required: false })}
122
+ onChange={({ target: { value } }) => {
123
+ setValue("startTime", `${value}:00`);
124
+ }}
121
125
  placeholder="hh:mm"
122
126
  defaultValue={startTime}
123
127
  disabled={disabled}
@@ -137,14 +141,11 @@ function RecurrenceIntervalAndFrequencyInput({
137
141
  if (!startTime || !time) {
138
142
  return true;
139
143
  }
140
- const currentStartTime = DateTime.fromFormat(
141
- startTime,
142
- TIME_FORMAT
143
- );
144
- const currentEndTime = DateTime.fromFormat(time, TIME_FORMAT);
144
+ const currentStartTime = DateTime.fromISO(startTime);
145
+ const currentEndTime = DateTime.fromISO(time);
145
146
 
146
- return currentEndTime.diff(currentStartTime, ["minutes"])
147
- .minutes > 0
147
+ return currentEndTime?.diff(currentStartTime, ["seconds"])
148
+ ?.seconds > 0
148
149
  ? true
149
150
  : `${t(`Validation:fieldLaterDate`, {
150
151
  attribute: t("Design:endTimeSmall"),
@@ -152,6 +153,9 @@ function RecurrenceIntervalAndFrequencyInput({
152
153
  })}`;
153
154
  },
154
155
  })}
156
+ onChange={({ target: { value } }) => {
157
+ setValue("endTime", `${value}:59`, { shouldValidate: true });
158
+ }}
155
159
  placeholder="hh:mm"
156
160
  defaultValue={endTime}
157
161
  disabled={disabled}