@licklist/design 0.44.500 → 0.44.502

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/events/event-venue-map/components/MapPoint/MapPoint.d.ts.map +1 -1
  2. package/dist/events/event-venue-map/components/MapPoint/MapPoint.js +1 -1
  3. package/dist/events/event-venue-map/components/MapPoint/components/ProductIcon/ProductIcon.d.ts.map +1 -1
  4. package/dist/events/event-venue-map/components/MapPoint/components/ProductIcon/ProductIcon.js +1 -1
  5. package/dist/events/event-venue-map/components/MapPoint/components/ProductTooltip/ProductTooltip.d.ts +9 -0
  6. package/dist/events/event-venue-map/components/MapPoint/components/ProductTooltip/ProductTooltip.d.ts.map +1 -0
  7. package/dist/events/event-venue-map/components/MapPoint/components/ProductTooltip/ProductTooltip.js +1 -0
  8. package/dist/events/event-venue-map/components/MapPoint/components/ProductTooltip/index.d.ts +2 -0
  9. package/dist/events/event-venue-map/components/MapPoint/components/ProductTooltip/index.d.ts.map +1 -0
  10. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.d.ts.map +1 -1
  11. package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.js +1 -1
  12. package/dist/product-set/product/ProductControl.d.ts +1 -0
  13. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  14. package/dist/product-set/product/ProductControl.js +1 -1
  15. package/dist/product-set/product/price/ProductPriceControl.d.ts +7 -3
  16. package/dist/product-set/product/price/ProductPriceControl.d.ts.map +1 -1
  17. package/dist/product-set/product/price/ProductPriceControl.js +1 -1
  18. package/dist/types/iframe.d.ts +2 -0
  19. package/dist/types/iframe.d.ts.map +1 -1
  20. package/package.json +1 -1
  21. package/src/events/event-venue-map/components/MapPoint/MapPoint.tsx +3 -1
  22. package/src/events/event-venue-map/components/MapPoint/components/ProductIcon/ProductIcon.tsx +13 -2
  23. package/src/events/event-venue-map/components/MapPoint/components/ProductTooltip/ProductTooltip.tsx +68 -0
  24. package/src/events/event-venue-map/components/MapPoint/components/ProductTooltip/index.ts +1 -0
  25. package/src/iframe/event/event-venue-map/IframeEventVenueMap.stories.tsx +5 -0
  26. package/src/iframe/order-process/OrderProcess.stories.tsx +1 -0
  27. package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +26 -7
  28. package/src/product-set/product/ProductControl.tsx +17 -2
  29. package/src/product-set/product/price/ProductPriceControl.tsx +43 -21
  30. package/src/types/iframe.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"MapPoint.d.ts","sourceRoot":"","sources":["../../../../../src/events/event-venue-map/components/MapPoint/MapPoint.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,aAAK,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,GACjC,WAAW,GAAG;IACZ,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IACjE,YAAY,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAClC,CAAC;AAEJ,eAAO,MAAM,QAAQ,sMAclB,aAAa,gBAmHf,CAAC"}
