@licklist/design 0.66.10-dev.0 → 0.66.10-dev.3
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/dist/auth/Login/LoginComponent.js +2 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +7 -2
- package/dist/events/edit-event-modal/utils/getDefaultProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/utils/getDefaultProductSet.js +22 -9
- package/dist/layout/DropDown.d.ts +2 -1
- package/dist/layout/DropDown.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +3 -3
- package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductCategoriesControl.js +1 -3
- package/dist/product-set/form/ProductZonesControl.d.ts +9 -0
- package/dist/product-set/form/ProductZonesControl.d.ts.map +1 -0
- package/dist/product-set/form/ProductZonesControl.js +214 -0
- package/dist/product-set/form/ProductsControl.d.ts +1 -3
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +2 -13
- package/dist/product-set/product/ProductControl.d.ts +5 -8
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +19 -301
- package/dist/product-set/product/advanced-options/AdvancedOptions.d.ts +8 -0
- package/dist/product-set/product/advanced-options/AdvancedOptions.d.ts.map +1 -0
- package/dist/product-set/product/advanced-options/AdvancedOptions.js +264 -0
- package/dist/product-set/product/advanced-options/index.d.ts +2 -0
- package/dist/product-set/product/advanced-options/index.d.ts.map +1 -0
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.js +1 -0
- package/dist/product-set/product-category/ProductCategoryControl.d.ts +0 -2
- package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.js +2 -57
- package/dist/product-set/product-zone/ProductZoneControl.d.ts +15 -0
- package/dist/product-set/product-zone/ProductZoneControl.d.ts.map +1 -0
- package/dist/product-set/product-zone/ProductZoneControl.js +263 -0
- package/dist/product-set/product-zone/index.d.ts +2 -0
- package/dist/product-set/product-zone/index.d.ts.map +1 -0
- package/dist/product-set/utils/index.d.ts.map +1 -1
- package/dist/product-set/utils/index.js +3 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts +3 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.js +15 -5
- package/dist/styles/product-set/CreateProductSetItem.scss +8 -0
- package/dist/styles/product-set/EditZoneSettingModal.scss +16 -0
- package/dist/styles/product-set/ProductSetForm.scss +14 -1
- package/dist/styles/product-set/_index.scss +2 -1
- package/package.json +1 -1
- package/src/auth/Login/LoginComponent.tsx +1 -1
- package/src/events/edit-event-modal/utils/getDefaultProductSet.ts +2 -4
- package/src/layout/DropDown.tsx +1 -1
- package/src/product-set/control/ProductSetControl.tsx +2 -1
- package/src/product-set/form/ProductCategoriesControl.tsx +0 -3
- package/src/product-set/form/ProductZonesControl.tsx +178 -0
- package/src/product-set/form/ProductsControl.tsx +0 -17
- package/src/product-set/product/ProductControl.tsx +23 -268
- package/src/product-set/product/advanced-options/AdvancedOptions.tsx +168 -0
- package/src/product-set/product/advanced-options/index.ts +1 -0
- package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +1 -1
- package/src/product-set/product-category/ProductCategoryControl.tsx +1 -60
- package/src/product-set/product-zone/ProductZoneControl.tsx +247 -0
- package/src/product-set/product-zone/index.ts +1 -0
- package/src/product-set/utils/index.ts +5 -1
- package/src/sortable-tree/SortableTreeItem.tsx +59 -45
- package/src/styles/product-set/CreateProductSetItem.scss +8 -0
- package/src/styles/product-set/EditZoneSettingModal.scss +16 -0
- package/src/styles/product-set/ProductSetForm.scss +14 -1
- package/src/styles/product-set/_index.scss +2 -1
- package/yarn.lock +108 -87
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { Col, Form } from "react-bootstrap";
|
|
3
|
+
import { Controller, Path, useFormContext } from "react-hook-form";
|
|
4
|
+
import { HookFormService } from "@licklist/plugins";
|
|
5
|
+
import { useId } from "@react-aria/utils";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { PRODUCT_DEfAULT_COLORS } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
|
|
8
|
+
import {
|
|
9
|
+
FieldNamePrefixPath,
|
|
10
|
+
FormValues,
|
|
11
|
+
} from "@licklist/plugins/dist/types/services/Form/hook-form-service";
|
|
12
|
+
import { ProductPriceControl } from "../price/ProductPriceControl";
|
|
13
|
+
import { PropertyControl } from "../../../snippet";
|
|
14
|
+
|
|
15
|
+
import { BooleanSwitch } from "../../../static";
|
|
16
|
+
import { ProductSetLoadingContext } from "../../form/context";
|
|
17
|
+
|
|
18
|
+
interface AdvancedOptionsProps<T> extends FieldNamePrefixPath<T> {
|
|
19
|
+
isOverrides: boolean;
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const AdvancedOptions = <T extends FormValues>({
|
|
24
|
+
fieldNamePrefix,
|
|
25
|
+
isOverrides,
|
|
26
|
+
isLoading,
|
|
27
|
+
}: AdvancedOptionsProps<T>) => {
|
|
28
|
+
const { t } = useTranslation(["Design", "Validation", "ProductSet"]);
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
register,
|
|
32
|
+
control,
|
|
33
|
+
formState: { errors },
|
|
34
|
+
} = useFormContext<T>();
|
|
35
|
+
|
|
36
|
+
const { productGroupList } = useContext(ProductSetLoadingContext);
|
|
37
|
+
|
|
38
|
+
const isRequiredId = useId();
|
|
39
|
+
const productGroupId = useId();
|
|
40
|
+
const termsAndConditionsId = useId();
|
|
41
|
+
const hasSpecialNotesId = useId();
|
|
42
|
+
const minSpendId = useId();
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<Form.Group
|
|
47
|
+
controlId={isRequiredId}
|
|
48
|
+
className="advanced-switch-container"
|
|
49
|
+
>
|
|
50
|
+
<Form.Label>{t("isRequired")}</Form.Label>
|
|
51
|
+
|
|
52
|
+
<Controller
|
|
53
|
+
render={({ field: { value, onChange, name } }) => (
|
|
54
|
+
<BooleanSwitch
|
|
55
|
+
name={name}
|
|
56
|
+
value={Boolean(value)}
|
|
57
|
+
onChange={onChange}
|
|
58
|
+
disabled={isLoading || isOverrides}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
61
|
+
control={control}
|
|
62
|
+
name={`${fieldNamePrefix}.isRequired` as Path<T>}
|
|
63
|
+
/>
|
|
64
|
+
</Form.Group>
|
|
65
|
+
|
|
66
|
+
<Form.Group
|
|
67
|
+
controlId={hasSpecialNotesId}
|
|
68
|
+
className="advanced-switch-container"
|
|
69
|
+
>
|
|
70
|
+
<Form.Label>{t("hasSpecialNotes")}</Form.Label>
|
|
71
|
+
|
|
72
|
+
<Controller
|
|
73
|
+
render={({ field: { value, onChange, name } }) => (
|
|
74
|
+
<BooleanSwitch
|
|
75
|
+
name={name}
|
|
76
|
+
value={Boolean(value)}
|
|
77
|
+
onChange={onChange}
|
|
78
|
+
disabled={isLoading || isOverrides}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
control={control}
|
|
82
|
+
name={`${fieldNamePrefix}.hasSpecialNotes` as Path<T>}
|
|
83
|
+
/>
|
|
84
|
+
</Form.Group>
|
|
85
|
+
|
|
86
|
+
<PropertyControl<T>
|
|
87
|
+
item={`${fieldNamePrefix}.color` as Path<T>}
|
|
88
|
+
label={t("ProductSet:selectColor")}
|
|
89
|
+
isDisabled={isOverrides}
|
|
90
|
+
isRequired={false}
|
|
91
|
+
defaultColors={PRODUCT_DEfAULT_COLORS}
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
<Form.Group controlId={productGroupId}>
|
|
95
|
+
<Form.Label>{t("productGroup")}</Form.Label>
|
|
96
|
+
<Form.Control
|
|
97
|
+
as="select"
|
|
98
|
+
{...register(`${fieldNamePrefix}.productGroupId` as Path<T>)}
|
|
99
|
+
isInvalid={HookFormService.isInvalid<T>(
|
|
100
|
+
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
101
|
+
errors,
|
|
102
|
+
)}
|
|
103
|
+
disabled={isLoading || isOverrides}
|
|
104
|
+
defaultValue=""
|
|
105
|
+
>
|
|
106
|
+
<option value="">{t("Design:selectProductGroup")}</option>
|
|
107
|
+
{productGroupList.map((productGroup) => {
|
|
108
|
+
return (
|
|
109
|
+
<option value={productGroup.id} key={productGroup.id}>
|
|
110
|
+
{productGroup.value}
|
|
111
|
+
</option>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
114
|
+
</Form.Control>
|
|
115
|
+
<Form.Control.Feedback type="invalid">
|
|
116
|
+
{HookFormService.getErrors<T>(
|
|
117
|
+
`${fieldNamePrefix}.productGroupId` as Path<T>,
|
|
118
|
+
errors,
|
|
119
|
+
)}
|
|
120
|
+
</Form.Control.Feedback>
|
|
121
|
+
</Form.Group>
|
|
122
|
+
|
|
123
|
+
<Col lg={8} md={8} className="pl-0">
|
|
124
|
+
<Form.Group controlId={termsAndConditionsId}>
|
|
125
|
+
<Form.Label>{t("productTermsConditions")}</Form.Label>
|
|
126
|
+
|
|
127
|
+
<Controller
|
|
128
|
+
render={({ field: { value, onChange, name, ref } }) => (
|
|
129
|
+
<Form.Control
|
|
130
|
+
ref={ref}
|
|
131
|
+
as="textarea"
|
|
132
|
+
rows={3}
|
|
133
|
+
value={value as string}
|
|
134
|
+
onChange={onChange}
|
|
135
|
+
isInvalid={HookFormService.isInvalid<T>(
|
|
136
|
+
`${fieldNamePrefix}.termsAndConditions` as Path<T>,
|
|
137
|
+
errors,
|
|
138
|
+
)}
|
|
139
|
+
disabled={isLoading || isOverrides}
|
|
140
|
+
name={name}
|
|
141
|
+
/>
|
|
142
|
+
)}
|
|
143
|
+
control={control}
|
|
144
|
+
name={`${fieldNamePrefix}.termsAndConditions` as Path<T>}
|
|
145
|
+
/>
|
|
146
|
+
|
|
147
|
+
<Form.Control.Feedback type="invalid">
|
|
148
|
+
{HookFormService.getErrors<T>(
|
|
149
|
+
`${fieldNamePrefix}.termsAndConditions` as Path<T>,
|
|
150
|
+
errors,
|
|
151
|
+
)}
|
|
152
|
+
</Form.Control.Feedback>
|
|
153
|
+
</Form.Group>
|
|
154
|
+
</Col>
|
|
155
|
+
|
|
156
|
+
<Form.Group controlId={minSpendId} className="advanced-switch-container">
|
|
157
|
+
<ProductPriceControl
|
|
158
|
+
title={t("minSpend")}
|
|
159
|
+
isRequired={false}
|
|
160
|
+
isMoreThanZero
|
|
161
|
+
allowDeposits={false}
|
|
162
|
+
isLoading={isLoading || isOverrides}
|
|
163
|
+
fieldNamePrefix={`${fieldNamePrefix}.minSpend` as Path<T>}
|
|
164
|
+
/>
|
|
165
|
+
</Form.Group>
|
|
166
|
+
</>
|
|
167
|
+
);
|
|
168
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AdvancedOptions";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback,
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
2
|
import { Form, Col, Collapse, InputGroup, Row } from "react-bootstrap";
|
|
3
3
|
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
@@ -13,12 +13,10 @@ import {
|
|
|
13
13
|
CATEGORY_TYPE_TICKETS,
|
|
14
14
|
CATEGORY_TYPE_FIXED_DURATION,
|
|
15
15
|
} from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
|
|
16
|
-
import { Zone } from "@licklist/core/dist/DataMapper/Provider/ZoneDataMapper";
|
|
17
16
|
import { Switch, BooleanSwitch } from "../../static";
|
|
18
17
|
import { ProductSetFormValues } from "../form/ProductSetForm";
|
|
19
18
|
import { IsDeletableEvent, ProductCategory } from "../types";
|
|
20
19
|
import { ReactComponent as IncrementIcon } from "../../assets/dashboard/increment.svg";
|
|
21
|
-
import { ProductSetLoadingContext } from "../form/context";
|
|
22
20
|
|
|
23
21
|
export interface ProductCategoryControlValues extends FormValues {
|
|
24
22
|
id: number;
|
|
@@ -39,7 +37,6 @@ export interface ProductCategoryControlValues extends FormValues {
|
|
|
39
37
|
weight?: number;
|
|
40
38
|
isReusable?: boolean;
|
|
41
39
|
termsAndConditions?: string;
|
|
42
|
-
zoneId?: Zone["id"];
|
|
43
40
|
sort: number | null;
|
|
44
41
|
}
|
|
45
42
|
|
|
@@ -102,14 +99,10 @@ export function ProductCategoryControl({
|
|
|
102
99
|
const isTimeRelatedId = useId();
|
|
103
100
|
const collectUserInfoId = useId();
|
|
104
101
|
const hasTicketId = useId();
|
|
105
|
-
const zoneId = useId();
|
|
106
102
|
const overallQuantityId = useId();
|
|
107
103
|
|
|
108
104
|
const allowDepositsId = useId();
|
|
109
105
|
const remainderExpireAfterId = useId();
|
|
110
|
-
const { providerHasBookingManagement, zones = [] } = useContext(
|
|
111
|
-
ProductSetLoadingContext,
|
|
112
|
-
);
|
|
113
106
|
|
|
114
107
|
// @TODO not for first release
|
|
115
108
|
// const hasBookingManagementId = useId();
|
|
@@ -129,10 +122,6 @@ export function ProductCategoryControl({
|
|
|
129
122
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
130
123
|
}, [maxSubItems, fieldNamePrefix]);
|
|
131
124
|
|
|
132
|
-
const isZoneCategory =
|
|
133
|
-
category.type === CATEGORY_TYPE_FIXED_DURATION ||
|
|
134
|
-
category.type === CATEGORY_TYPE_GAME;
|
|
135
|
-
|
|
136
125
|
return (
|
|
137
126
|
<>
|
|
138
127
|
<Col md={12} xl className="p-0">
|
|
@@ -387,54 +376,6 @@ export function ProductCategoryControl({
|
|
|
387
376
|
</Form.Group>
|
|
388
377
|
</Col>
|
|
389
378
|
</Row>
|
|
390
|
-
|
|
391
|
-
{isZoneCategory && (
|
|
392
|
-
<>
|
|
393
|
-
<Row>
|
|
394
|
-
<Col>
|
|
395
|
-
<Form.Group controlId={zoneId}>
|
|
396
|
-
<Form.Label>{t("Design:zone")}</Form.Label>
|
|
397
|
-
<Controller
|
|
398
|
-
control={control}
|
|
399
|
-
name={`${fieldNamePrefix}.zoneId`}
|
|
400
|
-
render={({ field }) => (
|
|
401
|
-
<Form.Control
|
|
402
|
-
as="select"
|
|
403
|
-
disabled={isOverride}
|
|
404
|
-
isInvalid={HookFormService.isInvalid<ProductSetFormValues>(
|
|
405
|
-
`${fieldNamePrefix}.zoneId`,
|
|
406
|
-
errors,
|
|
407
|
-
)}
|
|
408
|
-
{...field}
|
|
409
|
-
>
|
|
410
|
-
<option value={null}>{t("Design:choose")}</option>
|
|
411
|
-
{zones.map((zone) => (
|
|
412
|
-
<option key={zone.id} value={zone.id}>
|
|
413
|
-
{zone.name}
|
|
414
|
-
</option>
|
|
415
|
-
))}
|
|
416
|
-
</Form.Control>
|
|
417
|
-
)}
|
|
418
|
-
rules={{
|
|
419
|
-
required: {
|
|
420
|
-
value: providerHasBookingManagement,
|
|
421
|
-
message: t("Validation:fieldRequired", {
|
|
422
|
-
attribute: t("zone"),
|
|
423
|
-
}),
|
|
424
|
-
},
|
|
425
|
-
}}
|
|
426
|
-
/>
|
|
427
|
-
<Form.Control.Feedback type="invalid">
|
|
428
|
-
{HookFormService.getErrors<ProductSetFormValues>(
|
|
429
|
-
`${fieldNamePrefix}.zoneId`,
|
|
430
|
-
errors,
|
|
431
|
-
)}
|
|
432
|
-
</Form.Control.Feedback>
|
|
433
|
-
</Form.Group>
|
|
434
|
-
</Col>
|
|
435
|
-
</Row>
|
|
436
|
-
</>
|
|
437
|
-
)}
|
|
438
379
|
</Col>
|
|
439
380
|
|
|
440
381
|
<Col md={12} xl className="p-0">
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { useContext, useEffect, useMemo } from "react";
|
|
2
|
+
import { Col, Form, Row } from "react-bootstrap";
|
|
3
|
+
import {
|
|
4
|
+
ArrayPath,
|
|
5
|
+
Controller,
|
|
6
|
+
Path,
|
|
7
|
+
PathValue,
|
|
8
|
+
UnpackNestedValue,
|
|
9
|
+
useFormContext,
|
|
10
|
+
useWatch,
|
|
11
|
+
} from "react-hook-form";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
13
|
+
import {
|
|
14
|
+
CategoryType,
|
|
15
|
+
CATEGORY_TYPE_FIXED_DURATION,
|
|
16
|
+
CATEGORY_TYPE_GAME,
|
|
17
|
+
} from "@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper";
|
|
18
|
+
import {
|
|
19
|
+
FieldNamePrefixPath,
|
|
20
|
+
FormValues,
|
|
21
|
+
} from "@licklist/plugins/dist/types/services/Form/hook-form-service";
|
|
22
|
+
import { HookFormService } from "@licklist/plugins";
|
|
23
|
+
import { ProductZone } from "@licklist/core/dist/DataMapper/Product/ProductZoneDataMapper";
|
|
24
|
+
import { ProductDurationControl } from "../product/duration/ProductDurationControl";
|
|
25
|
+
import { FormNumberInput } from "../../static/form-number-input";
|
|
26
|
+
import { FixedDurationOptions } from "../product/fixed-duration-fields";
|
|
27
|
+
import { ProductSetLoadingContext } from "../form/context";
|
|
28
|
+
|
|
29
|
+
export interface ProductZoneControlValues extends FormValues, ProductZone {
|
|
30
|
+
id: number | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ProductZoneProps<T> extends FieldNamePrefixPath<T> {
|
|
34
|
+
isOverrides: boolean;
|
|
35
|
+
categoryType?: CategoryType;
|
|
36
|
+
productZonesFieldName: ArrayPath<T>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const ProductZoneControl = <T extends FormValues>({
|
|
40
|
+
isOverrides,
|
|
41
|
+
categoryType,
|
|
42
|
+
fieldNamePrefix,
|
|
43
|
+
productZonesFieldName,
|
|
44
|
+
}: ProductZoneProps<T>) => {
|
|
45
|
+
const { t } = useTranslation(["Design", "Validation", "ProductSet"]);
|
|
46
|
+
const {
|
|
47
|
+
trigger,
|
|
48
|
+
control,
|
|
49
|
+
setValue,
|
|
50
|
+
clearErrors,
|
|
51
|
+
formState: { errors },
|
|
52
|
+
} = useFormContext();
|
|
53
|
+
|
|
54
|
+
const productZones = useWatch({
|
|
55
|
+
control,
|
|
56
|
+
name: productZonesFieldName,
|
|
57
|
+
}) as ProductZoneControlValues[];
|
|
58
|
+
|
|
59
|
+
const { capacity, zoneId } = useWatch({
|
|
60
|
+
control,
|
|
61
|
+
name: `${fieldNamePrefix}`,
|
|
62
|
+
});
|
|
63
|
+
const disabledDuration = capacity === "0" || !capacity;
|
|
64
|
+
|
|
65
|
+
const { providerHasBookingManagement, zones = [] } = useContext(
|
|
66
|
+
ProductSetLoadingContext,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const currentZoneData = zones.find((zone) => zone.id === Number(zoneId));
|
|
70
|
+
|
|
71
|
+
const availableZones = useMemo(
|
|
72
|
+
() =>
|
|
73
|
+
zones.filter(
|
|
74
|
+
(zone) =>
|
|
75
|
+
!productZones.find(
|
|
76
|
+
(productZone) =>
|
|
77
|
+
Number(productZone.zoneId) === zone.id &&
|
|
78
|
+
productZone.zoneId !== zoneId,
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
[zones, productZones, zoneId],
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!disabledDuration) {
|
|
86
|
+
trigger(`${fieldNamePrefix}.duration` as Path<T>);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setValue(
|
|
90
|
+
`${fieldNamePrefix}.duration` as Path<T>,
|
|
91
|
+
/* @ts-expect-error 6385 */
|
|
92
|
+
0 as UnpackNestedValue<PathValue<T, Path<T>>>,
|
|
93
|
+
);
|
|
94
|
+
clearErrors(`${fieldNamePrefix}.duration` as Path<T>);
|
|
95
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
+
}, [disabledDuration]);
|
|
97
|
+
|
|
98
|
+
const onChangeGameCapacity = (value: number) => {
|
|
99
|
+
if (!currentZoneData?.defaultDuration) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setValue(
|
|
103
|
+
`${fieldNamePrefix}.duration` as Path<T>,
|
|
104
|
+
/* @ts-expect-error 6385 */
|
|
105
|
+
(value * currentZoneData?.defaultDuration) as UnpackNestedValue<
|
|
106
|
+
PathValue<T, Path<T>>
|
|
107
|
+
>,
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<>
|
|
113
|
+
<Row>
|
|
114
|
+
<Col>
|
|
115
|
+
<Form.Group>
|
|
116
|
+
<Form.Label>{t("Design:zone")}</Form.Label>
|
|
117
|
+
<Controller
|
|
118
|
+
control={control}
|
|
119
|
+
name={`${fieldNamePrefix}.zoneId`}
|
|
120
|
+
render={({ field }) => (
|
|
121
|
+
<Form.Control
|
|
122
|
+
as="select"
|
|
123
|
+
disabled={isOverrides}
|
|
124
|
+
isInvalid={HookFormService.isInvalid(
|
|
125
|
+
`${fieldNamePrefix}.zoneId`,
|
|
126
|
+
errors,
|
|
127
|
+
)}
|
|
128
|
+
{...field}
|
|
129
|
+
>
|
|
130
|
+
<option value={null}>{t("Design:choose")}</option>
|
|
131
|
+
{availableZones.map((zone) => (
|
|
132
|
+
<option key={zone.id} value={zone.id}>
|
|
133
|
+
{zone.name}
|
|
134
|
+
</option>
|
|
135
|
+
))}
|
|
136
|
+
</Form.Control>
|
|
137
|
+
)}
|
|
138
|
+
rules={{
|
|
139
|
+
required: {
|
|
140
|
+
value: providerHasBookingManagement,
|
|
141
|
+
message: t("Validation:fieldRequired", {
|
|
142
|
+
attribute: t("zone"),
|
|
143
|
+
}),
|
|
144
|
+
},
|
|
145
|
+
}}
|
|
146
|
+
/>
|
|
147
|
+
<Form.Control.Feedback type="invalid">
|
|
148
|
+
{HookFormService.getErrors(
|
|
149
|
+
`${fieldNamePrefix}.zoneId` as Path<T>,
|
|
150
|
+
errors,
|
|
151
|
+
)}
|
|
152
|
+
</Form.Control.Feedback>
|
|
153
|
+
</Form.Group>
|
|
154
|
+
</Col>
|
|
155
|
+
</Row>
|
|
156
|
+
</>
|
|
157
|
+
{categoryType === CATEGORY_TYPE_FIXED_DURATION && (
|
|
158
|
+
<Row className="align-items-start duration-capacity-container">
|
|
159
|
+
<ProductDurationControl
|
|
160
|
+
fieldNamePrefix={fieldNamePrefix}
|
|
161
|
+
disabled={disabledDuration || isOverrides}
|
|
162
|
+
/>
|
|
163
|
+
|
|
164
|
+
<Col lg={4} md={4}>
|
|
165
|
+
<FormNumberInput
|
|
166
|
+
fieldName={`${fieldNamePrefix}.capacity`}
|
|
167
|
+
label={t("capacity")}
|
|
168
|
+
disabled={isOverrides}
|
|
169
|
+
rules={{
|
|
170
|
+
min: {
|
|
171
|
+
value: 0,
|
|
172
|
+
message: t("Validation:fieldMinNumber", {
|
|
173
|
+
attribute: t("capacity"),
|
|
174
|
+
min: 0,
|
|
175
|
+
}) as string,
|
|
176
|
+
},
|
|
177
|
+
}}
|
|
178
|
+
/>
|
|
179
|
+
</Col>
|
|
180
|
+
{disabledDuration && (
|
|
181
|
+
<div className="duration-hint duration-capacity-container">
|
|
182
|
+
{t("Design:forDurationEditing")}
|
|
183
|
+
</div>
|
|
184
|
+
)}
|
|
185
|
+
</Row>
|
|
186
|
+
)}
|
|
187
|
+
|
|
188
|
+
{categoryType === CATEGORY_TYPE_GAME && (
|
|
189
|
+
<>
|
|
190
|
+
<Row className="align-items-start duration-capacity-container">
|
|
191
|
+
<Col lg={4} md={4}>
|
|
192
|
+
<FormNumberInput
|
|
193
|
+
fieldName={`${fieldNamePrefix}.capacity`}
|
|
194
|
+
label={t("capacity")}
|
|
195
|
+
onChange={onChangeGameCapacity}
|
|
196
|
+
disabled={isOverrides}
|
|
197
|
+
rules={{
|
|
198
|
+
min: {
|
|
199
|
+
value: 0,
|
|
200
|
+
message: t("Validation:fieldMinNumber", {
|
|
201
|
+
attribute: t("capacity"),
|
|
202
|
+
min: 1,
|
|
203
|
+
}) as string,
|
|
204
|
+
},
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
207
|
+
</Col>
|
|
208
|
+
<Col lg={4} md={4}>
|
|
209
|
+
<FormNumberInput
|
|
210
|
+
fieldName={`${fieldNamePrefix}.duration`}
|
|
211
|
+
label={t("durationMinutes")}
|
|
212
|
+
disabled={disabledDuration || isOverrides}
|
|
213
|
+
rules={{
|
|
214
|
+
min: {
|
|
215
|
+
value: 0,
|
|
216
|
+
message: t("Validation:fieldMinNumber", {
|
|
217
|
+
attribute: t("duration"),
|
|
218
|
+
min: 0,
|
|
219
|
+
}) as string,
|
|
220
|
+
},
|
|
221
|
+
validate: (val) => {
|
|
222
|
+
if (!disabledDuration && (!val || val < 1)) {
|
|
223
|
+
return t("Validation:fieldRequired", {
|
|
224
|
+
attribute: t("duration"),
|
|
225
|
+
}) as string;
|
|
226
|
+
}
|
|
227
|
+
return true;
|
|
228
|
+
},
|
|
229
|
+
}}
|
|
230
|
+
/>
|
|
231
|
+
</Col>
|
|
232
|
+
</Row>
|
|
233
|
+
{disabledDuration && (
|
|
234
|
+
<div className="duration-hint pl-0">
|
|
235
|
+
{t("Design:forDurationEditing")}
|
|
236
|
+
</div>
|
|
237
|
+
)}
|
|
238
|
+
</>
|
|
239
|
+
)}
|
|
240
|
+
|
|
241
|
+
<FixedDurationOptions
|
|
242
|
+
fieldNamePrefix={fieldNamePrefix}
|
|
243
|
+
isOverrides={isOverrides}
|
|
244
|
+
/>
|
|
245
|
+
</>
|
|
246
|
+
);
|
|
247
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ProductZoneControl";
|
|
@@ -2,6 +2,7 @@ import { EmailTemplate } from "@licklist/core/dist/DataMapper/Notification/Email
|
|
|
2
2
|
import { SmsTemplate } from "@licklist/core/dist/DataMapper/Notification/SmsTemplateDataMapper";
|
|
3
3
|
import { TFunction } from "react-i18next";
|
|
4
4
|
import { UseFormSetError } from "react-hook-form";
|
|
5
|
+
import { checkIfZoneCategory } from "@licklist/plugins";
|
|
5
6
|
import { TemplateItem } from "../control/ProductSetControl";
|
|
6
7
|
import { ProductSetFormValues } from "../form/ProductSetForm";
|
|
7
8
|
|
|
@@ -60,7 +61,10 @@ export const checkAvailableTimesErrors = ({
|
|
|
60
61
|
let hasError = false;
|
|
61
62
|
|
|
62
63
|
const hasCategoryWithZone = values?.steps?.some(
|
|
63
|
-
(step) =>
|
|
64
|
+
(step) =>
|
|
65
|
+
!!step?.productCategories.some((category) =>
|
|
66
|
+
checkIfZoneCategory(category.type),
|
|
67
|
+
),
|
|
64
68
|
);
|
|
65
69
|
if (!hasCategoryWithZone) {
|
|
66
70
|
return hasError;
|