@licklist/design 0.53.0-dev.3 → 0.53.0-dev.4
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/CategoryProduct/CategoryProduct.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/CategoryProduct.js +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +1 -1
- package/package.json +1 -1
- package/src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx +5 -2
- package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAC;AAI7D,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,wBAAwB,EAAE,CAAC;IAChD,eAAe,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC9C;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"CategoryProduct.d.ts","sourceRoot":"","sources":["../../../../../src/iframe/order-process/components/CategoryProduct/CategoryProduct.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAC;AAI7D,UAAU,oBAAoB;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kBAAkB,CAAC,EAAE,wBAAwB,EAAE,CAAC;IAChD,eAAe,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC9C;AAED,eAAO,MAAM,eAAe,sFAMzB,oBAAoB,gBAmLtB,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"),o=require("react-i18next"),a=require("react-hook-form"),c=e(require("@licklist/plugins/dist/services/Form/HookFormService")),s=e(require("clsx")),u=require("react-intl"),
|
|
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"),o=require("react-i18next"),a=require("react-hook-form"),c=e(require("@licklist/plugins/dist/services/Form/HookFormService")),s=e(require("clsx")),u=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,v=e.canExpandDescription,y=void 0===v||v,f=e.productsWithErrors,g=e.soldOutProducts,E=u.useIntl().formatNumber,q=o.useTranslation(["Design","Validation"]).t,_=a.useFormContext(),x=_.control,N=_.clearErrors,A=_.setError,C=p.allowDeposits&&(null==m?void 0:m.deposit)<m.price,D=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]),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(){D&&A("".concat(m.id),{message:D,type:"validate"})}),[D,m.id]),i.createElement(a.Controller,{control:x,name:"".concat(m.id),rules:{required:m.isRequired,validate:function(e){var r,t=m.isRequired,i=void 0!==t&&t,n=m.maxAmount,o=void 0===n?0:n,a=m.minAmount,c=void 0===a?0:a,s=null!==(r=null==e?void 0:e.quantity)&&void 0!==r?r:0;return!e||(!s&&!i||(!s&&i?q("Design:pleaseSelectAtLeastFrom",{min:1,type:"item",from:"this category"}):s<c?q("Validation:fieldMinNumber",{min:m.minAmount,attribute:m.name}):!(o&&s>=c&&o<s)||q("Validation:quantityMaxNumber",{max:m.maxAmount})))}},render:function(e){var t=e.field,o=t.onChange,a=t.value,u=void 0===a?{}:a,v=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:s("iframe-event__product",g&&"error")},i.createElement(d.TicketDescription,{title:m.name,description:m.description,className:s("iframe-event__product-description"),images:m.images,isRequired:m.isRequired,canExpand:y})),i.createElement("div",{className:"iframe-event__product-price-wrapper"},i.createElement("span",{className:"product-price"},E(p.allowDeposits?null==m?void 0:m.deposit:m.price,{style:"currency",currency:n.Currency.GBP})),i.createElement(l.ProductQuantityInput,{onChange:o,productInfo:u,refCallback:v,clearErrors:N,product:r.__assign(r.__assign({},m),{isSoldOut:(null==m?void 0:m.isSoldOut)||P()}),category:p,invalid:g})),C&&!(null==p?void 0:p.remainderExpireAfter)&&i.createElement("div",{className:"mt-4"},q("Design:payNowAndUponArrival",{deposit:E(null==m?void 0:m.deposit,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-(null==m?void 0:m.deposit),{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(null==m?void 0:m.deposit,{style:"currency",currency:n.Currency.GBP}),remainder:E(m.price-(null==m?void 0:m.deposit),{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 +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=e(require("react")),n=require("react-i18next"),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=e(require("react")),n=require("react-i18next"),o=require("react-bootstrap"),i=e(require("clsx")),u=require("../NumberInput/NumberInput.js");exports.ProductQuantityInput=function(e){var r=e.product,l=e.category,a=e.onChange,d=e.clearErrors,c=e.refCallback,s=e.productInfo,v=e.invalid,m=n.useTranslation("Design").t,p=function(e){var t,n=e;(null==r?void 0:r.maxAmount)&&e>(null==r?void 0:r.maxAmount)&&(n=null==r?void 0:r.maxAmount),a({id:r.id,name:r.name,deposit:null==r?void 0:r.deposit,hasDeposit:l.allowDeposits&&(null==r?void 0:r.deposit)<r.price,price:r.price,productCategoryId:l.id,zoneId:null===(t=l.zone)||void 0===t?void 0:t.id,quantity:n,capacity:null==r?void 0:r.capacity})};return r.isSoldOut?t.createElement("div",{className:"iframe-event__sold-out-wrapper"},m("Design:soldOut")):1===(null==r?void 0:r.maxAmount)?t.createElement(o.Button,{ref:c,disabled:r.isSoldOut,className:i("iframe-event__".concat((null==s?void 0:s.quantity)?"unselect-product":"select-product"),v&&"error"),onClick:function(){return p((null==s?void 0:s.quantity)?0:1)}},m("Design:".concat((null==s?void 0:s.quantity)?"unselect":"select"))):t.createElement(u.NumberInput,{ref:c,onChange:function(e){p(e||null),d("".concat(r.id))},onArrowDown:function(){p((null==s?void 0:s.quantity)-1||0),d("".concat(r.id))},onArrowUp:function(){var e;p((null!==(e=null==s?void 0:s.quantity)&&void 0!==e?e:0)+1),d("".concat(r.id))},min:0,max:(null==r?void 0:r.maxAmount)?Number(null==r?void 0:r.maxAmount):void 0,placeholder:"0",disabled:r.isSoldOut,value:null==s?void 0:s.quantity,className:i(v&&"error")})};
|
package/package.json
CHANGED
|
@@ -32,6 +32,9 @@ export const CategoryProduct = ({
|
|
|
32
32
|
const { t } = useTranslation(["Design", "Validation"]);
|
|
33
33
|
const { control, clearErrors, setError } = useFormContext();
|
|
34
34
|
|
|
35
|
+
const hasDeposits =
|
|
36
|
+
category.allowDeposits && product?.deposit < product.price;
|
|
37
|
+
|
|
35
38
|
const productQuantityError = useMemo(() => {
|
|
36
39
|
if (!productsWithErrors) {
|
|
37
40
|
return undefined;
|
|
@@ -155,7 +158,7 @@ export const CategoryProduct = ({
|
|
|
155
158
|
invalid={invalid}
|
|
156
159
|
/>
|
|
157
160
|
</div>
|
|
158
|
-
{
|
|
161
|
+
{hasDeposits && !category?.remainderExpireAfter && (
|
|
159
162
|
<div className="mt-4">
|
|
160
163
|
{t("Design:payNowAndUponArrival", {
|
|
161
164
|
deposit: formatNumber(product?.deposit, {
|
|
@@ -170,7 +173,7 @@ export const CategoryProduct = ({
|
|
|
170
173
|
</div>
|
|
171
174
|
)}
|
|
172
175
|
|
|
173
|
-
{
|
|
176
|
+
{hasDeposits && category?.remainderExpireAfter > 0 && (
|
|
174
177
|
<div className="mt-4">
|
|
175
178
|
{t("Design:payNowAndReminderDays", {
|
|
176
179
|
deposit: formatNumber(product?.deposit, {
|
|
@@ -53,7 +53,7 @@ export const ProductQuantityInput = ({
|
|
|
53
53
|
id: product.id,
|
|
54
54
|
name: product.name,
|
|
55
55
|
deposit: product?.deposit,
|
|
56
|
-
hasDeposit: category.allowDeposits,
|
|
56
|
+
hasDeposit: category.allowDeposits && product?.deposit < product.price,
|
|
57
57
|
price: product.price,
|
|
58
58
|
productCategoryId: category.id,
|
|
59
59
|
zoneId: category.zone?.id,
|