1
+ {"version":3,"file":"MapPoint.d.ts","sourceRoot":"","sources":["../../../../../src/events/event-venue-map/components/MapPoint/MapPoint.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,aAAK,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,GACjC,WAAW,GAAG;IACZ,gBAAgB,EAAE,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IACjE,YAAY,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAClC,CAAC;AAEJ,eAAO,MAAM,QAAQ,sMAclB,aAAa,gBAqHf,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,o=require("tslib"),n=require("react"),t=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,i=require("@licklist/plugins/dist/context/event/EventVenueMapContext"),r=require("react-konva"),u=require("../../utils/index.js"),c=require("./components/PointIcon/PointIcon.js"),d=require("./components/ProductIcon/ProductIcon.js");exports.MapPoint=function(e){var s=e.xCoordinate,l=e.yCoordinate,a=e.id,f=e.imageOffsetX,p=e.imageOffsetY,v=e.imageScale,m=e.localId,P=e.pointNumber,I=e.changeCursorType,x=e.usedInIframe,C=e.choosedProductUuids,M=void 0===C?[]:C,O=e.errorOnChoosedProductUuids,g=void 0===O?[]:O,E=e.isSoldOut,y=n.useContext(i.EventVenueMapContext),b=y.setActiveElementKey,h=y.activeElementKey,q=y.setMapPoints,U=y.editMode,j=y.mapPointProducts,S=o.__read(u.calculatePointsCoordinates(s,l,{imageScale:v,imageOffsetX:f,imageOffsetY:p}),2),B=S[0],_=S[1],k=String(a||m),A=k===h,K=j.find((function(e){return a&&e.pointId&&e.pointId===a})),N=Boolean(j.find((function(e){return M.includes(null==e?void 0:e.productUuid)&&M.includes(null==K?void 0:K.productUuid)}))),T=Boolean(j.find((function(e){return g.includes(null==e?void 0:e.productUuid)&&g.includes(null==K?void 0:K.productUuid)}))),V=function(e){e.cancelBubble=!0,A||E||(b(k),q((function(e){var o=e.slice(),n=o.find((function(e){return e.id===a||(null==e?void 0:e.localId)===m})),t=o.indexOf(n);return o.splice(t,1),o.push(n),o})))};return t.createElement(r.Group,{onClick:V,onTap:V,onMouseEnter:function(){I("pointer")},onMouseLeave:function(){I()}},x?t.createElement(d.ProductIcon,{x:B,y:_,isSoldOut:E,isActive:A,isProductChoosed:N,isErrorOnChoosedProduct:T}):t.createElement(c.PointIcon,{x:B,y:_,isActive:A,hasProduct:!E&&Boolean(K),pointNumber:P,onDelete:function(){b(),I(),q((function(e){return u.removeMapPointFromPoints(e,a,m)}))},editMode:U}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("tslib"),o=require("react"),t=(e=o)&&"object"==typeof e&&"default"in e?e.default:e,i=require("@licklist/plugins/dist/context/event/EventVenueMapContext"),r=require("react-konva"),u=require("../../utils/index.js"),c=require("./components/PointIcon/PointIcon.js"),d=require("./components/ProductIcon/ProductIcon.js");exports.MapPoint=function(e){var s=e.xCoordinate,l=e.yCoordinate,a=e.id,f=e.imageOffsetX,p=e.imageOffsetY,v=e.imageScale,m=e.localId,P=e.pointNumber,I=e.changeCursorType,x=e.usedInIframe,C=e.choosedProductUuids,M=void 0===C?[]:C,O=e.errorOnChoosedProductUuids,g=void 0===O?[]:O,E=e.isSoldOut,y=o.useContext(i.EventVenueMapContext),b=y.setActiveElementKey,h=y.activeElementKey,q=y.setMapPoints,U=y.editMode,j=y.mapPointProducts,S=n.__read(u.calculatePointsCoordinates(s,l,{imageScale:v,imageOffsetX:f,imageOffsetY:p}),2),B=S[0],_=S[1],k=String(a||m),A=k===h,K=j.find((function(e){return a&&e.pointId&&e.pointId===a})),N=Boolean(j.find((function(e){return M.includes(null==e?void 0:e.productUuid)&&M.includes(null==K?void 0:K.productUuid)}))),T=Boolean(j.find((function(e){return g.includes(null==e?void 0:e.productUuid)&&g.includes(null==K?void 0:K.productUuid)}))),V=function(){q((function(e){var n=e.slice(),o=n.find((function(e){return a&&e.id===a||m&&e.localId===m})),t=n.indexOf(o);return n.splice(t,1),n.push(o),n}))},X=function(e){e.cancelBubble=!0,A||E||(b(k),V())};return t.createElement(r.Group,{onClick:X,onTap:X,onMouseEnter:function(){V(),I("pointer")},onMouseLeave:function(){I()}},x?t.createElement(d.ProductIcon,{x:B,y:_,isSoldOut:E,isActive:A,isProductChoosed:N,isErrorOnChoosedProduct:T}):t.createElement(c.PointIcon,{x:B,y:_,isActive:A,hasProduct:!E&&Boolean(K),pointNumber:P,onDelete:function(){b(),I(),q((function(e){return u.removeMapPointFromPoints(e,a,m)}))},editMode:U}))};
@@ -1 +1 @@
1
- {"version":3,"file":"ProductIcon.d.ts","sourceRoot":"","sources":["../../../../../../src/events/event-venue-map/components/MapPoint/components/ProductIcon/ProductIcon.tsx"],"names":[],"mappings":";AACA,OAAO,EAAQ,eAAe,EAAiB,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,MAAM,OAAO,CAAC;AAyB1B,oBAAY,gBAAgB,GAAG,eAAe,GAC5C,KAAK,CAAC,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uBAAuB,EAAE,OAAO,CAAC;IACjC,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAkBJ,eAAO,MAAM,WAAW,8EAOrB,gBAAgB,gBA8FlB,CAAC"}
1
+ {"version":3,"file":"ProductIcon.d.ts","sourceRoot":"","sources":["../../../../../../src/events/event-venue-map/components/MapPoint/components/ProductIcon/ProductIcon.tsx"],"names":[],"mappings":";AACA,OAAO,EAAQ,eAAe,EAAiB,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,MAAM,OAAO,CAAC;AA0B1B,oBAAY,gBAAgB,GAAG,eAAe,GAC5C,KAAK,CAAC,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uBAAuB,EAAE,OAAO,CAAC;IACjC,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAkBJ,eAAO,MAAM,WAAW,8EAOrB,gBAAgB,gBAwGlB,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o,t=require("tslib"),e=require("react"),r=(o=e)&&"object"==typeof o&&"default"in o?o.default:o,n=require("react-konva"),i="#FFFFFF",a="#FFFFFF80",c="#0E8CE2",l="#878787",d=function(o,t){void 0===t&&(t=!1);var e=document.getElementById("snippet-template-context");if(e){var r=getComputedStyle(e).getPropertyValue(o);return!r||r&&!t?r:"".concat(r,"80")}};exports.ProductIcon=function(o){var p,s,u=o.x,v=o.y,C=o.isActive,F=o.isSoldOut,f=o.isErrorOnChoosedProduct,k=o.isProductChoosed,P=e.useMemo((function(){return{pointBackgroundColor:d("--snippet-canvas-point-background-color")||i,pointBorderColor:d("--snippet-canvas-point-border-color",!0)||a,pointFontColor:d("--snippet-canvas-point-font-color")||c,activePointBackgroundColor:d("--snippet-canvas-active-point-background-color")||c,activePointBorderColor:d("--snippet-canvas-active-point-border-color",!0)||a,activePointFontColor:d("--snippet-canvas-active-point-font-color")||i}}),[C,f,k]);return r.createElement(n.Group,{x:u,y:v},r.createElement(n.Circle,t.__assign({radius:14,strokeWidth:2,x:0,y:-21},(p=P.pointBackgroundColor,s=P.pointBorderColor,C&&(s=P.activePointBorderColor),k&&(p=P.activePointBackgroundColor),f&&(s="#ff000080"),F&&(s=l,p=l),{fill:p,stroke:s}))),k?r.createElement(n.Path,{x:-7,y:-28,data:"M1.5 6L5.5 10L13.5 2",width:28,height:28,fill:P.activePointBackgroundColor,stroke:P.activePointFontColor,strokeWidth:3}):r.createElement(n.Path,{x:-7,y:-28,data:"M14 0C9.3569 0.6633 4.6431 0.6633 0 0L6 7V13H3V14H11V13H8V7L14 0Z",width:28,height:28,strokeWidth:1,fill:P.pointFontColor,stroke:P.pointFontColor}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o,t=require("tslib"),e=require("react"),r=(o=e)&&"object"==typeof o&&"default"in o?o.default:o,n=require("react-konva"),i=require("../ProductTooltip/ProductTooltip.js"),a="#FFFFFF",c="#FFFFFF80",l="#0E8CE2",u="#878787",d=function(o,t){void 0===t&&(t=!1);var e=document.getElementById("snippet-template-context");if(e){var r=getComputedStyle(e).getPropertyValue(o);return!r||r&&!t?r:"".concat(r,"80")}};exports.ProductIcon=function(o){var s,p,v=o.x,C=o.y,f=o.isActive,F=o.isSoldOut,P=o.isErrorOnChoosedProduct,k=o.isProductChoosed,g=-28,h=t.__read(e.useState(!1),2),y=h[0],m=h[1],x=e.useMemo((function(){return{pointBackgroundColor:d("--snippet-canvas-point-background-color")||a,pointBorderColor:d("--snippet-canvas-point-border-color",!0)||c,pointFontColor:d("--snippet-canvas-point-font-color")||l,activePointBackgroundColor:d("--snippet-canvas-active-point-background-color")||l,activePointBorderColor:d("--snippet-canvas-active-point-border-color",!0)||c,activePointFontColor:d("--snippet-canvas-active-point-font-color")||a}}),[f,P,k]);return r.createElement(n.Group,{x:v,y:C,onMouseEnter:function(){return m(!0)},onMouseLeave:function(){return m(!1)}},r.createElement(n.Circle,t.__assign({radius:14,strokeWidth:2,x:0,y:-21},(s=x.pointBackgroundColor,p=x.pointBorderColor,f&&(p=x.activePointBorderColor),k&&(s=x.activePointBackgroundColor),P&&(p="#ff000080"),F&&(p=u,s=u),{fill:s,stroke:p}))),y&&F&&r.createElement(i.ProductTooltip,{x:-7,y:g,text:"Sold out"}),k?r.createElement(n.Path,{x:-7,y:g,data:"M1.5 6L5.5 10L13.5 2",width:28,height:28,fill:x.activePointBackgroundColor,stroke:x.activePointFontColor,strokeWidth:3}):r.createElement(n.Path,{x:-7,y:g,data:"M14 0C9.3569 0.6633 4.6431 0.6633 0 0L6 7V13H3V14H11V13H8V7L14 0Z",width:28,height:28,strokeWidth:1,fill:x.pointFontColor,stroke:x.pointFontColor}))};
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ declare type ProductTooltipProps = {
3
+ x: number;
4
+ y: number;
5
+ text: string;
6
+ };
7
+ export declare const ProductTooltip: ({ x, y, text }: ProductTooltipProps) => JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=ProductTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductTooltip.d.ts","sourceRoot":"","sources":["../../../../../../src/events/event-venue-map/components/MapPoint/components/ProductTooltip/ProductTooltip.tsx"],"names":[],"mappings":";AAkBA,aAAK,mBAAmB,GAAG;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,cAAc,mBAAoB,mBAAmB,gBA2CjE,CAAC"}
@@ -0,0 +1 @@
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,i=require("react-konva"),l="#000";exports.ProductTooltip=function(e){var t=e.x,o=e.y,c=e.text;return r.createElement(i.Group,{width:60,height:20,x:t+30,y:o-1},r.createElement(i.Rect,{x:-5,y:5,sceneFunc:function(e){e.beginPath(),e.moveTo(0,5),e.lineTo(5,0),e.lineTo(5,10),e.closePath(),e.fill()},fill:l,borderColor:l,opacity:.8}),r.createElement(i.Rect,{x:0,y:0,width:60,height:20,fill:l,cornerRadius:5,opacity:.8}),r.createElement(i.Text,{y:4,text:c,strokeWidth:5,width:60,align:"center",verticalAlign:"middle",fill:"#FFF"}))};
@@ -0,0 +1,2 @@
1
+ export { ProductTooltip } from "./ProductTooltip";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/events/event-venue-map/components/MapPoint/components/ProductTooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -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;IAC1D,eAAe,CAAC,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;CACxD;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,gBAqLtB,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,gBAwMtB,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("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)))}})};
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"),c=require("react-hook-form"),o=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,y=e.canExpandDescription,v=void 0===y||y,f=e.productsWithErrors,g=e.soldOutProducts,E=s.useIntl().formatNumber,q=a.useTranslation(["Design","Validation"]).t,_=c.useFormContext(),x=_.control,N=_.clearErrors,S=_.setError,A=t.useMemo((function(){if(f){var e=f.find((function(e){return e.product_id===m.id}));return null==e?void 0:e.message}}),[f,m.id]),C=t.useMemo((function(){if(p.allowDeposits&&m.deposit&&!(null==m?void 0:m.isSoldOut)&&!(m.deposit>=m.price))return m.deposit}),[p,m]),P=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(){A&&S("".concat(m.id),{message:A,type:"validate"})}),[A,m.id]),i.createElement(c.Controller,{control:x,name:"".concat(m.id),rules:{required:m.isRequired,validate:function(e){var r,t=m.isRequired,i=void 0!==t&&t,a=m.maxAmount,c=void 0===a?0:a,o=m.minAmount,u=void 0===o?0:o,s=m.minSpend,d=m.price,l=null!==(r=null==e?void 0:e.quantity)&&void 0!==r?r:0;return s&&l*d<s?q("Design:minimumSpendSumValidation",{minSpend:E(s,{style:"currency",currency:n.Currency.GBP})}):!e||(!l&&!i||(!l&&i?q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}):l<u?q("Validation:fieldMinNumber",{min:m.minAmount,attribute:m.name}):!(c&&l>=u&&c<l)||q("Validation:quantityMaxNumber",{max:m.maxAmount})))}},render:function(e){var t=e.field,a=t.onChange,c=t.value,s=void 0===c?{}:c,y=t.ref,f=e.fieldState,g=f.invalid,_=f.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!=C?C:m.price,{style:"currency",currency:n.Currency.GBP})),i.createElement(l.ProductQuantityInput,{onChange:a,productInfo:s,ref:y,clearErrors:N,product:r.__assign(r.__assign({},m),{isSoldOut:(null==m?void 0:m.isSoldOut)||P()}),category:p,invalid:g,deposit:C})),C&&!(null==p?void 0:p.remainderExpireAfter)&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndUponArrival",{deposit:E(C,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-C,{style:"currency",currency:n.Currency.GBP})})),C&&(null==p?void 0:p.remainderExpireAfter)>0&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndReminderDays",{deposit:E(C,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-C,{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"},o.hasError(_,"required")&&q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}),o.hasError(_,"validate")&&_.message)))}})};
@@ -22,6 +22,7 @@ export interface ProductControlValues extends FormValues, ProductDepositControlV
22
22
  isRequired: boolean;
