@licklist/design 0.44.485-dev.90 → 0.44.485-dev.92
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/index.js +1 -1
- package/dist/sales/manual-booking/index.d.ts +1 -5
- package/dist/sales/manual-booking/index.d.ts.map +1 -1
- package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts +1 -0
- package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts.map +1 -1
- package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.js +1 -1
- package/dist/sales/manual-booking/search-user/SearchUser.js +1 -1
- package/dist/sales/manual-booking/select-date-type-control/SelectDateTypeControl.d.ts +2 -2
- package/dist/sales/manual-booking/select-date-type-control/SelectDateTypeControl.js +1 -1
- package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts +3 -2
- package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts.map +1 -1
- package/dist/sales/manual-booking/select-menu/SelectMenu.js +1 -1
- package/dist/styles/sales/ManualBooking.scss +7 -1
- package/dist/types/iframe.d.ts +2 -0
- package/dist/types/iframe.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/sales/manual-booking/index.ts +1 -5
- package/src/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.tsx +3 -1
- package/src/sales/manual-booking/select-date-type-control/SelectDateTypeControl.stories.tsx +1 -1
- package/src/sales/manual-booking/select-date-type-control/SelectDateTypeControl.tsx +5 -5
- package/src/sales/manual-booking/select-menu/SelectMenu.tsx +4 -2
- package/src/styles/sales/ManualBooking.scss +7 -1
- package/src/types/iframe.ts +2 -0
- package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts +0 -16
- package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts.map +0 -1
- package/dist/sales/manual-booking/category-product/CategoryProduct.js +0 -1
- package/dist/sales/manual-booking/category-product/index.d.ts +0 -2
- package/dist/sales/manual-booking/category-product/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts +0 -17
- package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts.map +0 -1
- package/dist/sales/manual-booking/category-products/CategoryProducts.js +0 -1
- package/dist/sales/manual-booking/category-products/index.d.ts +0 -2
- package/dist/sales/manual-booking/category-products/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts +0 -15
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts.map +0 -1
- package/dist/sales/manual-booking/controll/ManualBookingStepsControll.js +0 -1
- package/dist/sales/manual-booking/controll/index.d.ts +0 -2
- package/dist/sales/manual-booking/controll/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/create-user/CreateUser.d.ts +0 -6
- package/dist/sales/manual-booking/create-user/CreateUser.d.ts.map +0 -1
- package/dist/sales/manual-booking/create-user/CreateUser.js +0 -1
- package/dist/sales/manual-booking/create-user/index.d.ts +0 -2
- package/dist/sales/manual-booking/create-user/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/customer-info/CustomerInfo.d.ts +0 -7
- package/dist/sales/manual-booking/customer-info/CustomerInfo.d.ts.map +0 -1
- package/dist/sales/manual-booking/customer-info/CustomerInfo.js +0 -1
- package/dist/sales/manual-booking/customer-info/index.d.ts +0 -2
- package/dist/sales/manual-booking/customer-info/index.d.ts.map +0 -1
- package/dist/sales/manual-booking/final-step/FinalStep.d.ts +0 -7
- package/dist/sales/manual-booking/final-step/FinalStep.d.ts.map +0 -1
- package/dist/sales/manual-booking/final-step/FinalStep.js +0 -1
- package/dist/sales/manual-booking/final-step/index.d.ts +0 -2
- package/dist/sales/manual-booking/final-step/index.d.ts.map +0 -1
- package/src/sales/manual-booking/category-product/CategoryProduct.tsx +0 -285
- package/src/sales/manual-booking/category-product/index.ts +0 -1
- package/src/sales/manual-booking/category-products/CategoryProducts.tsx +0 -69
- package/src/sales/manual-booking/category-products/index.ts +0 -1
- package/src/sales/manual-booking/controll/ManualBookingStepsControll.tsx +0 -121
- package/src/sales/manual-booking/controll/index.ts +0 -1
- package/src/sales/manual-booking/create-user/CreateUser.stories.tsx +0 -27
- package/src/sales/manual-booking/create-user/CreateUser.tsx +0 -224
- package/src/sales/manual-booking/create-user/index.ts +0 -1
- package/src/sales/manual-booking/customer-info/CustomerInfo.tsx +0 -128
- package/src/sales/manual-booking/customer-info/index.ts +0 -1
- package/src/sales/manual-booking/final-step/FinalStep.tsx +0 -38
- package/src/sales/manual-booking/final-step/index.ts +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),i=e(a),r=require("react-i18next"),l=e(require("@licklist/plugins/dist/context/app/hooks/useNotification")),n=require("react-bootstrap"),s=require("../../../static/Icon.js"),o=require("react-hook-form"),d=e(require("clsx")),u=require("../../../static/manual-date-picker/utils/index.js"),m=require("../../../static/manual-date-picker/ManualDatePicker.js");require("../../../static/index.js");var c=require("@licklist/plugins/dist"),v=require("../../../static/manual-date-picker/hooks/useManualDatePicker.js"),p=e(require("@licklist/plugins/dist/validation/Rules/lettersRule")),h=require("@licklist/core/dist/Config/DefaultUser");exports.CreateUser=function(e){var f,b=e.goToSearchUsers,N=e.providerId,g=r.useTranslation(["Sale","Design","App","Validation"]).t,E=l(),_=c.useDashboardUserApi(N).create,k=o.useFormContext(),y=k.formState,D=y.errors,F=y.isSubmitted,S=k.register,q=k.setValue,x=k.watch,C=k.getValues,I=x("birthdate"),V=x("firstName"),A=t.__read(v.useManualDatePicker({isRequired:!1,isSubmitted:F,fieldName:"birthdate",value:I,fieldErrors:c.HookFormService.getErrors("birthdate",D)}),2),L=A[0],R=A[1],j=R.isChoosedDateValid,U=R.fieldErrors,M=L.day,T=L.year,w=L.month;a.useEffect((function(){M&&w&&T&&j()&&q("birthdate",u.dateToSqlDate(M,w,T),{shouldValidate:!0})}),[M,w,T]);return i.createElement(i.Fragment,null,i.createElement(n.Button,{as:"button",type:"button",onClick:b,variant:"primary",className:"mb-4 mt-4 align-items-center d-flex"},g("Design:search"),i.createElement(s.default,{type:"search",height:"1.4rem",width:"1.4rem",className:"ml-3"})),i.createElement("div",{className:"input-label"},g("Design:firstName"),i.createElement("span",{className:"text-danger"},"*")),i.createElement(n.Form.Control,t.__assign({type:"text",isInvalid:!!(null==D?void 0:D.firstName)},S("firstName",{pattern:p,maxLength:255,required:!0}))),i.createElement(n.Form.Control.Feedback,{type:"invalid"},c.HookFormService.hasError(null==D?void 0:D.firstName,"required")&&g("Validation:fieldRequired",{attribute:g("Design:firstName")}),c.HookFormService.hasError(null==D?void 0:D.firstName,"pattern")&&g("Sale:fieldIsNotValid",{attribute:g("Design:firstName")})),i.createElement("div",{className:"input-label"},g("Design:lastName")),i.createElement(n.Form.Control,t.__assign({type:"text",isInvalid:!!(null==D?void 0:D.lastName)},S("lastName",{pattern:p,maxLength:255}))),i.createElement(n.Form.Control.Feedback,{type:"invalid"},(null==D?void 0:D.lastName)&&g("Sale:fieldIsNotValid",{attribute:g("Design:lastName")})),i.createElement("div",{className:"input-label"},g("Design:email")),i.createElement(n.Form.Control,t.__assign({type:"text",isInvalid:c.HookFormService.isInvalid("email",D)},S("email",{pattern:c.emailRule,maxLength:255}))),i.createElement(n.Form.Control.Feedback,{type:"invalid"},(null==D?void 0:D.email)&&g("Sale:fieldIsNotValid",{attribute:g("Design:email")})),i.createElement("div",{className:"input-label"},g("Design:phone")),i.createElement(n.Form.Control,t.__assign({type:"number"},S("phone",{pattern:c.phoneRule,maxLength:255}),{isInvalid:!!(null==D?void 0:D.phone)})),i.createElement(n.Form.Control.Feedback,{type:"invalid"},(null==D?void 0:D.phone)&&g("Sale:fieldIsNotValid",{attribute:"phone number"})),i.createElement("div",{className:"input-label"},g("Design:dayOfBirthShort")),i.createElement(n.Form.Control,t.__assign({type:"hidden"},S("birthdate",{validate:function(e){return!e||(!!c.checkIsValidBirthday(e)||"".concat(g("Sale:fieldIsNotValid",{attribute:g("App:birthday")})))}}),{isInvalid:!!D.birthdate,className:d("datetime-form-picker",I&&"date-input-with-value")})),i.createElement("div",{className:"d-flex"},i.createElement(m.ManualDatePicker,t.__assign({},L,{isRequred:!1}))),i.createElement(n.Form.Control.Feedback,{type:"invalid"},(null===(f=null==D?void 0:D.birthdate)||void 0===f?void 0:f.message)||U()),i.createElement(n.Button,{as:"button",type:"button",onClick:function(){return t.__awaiter(void 0,void 0,void 0,(function(){var e,a,i,r,l,n,s;return t.__generator(this,(function(o){switch(o.label){case 0:return e=C(),[4,_.execute({first_name:e.firstName,last_name:e.lastName,email:e.email,user_detail:{phone:e.phone,birthday:e.birthdate}})];case 1:return(a=o.sent())?(i={userId:String(a.id),firstName:a.firstName,lastName:a.lastName===h.DEFAULT_USER_LAST_NAME?null:a.lastName,email:a.email===h.DEFAULT_USER_EMAIL?null:a.email,phone:(null==a?void 0:a.userDetail)&&(null===(r=null==a?void 0:a.userDetail)||void 0===r?void 0:r.phone)?String(null===(l=null==a?void 0:a.userDetail)||void 0===l?void 0:l.phone):void 0,birthdate:(null==a?void 0:a.userDetail)&&(null===(n=a.userDetail)||void 0===n?void 0:n.birthday)?null===(s=a.userDetail)||void 0===s?void 0:s.birthday:void 0},Object.entries(i).forEach((function(e){var a=t.__read(e,2),i=a[0],r=a[1];q(i,r)})),E.success({title:g("App:success"),message:g("Notification:customerAddedSuccessfully")}),[2]):[2]}}))}))},variant:"primary",className:"mb-4",disabled:!V||(null==D?void 0:D.firstName)||(null==D?void 0:D.lastName)||(null==D?void 0:D.email)||(null==D?void 0:D.phone)||(null==D?void 0:D.birthday)||_.isLoading},g("Sale:addCustomer")))};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sales/manual-booking/create-user/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerInfo.d.ts","sourceRoot":"","sources":["../../../../src/sales/manual-booking/customer-info/CustomerInfo.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAShE,KAAK,iBAAiB,GAAG;IAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAW5D,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CA2G9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("react"),i=e(t),a=require("react-i18next"),o=require("react-bootstrap"),l=require("react-hook-form"),n=e(require("@licklist/plugins/dist/services/Form/HookFormService")),s=require("../../../collapsible-input-group/CollapsibleInputGroup.js"),u=require("../create-user/CreateUser.js"),c=require("../search-user/SearchUser.js"),m=["firstName","lastName","userId","birthday","phone","email"];exports.CustomerInfo=function(e){var d=e.providerId,f=a.useTranslation(["Sale","Design","Validation"]).t,v=l.useFormContext(),p=v.formState.errors,N=v.watch,h=v.clearErrors,E=v.setValue,b=v.register,q=N("firstName"),S=t.useMemo((function(){return n.hasError(null==p?void 0:p.firstName,"required")}),[null==p?void 0:p.firstName]),g=S?f("Validation:fieldRequired",{attribute:f("Sale:Customer first name")}):f("Sale:customerInfoError");t.useEffect((function(){S&&q&&q.length&&h("firstName")}),[null==p?void 0:p.firstName,q]);var I=t.useMemo((function(){return!!((null==p?void 0:p.firstName)||(null==p?void 0:p.lastName)||(null==p?void 0:p.email)||(null==p?void 0:p.phone)||(null==p?void 0:p.birthdate))}),[p.firstName,null==p?void 0:p.lastName,null==p?void 0:p.email,null==p?void 0:p.phone,null==p?void 0:p.birthdate]),C=r.__read(t.useState(!1),2),F=C[0],U=C[1],_=function(e){m.forEach((function(r){e&&r===e||E(r,void 0)}))};return b("firstName",{required:!0}),i.createElement(o.Accordion,{className:"medium-accordition accordition-customer-info"},i.createElement(s.CollapsibleInputGroup,{description:"",eventKey:"medium-accordition",label:i.createElement(i.Fragment,null,i.createElement("div",{className:"medium-accordition-header"},i.createElement("div",{className:"product-title"},f("Sale:customerInfo"))),I&&i.createElement("div",{className:"d-flex mt-3 w-100"},i.createElement("p",{className:"iframe-event__message-error mb-0"},g)))},i.createElement("div",{className:"customer-info"},F?i.createElement(i.Fragment,null,i.createElement(u.CreateUser,{goToSearchUsers:function(){U(!1),_()},providerId:d})):i.createElement(c.SearchUser,{providerId:d,handleNoFoundUsers:function(e){U(!0),_(e?"firstName":"email")}}))))};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sales/manual-booking/customer-info/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FinalStep.d.ts","sourceRoot":"","sources":["../../../../src/sales/manual-booking/final-step/FinalStep.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKlC,KAAK,cAAc,GAAG;IAAE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEzD,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CA8BxC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,a=require("react-i18next"),n=require("react-hook-form"),o=require("../customer-info/CustomerInfo.js");exports.FinalStep=function(e){var t=e.providerId,l=a.useTranslation("Sale").t,s=n.useFormContext().control;return r.createElement(r.Fragment,null,r.createElement("div",{className:"manual-booking-header mt-6 mt-5 border-bottom"},r.createElement("div",{className:"manual-booking-title"},l("Sale:finalSteps"))),r.createElement(o.CustomerInfo,{providerId:t}),r.createElement(n.Controller,{control:s,name:"specialNotes",render:function(e){var t=e.field,a=t.onChange,n=t.value,o=t.ref;return r.createElement("div",{className:"special-notes-container"},r.createElement("div",{className:"margin-top-2-rem input-label "},l("specialNotes")),r.createElement("textarea",{rows:3,onChange:a,ref:o,value:n,className:"special-notes"}))}}))};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sales/manual-booking/final-step/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
|
|
3
|
-
import { useFormContext, Controller } from "react-hook-form";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
import { useTranslation } from "react-i18next";
|
|
6
|
-
import { OverlayTrigger, Tooltip } from "react-bootstrap";
|
|
7
|
-
import MediaService from "@licklist/plugins/dist/services/Media/MediaService";
|
|
8
|
-
import { OrderProduct } from "@licklist/core/dist/DataMapper/Order/OrderProductDataMapper";
|
|
9
|
-
import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
10
|
-
import { NumberInputHorizontal } from "../number-input-horizontal";
|
|
11
|
-
import { Product } from "../../../types";
|
|
12
|
-
import { TipTapEditor } from "../../../tiptap-editor";
|
|
13
|
-
|
|
14
|
-
interface CategoryProductProps {
|
|
15
|
-
product: Product;
|
|
16
|
-
fieldIndex: `steps.${number}.productCategories.${number}.products.${number}`;
|
|
17
|
-
productsWithErrors?: QuantityCheckProductInfo[];
|
|
18
|
-
isLoading?: boolean;
|
|
19
|
-
isEditMode?: boolean;
|
|
20
|
-
isProductSetAvailable?: boolean;
|
|
21
|
-
orderProducts?: OrderProduct[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const CategoryProduct = ({
|
|
25
|
-
product,
|
|
26
|
-
fieldIndex,
|
|
27
|
-
productsWithErrors,
|
|
28
|
-
isLoading = false,
|
|
29
|
-
isEditMode = false,
|
|
30
|
-
isProductSetAvailable = false,
|
|
31
|
-
orderProducts,
|
|
32
|
-
}: CategoryProductProps) => {
|
|
33
|
-
const { t } = useTranslation(["Design", "Validation"]);
|
|
34
|
-
const { control, clearErrors, setError } = useFormContext();
|
|
35
|
-
const [isEditingPrice, setEditingPrice] = useState(false);
|
|
36
|
-
const imageSrc = product.images
|
|
37
|
-
? MediaService.getImageSrc(product.images)
|
|
38
|
-
: null;
|
|
39
|
-
|
|
40
|
-
const currentProductMaxValue: number | undefined = useMemo(() => {
|
|
41
|
-
if (!orderProducts) return undefined;
|
|
42
|
-
|
|
43
|
-
const orderProduct = orderProducts.find(
|
|
44
|
-
(orderProduct) => orderProduct.productId === product.id
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
if (!orderProduct) return undefined;
|
|
48
|
-
|
|
49
|
-
return orderProduct.quantity;
|
|
50
|
-
}, [orderProducts, product.id]);
|
|
51
|
-
|
|
52
|
-
const onPriceClick = () => {
|
|
53
|
-
// disable change price when not edit mode
|
|
54
|
-
// and product isSoldOut or isLoading new data
|
|
55
|
-
if ((!isEditMode && product.isSoldOut) || isLoading) return;
|
|
56
|
-
|
|
57
|
-
setEditingPrice(true);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const productQuantityError = useMemo(() => {
|
|
61
|
-
if (!productsWithErrors) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const error = productsWithErrors.find(
|
|
66
|
-
(productWithError) => productWithError.product_id === product.id
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
return error?.message;
|
|
70
|
-
}, [productsWithErrors, product.id]);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (!productQuantityError) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setError(`${fieldIndex}.quantity`, {
|
|
78
|
-
message: productQuantityError,
|
|
79
|
-
type: "validate",
|
|
80
|
-
});
|
|
81
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
-
}, [productQuantityError]);
|
|
83
|
-
|
|
84
|
-
const PriceControl = ({ ref, onChange, value, invalid }) => (
|
|
85
|
-
<NumberInputHorizontal
|
|
86
|
-
ref={ref}
|
|
87
|
-
onChange={(val) => {
|
|
88
|
-
onChange(val);
|
|
89
|
-
// @TODO: change any to some type
|
|
90
|
-
clearErrors(`${fieldIndex}.price` as any);
|
|
91
|
-
}}
|
|
92
|
-
onMinusClick={() => {
|
|
93
|
-
onChange(value - 1 || 0);
|
|
94
|
-
// @TODO: change any to some type
|
|
95
|
-
clearErrors(`${fieldIndex}.price` as any);
|
|
96
|
-
}}
|
|
97
|
-
onPlusClick={() => {
|
|
98
|
-
onChange((value ?? 0) + 1);
|
|
99
|
-
// @TODO: change any to some type
|
|
100
|
-
clearErrors(`${fieldIndex}.price` as any);
|
|
101
|
-
}}
|
|
102
|
-
min={0}
|
|
103
|
-
disabled={
|
|
104
|
-
isLoading || (!isEditMode && product.isSoldOut) || !isEditingPrice
|
|
105
|
-
}
|
|
106
|
-
value={Number(value || 0)}
|
|
107
|
-
className={clsx(invalid && "error")}
|
|
108
|
-
isLoading={isLoading}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<>
|
|
114
|
-
<Controller
|
|
115
|
-
// @TODO: change any to some type
|
|
116
|
-
name={`${fieldIndex}.price` as any}
|
|
117
|
-
control={control}
|
|
118
|
-
render={({
|
|
119
|
-
field: { onChange, value, ref },
|
|
120
|
-
fieldState: { invalid, error },
|
|
121
|
-
}) => {
|
|
122
|
-
return (
|
|
123
|
-
<>
|
|
124
|
-
<div className="medium-accordition-description-container">
|
|
125
|
-
<TipTapEditor
|
|
126
|
-
viewMode
|
|
127
|
-
disabled
|
|
128
|
-
content={product.description}
|
|
129
|
-
editorStyle={{ backgroundColor: "transparent" }}
|
|
130
|
-
/>
|
|
131
|
-
{!product.isSoldOut ? (
|
|
132
|
-
<OverlayTrigger
|
|
133
|
-
key="status-tooltip"
|
|
134
|
-
placement="top"
|
|
135
|
-
overlay={
|
|
136
|
-
<Tooltip id="tooltip-right">
|
|
137
|
-
<span>{t("Sale:clickToEdit")}</span>
|
|
138
|
-
</Tooltip>
|
|
139
|
-
}
|
|
140
|
-
>
|
|
141
|
-
<div
|
|
142
|
-
role="button"
|
|
143
|
-
tabIndex={0}
|
|
144
|
-
onClick={onPriceClick}
|
|
145
|
-
onKeyDown={onPriceClick}
|
|
146
|
-
>
|
|
147
|
-
<PriceControl
|
|
148
|
-
ref={ref}
|
|
149
|
-
onChange={onChange}
|
|
150
|
-
value={value}
|
|
151
|
-
invalid={invalid}
|
|
152
|
-
/>
|
|
153
|
-
</div>
|
|
154
|
-
</OverlayTrigger>
|
|
155
|
-
) : (
|
|
156
|
-
<PriceControl
|
|
157
|
-
ref={ref}
|
|
158
|
-
onChange={onChange}
|
|
159
|
-
value={value}
|
|
160
|
-
invalid={invalid}
|
|
161
|
-
/>
|
|
162
|
-
)}
|
|
163
|
-
</div>
|
|
164
|
-
{invalid && (
|
|
165
|
-
<div className="d-flex mt-3 w-100">
|
|
166
|
-
<p className="iframe-event__message-error">
|
|
167
|
-
{error &&
|
|
168
|
-
HookFormService.hasError(error, "validate") &&
|
|
169
|
-
error?.message}
|
|
170
|
-
</p>
|
|
171
|
-
</div>
|
|
172
|
-
)}
|
|
173
|
-
</>
|
|
174
|
-
);
|
|
175
|
-
}}
|
|
176
|
-
/>
|
|
177
|
-
|
|
178
|
-
<Controller
|
|
179
|
-
control={control}
|
|
180
|
-
name={`${fieldIndex}.quantity` as string}
|
|
181
|
-
rules={{
|
|
182
|
-
validate: (value) => {
|
|
183
|
-
if (!value) return true;
|
|
184
|
-
|
|
185
|
-
const { maxAmount = 0, isUnlimited = false } = product;
|
|
186
|
-
|
|
187
|
-
// In case when we edit order and product set not
|
|
188
|
-
// available by current date we should check on
|
|
189
|
-
// max amount which equals orderProduct.quantity
|
|
190
|
-
// We should check this before all next validations
|
|
191
|
-
if (currentProductMaxValue !== undefined && isEditMode) {
|
|
192
|
-
if (isUnlimited && isProductSetAvailable) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!isProductSetAvailable && value > currentProductMaxValue) {
|
|
197
|
-
return t("Validation:quantityMaxNumber", {
|
|
198
|
-
max: currentProductMaxValue,
|
|
199
|
-
}) as string;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (isUnlimited) {
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (value > maxAmount) {
|
|
208
|
-
return t("Validation:quantityMaxNumber", {
|
|
209
|
-
max: product.maxAmount,
|
|
210
|
-
}) as string;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return true;
|
|
214
|
-
},
|
|
215
|
-
}}
|
|
216
|
-
render={({
|
|
217
|
-
field: { onChange, value, ref },
|
|
218
|
-
fieldState: { invalid, error },
|
|
219
|
-
}) => {
|
|
220
|
-
return (
|
|
221
|
-
<div className="mb-8">
|
|
222
|
-
<div className="quantity-container">
|
|
223
|
-
<div className="number-input-horizontal-wrapper">
|
|
224
|
-
<NumberInputHorizontal
|
|
225
|
-
ref={ref}
|
|
226
|
-
size="big"
|
|
227
|
-
onChange={(val) => {
|
|
228
|
-
onChange(val);
|
|
229
|
-
}}
|
|
230
|
-
onMinusClick={() => {
|
|
231
|
-
onChange(value - 1 || 0);
|
|
232
|
-
}}
|
|
233
|
-
onPlusClick={() => {
|
|
234
|
-
onChange((value ?? 0) + 1);
|
|
235
|
-
}}
|
|
236
|
-
min={0}
|
|
237
|
-
disabled={
|
|
238
|
-
isLoading ||
|
|
239
|
-
(!isEditMode && !isProductSetAvailable) ||
|
|
240
|
-
(product.isSoldOut && !isEditMode) ||
|
|
241
|
-
(isEditMode &&
|
|
242
|
-
currentProductMaxValue === undefined &&
|
|
243
|
-
!isProductSetAvailable)
|
|
244
|
-
}
|
|
245
|
-
value={value || 0}
|
|
246
|
-
className={clsx(invalid && "error")}
|
|
247
|
-
isLoading={isLoading}
|
|
248
|
-
/>
|
|
249
|
-
</div>
|
|
250
|
-
{imageSrc && (
|
|
251
|
-
<div
|
|
252
|
-
className={[
|
|
253
|
-
"image-wrapper",
|
|
254
|
-
product.isSoldOut && "opacity-50",
|
|
255
|
-
].join(" ")}
|
|
256
|
-
>
|
|
257
|
-
<img src={imageSrc} alt={product.name} />
|
|
258
|
-
</div>
|
|
259
|
-
)}
|
|
260
|
-
</div>
|
|
261
|
-
|
|
262
|
-
{invalid && (
|
|
263
|
-
<div className="d-flex mt-3 w-100">
|
|
264
|
-
<p className="iframe-event__message-error">
|
|
265
|
-
{error &&
|
|
266
|
-
HookFormService.hasError(error, "validate") &&
|
|
267
|
-
error?.message}
|
|
268
|
-
</p>
|
|
269
|
-
</div>
|
|
270
|
-
)}
|
|
271
|
-
|
|
272
|
-
{!isLoading && !isProductSetAvailable && (
|
|
273
|
-
<div className="d-flex mt-3 w-100">
|
|
274
|
-
<p className="iframe-event__message-error">
|
|
275
|
-
{t("Design:productIsNotAvailableForSelectedDate")}
|
|
276
|
-
</p>
|
|
277
|
-
</div>
|
|
278
|
-
)}
|
|
279
|
-
</div>
|
|
280
|
-
);
|
|
281
|
-
}}
|
|
282
|
-
/>
|
|
283
|
-
</>
|
|
284
|
-
);
|
|
285
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./CategoryProduct";
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { Accordion } from "react-bootstrap";
|
|
4
|
-
import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
5
|
-
import { OrderProduct } from "@licklist/core/dist/DataMapper/Order/OrderProductDataMapper";
|
|
6
|
-
import { CollapsibleInputGroup } from "../../../collapsible-input-group";
|
|
7
|
-
import { Product } from "../../../types";
|
|
8
|
-
import { CategoryProduct } from "../category-product/CategoryProduct";
|
|
9
|
-
|
|
10
|
-
interface CategoryProductsProps {
|
|
11
|
-
stepIndex: number;
|
|
12
|
-
categoryIndex: number;
|
|
13
|
-
products?: Product[];
|
|
14
|
-
productsWithErrors?: QuantityCheckProductInfo[];
|
|
15
|
-
isLoading?: boolean;
|
|
16
|
-
isEditMode?: boolean;
|
|
17
|
-
isProductSetAvailable?: boolean;
|
|
18
|
-
orderProducts?: OrderProduct[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const CategoryProducts = ({
|
|
22
|
-
products,
|
|
23
|
-
stepIndex,
|
|
24
|
-
categoryIndex,
|
|
25
|
-
productsWithErrors,
|
|
26
|
-
isLoading = false,
|
|
27
|
-
isEditMode = false,
|
|
28
|
-
isProductSetAvailable = false,
|
|
29
|
-
orderProducts,
|
|
30
|
-
}: CategoryProductsProps) => {
|
|
31
|
-
return (
|
|
32
|
-
<>
|
|
33
|
-
{products?.map((product, index) => {
|
|
34
|
-
const fieldIndex =
|
|
35
|
-
`steps.${stepIndex}.productCategories.${categoryIndex}.products.${index}` as const;
|
|
36
|
-
return (
|
|
37
|
-
<Accordion
|
|
38
|
-
defaultActiveKey="product"
|
|
39
|
-
key={product.id}
|
|
40
|
-
className="medium-accordition"
|
|
41
|
-
>
|
|
42
|
-
<CollapsibleInputGroup
|
|
43
|
-
description=""
|
|
44
|
-
alwaysOpen
|
|
45
|
-
eventKey="product"
|
|
46
|
-
label={
|
|
47
|
-
<div className="medium-accordition-header">
|
|
48
|
-
<div className="medium-accordition-title">
|
|
49
|
-
{product?.name}
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
}
|
|
53
|
-
>
|
|
54
|
-
<CategoryProduct
|
|
55
|
-
fieldIndex={fieldIndex}
|
|
56
|
-
product={product}
|
|
57
|
-
productsWithErrors={productsWithErrors}
|
|
58
|
-
isLoading={isLoading}
|
|
59
|
-
isEditMode={isEditMode}
|
|
60
|
-
isProductSetAvailable={isProductSetAvailable}
|
|
61
|
-
orderProducts={orderProducts}
|
|
62
|
-
/>
|
|
63
|
-
</CollapsibleInputGroup>
|
|
64
|
-
</Accordion>
|
|
65
|
-
);
|
|
66
|
-
})}
|
|
67
|
-
</>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./CategoryProducts";
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { Accordion } from "react-bootstrap";
|
|
3
|
-
import { useFormContext } from "react-hook-form";
|
|
4
|
-
import { useTranslation } from "react-i18next";
|
|
5
|
-
import { QuantityCheckProductInfo } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
6
|
-
import { OrderProduct } from "@licklist/core/dist/DataMapper/Order/OrderProductDataMapper";
|
|
7
|
-
import { ErrorModal } from "../../../iframe/order-process/components/ErrorModal/ErrorModal";
|
|
8
|
-
import { MenuStep } from "../../../types";
|
|
9
|
-
import { CollapsibleInputGroup } from "../../../collapsible-input-group";
|
|
10
|
-
import { CategoryProducts } from "../category-products/CategoryProducts";
|
|
11
|
-
|
|
12
|
-
export interface ManualBookingStepsControllProps {
|
|
13
|
-
step: MenuStep;
|
|
14
|
-
stepIndex: number;
|
|
15
|
-
productsWithErrors?: QuantityCheckProductInfo[];
|
|
16
|
-
isLoading?: boolean;
|
|
17
|
-
isEditMode?: boolean;
|
|
18
|
-
isProductSetAvailable?: boolean;
|
|
19
|
-
orderProducts?: OrderProduct[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const ManualBookingStepsControll = ({
|
|
23
|
-
step,
|
|
24
|
-
stepIndex,
|
|
25
|
-
productsWithErrors,
|
|
26
|
-
isLoading = false,
|
|
27
|
-
isEditMode = false,
|
|
28
|
-
isProductSetAvailable = false,
|
|
29
|
-
orderProducts,
|
|
30
|
-
}: ManualBookingStepsControllProps) => {
|
|
31
|
-
const {
|
|
32
|
-
formState: { errors },
|
|
33
|
-
} = useFormContext();
|
|
34
|
-
const { t } = useTranslation(["Design"]);
|
|
35
|
-
const stepError =
|
|
36
|
-
errors && errors?.steps ? errors?.steps[stepIndex] : undefined;
|
|
37
|
-
|
|
38
|
-
const [showProductQuatityError, setShowProductQuantityError] =
|
|
39
|
-
useState(false);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (!productsWithErrors) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
setShowProductQuantityError(true);
|
|
46
|
-
}, [productsWithErrors]);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Accordion key={step.id} defaultActiveKey="step">
|
|
50
|
-
<ErrorModal
|
|
51
|
-
isOpen={showProductQuatityError}
|
|
52
|
-
onClose={() => setShowProductQuantityError(false)}
|
|
53
|
-
messageKey="pleaseCheckSelectedProducts"
|
|
54
|
-
/>
|
|
55
|
-
<CollapsibleInputGroup
|
|
56
|
-
alwaysOpen
|
|
57
|
-
description=""
|
|
58
|
-
eventKey="step"
|
|
59
|
-
label={
|
|
60
|
-
<>
|
|
61
|
-
<div className="step-title">{step?.name}</div>
|
|
62
|
-
{stepError && (
|
|
63
|
-
<div className="d-flex mt-3 w-100">
|
|
64
|
-
<p className="iframe-event__message-error mb-0">
|
|
65
|
-
{t("notValidStep")}
|
|
66
|
-
</p>
|
|
67
|
-
</div>
|
|
68
|
-
)}
|
|
69
|
-
</>
|
|
70
|
-
}
|
|
71
|
-
>
|
|
72
|
-
{step.productCategories.map((productCategory, categoryIndex) => {
|
|
73
|
-
const categoryError =
|
|
74
|
-
stepError && stepError?.productCategories
|
|
75
|
-
? stepError?.productCategories[categoryIndex]
|
|
76
|
-
: undefined;
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<Accordion
|
|
80
|
-
key={productCategory.id}
|
|
81
|
-
defaultActiveKey={
|
|
82
|
-
step.productCategories.length === 1 ? "categories" : undefined
|
|
83
|
-
}
|
|
84
|
-
>
|
|
85
|
-
<CollapsibleInputGroup
|
|
86
|
-
description=""
|
|
87
|
-
eventKey="categories"
|
|
88
|
-
alwaysOpen={step.productCategories.length === 1}
|
|
89
|
-
label={
|
|
90
|
-
<>
|
|
91
|
-
<div className="category-title">
|
|
92
|
-
{productCategory?.name}
|
|
93
|
-
</div>
|
|
94
|
-
{categoryError && (
|
|
95
|
-
<div className="d-flex mt-3 w-100">
|
|
96
|
-
<p className="iframe-event__message-error mb-0">
|
|
97
|
-
{t("notValidCategory")}
|
|
98
|
-
</p>
|
|
99
|
-
</div>
|
|
100
|
-
)}
|
|
101
|
-
</>
|
|
102
|
-
}
|
|
103
|
-
>
|
|
104
|
-
<CategoryProducts
|
|
105
|
-
products={productCategory?.products}
|
|
106
|
-
stepIndex={stepIndex}
|
|
107
|
-
categoryIndex={categoryIndex}
|
|
108
|
-
productsWithErrors={productsWithErrors}
|
|
109
|
-
isLoading={isLoading}
|
|
110
|
-
isEditMode={isEditMode}
|
|
111
|
-
isProductSetAvailable={isProductSetAvailable}
|
|
112
|
-
orderProducts={orderProducts}
|
|
113
|
-
/>
|
|
114
|
-
</CollapsibleInputGroup>
|
|
115
|
-
</Accordion>
|
|
116
|
-
);
|
|
117
|
-
})}
|
|
118
|
-
</CollapsibleInputGroup>
|
|
119
|
-
</Accordion>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./ManualBookingStepsControll";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Meta } from "@storybook/react";
|
|
3
|
-
import { useForm, FormProvider } from "react-hook-form";
|
|
4
|
-
import { Form } from "react-bootstrap";
|
|
5
|
-
import { CreateUser } from "./CreateUser";
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: "Sales/ManualBooking/CreateUser",
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
export const Default = (args) => {
|
|
12
|
-
const form = useForm({ mode: "onChange" });
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<FormProvider {...form}>
|
|
16
|
-
<Form>
|
|
17
|
-
<div style={{ height: "550px" }}>
|
|
18
|
-
<CreateUser {...args} />
|
|
19
|
-
</div>
|
|
20
|
-
</Form>
|
|
21
|
-
</FormProvider>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
Default.args = {
|
|
26
|
-
goToSearchUsers: () => {},
|
|
27
|
-
};
|