@licklist/design 0.44.485-dev.10 → 0.44.485-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.d.ts +2 -0
- package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.js +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts +3 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/Category.js +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts +3 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.js +1 -1
- package/dist/iframe/order-process/components/Category/Category.d.ts +2 -1
- package/dist/iframe/order-process/components/Category/Category.d.ts.map +1 -1
- package/dist/iframe/order-process/components/Category/Category.js +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts +2 -1
- package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.js +1 -1
- package/dist/iframe/order-process/components/StepsForm/StepsForm.d.ts +1 -0
- package/dist/iframe/order-process/components/StepsForm/StepsForm.d.ts.map +1 -1
- package/dist/iframe/order-process/components/StepsForm/StepsForm.js +1 -1
- package/package.json +1 -1
- package/src/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.tsx +4 -0
- package/src/iframe/order-process/components/CalendarStepsForm/components/Category.tsx +4 -0
- package/src/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.tsx +4 -0
- package/src/iframe/order-process/components/Category/Category.tsx +3 -0
- package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +16 -1
- package/src/iframe/order-process/components/StepsForm/StepsForm.tsx +3 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Step } from "@licklist/core/dist/DataMapper/Product/StepDataMapper";
|
|
3
|
+
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
3
4
|
import { MenuStep } from "../../../../types";
|
|
4
5
|
export interface CalendarStepsFormProps {
|
|
5
6
|
step: MenuStep;
|
|
@@ -13,6 +14,7 @@ export interface CalendarStepsFormProps {
|
|
|
13
14
|
onActiveVenueMapChange?: (nextVenueMapId: string) => void;
|
|
14
15
|
title: string;
|
|
15
16
|
menuStepWithVenueMap: Step;
|
|
17
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
16
18
|
}
|
|
17
19
|
export declare type StepsFormRef = {
|
|
18
20
|
getFormValues: () => Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarStepsForm.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,IAAI,EAAE,MAAM,uDAAuD,CAAC;
|
|
1
|
+
{"version":3,"file":"CalendarStepsForm.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CalendarStepsForm/CalendarStepsForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAUf,OAAO,EAAE,IAAI,EAAE,MAAM,uDAAuD,CAAC;AAG7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAY7C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAChD,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sBAAsB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB,EAAE,IAAI,CAAC;IAC3B,eAAe,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;CAC5D;AAED,oBAAY,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,iBAAiB,6FAoT7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tslib"),r=require("react"),n=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,o=require("react-i18next"),u=require("react-bootstrap"),i=require("react-hook-form"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tslib"),r=require("react"),n=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,o=require("react-i18next"),u=require("react-bootstrap"),i=require("react-hook-form"),s=require("lodash"),a=require("@licklist/plugins/dist/hooks/Value/usePreviousValue"),l=require("@licklist/plugins/dist/utils/ScrollUtils"),c=require("@licklist/plugins/dist/utils/FormValues"),d=require("../../../event/event-calendar/components/CalendarSelect/CalendarSelect.js"),f=require("../../../event/event-venue-map/IframeEventVenueMap.js"),m=require("../../constants.js"),p=require("./components/ErrorModal.js"),v=require("../utils/category.js"),g=require("./components/Category.js"),E=require("../../../page/components/PageBody/PageBody.js"),_=r.forwardRef((function(e,_){var y=e.step,S=e.isLastMenuStep,C=e.setFormValues,h=e.defaultValues,P=e.onSubmit,M=e.setFormErrors,q=e.id,V=void 0===q?m.STEP_FORM_ID:q,F=e.activeVenueMapId,b=e.title,k=e.menuStepWithVenueMap,j=e.onActiveVenueMapChange,I=e.soldOutProducts,O=i.useForm({defaultValues:h}),A=r.useRef(null),B=v.useCategory().verifyCategoryItems,T=O.control,x=O.formState.errors,K=O.formState,L=O.getValues,N=O.reset,R=O.setError,U=O.clearErrors,D=i.useWatch({control:T}),W=a.usePreviousValue(x),w=o.useTranslation("Design").t,H=t.__read(r.useState(""),2),z=H[0],G=H[1],J=t.__read(r.useState(F),2),Q=J[0],X=J[1],Y=t.__read(r.useState(void 0),2),Z=Y[0],$=Y[1],ee=t.__read(r.useState([]),2),te=ee[0],re=ee[1];r.useImperativeHandle(_,(function(){return{getFormValues:function(){return L()}}}));var ne=function(){var e;null===(e=A.current)||void 0===e||e.setActiveElementKey(void 0)},oe=r.useMemo((function(){var e;return null===(e=null==k?void 0:k.venueMapSet)||void 0===e?void 0:e.venueMaps}),[k]),ue=r.useMemo((function(){return oe&&k?oe.find((function(e){return String(e.id)===String(Q)})):null}),[oe,Q,k]),ie=r.useMemo((function(){if(!oe||!oe.length||!k)return[];var e=k.pointProducts.map((function(e){return e.pointId}));return oe.filter((function(t){var r=t.points;return r.length&&r.some((function(t){var r=t.id;return e.includes(r)}))})).map((function(e){return{label:e.name,value:e.id}}))}),[oe,k]),se=r.useMemo((function(){return ue?ue.points.filter((function(e){return Boolean(k.pointProducts.find((function(t){return t.pointId===e.id})))})):[]}),[k,ue]),ae=r.useCallback((function(e){var r;return y&&(null===(r=null==y?void 0:y.productCategories)||void 0===r?void 0:r.length)?null==y?void 0:y.productCategories.reduce((function(r,n){var o=n.products.filter((function(t){return e.includes(String(t.id))}));return o.length?t.__spreadArray(t.__spreadArray([],t.__read(r),!1),t.__read(o.map((function(e){return e.uuid}))),!1):r}),[]):[]}),[y]),le=r.useCallback((function(e){X(e),j&&j(e)}),[j]),ce=r.useMemo((function(){return ae(Object.keys(D).filter((function(e){var t,r;return Boolean(null===(t=D[e])||void 0===t?void 0:t.id)&&(null===(r=D[e])||void 0===r?void 0:r.quantity)>=1})).map((function(e){return String(e)})))}),[D,ae,x]),de=r.useMemo((function(){return Object.keys(x).length?ae(Object.keys(x).map((function(e){return String(e)}))):[]}),[x,ae,K]);return r.useEffect((function(){re(y.productCategories&&y.productCategories.length?y.productCategories.reduce((function(e,r){return t.__spreadArray(t.__spreadArray([],t.__read(e),!1),t.__read(r.products||[]),!1)}),[]):[])}),[y]),r.useEffect((function(){oe.length&&!Q&&X(String(oe[0].id))}),[oe,Q]),r.useEffect((function(){C(D),x&&setTimeout(U,0)}),[D]),r.useEffect((function(){c.isFormValuesEmpty(D)||G("")}),[D]),r.useEffect((function(){N(h)}),[h]),r.useEffect((function(){!s.isEqual(x,W)&&M&&M(x)}),[x,W,M]),r.useEffect((function(){Q!==F&&X(F)}),[F,Q]),r.useEffect((function(){$(void 0),ne()}),[Q,$]),n.createElement(n.Fragment,null,n.createElement(E.PageBody.LeftBlock,{title:b,component:ie.length>1&&n.createElement(d.CalendarSelect,{value:F,onChange:le,options:ie}),childrenClassName:"bordered"},n.createElement(p.ErrorModal,{isOpen:Boolean(z),messageKey:z,onClose:function(){return G("")}}),n.createElement(u.Form,{onSubmit:O.handleSubmit((function(e){if(S&&c.isFormValuesEmpty(e))G(w("pleaseSelectAtLeastFrom",{min:1,type:"item",from:"those categories"}));else{var t=B(e,y);if(t)return G(t.message),void R("category_".concat(t.id),{message:t.message});P(e)}}),(function(e){l.scrollToError(c.getFirstErrorKey(e)),G(w("pleaseCheckSelectedProducts"))})),id:V,className:"category-steps-form"},n.createElement(i.FormProvider,t.__assign({},O),n.createElement("div",{className:"position-relative"},ue&&n.createElement(n.Fragment,null,n.createElement(f.IframeEventVenueMap,{url:ue.image.url,usedInIframe:!0,onPointClick:$,products:te,points:se,pointProducts:k.pointProducts,ref:A,choosedProductUuids:ce,errorOnChoosedProductUuids:de}),n.createElement(g.Category,{productCategories:null==y?void 0:y.productCategories,activePointId:Z,pointProducts:k.pointProducts,onCloseModal:ne,soldOutProducts:I})))))))}));exports.CalendarStepsForm=_;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PointProduct } from "@licklist/core/dist/DataMapper/Product/PointProductDataMapper";
|
|
3
|
+
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
3
4
|
import { ProductCategory } from "../../../../../types";
|
|
4
5
|
export declare type CategoryProps = {
|
|
5
6
|
productCategories: ProductCategory[];
|
|
6
7
|
activePointId?: number;
|
|
7
8
|
pointProducts: PointProduct[];
|
|
8
9
|
onCloseModal: () => void;
|
|
10
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
9
11
|
};
|
|
10
|
-
export declare const Category: ({ productCategories, activePointId, pointProducts, onCloseModal, }: CategoryProps) => JSX.Element;
|
|
12
|
+
export declare const Category: ({ productCategories, activePointId, pointProducts, onCloseModal, soldOutProducts, }: CategoryProps) => JSX.Element;
|
|
11
13
|
//# sourceMappingURL=Category.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Category.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CalendarStepsForm/components/Category.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,oBAAY,aAAa,GAAG;IAC1B,iBAAiB,EAAE,eAAe,EAAE,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,YAAY,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"Category.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CalendarStepsForm/components/Category.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAC7F,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,oBAAY,aAAa,GAAG;IAC1B,iBAAiB,EAAE,eAAe,EAAE,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;CAC5D,CAAC;AAEF,eAAO,MAAM,QAAQ,wFAMlB,aAAa,gBAyBf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),o=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,r=require("./CategoryProductModal.js");exports.Category=function(e){var t=e.productCategories,a=e.activePointId,u=e.pointProducts,c=e.onCloseModal,d=e.soldOutProducts;return o.createElement(o.Fragment,null,0!==t.length&&t.map((function(e){return o.createElement("div",{key:e.id,className:"iframe-event__category"},e.products.map((function(t){return o.createElement(r.CategoryProductModal,{key:t.id,product:t,category:e,activePointId:a,pointProducts:u,onCloseModal:c,soldOutProducts:d})})))})))};
|
package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PointProduct } from "@licklist/core/dist/DataMapper/Product/PointProductDataMapper";
|
|
3
|
+
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
3
4
|
import { ProductCategory, Product } from "../../../../../types";
|
|
4
5
|
export declare type CategoryProductModalProps = {
|
|
5
6
|
activePointId?: number;
|
|
@@ -7,6 +8,7 @@ export declare type CategoryProductModalProps = {
|
|
|
7
8
|
category: ProductCategory;
|
|
8
9
|
pointProducts: PointProduct[];
|
|
9
10
|
onCloseModal: () => void;
|
|
11
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
10
12
|
};
|
|
11
|
-
export declare const CategoryProductModal: ({ activePointId, product, category, pointProducts, onCloseModal, }: CategoryProductModalProps) => JSX.Element;
|
|
13
|
+
export declare const CategoryProductModal: ({ activePointId, product, category, pointProducts, onCloseModal, soldOutProducts, }: CategoryProductModalProps) => JSX.Element;
|
|
12
14
|
//# sourceMappingURL=CategoryProductModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoryProductModal.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIhE,oBAAY,yBAAyB,GAAG;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,YAAY,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"CategoryProductModal.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,+DAA+D,CAAC;AAC7F,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIhE,oBAAY,yBAAyB,GAAG;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;CAC5D,CAAC;AAEF,eAAO,MAAM,oBAAoB,wFAO9B,yBAAyB,gBAmC3B,CAAC"}
|
package/dist/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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("react"),r=e(t),o=require("react-bootstrap"),
|
|
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("react"),r=e(t),o=require("react-bootstrap"),c=require("../../../../../static/Icon.js"),u=e(require("clsx")),a=require("../../CategoryProduct/CategoryProduct.js");exports.CategoryProductModal=function(e){var n=e.activePointId,d=e.product,i=e.category,s=e.pointProducts,l=e.onCloseModal,m=e.soldOutProducts,p=t.useMemo((function(){return s.find((function(e){return String(e.pointId)===String(n)}))}),[n,s]);return r.createElement("div",{className:u("category-product-modal",p&&p.productUuid===d.uuid&&"d-block")},r.createElement(a.CategoryProduct,{product:d,category:i,canExpandDescription:!1,soldOutProducts:m}),r.createElement("div",{className:"close-modal-button"},r.createElement(o.Button,{variant:"danger",className:"btn-sm rounded",onClick:l},r.createElement(c.default,{type:"times",height:"1rem"}))))};
|
|
@@ -5,8 +5,9 @@ import { StepsFormProps } from "../StepsForm/StepsForm";
|
|
|
5
5
|
interface CategoryProps {
|
|
6
6
|
productCategories: ProductCategory[];
|
|
7
7
|
productsWithErrors?: StepsFormProps["productsWithErrors"];
|
|
8
|
+
soldOutProducts?: StepsFormProps["productsWithErrors"];
|
|
8
9
|
errors?: DeepMap<Record<string, any>, FieldError>;
|
|
9
10
|
}
|
|
10
|
-
export declare function Category({ productCategories, productsWithErrors, errors, }: CategoryProps): JSX.Element;
|
|
11
|
+
export declare function Category({ productCategories, productsWithErrors, errors, soldOutProducts, }: CategoryProps): JSX.Element;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=Category.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Category.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/Category/Category.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,UAAU,aAAa;IACrB,iBAAiB,EAAE,eAAe,EAAE,CAAC;IACrC,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;CACnD;AAED,wBAAgB,QAAQ,CAAC,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"Category.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/Category/Category.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,UAAU,aAAa;IACrB,iBAAiB,EAAE,eAAe,EAAE,CAAC;IACrC,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IAC1D,eAAe,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;CACnD;AAED,wBAAgB,QAAQ,CAAC,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,EACN,eAAe,GAChB,EAAE,aAAa,eA+Bf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("react"),t=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,a=require("../CategoryProduct/CategoryProduct.js");exports.Category=function(e){var r=e.productCategories,o=e.productsWithErrors,c=e.errors;return t.createElement(t.Fragment,null,0!==r.length&&r.map((function(e){var r=null==c?void 0:c["category_".concat(e.id)];return t.createElement("div",{key:e.id,className:"iframe-event__category"},t.createElement("h4",{className:"iframe-event__name"},e.name),r&&t.createElement("div",{className:"iframe-event__message-error"},null==r?void 0:r.message),e.products.map((function(r){return t.createElement(a.CategoryProduct,{key:r.id,product:r,category:e,productsWithErrors:o})})))})))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("react"),t=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,a=require("../CategoryProduct/CategoryProduct.js");exports.Category=function(e){var r=e.productCategories,o=e.productsWithErrors,c=e.errors,u=e.soldOutProducts;return t.createElement(t.Fragment,null,0!==r.length&&r.map((function(e){var r=null==c?void 0:c["category_".concat(e.id)];return t.createElement("div",{key:e.id,className:"iframe-event__category"},t.createElement("h4",{className:"iframe-event__name"},e.name),r&&t.createElement("div",{className:"iframe-event__message-error"},null==r?void 0:r.message),e.products.map((function(r){return t.createElement(a.CategoryProduct,{key:r.id,product:r,category:e,productsWithErrors:o,soldOutProducts:u})})))})))};
|
|
@@ -6,7 +6,8 @@ interface CategoryProductProps {
|
|
|
6
6
|
category: ProductCategory;
|
|
7
7
|
canExpandDescription?: boolean;
|
|
8
8
|
productsWithErrors?: StepsFormProps["productsWithErrors"];
|
|
9
|
+
soldOutProducts?: StepsFormProps["productsWithErrors"];
|
|
9
10
|
}
|
|
10
|
-
export declare const CategoryProduct: ({ product, category, canExpandDescription, productsWithErrors, }: CategoryProductProps) => JSX.Element;
|
|
11
|
+
export declare const CategoryProduct: ({ product, category, canExpandDescription, productsWithErrors, soldOutProducts, }: CategoryProductProps) => JSX.Element;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=CategoryProduct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IAC1D,eAAe,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;CACxD;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,gBAqLtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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("
|
|
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),n=require("@licklist/core/dist/Config"),a=require("react-i18next"),o=require("react-hook-form"),c=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=e(require("clsx")),s=require("react-intl"),d=require("../../../event/ticket-description/TicketDescription.js"),l=require("./components/ProductQuantityInput/ProductQuantityInput.js");exports.CategoryProduct=function(e){var m=e.product,p=e.category,f=e.canExpandDescription,v=void 0===f||f,y=e.productsWithErrors,g=e.soldOutProducts,E=s.useIntl().formatNumber,q=a.useTranslation(["Design","Validation"]).t,_=o.useFormContext(),x=_.control,N=_.clearErrors,A=_.setError,C=t.useMemo((function(){if(y){var e=y.find((function(e){return e.product_id===m.id}));return null==e?void 0:e.message}}),[y,m.id]),P=t.useMemo((function(){if(p.allowDeposits&&m.deposit&&!(null==m?void 0:m.isSoldOut)&&!(m.deposit>=m.price))return m.deposit}),[p,m]),D=function(){if(g&&!(null==m?void 0:m.isSoldOut)){var e=g.find((function(e){return e.product_id===m.id}));return!!(null==e?void 0:e.message)}};return t.useEffect((function(){C&&A("".concat(m.id),{message:C,type:"validate"})}),[C,m.id]),i.createElement(o.Controller,{control:x,name:"".concat(m.id),rules:{required:m.isRequired,validate:function(e){if(!e)return!0;var r=m.isRequired,t=void 0!==r&&r,i=m.maxAmount,n=void 0===i?0:i,a=m.minAmount,o=void 0===a?0:a,c=e.quantity,u=void 0===c?0:c;return!u&&!t||(!u&&t?q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}):u<o?q("Validation:fieldMinNumber",{min:m.minAmount,attribute:m.name}):!(n&&u>=o&&n<u)||q("Validation:quantityMaxNumber",{max:m.maxAmount}))}},render:function(e){var t=e.field,a=t.onChange,o=t.value,s=void 0===o?{}:o,f=t.ref,y=e.fieldState,g=y.invalid,_=y.error;return i.createElement("div",{id:String(m.id),className:"iframe-event__category-product"},i.createElement("div",{className:u("iframe-event__product",g&&"error")},i.createElement(d.TicketDescription,{title:m.name,description:m.description,className:u("iframe-event__product-description"),images:m.images,isRequired:m.isRequired,canExpand:v})),i.createElement("div",{className:"iframe-event__product-price-wrapper"},i.createElement("span",{className:"product-price"},E(null!=P?P:m.price,{style:"currency",currency:n.Currency.GBP})),i.createElement(l.ProductQuantityInput,{onChange:a,productInfo:s,ref:f,clearErrors:N,product:r.__assign(r.__assign({},m),{isSoldOut:(null==m?void 0:m.isSoldOut)||D()}),category:p,invalid:g,deposit:P})),P&&!(null==p?void 0:p.remainderExpireAfter)&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndUponArrival",{deposit:E(P,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-P,{style:"currency",currency:n.Currency.GBP})})),P&&(null==p?void 0:p.remainderExpireAfter)>0&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndReminderDays",{deposit:E(P,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-P,{style:"currency",currency:n.Currency.GBP}),days:null==p?void 0:p.remainderExpireAfter})),g&&i.createElement("div",{className:"d-flex mt-3 w-100"},i.createElement("p",{className:"iframe-event__message-error"},c.hasError(_,"required")&&q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}),c.hasError(_,"validate")&&_.message)))}})};
|
|
@@ -10,6 +10,7 @@ export interface StepsFormProps {
|
|
|
10
10
|
setFormErrors?: (errors: Record<string, any>) => void;
|
|
11
11
|
id?: string;
|
|
12
12
|
productsWithErrors?: ProductQuantityCheckResponse["products"];
|
|
13
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
13
14
|
}
|
|
14
15
|
export declare type StepsFormRef = {
|
|
15
16
|
getFormValues: () => Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepsForm.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/StepsForm/StepsForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAChD,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kBAAkB,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"StepsForm.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/StepsForm/StepsForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAE5F,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAChD,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kBAAkB,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;IAC9D,eAAe,CAAC,EAAE,4BAA4B,CAAC,UAAU,CAAC,CAAC;CAC5D;AAED,oBAAY,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,SAAS,qFAsIrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),s=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,o=require("react-i18next"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),s=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,o=require("react-i18next"),u=require("react-bootstrap"),i=require("react-hook-form"),a=require("lodash"),l=require("@licklist/plugins/dist/hooks/Value/usePreviousValue"),n=require("@licklist/plugins/dist/utils/ScrollUtils"),c=require("@licklist/plugins/dist/utils/FormValues"),d=require("../Category/Category.js"),m=require("../../constants.js"),f=require("../CalendarStepsForm/components/ErrorModal.js"),E=require("../utils/category.js"),p="NO_ORDER_ITEMS_ERROR",g=t.forwardRef((function(e,g){var v=e.step,y=e.isLastMenuStep,q=e.setFormValues,F=e.defaultValues,S=e.onSubmit,V=e.setFormErrors,_=e.id,C=void 0===_?m.STEP_FORM_ID:_,h=e.productsWithErrors,O=e.soldOutProducts,P=i.useForm({defaultValues:F}),b=o.useTranslation(["Design","Validation"]).t,j=r.__read(t.useState(""),2),R=j[0],T=j[1],k=E.useCategory().verifyCategoryItems,M=P.control,x=P.formState.errors,I=P.getValues,D=P.setError,K=P.clearErrors,N=P.reset,W=i.useWatch({control:M}),L=l.usePreviousValue(x);t.useImperativeHandle(g,(function(){return{getFormValues:function(){return I()}}})),t.useEffect((function(){h&&T(b("soldOutProduct"))}),[h]);return t.useEffect((function(){x&&setTimeout(K,0),q(W)}),[W]),t.useEffect((function(){c.isFormValuesEmpty(W)||K(p)}),[W,K]),t.useEffect((function(){N(F)}),[F]),t.useEffect((function(){!a.isEqual(x,L)&&V&&V(x)}),[x,L,V]),s.createElement(u.Form,{onSubmit:P.handleSubmit((function(e){if(y&&c.isFormValuesEmpty(e))return D(p,{}),void n.scrollToError(p);var r=k(e,v);if(r)return T(r.message),void D("category_".concat(r.id),{message:r.message});S(e)}),(function(e){n.scrollToError(c.getFirstErrorKey(e)),T(b("pleaseCheckSelectedProducts"))})),id:C},s.createElement(i.FormProvider,r.__assign({},P),s.createElement(f.ErrorModal,{isOpen:Boolean(R),messageKey:R,onClose:function(){return T("")}}),s.createElement("div",null,s.createElement("div",{className:"iframe-event"},s.createElement(d.Category,{productCategories:null==v?void 0:v.productCategories,productsWithErrors:h,errors:x,soldOutProducts:O}),x[p]&&s.createElement("div",{className:"d-flex m-5 justify-content-center form-error",id:p},s.createElement(o.Trans,{t:b,i18nKey:"pleaseSelectAtLeastFrom",values:{min:1,type:"item",from:"those categories"}}))))))}));exports.StepsForm=g;
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { Step } from "@licklist/core/dist/DataMapper/Product/StepDataMapper";
|
|
20
20
|
import { useTranslation } from "react-i18next";
|
|
21
21
|
import { Product } from "@licklist/core/dist/DataMapper/Product/ProductDataMapper";
|
|
22
|
+
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
22
23
|
import { Category } from "./components/Category";
|
|
23
24
|
import { MenuStep } from "../../../../types";
|
|
24
25
|
import { STEP_FORM_ID } from "../../constants";
|
|
@@ -44,6 +45,7 @@ export interface CalendarStepsFormProps {
|
|
|
44
45
|
onActiveVenueMapChange?: (nextVenueMapId: string) => void;
|
|
45
46
|
title: string;
|
|
46
47
|
menuStepWithVenueMap: Step;
|
|
48
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
export type StepsFormRef = {
|
|
@@ -67,6 +69,7 @@ export const CalendarStepsForm = forwardRef<
|
|
|
67
69
|
title,
|
|
68
70
|
menuStepWithVenueMap,
|
|
69
71
|
onActiveVenueMapChange,
|
|
72
|
+
soldOutProducts,
|
|
70
73
|
},
|
|
71
74
|
ref
|
|
72
75
|
) => {
|
|
@@ -346,6 +349,7 @@ export const CalendarStepsForm = forwardRef<
|
|
|
346
349
|
activePointId={activePointId}
|
|
347
350
|
pointProducts={menuStepWithVenueMap.pointProducts}
|
|
348
351
|
onCloseModal={onCloseProductModal}
|
|
352
|
+
soldOutProducts={soldOutProducts}
|
|
349
353
|
/>
|
|
350
354
|
</>
|
|
351
355
|
)}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PointProduct } from "@licklist/core/dist/DataMapper/Product/PointProductDataMapper";
|
|
3
|
+
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
3
4
|
import { ProductCategory } from "../../../../../types";
|
|
4
5
|
import { CategoryProductModal } from "./CategoryProductModal";
|
|
5
6
|
|
|
@@ -8,6 +9,7 @@ export type CategoryProps = {
|
|
|
8
9
|
activePointId?: number;
|
|
9
10
|
pointProducts: PointProduct[];
|
|
10
11
|
onCloseModal: () => void;
|
|
12
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export const Category = ({
|
|
@@ -15,6 +17,7 @@ export const Category = ({
|
|
|
15
17
|
activePointId,
|
|
16
18
|
pointProducts,
|
|
17
19
|
onCloseModal,
|
|
20
|
+
soldOutProducts,
|
|
18
21
|
}: CategoryProps) => {
|
|
19
22
|
return (
|
|
20
23
|
<>
|
|
@@ -31,6 +34,7 @@ export const Category = ({
|
|
|
31
34
|
activePointId={activePointId}
|
|
32
35
|
pointProducts={pointProducts}
|
|
33
36
|
onCloseModal={onCloseModal}
|
|
37
|
+
soldOutProducts={soldOutProducts}
|
|
34
38
|
/>
|
|
35
39
|
);
|
|
36
40
|
})}
|
package/src/iframe/order-process/components/CalendarStepsForm/components/CategoryProductModal.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { useMemo } from "react";
|
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { Button } from "react-bootstrap";
|
|
4
4
|
import { PointProduct } from "@licklist/core/dist/DataMapper/Product/PointProductDataMapper";
|
|
5
|
+
import { ProductQuantityCheckResponse } from "@licklist/plugins/dist/types/Api/verifyStock";
|
|
5
6
|
import { ProductCategory, Product } from "../../../../../types";
|
|
6
7
|
import { CategoryProduct } from "../../CategoryProduct";
|
|
7
8
|
import Icon from "../../../../../static/Icon";
|
|
@@ -12,6 +13,7 @@ export type CategoryProductModalProps = {
|
|
|
12
13
|
category: ProductCategory;
|
|
13
14
|
pointProducts: PointProduct[];
|
|
14
15
|
onCloseModal: () => void;
|
|
16
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
export const CategoryProductModal = ({
|
|
@@ -20,6 +22,7 @@ export const CategoryProductModal = ({
|
|
|
20
22
|
category,
|
|
21
23
|
pointProducts,
|
|
22
24
|
onCloseModal,
|
|
25
|
+
soldOutProducts,
|
|
23
26
|
}: CategoryProductModalProps) => {
|
|
24
27
|
const activePointProduct = useMemo(
|
|
25
28
|
() =>
|
|
@@ -42,6 +45,7 @@ export const CategoryProductModal = ({
|
|
|
42
45
|
product={product}
|
|
43
46
|
category={category}
|
|
44
47
|
canExpandDescription={false}
|
|
48
|
+
soldOutProducts={soldOutProducts}
|
|
45
49
|
/>
|
|
46
50
|
<div className="close-modal-button">
|
|
47
51
|
<Button
|
|
@@ -8,6 +8,7 @@ import { StepsFormProps } from "../StepsForm/StepsForm";
|
|
|
8
8
|
interface CategoryProps {
|
|
9
9
|
productCategories: ProductCategory[];
|
|
10
10
|
productsWithErrors?: StepsFormProps["productsWithErrors"];
|
|
11
|
+
soldOutProducts?: StepsFormProps["productsWithErrors"];
|
|
11
12
|
errors?: DeepMap<Record<string, any>, FieldError>;
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -15,6 +16,7 @@ export function Category({
|
|
|
15
16
|
productCategories,
|
|
16
17
|
productsWithErrors,
|
|
17
18
|
errors,
|
|
19
|
+
soldOutProducts,
|
|
18
20
|
}: CategoryProps) {
|
|
19
21
|
return (
|
|
20
22
|
<>
|
|
@@ -37,6 +39,7 @@ export function Category({
|
|
|
37
39
|
product={product}
|
|
38
40
|
category={category}
|
|
39
41
|
productsWithErrors={productsWithErrors}
|
|
42
|
+
soldOutProducts={soldOutProducts}
|
|
40
43
|
/>
|
|
41
44
|
);
|
|
42
45
|
})}
|
|
@@ -15,6 +15,7 @@ interface CategoryProductProps {
|
|
|
15
15
|
category: ProductCategory;
|
|
16
16
|
canExpandDescription?: boolean;
|
|
17
17
|
productsWithErrors?: StepsFormProps["productsWithErrors"];
|
|
18
|
+
soldOutProducts?: StepsFormProps["productsWithErrors"];
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const CategoryProduct = ({
|
|
@@ -22,6 +23,7 @@ export const CategoryProduct = ({
|
|
|
22
23
|
category,
|
|
23
24
|
canExpandDescription = true,
|
|
24
25
|
productsWithErrors,
|
|
26
|
+
soldOutProducts,
|
|
25
27
|
}: CategoryProductProps) => {
|
|
26
28
|
const { formatNumber } = useIntl();
|
|
27
29
|
const { t } = useTranslation(["Design", "Validation"]);
|
|
@@ -49,6 +51,16 @@ export const CategoryProduct = ({
|
|
|
49
51
|
return product.deposit;
|
|
50
52
|
}, [category, product]);
|
|
51
53
|
|
|
54
|
+
const checkIfSoldOutProduct = () => {
|
|
55
|
+
if (!soldOutProducts || product?.isSoldOut) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const error = soldOutProducts.find(
|
|
59
|
+
(productWithError) => productWithError.product_id === product.id
|
|
60
|
+
);
|
|
61
|
+
return !!error?.message;
|
|
62
|
+
};
|
|
63
|
+
|
|
52
64
|
useEffect(() => {
|
|
53
65
|
if (!productQuantityError) {
|
|
54
66
|
return;
|
|
@@ -136,7 +148,10 @@ export const CategoryProduct = ({
|
|
|
136
148
|
productInfo={productInfo}
|
|
137
149
|
ref={ref}
|
|
138
150
|
clearErrors={clearErrors}
|
|
139
|
-
product={
|
|
151
|
+
product={{
|
|
152
|
+
...product,
|
|
153
|
+
isSoldOut: product?.isSoldOut || checkIfSoldOutProduct(),
|
|
154
|
+
}}
|
|
140
155
|
category={category}
|
|
141
156
|
invalid={invalid}
|
|
142
157
|
deposit={deposit}
|
|
@@ -32,6 +32,7 @@ export interface StepsFormProps {
|
|
|
32
32
|
setFormErrors?: (errors: Record<string, any>) => void;
|
|
33
33
|
id?: string;
|
|
34
34
|
productsWithErrors?: ProductQuantityCheckResponse["products"];
|
|
35
|
+
soldOutProducts?: ProductQuantityCheckResponse["products"];
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export type StepsFormRef = {
|
|
@@ -49,6 +50,7 @@ export const StepsForm = forwardRef<StepsFormRef, StepsFormProps>(
|
|
|
49
50
|
setFormErrors,
|
|
50
51
|
id = STEP_FORM_ID,
|
|
51
52
|
productsWithErrors,
|
|
53
|
+
soldOutProducts,
|
|
52
54
|
},
|
|
53
55
|
ref
|
|
54
56
|
) => {
|
|
@@ -150,6 +152,7 @@ export const StepsForm = forwardRef<StepsFormRef, StepsFormProps>(
|
|
|
150
152
|
productCategories={step?.productCategories}
|
|
151
153
|
productsWithErrors={productsWithErrors}
|
|
152
154
|
errors={errors}
|
|
155
|
+
soldOutProducts={soldOutProducts}
|
|
153
156
|
/>
|
|
154
157
|
|
|
155
158
|
{errors[NO_ORDER_ITEMS_ERROR] && (
|