@licklist/design 0.58.6-dev.9 → 0.58.7
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.
- package/bitbucket-pipelines.yml +8 -0
- package/dist/assets/iframe/calendar.svg +2 -2
- package/dist/assets/iframe/calendar.svg.js +1 -1
- package/dist/assets/iframe/ticket.svg +2 -2
- package/dist/assets/iframe/ticket.svg.js +1 -1
- package/dist/calendar/Calendar.d.ts +1 -1
- package/dist/calendar/Calendar.d.ts.map +1 -1
- package/dist/calendar/Calendar.js +1 -1
- package/dist/calendar/components/CalendarButtons/CalendarButtons.js +1 -1
- package/dist/calendar/components/CalendarDates/CalendarDates.d.ts +2 -2
- package/dist/calendar/components/CalendarDates/CalendarDates.d.ts.map +1 -1
- package/dist/calendar/components/CalendarDates/CalendarDates.js +1 -1
- package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +1 -1
- package/dist/events/event-statistic-modal/EventStatisticModal.js +1 -1
- package/dist/iframe/event/event-card/IframeEventCard.d.ts +1 -2
- package/dist/iframe/event/event-card/IframeEventCard.d.ts.map +1 -1
- package/dist/iframe/event/event-card/IframeEventCard.js +1 -1
- package/dist/iframe/event/event-venue-map/IframeEventVenueMap.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts +2 -2
- package/dist/iframe/order-process/components/BookingSummary/BookingSummary.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/BookingSummary.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.d.ts +2 -4
- package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.d.ts +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.d.ts +2 -4
- package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.d.ts.map +1 -1
- package/dist/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.js +1 -1
- package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts +0 -4
- package/dist/iframe/order-process/components/BookingSummary/types/index.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.js +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +1 -1
- package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.d.ts.map +1 -1
- package/dist/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.js +1 -1
- package/dist/iframe/page/components/PageBody/constants.d.ts +0 -1
- package/dist/iframe/page/components/PageBody/constants.d.ts.map +1 -1
- package/dist/iframe/page/components/PageBody/constants.js +1 -1
- package/dist/iframe/page/components/PageBody/hooks/useResizePageBody.d.ts.map +1 -1
- package/dist/iframe/page/components/PageBody/hooks/useResizePageBody.js +1 -1
- package/dist/iframe/payment/order-items-table/OrderItemsTable.js +1 -1
- package/dist/iframe/payment/order-items-table/utils/paymentSummary.js +1 -1
- package/dist/iframe/payment/payment-form/PaymentForm.js +1 -1
- package/dist/iframe/payment/payment-page/PaymentPage.d.ts.map +1 -1
- package/dist/iframe/payment/payment-page/PaymentPage.js +1 -1
- package/dist/iframe/payment/payment-page/PaymentTimer.js +1 -1
- package/dist/iframe/payment/payment-status-page/PaymentStatusPage.js +1 -1
- package/dist/iframe/ryft/RyftPaymentForm.d.ts.map +1 -1
- package/dist/iframe/ryft/RyftPaymentForm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/product-set/card/ProductSetCard.d.ts +1 -2
- package/dist/product-set/card/ProductSetCard.d.ts.map +1 -1
- package/dist/product-set/card/ProductSetCard.js +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts +1 -2
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +1 -1
- package/dist/product-set/control/TutorialGifCard.d.ts +1 -2
- package/dist/product-set/control/TutorialGifCard.d.ts.map +1 -1
- package/dist/product-set/control/TutorialGifCard.js +1 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts +1 -2
- package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductCategoriesControl.js +1 -1
- package/dist/product-set/form/ProductSetForm.d.ts +2 -7
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +1 -1
- package/dist/product-set/form/ProductsControl.d.ts +1 -2
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +1 -1
- package/dist/product-set/form/StepsControl.d.ts +1 -2
- package/dist/product-set/form/StepsControl.d.ts.map +1 -1
- package/dist/product-set/form/StepsControl.js +1 -1
- package/dist/product-set/form/SubProductsControl.d.ts +1 -2
- package/dist/product-set/form/SubProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/SubProductsControl.js +1 -1
- package/dist/product-set/form/VenueMapsControl.js +1 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.d.ts +1 -2
- package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.js +1 -1
- package/dist/product-set/item/CreateProductSetItem.d.ts +1 -2
- package/dist/product-set/item/CreateProductSetItem.d.ts.map +1 -1
- package/dist/product-set/item/CreateProductSetItem.js +1 -1
- package/dist/product-set/product/ProductControl.d.ts +1 -3
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts +2 -4
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +1 -1
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.js +1 -1
- package/dist/product-set/product/quantity/ProductQuantityControl.d.ts +0 -1
- package/dist/product-set/product/quantity/ProductQuantityControl.d.ts.map +1 -1
- package/dist/product-set/product/quantity/ProductQuantityControl.js +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.d.ts +1 -3
- package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.js +1 -1
- package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
- package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +0 -2
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
- package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
- package/dist/sales/booking/results/components/ResultCard.js +1 -1
- package/dist/sales/notes/NotesTableRow.js +1 -1
- package/dist/setting/dashboard/snippets/card/SnippetCard.js +1 -1
- package/dist/snippet/snippet-template/control/PropertyControl.d.ts +1 -3
- package/dist/snippet/snippet-template/control/PropertyControl.d.ts.map +1 -1
- package/dist/snippet/snippet-template/control/PropertyControl.js +1 -1
- package/dist/snippet/snippet-template/preview/Preview.js +1 -1
- package/dist/sortable-list/SortableList.d.ts +1 -2
- package/dist/sortable-list/SortableList.d.ts.map +1 -1
- package/dist/sortable-list/SortableList.js +1 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts +1 -3
- package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.js +1 -1
- package/dist/static/manual-date-picker/ManualDatePicker.js +1 -1
- package/dist/static/manual-date-picker/constants/index.d.ts +1 -4
- package/dist/static/manual-date-picker/constants/index.d.ts.map +1 -1
- package/dist/static/manual-date-picker/constants/index.js +1 -1
- package/dist/static/manual-date-picker/utils/index.d.ts +0 -4
- package/dist/static/manual-date-picker/utils/index.d.ts.map +1 -1
- package/dist/static/manual-date-picker/utils/index.js +1 -1
- package/dist/striped-static-table/StripedStaticTable.js +1 -1
- package/dist/styles/iframe-events/Card.scss +8 -24
- package/dist/styles/iframe-events/PoweredBy.scss +2 -2
- package/dist/styles/iframe-order-process/IframeOrderProcess.scss +20 -57
- package/dist/styles/iframe-page/Page.scss +0 -1
- package/dist/styles/iframe-page/PageBody.scss +12 -34
- package/dist/styles/iframe-page/PageHeader.scss +39 -41
- package/dist/styles/product-set/EditVenueMapSetModal.scss +1 -1
- package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +2 -125
- package/dist/styles/sales/BookingResults.scss +1 -1
- package/dist/venue-map-sets/form/components/VenueMapImageControl.js +1 -1
- package/jest.config.js +29 -0
- package/package.json +35 -10
- package/src/assets/iframe/calendar.svg +2 -2
- package/src/assets/iframe/ticket.svg +2 -2
- package/src/calendar/Calendar.stories.tsx +0 -23
- package/src/calendar/Calendar.tsx +5 -5
- package/src/calendar/components/CalendarDates/CalendarDates.tsx +5 -0
- package/src/iframe/event/event-card/IframeEventCard.stories.tsx +0 -1
- package/src/iframe/event/event-card/IframeEventCard.tsx +8 -7
- package/src/iframe/order-process/components/BookingSummary/BookingSummary.stories.tsx +0 -9
- package/src/iframe/order-process/components/BookingSummary/BookingSummary.tsx +7 -58
- package/src/iframe/order-process/components/BookingSummary/components/BookingSummaryAccordion/BookingSummaryAccordion.tsx +0 -8
- package/src/iframe/order-process/components/BookingSummary/components/SummaryTotal/components/SummaryTotalBlock.tsx +4 -4
- package/src/iframe/order-process/components/BookingSummary/components/ToggleHeader/ToggleHeader.tsx +10 -63
- package/src/iframe/order-process/components/BookingSummary/types/index.ts +0 -4
- package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +1 -1
- package/src/iframe/page/components/PageBody/components/LeftBlock/LeftBlock.tsx +1 -3
- package/src/iframe/page/components/PageBody/constants.ts +0 -2
- package/src/iframe/page/components/PageBody/hooks/useResizePageBody.ts +0 -10
- package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +6 -6
- package/src/iframe/payment/payment-page/PaymentPage.stories.tsx +6 -546
- package/src/iframe/payment/payment-page/PaymentPage.tsx +29 -38
- package/src/iframe/ryft/RyftPaymentForm.tsx +5 -11
- package/src/product-set/card/ProductSetCard.tsx +1 -12
- package/src/product-set/control/ProductSetControl.tsx +24 -46
- package/src/product-set/control/TutorialGifCard.tsx +3 -11
- package/src/product-set/form/ProductCategoriesControl.tsx +1 -12
- package/src/product-set/form/ProductSetForm.tsx +1 -10
- package/src/product-set/form/ProductsControl.tsx +0 -10
- package/src/product-set/form/StepsControl.tsx +2 -8
- package/src/product-set/form/SubProductsControl.tsx +0 -3
- package/src/product-set/hooks/useSortableTreeFunctions.ts +0 -6
- package/src/product-set/item/CreateProductSetItem.tsx +0 -3
- package/src/product-set/product/ProductControl.tsx +15 -48
- package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +2 -8
- package/src/product-set/product/quantity/ProductQuantityControl.tsx +3 -4
- package/src/product-set/product-category/ProductCategoryControl.tsx +50 -116
- package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +18 -4
- package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +1 -4
- package/src/sales/booking/results/BookingResults.stories.tsx +2 -3
- package/src/sales/booking/results/components/ResultCard.tsx +5 -2
- package/src/snippet/snippet-template/control/PropertyControl.tsx +2 -6
- package/src/sortable-list/SortableList.tsx +0 -3
- package/src/sortable-tree/SortableTreeItem.tsx +0 -6
- package/src/static/manual-date-picker/ManualDatePicker.tsx +3 -3
- package/src/static/manual-date-picker/constants/index.ts +2 -6
- package/src/static/manual-date-picker/utils/index.ts +0 -11
- package/src/static/switch/BooleanSwitch.tsx +1 -1
- package/src/styles/iframe-events/Card.scss +8 -24
- package/src/styles/iframe-events/PoweredBy.scss +2 -2
- package/src/styles/iframe-order-process/IframeOrderProcess.scss +20 -57
- package/src/styles/iframe-page/Page.scss +0 -1
- package/src/styles/iframe-page/PageBody.scss +12 -34
- package/src/styles/iframe-page/PageHeader.scss +39 -41
- package/src/styles/product-set/EditVenueMapSetModal.scss +1 -1
- package/src/styles/ryft-payment-form/RyftPaymentForm.scss +2 -125
- package/src/styles/sales/BookingResults.scss +1 -1
- package/tests/Auth/Authorizer.test.tsx +194 -0
- package/tests/Auth/Layout/UserNavDropDown.test.tsx +43 -0
- package/tests/Auth/Layout/UserNavDropDownToggle.test.tsx +33 -0
- package/tests/Auth/Login/LoginComponent.test.tsx +246 -0
- package/tests/Auth/Login/LoginFormComponent.test.tsx +182 -0
- package/tests/Auth/Register/RegisterComponent.test.tsx +285 -0
- package/tests/Auth/Register/RegisterFormComponent.test.tsx +170 -0
- package/tests/Auth/Settings/Dashboard/IpInput.test.tsx +130 -0
- package/tests/Auth/Social/SocialCallbackComponent.test.tsx +133 -0
- package/tests/Auth/Social/SocialFormComponent.test.tsx +118 -0
- package/tests/FileUpload/FileUpload.test.tsx +42 -0
- package/tests/Notification/EmailTemplate.test.tsx +82 -0
- package/tests/ProductSet/ProductSetPopover.test.tsx +40 -0
- package/tests/Report/Report.test.tsx +48 -0
- package/tests/Sales/Coupon.test.tsx +51 -0
- package/tests/Sales/SalesAndVIews.test.tsx +63 -0
- package/tests/SnippetTemplates/SnippetTemplates.test.tsx +56 -0
- package/tests/Table/FilterHelperComponent.test.tsx +88 -0
- package/tests/Table/PaginationHelperComponent.test.tsx +109 -0
- package/tests/Table/PerPageHelperComponent.test.tsx +34 -0
- package/tests/Table/TableHelperComponent.test.tsx +295 -0
- package/tests/TipTapEditor/TipTapEditor.test.tsx +28 -0
- package/tests/__mock__/hooks/useAuthApi.ts +13 -0
- package/tests/__mock__/hooks/useAuthMock.ts +13 -0
- package/tests/__mock__/hooks/useFormMock.ts +27 -0
- package/tests/__mock__/hooks/useNotificationMock.ts +13 -0
- package/tests/__mock__/hooks/useQueryMock.ts +16 -0
- package/tests/__mock__/hooks/useSocialApiMock.ts +20 -0
- package/tests/__mock__/hooks/useTranslationMock.ts +17 -0
- package/tests/__mock__/hooks/useUserApiMock.ts +18 -0
- package/tests/__mock__/hooks/useUserMock.ts +13 -0
- package/tests/__mock__/styleMock.js +1 -0
- package/tests/__mock__/windowMock.ts +5 -0
- package/tests/packages/react-query.tsx +28 -0
- package/tests/setupTests.ts +10 -0
- package/dist/iframe/ryft/utils/ryft-form.d.ts +0 -5
- package/dist/iframe/ryft/utils/ryft-form.d.ts.map +0 -1
- package/dist/iframe/ryft/utils/ryft-form.js +0 -1
- package/dist/product-set/control/DateInput.d.ts +0 -17
- package/dist/product-set/control/DateInput.d.ts.map +0 -1
- package/dist/product-set/control/DateInput.js +0 -1
- package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts +0 -11
- package/dist/product-set/control/ProductSetRecurrenceOverridesControl.d.ts.map +0 -1
- package/dist/product-set/control/ProductSetRecurrenceOverridesControl.js +0 -1
- package/dist/recurring-date-picker-input/DatePickerInput.d.ts +0 -19
- package/dist/recurring-date-picker-input/DatePickerInput.d.ts.map +0 -1
- package/dist/recurring-date-picker-input/DatePickerInput.js +0 -1
- package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts +0 -15
- package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.d.ts.map +0 -1
- package/dist/recurring-date-picker-input/RecurrenceAndFrequencyInput.js +0 -1
- package/src/iframe/ryft/utils/ryft-form.ts +0 -47
- package/src/product-set/control/DateInput.tsx +0 -313
- package/src/product-set/control/ProductSetRecurrenceOverridesControl.tsx +0 -63
- package/src/recurring-date-picker-input/DatePickerInput.tsx +0 -93
- package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +0 -136
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { useEffect,
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
3
|
import { useForm } from "react-hook-form";
|
|
4
|
+
import Form from "react-bootstrap/Form";
|
|
4
5
|
|
|
5
6
|
import Button from "react-bootstrap/Button";
|
|
6
7
|
import { useHistory } from "react-router-dom";
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
AttemptPaymentResponse,
|
|
14
15
|
} from "@licklist/plugins/dist/hooks/Ryft/useRyftPayment";
|
|
15
16
|
import { BlockLoader, ButtonLoader } from "../../static";
|
|
16
|
-
import { injectComponentsInRyftForm } from "./utils/ryft-form";
|
|
17
17
|
|
|
18
18
|
export const ryftErrorMap: Record<string, string> = {
|
|
19
19
|
insufficient_funds: "insufficientFunds",
|
|
@@ -50,7 +50,6 @@ export const RyftPaymentForm = ({
|
|
|
50
50
|
onSubmit,
|
|
51
51
|
}: RyftPaymentFormProps) => {
|
|
52
52
|
const { t } = useTranslation(["Design", "Validation", "Ryft"]);
|
|
53
|
-
const formRef = useRef<HTMLFormElement | null>(null);
|
|
54
53
|
const history = useHistory();
|
|
55
54
|
|
|
56
55
|
const [isValid, setIsValid] = useState(false);
|
|
@@ -118,12 +117,6 @@ export const RyftPaymentForm = ({
|
|
|
118
117
|
}
|
|
119
118
|
};
|
|
120
119
|
|
|
121
|
-
useEffect(
|
|
122
|
-
() => injectComponentsInRyftForm({ t }),
|
|
123
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
-
[formRef.current?.childNodes?.length]
|
|
125
|
-
);
|
|
126
|
-
|
|
127
120
|
useEffect(() => {
|
|
128
121
|
if (!accountId.data || accountId.isError) return;
|
|
129
122
|
|
|
@@ -182,14 +175,15 @@ export const RyftPaymentForm = ({
|
|
|
182
175
|
|
|
183
176
|
return (
|
|
184
177
|
<>
|
|
178
|
+
<Form.Label>{t("Design:paymentDetails")}</Form.Label>
|
|
179
|
+
{/* For unknown reasons ryft doesn't work with bootstrap form */}
|
|
185
180
|
<form
|
|
186
|
-
ref={formRef}
|
|
187
181
|
id="ryft-pay-form"
|
|
188
182
|
noValidate
|
|
189
183
|
onSubmit={methods.handleSubmit(handleSubmit)}
|
|
190
184
|
className="ryft-payment-form"
|
|
191
185
|
>
|
|
192
|
-
<div className="submit-button-wrapper mt-
|
|
186
|
+
<div className="submit-button-wrapper mt-3 p-1">
|
|
193
187
|
<Button type="submit" disabled={isBtnDisabled || !isValid}>
|
|
194
188
|
{isBtnDisabled && <ButtonLoader />}
|
|
195
189
|
{t("Design:buyNow")}
|
|
@@ -18,7 +18,6 @@ export interface ProductSetCardProps extends HasPermissionProp {
|
|
|
18
18
|
onCopy: () => void;
|
|
19
19
|
onRemove: () => void;
|
|
20
20
|
className?: string;
|
|
21
|
-
override?: number;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export function ProductSetCard({
|
|
@@ -29,7 +28,6 @@ export function ProductSetCard({
|
|
|
29
28
|
onRemove,
|
|
30
29
|
className = "",
|
|
31
30
|
hasPermission = true,
|
|
32
|
-
override = 0,
|
|
33
31
|
}: ProductSetCardProps) {
|
|
34
32
|
const { t } = useTranslation("Design");
|
|
35
33
|
const popoverId = useId();
|
|
@@ -46,16 +44,7 @@ export function ProductSetCard({
|
|
|
46
44
|
>
|
|
47
45
|
<div className={productSetCardClasses}>
|
|
48
46
|
<div className="product-set-card-link">
|
|
49
|
-
|
|
50
|
-
<div>
|
|
51
|
-
{name} {rrule && `(${RRule.fromString(rrule).toText()})`}
|
|
52
|
-
</div>
|
|
53
|
-
{!!override && (
|
|
54
|
-
<div className="h6 bold ml-1">
|
|
55
|
-
{`${override} ${t(override > 1 ? "overrides" : "override")}`}
|
|
56
|
-
</div>
|
|
57
|
-
)}
|
|
58
|
-
</div>
|
|
47
|
+
{name} {rrule && `(${RRule.fromString(rrule).toText()})`}
|
|
59
48
|
</div>
|
|
60
49
|
<div className="d-flex">
|
|
61
50
|
<div className="product-set-card-menu-eye-container">
|
|
@@ -34,7 +34,6 @@ import TutorialGifCard from "./TutorialGifCard";
|
|
|
34
34
|
import { Step } from "../types";
|
|
35
35
|
import { StepsControl } from "../form/StepsControl";
|
|
36
36
|
import { Typeahead } from "../../typeahead";
|
|
37
|
-
import { DateInput } from "./DateInput";
|
|
38
37
|
|
|
39
38
|
const OPERATIONAL_COST_TITLES = {
|
|
40
39
|
[OPERATIONAL_COST_PROVIDER]: "operationalCostProvider",
|
|
@@ -87,7 +86,6 @@ export interface ProductSetControlProps {
|
|
|
87
86
|
showSmsTemplate?: boolean;
|
|
88
87
|
workHours?: WorkHour[];
|
|
89
88
|
providerHasBookingManagement?: boolean;
|
|
90
|
-
isOverrides?: boolean;
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
export function ProductSetControl({
|
|
@@ -103,7 +101,6 @@ export function ProductSetControl({
|
|
|
103
101
|
showSmsTemplate,
|
|
104
102
|
workHours,
|
|
105
103
|
providerHasBookingManagement = false,
|
|
106
|
-
isOverrides = false,
|
|
107
104
|
}: ProductSetControlProps) {
|
|
108
105
|
const { t } = useTranslation(["Design", "Validation", "Notification"]);
|
|
109
106
|
const {
|
|
@@ -121,9 +118,6 @@ export function ProductSetControl({
|
|
|
121
118
|
const termsAndConditionsId = useId();
|
|
122
119
|
const relyOnPeopleTypeId = useId();
|
|
123
120
|
|
|
124
|
-
const showSmsTemplateSelector = showSmsTemplate && !isOverrides;
|
|
125
|
-
const showEmailTemplateSelector = showEmailTemplate && !isOverrides;
|
|
126
|
-
|
|
127
121
|
return (
|
|
128
122
|
<Row
|
|
129
123
|
className={`product-set-form ${
|
|
@@ -165,30 +159,20 @@ export function ProductSetControl({
|
|
|
165
159
|
</Form.Control.Feedback>
|
|
166
160
|
</Form.Group>
|
|
167
161
|
|
|
168
|
-
{
|
|
169
|
-
<
|
|
162
|
+
{isCreateAction && (
|
|
163
|
+
<DateAndRecurrenceInput
|
|
164
|
+
isEventEditProductSet={isEventEditProductSet}
|
|
170
165
|
workHours={workHours}
|
|
171
166
|
isLoading={isLoading}
|
|
172
167
|
providerHasBookingManagement={providerHasBookingManagement}
|
|
173
168
|
/>
|
|
174
|
-
) : (
|
|
175
|
-
<>
|
|
176
|
-
{isCreateAction && (
|
|
177
|
-
<DateAndRecurrenceInput
|
|
178
|
-
isEventEditProductSet={isEventEditProductSet}
|
|
179
|
-
workHours={workHours}
|
|
180
|
-
isLoading={isLoading}
|
|
181
|
-
providerHasBookingManagement={providerHasBookingManagement}
|
|
182
|
-
/>
|
|
183
|
-
)}
|
|
184
|
-
</>
|
|
185
169
|
)}
|
|
186
170
|
|
|
187
171
|
<div className="divider" />
|
|
188
172
|
|
|
189
|
-
<TutorialGifCard
|
|
173
|
+
<TutorialGifCard />
|
|
190
174
|
|
|
191
|
-
<StepsControl isLoading={isLoading}
|
|
175
|
+
<StepsControl isLoading={isLoading} />
|
|
192
176
|
</Col>
|
|
193
177
|
<Col md={6} sm={12}>
|
|
194
178
|
<div className="second-column">
|
|
@@ -228,7 +212,6 @@ export function ProductSetControl({
|
|
|
228
212
|
{...register("operationalCost", { required: true })}
|
|
229
213
|
as="select"
|
|
230
214
|
defaultValue={OPERATIONAL_COST_PROVIDER}
|
|
231
|
-
disabled={isOverrides}
|
|
232
215
|
isInvalid={HookFormService.isInvalid("operationalCost", errors)}
|
|
233
216
|
>
|
|
234
217
|
{Object.keys(OPERATIONAL_COST_TYPES).map((operationalCost) => (
|
|
@@ -258,7 +241,6 @@ export function ProductSetControl({
|
|
|
258
241
|
{...register("relyOnPeopleType")}
|
|
259
242
|
as="select"
|
|
260
243
|
defaultValue={null}
|
|
261
|
-
disabled={isOverrides}
|
|
262
244
|
isInvalid={HookFormService.isInvalid("relyOnPeopleType", errors)}
|
|
263
245
|
>
|
|
264
246
|
<option value="">{t("notRequired")} </option>
|
|
@@ -286,7 +268,7 @@ export function ProductSetControl({
|
|
|
286
268
|
{...register("termsAndConditions")}
|
|
287
269
|
as="textarea"
|
|
288
270
|
rows={2}
|
|
289
|
-
disabled={isLoading
|
|
271
|
+
disabled={isLoading}
|
|
290
272
|
isInvalid={HookFormService.isInvalid(
|
|
291
273
|
"termsAndConditions",
|
|
292
274
|
errors
|
|
@@ -301,32 +283,30 @@ export function ProductSetControl({
|
|
|
301
283
|
<Form.Label className="mt-4">
|
|
302
284
|
{t("Design:emailTemplate")}
|
|
303
285
|
</Form.Label>
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
)}
|
|
322
|
-
</>
|
|
286
|
+
{showEmailTemplate ? (
|
|
287
|
+
<Typeahead
|
|
288
|
+
name="emailTemplates"
|
|
289
|
+
options={emailTemplates}
|
|
290
|
+
isMultipleChoise
|
|
291
|
+
placeholder={t("Design:choose")}
|
|
292
|
+
noOptionsMessage={t("Design:noActiveTemplates", {
|
|
293
|
+
notification: t("Design:email"),
|
|
294
|
+
})}
|
|
295
|
+
/>
|
|
296
|
+
) : (
|
|
297
|
+
<WarningMessage
|
|
298
|
+
message={t("Design:noActiveTemplates", {
|
|
299
|
+
notification: t("Design:email"),
|
|
300
|
+
})}
|
|
301
|
+
/>
|
|
302
|
+
)}
|
|
323
303
|
|
|
324
304
|
<Form.Label
|
|
325
305
|
className={clsx(emailTemplates.length > 0 ? "mt-4" : "mt-1")}
|
|
326
306
|
>
|
|
327
307
|
{t("Design:smsTemplate")}
|
|
328
308
|
</Form.Label>
|
|
329
|
-
{
|
|
309
|
+
{showSmsTemplate ? (
|
|
330
310
|
<Typeahead
|
|
331
311
|
name="smsTemplates"
|
|
332
312
|
options={smsTemplates}
|
|
@@ -359,7 +339,6 @@ export function ProductSetControl({
|
|
|
359
339
|
onChange={field.onChange}
|
|
360
340
|
value={fieldValue}
|
|
361
341
|
as="select"
|
|
362
|
-
disabled={isOverrides}
|
|
363
342
|
isInvalid={HookFormService.isInvalid(
|
|
364
343
|
"fieldSetId",
|
|
365
344
|
errors
|
|
@@ -396,7 +375,6 @@ export function ProductSetControl({
|
|
|
396
375
|
}) as string;
|
|
397
376
|
},
|
|
398
377
|
})}
|
|
399
|
-
disabled={isOverrides}
|
|
400
378
|
isInvalid={HookFormService.isInvalid("thankYouPageUrl", errors)}
|
|
401
379
|
/>
|
|
402
380
|
|
|
@@ -9,14 +9,10 @@ import { Icon, Image } from "../../static";
|
|
|
9
9
|
|
|
10
10
|
export interface TutorialGifCardProps {
|
|
11
11
|
tutorialAsset?: string;
|
|
12
|
-
isOverrides?: boolean;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
// @TODO: Tutorial GIF asset should be passed as context, which is better
|
|
16
|
-
const TutorialGifCard = ({
|
|
17
|
-
tutorialAsset,
|
|
18
|
-
isOverrides,
|
|
19
|
-
}: TutorialGifCardProps) => {
|
|
15
|
+
const TutorialGifCard = ({ tutorialAsset }: TutorialGifCardProps) => {
|
|
20
16
|
const { pathname } = useLocation();
|
|
21
17
|
const [isVisible, setIsVisible] = useState(pathname?.includes("/create"));
|
|
22
18
|
const { t } = useTranslation(["Design"]);
|
|
@@ -50,12 +46,8 @@ const TutorialGifCard = ({
|
|
|
50
46
|
</button>
|
|
51
47
|
</Card.Header>
|
|
52
48
|
<Card.Body className="tutorial-card-body">
|
|
53
|
-
<p>
|
|
54
|
-
|
|
55
|
-
</p>
|
|
56
|
-
<span>
|
|
57
|
-
{t(isOverrides ? "buildOverrideRules" : "buildProductSetDesc")}
|
|
58
|
-
</span>
|
|
49
|
+
<p>{t("buildProductSet")}</p>
|
|
50
|
+
<span>{t("buildProductSetDesc")}</span>
|
|
59
51
|
{tutorialAsset && <Image src={tutorialAsset} alt="Tutorial Gif" />}
|
|
60
52
|
</Card.Body>
|
|
61
53
|
</Card>
|
|
@@ -35,7 +35,6 @@ import { useSortableTreeFunctions } from "../hooks/useSortableTreeFunctions";
|
|
|
35
35
|
|
|
36
36
|
interface ProductCategoriesControlProps extends WithIsLoading {
|
|
37
37
|
stepIndex: number;
|
|
38
|
-
isOverrides?: boolean;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
const getCategoryDefaultValue = (
|
|
@@ -66,7 +65,6 @@ const getCategoryDefaultValue = (
|
|
|
66
65
|
export function ProductCategoriesControl({
|
|
67
66
|
isLoading,
|
|
68
67
|
stepIndex,
|
|
69
|
-
isOverrides,
|
|
70
68
|
}: ProductCategoriesControlProps) {
|
|
71
69
|
const { t } = useTranslation("Design");
|
|
72
70
|
const {
|
|
@@ -107,7 +105,6 @@ export function ProductCategoriesControl({
|
|
|
107
105
|
const { edit, saveValidField, cancelChanges } = useSortableTreeFunctions({
|
|
108
106
|
fieldName: productCategoriesFieldName,
|
|
109
107
|
remove,
|
|
110
|
-
isOverrides,
|
|
111
108
|
});
|
|
112
109
|
|
|
113
110
|
const productCategories: ProductCategory[] = useWatch({
|
|
@@ -132,7 +129,7 @@ export function ProductCategoriesControl({
|
|
|
132
129
|
});
|
|
133
130
|
|
|
134
131
|
const handleDragEnd = (event) => {
|
|
135
|
-
|
|
132
|
+
// @TODO uncomment when will be fix for change sort index
|
|
136
133
|
const { active, over } = event;
|
|
137
134
|
|
|
138
135
|
if (!active || !over || !active?.id || !over?.id) return;
|
|
@@ -269,10 +266,8 @@ export function ProductCategoriesControl({
|
|
|
269
266
|
categoryName={value}
|
|
270
267
|
stepIndex={stepIndex}
|
|
271
268
|
productCategoryIndex={index}
|
|
272
|
-
isOverride={isOverrides}
|
|
273
269
|
/>
|
|
274
270
|
}
|
|
275
|
-
isOverride={isOverrides}
|
|
276
271
|
onDelete={() => remove(index)}
|
|
277
272
|
validate={() =>
|
|
278
273
|
trigger(`steps.${stepIndex}.productCategories.${index}`)
|
|
@@ -295,7 +290,6 @@ export function ProductCategoriesControl({
|
|
|
295
290
|
zones={zones}
|
|
296
291
|
productCategoryIndex={index}
|
|
297
292
|
categoryType={productCategory.type}
|
|
298
|
-
isOverrides={isOverrides}
|
|
299
293
|
/>
|
|
300
294
|
</SortableTree.Item>
|
|
301
295
|
)}
|
|
@@ -305,9 +299,7 @@ export function ProductCategoriesControl({
|
|
|
305
299
|
</SortableTree>
|
|
306
300
|
<CreateProductSetItem
|
|
307
301
|
title={t("addCategory")}
|
|
308
|
-
isOverride={isOverrides}
|
|
309
302
|
onClick={() => {
|
|
310
|
-
if (isOverrides) return;
|
|
311
303
|
setIsSelectCategoryVisible(true);
|
|
312
304
|
}}
|
|
313
305
|
/>
|
|
@@ -316,7 +308,6 @@ export function ProductCategoriesControl({
|
|
|
316
308
|
isVisible={isSelectCategoryVisible}
|
|
317
309
|
onHide={() => setIsSelectCategoryVisible(false)}
|
|
318
310
|
onCategorySelect={(categoryType) => {
|
|
319
|
-
if (isOverrides) return;
|
|
320
311
|
append(getCategoryDefaultValue(categoryType, fields.length));
|
|
321
312
|
setShowCategoryModal(true);
|
|
322
313
|
if (
|
|
@@ -330,9 +321,7 @@ export function ProductCategoriesControl({
|
|
|
330
321
|
<>
|
|
331
322
|
<CreateProductSetItem
|
|
332
323
|
title={t("editMap")}
|
|
333
|
-
isOverride={isOverrides}
|
|
334
324
|
onClick={() => {
|
|
335
|
-
if (isOverrides) return;
|
|
336
325
|
setIsVenueMapSetModalVisible(true);
|
|
337
326
|
}}
|
|
338
327
|
className={clsx(
|
|
@@ -26,19 +26,14 @@ 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
|
-
|
|
34
|
+
WithId,
|
|
39
35
|
ProductSetControlValues {
|
|
40
36
|
steps: Step[];
|
|
41
|
-
isOverrides?: boolean;
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
export interface ProductSetFormProps
|
|
@@ -55,7 +50,6 @@ export interface ProductSetFormProps
|
|
|
55
50
|
providerHasBookingManagement?: ProviderBookingManagementSetting["hasBookingManagement"];
|
|
56
51
|
zones?: Zone[] | null;
|
|
57
52
|
isCreateAction?: boolean;
|
|
58
|
-
isOverrides?: boolean;
|
|
59
53
|
workHours?: WorkHour[];
|
|
60
54
|
}
|
|
61
55
|
|
|
@@ -73,7 +67,6 @@ export function ProductSetForm({
|
|
|
73
67
|
zones,
|
|
74
68
|
isCreateAction,
|
|
75
69
|
workHours,
|
|
76
|
-
isOverrides,
|
|
77
70
|
...shared
|
|
78
71
|
}: ProductSetFormProps) {
|
|
79
72
|
const { t } = useTranslation("Design");
|
|
@@ -91,7 +84,6 @@ export function ProductSetForm({
|
|
|
91
84
|
});
|
|
92
85
|
|
|
93
86
|
const { setError, reset } = form;
|
|
94
|
-
|
|
95
87
|
const formValues = form.watch();
|
|
96
88
|
|
|
97
89
|
const submitHandler = (onSubmit: (values: ProductSetFormValues) => void) => {
|
|
@@ -169,7 +161,6 @@ export function ProductSetForm({
|
|
|
169
161
|
companyName={companyName}
|
|
170
162
|
workHours={workHours}
|
|
171
163
|
providerHasBookingManagement={providerHasBookingManagement}
|
|
172
|
-
isOverrides={isOverrides}
|
|
173
164
|
/>
|
|
174
165
|
<Row>
|
|
175
166
|
<Col md={6} sm={12} />
|
|
@@ -34,7 +34,6 @@ interface ProductsControlProps extends WithIsLoading {
|
|
|
34
34
|
hasTicket?: boolean;
|
|
35
35
|
categoryType: CategoryType;
|
|
36
36
|
zones?: Zone[];
|
|
37
|
-
isOverrides?: boolean;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
const getDefaultProductValue = (sort: number): Product => ({
|
|
@@ -78,7 +77,6 @@ export function ProductsControl({
|
|
|
78
77
|
hasTicket,
|
|
79
78
|
categoryType,
|
|
80
79
|
zones,
|
|
81
|
-
isOverrides,
|
|
82
80
|
}: ProductsControlProps) {
|
|
83
81
|
const { t } = useTranslation("Design");
|
|
84
82
|
const form = useFormContext<ProductSetFormValues>();
|
|
@@ -114,7 +112,6 @@ export function ProductsControl({
|
|
|
114
112
|
const { edit, saveValidField, cancelChanges } = useSortableTreeFunctions({
|
|
115
113
|
fieldName: productControlFieldName,
|
|
116
114
|
remove,
|
|
117
|
-
isOverrides,
|
|
118
115
|
});
|
|
119
116
|
|
|
120
117
|
const allowDeposits = watch(
|
|
@@ -162,7 +159,6 @@ export function ProductsControl({
|
|
|
162
159
|
});
|
|
163
160
|
|
|
164
161
|
const handleDragEnd = (_event) => {
|
|
165
|
-
if (isOverrides) return;
|
|
166
162
|
const { active, over } = _event;
|
|
167
163
|
|
|
168
164
|
if (!active || !over || !active?.id || !over?.id) return;
|
|
@@ -180,7 +176,6 @@ export function ProductsControl({
|
|
|
180
176
|
};
|
|
181
177
|
|
|
182
178
|
const onProductRemove = (index: number) => {
|
|
183
|
-
if (isOverrides) return;
|
|
184
179
|
const currentProduct = getValues(
|
|
185
180
|
`${productControlFieldName}.${index}` as const
|
|
186
181
|
);
|
|
@@ -220,12 +215,10 @@ export function ProductsControl({
|
|
|
220
215
|
isExpanded={isFirstProductAdded}
|
|
221
216
|
isInvalid={!!categoryProductErrors}
|
|
222
217
|
title={value}
|
|
223
|
-
isOverride={isOverrides}
|
|
224
218
|
badge={<Badge className="product-badge">{t("product")}</Badge>}
|
|
225
219
|
isIconInHeader={false}
|
|
226
220
|
cancelChanges={() => cancelChanges(index)}
|
|
227
221
|
edit={() => edit(index)}
|
|
228
|
-
isProduct
|
|
229
222
|
secondaryBadge={getBadgeConfig(categoryType, t(categoryType))}
|
|
230
223
|
subTitle={
|
|
231
224
|
<div className="product-set-badges-container">
|
|
@@ -262,7 +255,6 @@ export function ProductsControl({
|
|
|
262
255
|
hasTicket={hasTicket}
|
|
263
256
|
categoryType={categoryType}
|
|
264
257
|
zoneDuration={catergoryZone?.defaultDuration}
|
|
265
|
-
isOverrides={isOverrides}
|
|
266
258
|
/>
|
|
267
259
|
}
|
|
268
260
|
onDelete={() => onProductRemove(index)}
|
|
@@ -284,9 +276,7 @@ export function ProductsControl({
|
|
|
284
276
|
</SortableTree>
|
|
285
277
|
<CreateProductSetItem
|
|
286
278
|
title={t("addProduct")}
|
|
287
|
-
isOverride={isOverrides}
|
|
288
279
|
onClick={() => {
|
|
289
|
-
if (isOverrides) return;
|
|
290
280
|
append(getDefaultProductValue(fields.length));
|
|
291
281
|
setShowProductModal(true);
|
|
292
282
|
|
|
@@ -18,10 +18,9 @@ import { ProductSetFormValues } from "./ProductSetForm";
|
|
|
18
18
|
|
|
19
19
|
interface StepsControlProps {
|
|
20
20
|
isLoading: boolean;
|
|
21
|
-
isOverrides?: boolean;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export function StepsControl({ isLoading
|
|
23
|
+
export function StepsControl({ isLoading }: StepsControlProps) {
|
|
25
24
|
const form = useFormContext<ProductSetFormValues>();
|
|
26
25
|
const { t } = useTranslation("Design");
|
|
27
26
|
const [showStepModal, setShowStepModal] = useState(false);
|
|
@@ -43,7 +42,6 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
43
42
|
const { edit, saveValidField, cancelChanges } = useSortableTreeFunctions({
|
|
44
43
|
fieldName: "steps",
|
|
45
44
|
remove,
|
|
46
|
-
isOverrides,
|
|
47
45
|
});
|
|
48
46
|
|
|
49
47
|
useEffect(() => {
|
|
@@ -92,9 +90,8 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
92
90
|
modalLabel={t("addNewStep")}
|
|
93
91
|
modalClass={ProductSetModalClasses.step}
|
|
94
92
|
isNewAdded={showStepModal}
|
|
95
|
-
edit={() =>
|
|
93
|
+
edit={() => edit(index)}
|
|
96
94
|
cancelChanges={() => cancelChanges(index)}
|
|
97
|
-
isOverride={isOverrides}
|
|
98
95
|
subTitle={
|
|
99
96
|
<div className="product-set-badges-container">
|
|
100
97
|
<div className="product-set-subtitle-dot product-set-subtitle-step-dot" />
|
|
@@ -139,7 +136,6 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
139
136
|
<ProductCategoriesControl
|
|
140
137
|
isLoading={isLoading}
|
|
141
138
|
stepIndex={index}
|
|
142
|
-
isOverrides={isOverrides}
|
|
143
139
|
/>
|
|
144
140
|
</SortableTree.Item>
|
|
145
141
|
)}
|
|
@@ -149,9 +145,7 @@ export function StepsControl({ isLoading, isOverrides }: StepsControlProps) {
|
|
|
149
145
|
|
|
150
146
|
<CreateProductSetItem
|
|
151
147
|
title={t("addStep")}
|
|
152
|
-
isOverride={isOverrides}
|
|
153
148
|
onClick={() => {
|
|
154
|
-
if (isOverrides) return;
|
|
155
149
|
append(getDefaultStepsValues());
|
|
156
150
|
setShowStepModal(true);
|
|
157
151
|
if (errors.steps?.type === HookFormService.manualErrorType) {
|
|
@@ -15,7 +15,6 @@ interface SubProductsControlProps {
|
|
|
15
15
|
productCategoryIndex: number;
|
|
16
16
|
productIndex: number;
|
|
17
17
|
isLoading: boolean;
|
|
18
|
-
isOverrides?: boolean;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export function SubProductsControl({
|
|
@@ -24,7 +23,6 @@ export function SubProductsControl({
|
|
|
24
23
|
stepIndex,
|
|
25
24
|
productCategoryIndex,
|
|
26
25
|
productIndex,
|
|
27
|
-
isOverrides,
|
|
28
26
|
}: SubProductsControlProps) {
|
|
29
27
|
const form = useFormContext<ProductSetFormValues>();
|
|
30
28
|
const { fields, append } = useFieldArray({
|
|
@@ -51,7 +49,6 @@ export function SubProductsControl({
|
|
|
51
49
|
key={`sub-product-${subProduct.id}-${index}`}
|
|
52
50
|
id={subProduct.id}
|
|
53
51
|
title={subProduct.name}
|
|
54
|
-
isOverride={isOverrides}
|
|
55
52
|
body={
|
|
56
53
|
<ProductControl<ProductSetFormValues>
|
|
57
54
|
isLoading={isLoading}
|
|
@@ -4,30 +4,24 @@ import { useFormContext } from "react-hook-form";
|
|
|
4
4
|
interface useSortableTreeFunctionsProps {
|
|
5
5
|
fieldName: string;
|
|
6
6
|
remove: (index?: number | number[]) => void;
|
|
7
|
-
isOverrides?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export const useSortableTreeFunctions = ({
|
|
10
9
|
fieldName,
|
|
11
10
|
remove,
|
|
12
|
-
isOverrides,
|
|
13
11
|
}: useSortableTreeFunctionsProps) => {
|
|
14
12
|
const { getValues, setValue } = useFormContext();
|
|
15
13
|
const [previousValue, setEditValue] = useState(null);
|
|
16
14
|
|
|
17
15
|
const edit = (index: number) => {
|
|
18
|
-
if (isOverrides) return;
|
|
19
16
|
const currentCategoryProduct = getValues(`${fieldName}.${index}` as const);
|
|
20
17
|
const cloneCategoryProduct = structuredClone(currentCategoryProduct);
|
|
21
18
|
setEditValue(cloneCategoryProduct);
|
|
22
19
|
};
|
|
23
20
|
|
|
24
21
|
const cancelChanges = (index: number) => {
|
|
25
|
-
if (isOverrides) return;
|
|
26
22
|
if (!previousValue) {
|
|
27
|
-
// eslint-disable-next-line consistent-return
|
|
28
23
|
return remove(index);
|
|
29
24
|
}
|
|
30
|
-
// eslint-disable-next-line consistent-return
|
|
31
25
|
return setValue(`${fieldName}.${index}` as const, previousValue);
|
|
32
26
|
};
|
|
33
27
|
|
|
@@ -6,21 +6,18 @@ interface CreateProductSetItemProps {
|
|
|
6
6
|
onClick: () => void;
|
|
7
7
|
title: string;
|
|
8
8
|
className?: string;
|
|
9
|
-
isOverride?: boolean;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export function CreateProductSetItem({
|
|
13
12
|
onClick,
|
|
14
13
|
title,
|
|
15
14
|
className,
|
|
16
|
-
isOverride,
|
|
17
15
|
}: CreateProductSetItemProps) {
|
|
18
16
|
return (
|
|
19
17
|
<button
|
|
20
18
|
className={clsx(
|
|
21
19
|
"product-set-item-wrapper w-100",
|
|
22
20
|
`product-set-item-wrapper-${title.toLowerCase().split(" ")[1]}`,
|
|
23
|
-
isOverride && "bg-light",
|
|
24
21
|
className
|
|
25
22
|
)}
|
|
26
23
|
onClick={onClick}
|