23
23
  quantitySelector: number;
24
24
  hasSpecialNotes: boolean;
25
+ minSpend?: number | null;
25
26
  type?: ProductType;
26
27
  weight?: number;
27
28
  tierId?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"ProductControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product/ProductControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EAMb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AAEvF,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAEtE,OAAc,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAef,OAAO,EACL,KAAK,EAEN,MAAM,sDAAsD,CAAC;AAO9D,OAAO,EAEL,oCAAoC,EACpC,qCAAqC,EACtC,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,WAAW,oBACf,SAAQ,UAAU,EAChB,2BAA2B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B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,EACnD,SAAiB,EACjB,eAAe,EACf,aAAqB,EACrB,oBAA4B,EAC5B,QAAa,EACb,MAAM,EACN,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,YAAY,GACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAmfxB"}
1
+ {"version":3,"file":"ProductControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product/ProductControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EAMb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AAEvF,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAEtE,OAAc,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAef,OAAO,EACL,KAAK,EAEN,MAAM,sDAAsD,CAAC;AAO9D,OAAO,EAEL,oCAAoC,EACpC,qCAAqC,EACtC,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,iCAAiC,CAAC;AAOzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,WAAW,oBACf,SAAQ,UAAU,EAChB,2BAA2B,EAC3B,qCAAqC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC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 -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("tslib"),a=require("react"),n=e(a),r=require("react-i18next"),o=e(require("react-bootstrap/Row")),l=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),m=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),d=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var p=require("../form/context.js"),g=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),f=require("./booking-management/ProductBookingManagementControl.js"),C=require("./deposit/ProductDepositControl.js"),v=require("./quantity/ProductQuantityControl.js"),b=require("./quantity/ProductQuantityConstantControl.js"),h=require("./quantity/ProductQuantityRechargingControl.js"),F=e(require("react-bootstrap/Collapse")),I=require("@licklist/plugins/dist/hooks/Media/useImages"),N=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),P=require("../../file-upload/FileUpload.js"),q=require("../../tiptap-editor/TipTapEditor.js"),y=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),x=require("./price/ProductPriceControl.js");exports.ProductControl=function(e){var T=e.isLoading,_=void 0!==T&&T,L=e.fieldNamePrefix,j=e.allowDeposits,S=void 0!==j&&j,w=e.hasBookingManagement,A=void 0!==w&&w,D=e.zoneList,G=void 0===D?[]:D,B=e.onCopy,M=e.onProductNameChange,R=e.productName,O=e.hasTicket,U=e.categoryType,Y=s.useFormContext(),Q=Y.register,V=Y.control,H=Y.formState.errors,z=Y.setValue,X=Y.getValues,W=Y.watch,J=a.useContext(p.ProductSetLoadingContext),K=J.setLoading,Z=J.providerHasBookingManagement,$=r.useTranslation("Design").t,ee=t.__read(a.useState(!1),2),te=ee[0],ae=ee[1],ne=t.__read(a.useState(null),2),re=ne[0],oe=ne[1],le=Boolean(W("".concat(L,".isUnlimited"))),ie=u.useId(),ce=u.useId(),se=u.useId(),me=u.useId(),ue=u.useId(),de=u.useId(),Ee=u.useId(),pe=u.useId(),ge=u.useId(),fe=u.useId(),Ce=[{id:1,value:$("quantitySelector")},{id:2,value:$("stockControl")}],ve=a.useCallback((function(){return ae((function(e){return!e}))}),[]),be=s.useWatch({control:V,name:"".concat(L,".quantitySelector")}),he=I.useImages(re),Fe=he.images,Ie=he.handleImageRemove,Ne=he.handleImageUploading,Pe=he.isLoading,qe=a.useCallback((function(e){Ne(e,N.IMAGE_TYPE_IMAGE)}),[Ne]),ye=a.useCallback((function(e,t){Ie(String(e),t)}),[Ie]),ke=function(e){return e.target.select()};a.useEffect((function(){K(Pe)}),[K,Pe]),a.useEffect((function(){var e=X("".concat(L,".images"));oe(e)}),[X,oe,L]),a.useEffect((function(){Array.isArray(Fe)&&z("".concat(L,".images"),Fe)}),[Fe,L,z]);var xe=null!=be?be:"1",Te=g.QUANTITY_TYPE_LIST_DTO[xe];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:ce},n.createElement(i.Form.Label,null,$("name")),n.createElement(i.Form.Control,t.__assign({},Q("".concat(L,".name")),{value:R,onChange:M,isInvalid:m.isInvalid("".concat(L,".name"),H),disabled:_,placeholder:$("name")})),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".name"),H))),n.createElement(i.Form.Group,{controlId:se},n.createElement(i.Form.Label,null,$("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(q.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:_})},control:V,name:"".concat(L,".description")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".description"),H))),S?n.createElement(o,null,n.createElement(C.ProductDepositControl,{isLoading:_,fieldNamePrefix:L}),n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:L,title:$("totalPrice"),allowDeposits:S})):n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:L}),n.createElement("div",null,n.createElement(v.ProductQuantityControl,{isLoading:_,fieldNamePrefix:L,onFocus:ke}),Te===g.QUANTITY_TYPE_CONSTANT&&n.createElement(b.ProductQuantityConstantControl,{isLoading:_,fieldNamePrefix:L,onFocus:ke,disabled:le}),Te===g.QUANTITY_TYPE_RECHARGING&&n.createElement(h.ProductQuantityRechargingControl,{isLoading:_,fieldNamePrefix:L,onFocus:ke,disabled:le}),n.createElement(i.Form.Group,{controlId:fe,className:"custom-checkbox"},n.createElement(i.Form.Check,t.__assign({custom:!0,type:"checkbox"},Q("".concat(L,".isUnlimited")),{name:"".concat(L,".isUnlimited"),disabled:_})),n.createElement(i.Form.Check.Label,null,$("isUnlimited")))),n.createElement(i.Form.Group,{controlId:pe},n.createElement(i.Form.Label,null,$("quantitySelectorType")),n.createElement(i.Form.Control,t.__assign({as:"select",defaultValue:O?Ce[0].id:void 0},Q("".concat(L,".quantitySelector")),{isInvalid:m.isInvalid("".concat(L,".quantitySelector"),H),disabled:_||O}),Ce.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".quantitySelector"),H))))),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:L,providerHasBookingManagement:Z}),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity")}))),U===g.CATEGORY_TYPE_GAME&&n.createElement(o,{className:"align-items-start"},n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("capacity")})}}})),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".duration"),label:$("durationMinutes"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("duration")})}}}))),n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:me},n.createElement(i.Form.Label,null,$("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,l=t.ref;return n.createElement(i.Form.Control,{ref:l,as:"textarea",rows:3,value:a,onChange:r,isInvalid:m.isInvalid("".concat(L,".termsAndConditions"),H),disabled:_,name:o})},control:V,name:"".concat(L,".termsAndConditions")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".termsAndConditions"),H)))),n.createElement(l,{lg:4,md:4,className:"licklist-file-upload-wrapper"},n.createElement(P.FileUpload,{onFilesChange:qe,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:ye,defaultFiles:Fe,isLoading:Pe,withIcon:!0,title:$("addImage")}))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(i.Form.Group,{controlId:ue,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isAvailable")})),n.createElement(i.Form.Group,{controlId:de,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isSoldOut")})),n.createElement(i.Form.Group,{controlId:ie,className:"custom-checkbox"},n.createElement(i.Form.Check,{custom:!0,type:"checkbox",name:ie,disabled:_},n.createElement(i.Form.Check.Input,{checked:te,onChange:ve,type:"checkbox"}),n.createElement(i.Form.Check.Label,null,$("showAdvancedOptions"))))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(F,{in:te},n.createElement("div",null,n.createElement(i.Form.Group,{controlId:Ee,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isRequired")})),n.createElement(i.Form.Group,{controlId:ge,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(d.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".hasSpecialNotes")})),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(y.FixedDurationOptions,{fieldNamePrefix:L}))),n.createElement(o,null,n.createElement(l,{xs:12},A&&n.createElement(f.ProductBookingManagementControl,{isLoading:_,zoneList:G,fieldNamePrefix:L})))),n.createElement(o,null,n.createElement(l,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(B)&&n.createElement(i.Button,{onClick:B,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",$("copy"))))))};
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"),n=e(a),r=require("react-i18next"),o=e(require("react-bootstrap/Row")),l=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),m=e(require("@licklist/plugins/dist/services/Form/HookFormService")),d=require("@react-aria/utils"),u=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var p=require("../form/context.js"),g=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),f=require("./booking-management/ProductBookingManagementControl.js"),C=require("./deposit/ProductDepositControl.js"),v=require("./quantity/ProductQuantityControl.js"),b=require("./quantity/ProductQuantityConstantControl.js"),h=require("./quantity/ProductQuantityRechargingControl.js"),F=e(require("react-bootstrap/Collapse")),I=require("@licklist/plugins/dist/hooks/Media/useImages"),P=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),N=require("../../file-upload/FileUpload.js"),q=require("../../tiptap-editor/TipTapEditor.js"),y=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),x=require("./price/ProductPriceControl.js");exports.ProductControl=function(e){var T=e.isLoading,_=void 0!==T&&T,L=e.fieldNamePrefix,S=e.allowDeposits,w=void 0!==S&&S,j=e.hasBookingManagement,A=void 0!==j&&j,D=e.zoneList,G=void 0===D?[]:D,M=e.onCopy,B=e.onProductNameChange,R=e.productName,O=e.hasTicket,U=e.categoryType,Y=s.useFormContext(),Q=Y.register,V=Y.control,H=Y.formState.errors,z=Y.setValue,X=Y.getValues,W=Y.watch,Z=a.useContext(p.ProductSetLoadingContext),J=Z.setLoading,K=Z.providerHasBookingManagement,$=r.useTranslation("Design").t,ee=t.__read(a.useState(!1),2),te=ee[0],ae=ee[1],ne=t.__read(a.useState(null),2),re=ne[0],oe=ne[1],le=Boolean(W("".concat(L,".isUnlimited"))),ie=d.useId(),ce=d.useId(),se=d.useId(),me=d.useId(),de=d.useId(),ue=d.useId(),Ee=d.useId(),pe=d.useId(),ge=d.useId(),fe=d.useId(),Ce=d.useId(),ve=[{id:1,value:$("quantitySelector")},{id:2,value:$("stockControl")}],be=a.useCallback((function(){return ae((function(e){return!e}))}),[]),he=s.useWatch({control:V,name:"".concat(L,".quantitySelector")}),Fe=I.useImages(re),Ie=Fe.images,Pe=Fe.handleImageRemove,Ne=Fe.handleImageUploading,qe=Fe.isLoading,ye=a.useCallback((function(e){Ne(e,P.IMAGE_TYPE_IMAGE)}),[Ne]),ke=a.useCallback((function(e,t){Pe(String(e),t)}),[Pe]),xe=function(e){return e.target.select()};a.useEffect((function(){J(qe)}),[J,qe]),a.useEffect((function(){var e=X("".concat(L,".images"));oe(e)}),[X,oe,L]),a.useEffect((function(){Array.isArray(Ie)&&z("".concat(L,".images"),Ie)}),[Ie,L,z]);var Te=null!=he?he:"1",_e=g.QUANTITY_TYPE_LIST_DTO[Te];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:ce},n.createElement(i.Form.Label,null,$("name")),n.createElement(i.Form.Control,t.__assign({},Q("".concat(L,".name")),{value:R,onChange:B,isInvalid:m.isInvalid("".concat(L,".name"),H),disabled:_,placeholder:$("name")})),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".name"),H))),n.createElement(i.Form.Group,{controlId:se},n.createElement(i.Form.Label,null,$("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(q.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:_})},control:V,name:"".concat(L,".description")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".description"),H))),w?n.createElement(o,null,n.createElement(C.ProductDepositControl,{isLoading:_,fieldNamePrefix:L}),n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:"".concat(L,".price"),title:$("totalPrice"),allowDeposits:w})):n.createElement(x.ProductPriceControl,{isLoading:_,fieldNamePrefix:"".concat(L,".price")}),n.createElement("div",null,n.createElement(v.ProductQuantityControl,{isLoading:_,fieldNamePrefix:L,onFocus:xe}),_e===g.QUANTITY_TYPE_CONSTANT&&n.createElement(b.ProductQuantityConstantControl,{isLoading:_,fieldNamePrefix:L,onFocus:xe,disabled:le}),_e===g.QUANTITY_TYPE_RECHARGING&&n.createElement(h.ProductQuantityRechargingControl,{isLoading:_,fieldNamePrefix:L,onFocus:xe,disabled:le}),n.createElement(i.Form.Group,{controlId:fe,className:"custom-checkbox"},n.createElement(i.Form.Check,t.__assign({custom:!0,type:"checkbox"},Q("".concat(L,".isUnlimited")),{name:"".concat(L,".isUnlimited"),disabled:_})),n.createElement(i.Form.Check.Label,null,$("isUnlimited")))),n.createElement(i.Form.Group,{controlId:pe},n.createElement(i.Form.Label,null,$("quantitySelectorType")),n.createElement(i.Form.Control,t.__assign({as:"select",defaultValue:O?ve[0].id:void 0},Q("".concat(L,".quantitySelector")),{isInvalid:m.isInvalid("".concat(L,".quantitySelector"),H),disabled:_||O}),ve.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".quantitySelector"),H))))),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:L,providerHasBookingManagement:K}),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity")}))),U===g.CATEGORY_TYPE_GAME&&n.createElement(o,{className:"align-items-start"},n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".capacity"),label:$("capacity"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("capacity")})}}})),n.createElement(l,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(L,".duration"),label:$("durationMinutes"),rules:{min:{value:1,message:$("Validation:fieldRequired",{attribute:$("duration")})}}}))),n.createElement(o,null,n.createElement(l,{lg:8,md:8},n.createElement(i.Form.Group,{controlId:me},n.createElement(i.Form.Label,null,$("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,l=t.ref;return n.createElement(i.Form.Control,{ref:l,as:"textarea",rows:3,value:a,onChange:r,isInvalid:m.isInvalid("".concat(L,".termsAndConditions"),H),disabled:_,name:o})},control:V,name:"".concat(L,".termsAndConditions")}),n.createElement(i.Form.Control.Feedback,{type:"invalid"},m.getErrors("".concat(L,".termsAndConditions"),H)))),n.createElement(l,{lg:4,md:4,className:"licklist-file-upload-wrapper"},n.createElement(N.FileUpload,{onFilesChange:ye,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:ke,defaultFiles:Ie,isLoading:qe,withIcon:!0,title:$("addImage")}))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(i.Form.Group,{controlId:de,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isAvailable")})),n.createElement(i.Form.Group,{controlId:ue,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isSoldOut")})),n.createElement(i.Form.Group,{controlId:ie,className:"custom-checkbox"},n.createElement(i.Form.Check,{custom:!0,type:"checkbox",name:ie,disabled:_},n.createElement(i.Form.Check.Input,{checked:te,onChange:be,type:"checkbox"}),n.createElement(i.Form.Check.Label,null,$("showAdvancedOptions"))))),n.createElement(l,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(F,{in:te},n.createElement("div",null,n.createElement(i.Form.Group,{controlId:Ee,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".isRequired")})),n.createElement(i.Form.Group,{controlId:ge,className:"advanced-switch-container"},n.createElement(i.Form.Label,null,$("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(u.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:_})},control:V,name:"".concat(L,".hasSpecialNotes")})),U===g.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(y.FixedDurationOptions,{fieldNamePrefix:L}),n.createElement(i.Form.Group,{controlId:Ce,className:"advanced-switch-container"},n.createElement(x.ProductPriceControl,{title:$("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:_,fieldNamePrefix:"".concat(L,".minSpend")})))),n.createElement(o,null,n.createElement(l,{xs:12},A&&n.createElement(f.ProductBookingManagementControl,{isLoading:_,zoneList:G,fieldNamePrefix:L})))),n.createElement(o,null,n.createElement(l,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(M)&&n.createElement(i.Button,{onClick:M,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",$("copy"))))))};
@@ -1,12 +1,16 @@
1
1
  /// <reference types="react" />
2
- import { FieldNamePrefixPath, FormValues } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
2
+ import { FormValues } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
3
+ import { Path } from "react-hook-form";
3
4
  export interface ProductPriceControlValues extends FormValues {
4
5
  price: number;
5
6
  }
6
- export interface ProductPriceControlProps<T> extends FieldNamePrefixPath<T> {
7
+ export interface ProductPriceControlProps<T> {
7
8
  isLoading: boolean;
8
9
  title?: string;
9
10
  allowDeposits?: boolean;
11
+ fieldNamePrefix: Path<T>;
12
+ isRequired?: boolean;
13
+ isMoreThanZero?: boolean;
10
14
  }
11
- export declare function ProductPriceControl<T extends FormValues>({ isLoading, fieldNamePrefix, title, allowDeposits, }: ProductPriceControlProps<T>): JSX.Element;
15
+ export declare function ProductPriceControl<T extends FormValues>({ isLoading, fieldNamePrefix, title, allowDeposits, isRequired, isMoreThanZero, }: ProductPriceControlProps<T>): JSX.Element;
12
16
  //# sourceMappingURL=ProductPriceControl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProductPriceControl.d.ts","sourceRoot":"","sources":["../../../../src/product-set/product/price/ProductPriceControl.tsx"],"names":[],"mappings":";AAEA,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAStE,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IACzE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,EACxD,SAAiB,EACjB,eAAe,EACf,KAAK,EACL,aAAa,GACd,EAAE,wBAAwB,CAAC,CAAC,CAAC,eA4E7B"}
1
+ {"version":3,"file":"ProductPriceControl.d.ts","sourceRoot":"","sources":["../../../../src/product-set/product/price/ProductPriceControl.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAK1F,OAAO,EAAc,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AAInE,MAAM,WAAW,yBAA0B,SAAQ,UAAU;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,EACxD,SAAiB,EACjB,eAAe,EACf,KAAK,EACL,aAAa,EACb,UAAiB,EACjB,cAAc,GACf,EAAE,wBAAwB,CAAC,CAAC,CAAC,eAgG7B"}
@@ -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=e(require("react")),t=require("react-i18next"),a=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),n=require("../../../static/Icon.js"),o=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/HookFormService")),c=require("@react-aria/utils"),u=e(require("react-bootstrap/InputGroup"));exports.ProductPriceControl=function(e){var s=e.isLoading,m=void 0!==s&&s,d=e.fieldNamePrefix,p=e.title,f=e.allowDeposits,v=o.useFormContext(),b=v.control,q=v.formState.errors,x=t.useTranslation("Design").t,E=c.useId();return r.createElement(a,{xs:f?12:void 0,sm:f?6:void 0,className:!f&&"p-0"},r.createElement(i.Form.Group,{controlId:E},r.createElement(i.Form.Label,null,null!=p?p:x("price")),r.createElement(u,{hasValidation:!0},r.createElement(u.Prepend,null,r.createElement(u.Text,null,r.createElement(n.default,{type:"pound-sign",width:".6rem",className:"p-0"}))),r.createElement(o.Controller,{render:function(e){var t=e.field,a=t.value,n=t.onChange,o=t.name,c=t.ref;return r.createElement(i.Form.Control,{ref:c,type:"number",min:0,max:999999.99,step:"0.01",value:a,name:o,onChange:n,isInvalid:l.isInvalid("".concat(d,".price"),q),disabled:m})},control:b,name:"".concat(d,".price"),rules:{required:x("Validation:fieldRequired",{attribute:x("price")}),min:{value:0,message:x("Validation:fieldMinNumber",{attribute:x("price"),min:0})},max:{value:999999.99,message:x("Validation:fieldMaxNumber",{attribute:x("price"),max:999999.99})}}}),r.createElement(i.Form.Control.Feedback,{type:"invalid"},l.getErrors("".concat(d,".price"),q)))))};
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=e(require("react")),t=require("react-i18next"),a=e(require("react-bootstrap/Col")),i=require("react-bootstrap"),n=require("../../../static/Icon.js"),o=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),s=e(require("react-bootstrap/InputGroup"));exports.ProductPriceControl=function(e){var c=e.isLoading,m=void 0!==c&&c,d=e.fieldNamePrefix,p=e.title,f=e.allowDeposits,v=e.isRequired,b=void 0===v||v,q=e.isMoreThanZero,x=o.useFormContext(),E=x.control,g=x.formState.errors,C=t.useTranslation("Design").t,F=null!=p?p:C("price"),N=u.useId();return r.createElement(a,{xs:f?12:void 0,sm:f?6:void 0,className:!f&&"p-0"},r.createElement(i.Form.Group,{controlId:N},r.createElement(i.Form.Label,null,F),r.createElement(s,{hasValidation:!0},r.createElement(s.Prepend,null,r.createElement(s.Text,null,r.createElement(n.default,{type:"pound-sign",width:".6rem",className:"p-0"}))),r.createElement(o.Controller,{render:function(e){var t=e.field,a=t.value,n=t.onChange,o=t.name,u=t.ref;return r.createElement(i.Form.Control,{ref:u,type:"number",min:0,max:999999.99,step:"0.01",value:a,name:o,onChange:n,isInvalid:l.isInvalid("".concat(d),g),disabled:m})},control:E,name:"".concat(d),rules:{required:!!b&&C("Validation:fieldRequired",{attribute:F}),min:q?void 0:{value:0,message:C("Validation:fieldMinNumber",{attribute:F,min:0})},max:{value:999999.99,message:C("Validation:fieldMaxNumber",{attribute:F,max:999999.99})},validate:function(e){return!!(!q||q&&(null==e||""===e)||q&&Number(e)>0)||C("Validation:fieldGreaterMinNumber",{attribute:F,min:0})}}}),r.createElement(i.Form.Control.Feedback,{type:"invalid"},l.getErrors("".concat(d),g)))))};
@@ -5,8 +5,10 @@ export interface Product {
5
5
  description: string;
6
6
  deposit: number;
7
7
  price: number;
8
+ minSub?: number;
8
9
  minAmount?: number;
9
10
  maxAmount?: number;
11
+ minSpend?: number;
10
12
  isSoldOut?: boolean;
11
13
  isRequired?: boolean;
12
14
  isUnlimited?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"iframe.d.ts","sourceRoot":"","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,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,eAAe,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,oBAAY,UAAU,GAAG,CACvB,GAAG,EACC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACrB,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,KAC5D,IAAI,CAAC;AAEV,oBAAY,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.44.500",
3
+ "version": "0.44.502",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -78,7 +78,8 @@ export const MapPoint = ({
78
78
  // have 2 points near one by one
79
79
  const nextPoints = prevPoints.slice();
80
80
  const currentPoint = nextPoints.find(
81
- (i) => i.id === id || i?.localId === localId
81
+ (point) =>
82
+ (id && point.id === id) || (localId && point.localId === localId)
82
83
  );
83
84
  const currentPointIndex = nextPoints.indexOf(currentPoint);
84
85
 
@@ -106,6 +107,7 @@ export const MapPoint = ({
106
107
  };
107
108
 
108
109
  const onMouseEnter = () => {
110
+ changePointPosition();
109
111
  changeCursorType("pointer");
110
112
  };
111
113
 
@@ -1,6 +1,7 @@
1
- import React, { useMemo } from "react";
1
+ import React, { useMemo, useState } from "react";
2
2
  import { Path, KonvaNodeEvents, Group, Circle } from "react-konva";
3
3
  import Konva from "konva";
4
+ import { ProductTooltip } from "../ProductTooltip";
4
5
 
5
6
  const ICON_DATA =
6
7
  "M14 0C9.3569 0.6633 4.6431 0.6633 0 0L6 7V13H3V14H11V13H8V7L14 0Z";
@@ -62,6 +63,8 @@ export const ProductIcon = ({
62
63
  const defaultX = -X_OFFSET;
63
64
  const defaultY = -Y_OFFSET;
64
65
 
66
+ const [hovered, setHovered] = useState<boolean>(false);
67
+
65
68
  const cssVariableValues = useMemo(() => {
66
69
  return {
67
70
  pointBackgroundColor:
@@ -119,7 +122,12 @@ export const ProductIcon = ({
119
122
  };
120
123
 
121
124
  return (
122
- <Group x={x} y={y}>
125
+ <Group
126
+ x={x}
127
+ y={y}
128
+ onMouseEnter={() => setHovered(true)}
129
+ onMouseLeave={() => setHovered(false)}
130
+ >
123
131
  <Circle
124
132
  radius={CIRCLE_RADIUS}
125
133
  strokeWidth={POINT_STROKE_WIDTH}
@@ -127,6 +135,9 @@ export const ProductIcon = ({
127
135
  y={defaultY * 0.75}
128
136
  {...circleColors()}
129
137
  />
138
+ {hovered && isSoldOut && (
139
+ <ProductTooltip x={defaultX} y={defaultY} text="Sold out" />
140
+ )}
130
141
  {isProductChoosed ? (
131
142
  <Path
132
143
  x={defaultX}
@@ -0,0 +1,68 @@
1
+ import React from "react";
2
+ import { Group, Rect, Text } from "react-konva";
3
+
4
+ const TOOLTIP_WIDTH = 60;
5
+ const TOOLTIP_HEIGHT = 20;
6
+
7
+ const BACKGROUND_COLOR = "#000";
8
+ const BACKGROUND_Y_OFFSET = 1;
9
+ const BACKGROUND_X_OFFSET = 30;
10
+ const BACKGROUND_RADIUS = 5;
11
+ const BACKGROUND_OPACITY = 0.8;
12
+
13
+ const TEXT_Y_OFFSET = 4;
14
+ const TEXT_STROKE_WIDTH = 5;
15
+ const TEXT_COLOR = "#FFF";
16
+ const TEXT_ALIGN = "center";
17
+ const TEXT_VERTICAL_ALIGN = "middle";
18
+
19
+ type ProductTooltipProps = {
20
+ x: number;
21
+ y: number;
22
+ text: string;
23
+ };
24
+
25
+ export const ProductTooltip = ({ x, y, text }: ProductTooltipProps) => {
26
+ return (
27
+ <Group
28
+ width={TOOLTIP_WIDTH}
29
+ height={TOOLTIP_HEIGHT}
30
+ x={x + BACKGROUND_X_OFFSET}
31
+ y={y - BACKGROUND_Y_OFFSET}
32
+ >
33
+ <Rect
34
+ x={-5}
35
+ y={5}
36
+ sceneFunc={(context) => {
37
+ context.beginPath();
38
+ context.moveTo(0, 5);
39
+ context.lineTo(5, 0);
40
+ context.lineTo(5, 10);
41
+ context.closePath();
42
+ context.fill();
43
+ }}
44
+ fill={BACKGROUND_COLOR}
45
+ borderColor={BACKGROUND_COLOR}
46
+ opacity={BACKGROUND_OPACITY}
47
+ />
48
+ <Rect
49
+ x={0}
50
+ y={0}
51
+ width={TOOLTIP_WIDTH}
52
+ height={TOOLTIP_HEIGHT}
53
+ fill={BACKGROUND_COLOR}
54
+ cornerRadius={BACKGROUND_RADIUS}
55
+ opacity={BACKGROUND_OPACITY}
56
+ />
57
+ <Text
58
+ y={TEXT_Y_OFFSET}
59
+ text={text}
60
+ strokeWidth={TEXT_STROKE_WIDTH}
61
+ width={TOOLTIP_WIDTH}
62
+ align={TEXT_ALIGN}
63
+ verticalAlign={TEXT_VERTICAL_ALIGN}
64
+ fill={TEXT_COLOR}
65
+ />
66
+ </Group>
67
+ );
68
+ };
@@ -0,0 +1 @@
1
+ export { ProductTooltip } from "./ProductTooltip";
@@ -6,6 +6,7 @@ import { Page, PageBody, PageHeader } from "../../page";
6
6
  import { BookingSummaryFooter } from "../../order-process/components/BookingSummaryFooter";
7
7
  import { BookingSummary } from "../../order-process/components/BookingSummary";
8
8
  import { CalendarSelect } from "../event-calendar/components/CalendarSelect";
9
+ import { Product } from "../../../types";
9
10
 
10
11
  export default {
11
12
  title: "Iframe/Event/IframeEventVenueMap",
@@ -268,6 +269,10 @@ export function Default() {
268
269
  pointProducts={MENU_STEPS[0].pointProducts}
269
270
  usedInIframe={usedInIframe}
270
271
  onPointClick={(pointId) => console.log({ pointId })}
272
+ products={
273
+ MENU_STEPS[0].productCategories[0]
274
+ .products as Partial<Product>[]
275
+ }
271
276
  choosedProductUuids={[
272
277
  "beb6393c-2fdd-40f7-bb92-8800685b203f",
273
278
  "beb6393c-2fdd-40f7-bb92-8800685b203a",
@@ -49,6 +49,7 @@ const productCategories = [
49
49
 
50
50
  price: 5,
51
51
  deposit: 3,
52
+ minSub: 10,
52
53
  isRequired: true,
53
54
  images: IMAGES,
54
55
  },
@@ -83,17 +83,32 @@ export const CategoryProduct = ({
83
83
  // One case when no value is that we have product,
84
84
  // but didn't click on number input.
85
85
  // If it will be required then required check fired firstly.
86
- if (!value) return true;
87
86
 
88
- const { isRequired = false, maxAmount = 0, minAmount = 0 } = product;
87
+ const {
88
+ isRequired = false,
89
+ maxAmount = 0,
90
+ minAmount = 0,
91
+ minSpend,
92
+ price,
93
+ } = product;
94
+
95
+ const currentQuantity = value?.quantity ?? 0;
96
+ if (minSpend && currentQuantity * price < minSpend) {
97
+ return t("Design:minimumSpendSumValidation", {
98
+ minSpend: formatNumber(minSpend, {
99
+ style: "currency",
100
+ currency: Config.Currency.GBP,
101
+ }),
102
+ }) as string;
103
+ }
89
104
 
90
- const { quantity = 0 } = value;
105
+ if (!value) return true;
91
106
 
92
- if (!quantity && !isRequired) {
107
+ if (!currentQuantity && !isRequired) {
93
108
  return true;
94
109
  }
95
110
 
96
- if (!quantity && isRequired) {
111
+ if (!currentQuantity && isRequired) {
97
112
  return t("Design:pleaseSelectAtLeastFrom", {
98
113
  min: 1,
99
114
  type: "item",
@@ -101,14 +116,18 @@ export const CategoryProduct = ({
101
116
  }) as string;
102
117
  }
103
118
 
104
- if (quantity < minAmount) {
119
+ if (currentQuantity < minAmount) {
105
120
  return t("Validation:fieldMinNumber", {
106
121
  min: product.minAmount,
107
122
  attribute: product.name,
108
123
  }) as string;
109
124
  }
110
125
 
111
- if (maxAmount && quantity >= minAmount && maxAmount < quantity) {
126
+ if (
127
+ maxAmount &&
128
+ currentQuantity >= minAmount &&
129
+ maxAmount < currentQuantity
130
+ ) {
112
131
  return t("Validation:quantityMaxNumber", {
113
132
  max: product.maxAmount,
114
133
  }) as string;
@@ -86,6 +86,7 @@ export interface ProductControlValues
86
86
  isRequired: boolean;
87
87
  quantitySelector: number;
88
88
  hasSpecialNotes: boolean;
89
+ minSpend?: number | null;
89
90
  type?: ProductType;
90
91
  weight?: number;
91
92
  tierId?: number;
@@ -157,6 +158,7 @@ export function ProductControl<T extends FormValues>({
157
158
  const quantitySelectorId = useId();
158
159
  const hasSpecialNotesId = useId();
159
160
  const unlimitedQuantityId = useId();
161
+ const minSpendId = useId();
160
162
 
161
163
  const quantitySelectorList: SelectItem[] = [
162
164
  { id: 1, value: t("quantitySelector") },
@@ -274,7 +276,7 @@ export function ProductControl<T extends FormValues>({
274
276
  />
275
277
  <ProductPriceControl<T>
276
278
  isLoading={isLoading}
277
- fieldNamePrefix={fieldNamePrefix}
279
+ fieldNamePrefix={`${fieldNamePrefix}.price` as Path<T>}
278
280
  title={t("totalPrice")}
279
281
  allowDeposits={allowDeposits}
280
282
  />
@@ -282,7 +284,7 @@ export function ProductControl<T extends FormValues>({
282
284
  ) : (
283
285
  <ProductPriceControl<T>
284
286
  isLoading={isLoading}
285
- fieldNamePrefix={fieldNamePrefix}
287
+ fieldNamePrefix={`${fieldNamePrefix}.price` as Path<T>}
286
288
  />
287
289
  )}
288
290
 
@@ -557,6 +559,19 @@ export function ProductControl<T extends FormValues>({
557
559
  {categoryType === CATEGORY_TYPE_FIXED_DURATION && (
558
560
  <FixedDurationOptions fieldNamePrefix={fieldNamePrefix} />
559
561
  )}
562
+ <Form.Group
563
+ controlId={minSpendId}
564
+ className="advanced-switch-container"
565
+ >
566
+ <ProductPriceControl
567
+ title={t("minSpend")}
568
+ isRequired={false}
569
+ isMoreThanZero
570
+ allowDeposits={false}
571
+ isLoading={isLoading}
572
+ fieldNamePrefix={`${fieldNamePrefix}.minSpend` as Path<T>}
573
+ />
574
+ </Form.Group>
560
575
  </div>
561
576
  </Collapse>
562
577
 
@@ -1,9 +1,6 @@
1
1
  import React from "react";
2
2
  import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
3
- import {
4
- FieldNamePrefixPath,
5
- FormValues,
6
- } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
3
+ import { FormValues } from "@licklist/plugins/dist/types/services/Form/hook-form-service";
7
4
  import { useId } from "@react-aria/utils";
8
5
  import { Form } from "react-bootstrap";
9
6
  import Col from "react-bootstrap/Col";
@@ -16,10 +13,13 @@ export interface ProductPriceControlValues extends FormValues {
16
13
  price: number;
17
14
  }
18
15
 
19
- export interface ProductPriceControlProps<T> extends FieldNamePrefixPath<T> {
16
+ export interface ProductPriceControlProps<T> {
20
17
  isLoading: boolean;
21
18
  title?: string;
22
19
  allowDeposits?: boolean;
20
+ fieldNamePrefix: Path<T>;
21
+ isRequired?: boolean;
22
+ isMoreThanZero?: boolean;
23
23
  }
24
24
 
25
25
  export function ProductPriceControl<T extends FormValues>({
@@ -27,13 +27,15 @@ export function ProductPriceControl<T extends FormValues>({
27
27
  fieldNamePrefix,
28
28
  title,
29
29
  allowDeposits,
30
+ isRequired = true,
31
+ isMoreThanZero,
30
32
  }: ProductPriceControlProps<T>) {
31
33
  const {
32
34
  control,
33
35
  formState: { errors },
34
36
  } = useFormContext<T>();
35
37
  const { t } = useTranslation("Design");
36
-
38
+ const productTitle = title ?? t("price");
37
39
  const priceId = useId();
38
40
 
39
41
  return (
@@ -43,7 +45,7 @@ export function ProductPriceControl<T extends FormValues>({
43
45
  className={!allowDeposits && "p-0"}
44
46
  >
45
47
  <Form.Group controlId={priceId}>
46
- <Form.Label>{title ?? t("price")}</Form.Label>
48
+ <Form.Label>{productTitle}</Form.Label>
47
49
 
48
50
  <InputGroup hasValidation>
49
51
  <InputGroup.Prepend>
@@ -64,38 +66,58 @@ export function ProductPriceControl<T extends FormValues>({
64
66
  name={name}
65
67
  onChange={onChange}
66
68
  isInvalid={HookFormService.isInvalid<T>(
67
- `${fieldNamePrefix}.price` as Path<T>,
69
+ `${fieldNamePrefix}` as Path<T>,
68
70
  errors
69
71
  )}
70
72
  disabled={isLoading}
71
73
  />
72
74
  )}
73
75
  control={control}
74
- name={`${fieldNamePrefix}.price` as Path<T>}
76
+ name={`${fieldNamePrefix}` as Path<T>}
75
77
  rules={{
76
- required: t("Validation:fieldRequired", {
77
- attribute: t("price"),
78
- }) as string,
79
- min: {
80
- value: 0,
81
- message: t("Validation:fieldMinNumber", {
82
- attribute: t("price"),
83
- min: 0,
84
- }) as string,
85
- },
78
+ required: isRequired
79
+ ? (t("Validation:fieldRequired", {
80
+ attribute: productTitle,
81
+ }) as string)
82
+ : false,
83
+ min: !isMoreThanZero
84
+ ? {
85
+ value: 0,
86
+ message: t("Validation:fieldMinNumber", {
87
+ attribute: productTitle,
88
+ min: 0,
89
+ }) as string,
90
+ }
91
+ : undefined,
86
92
  max: {
87
93
  value: 999999.99,
88
94
  message: t("Validation:fieldMaxNumber", {
89
- attribute: t("price"),
95
+ attribute: productTitle,
90
96
  max: 999999.99,
91
97
  }) as string,
92
98
  },
99
+
100
+ validate: (value) => {
101
+ if (
102
+ !isMoreThanZero ||
103
+ (isMoreThanZero &&
104
+ (value === undefined || value === null || value === "")) ||
105
+ (isMoreThanZero && Number(value) > 0)
106
+ ) {
107
+ return true;
108
+ }
109
+
110
+ return t("Validation:fieldGreaterMinNumber", {
111
+ attribute: productTitle,
112
+ min: 0,
113
+ }) as string;
114
+ },
93
115
  }}
94
116
  />
95
117
 
96
118
  <Form.Control.Feedback type="invalid">
97
119
  {HookFormService.getErrors<T>(
98
- `${fieldNamePrefix}.price` as Path<T>,
120
+ `${fieldNamePrefix}` as Path<T>,
99
121
  errors
100
122
  )}
101
123
  </Form.Control.Feedback>
@@ -6,8 +6,10 @@ export interface Product {
6
6
  description: string;
7
7
  deposit: number;
8
8
  price: number;
9
+ minSub?: number;
9
10
  minAmount?: number;
10
11
  maxAmount?: number;
12
+ minSpend?: number;
11
13
  isSoldOut?: boolean;
12
14
  isRequired?: boolean;
13
15
  isUnlimited?: boolean;