@bikdotai/bik-component-library 0.0.524 → 0.0.526
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/cjs/components/discount-modal/DiscountUtils.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/BackTrackComponent.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/Body.js +1 -0
- package/dist/esm/components/discount-modal/DiscountUtils.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/BackTrackComponent.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/Body.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./type.js"),t=require("../../utils/DateUtils.js");function i(e,t){const i=[];return t.forEach((t=>{e.find((e=>e.toString()===t.id))&&i.push(t.name)})),i}exports.descriptionBuilder=(n,r,l,u)=>{var o,d,T;return(null==n?void 0:n.isStaticCoupon)&&(null==n?void 0:n.description)?n.description:n.targetType===e.DISCOUNT_TARGET_TYPES.LINE_ITEM&&n.targetSelection===e.DISCOUNT_TARGET_SELECTION.ALL?`${n.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?r:""}${(null!==(o=n.value)&&void 0!==o?o:0).toString()}${n.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on all products\n ${n.minAmount?`| Minimum purchase of ${r}${n.minAmount}`:""} ${n.minQuantity?`| Buy ${n.minQuantity} products`:""} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():n.targetType===e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?`\n Free shipping on your order ${n.minAmount?`| Minimum purchase of ${r}${n.minAmount}`:""} ${n.minQuantity?`| Buy ${n.minQuantity} products`:""} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():n.targetSelection===e.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(d=n.prerequisiteProductIds)||void 0===d?void 0:d.length)||(null===(T=n.prerequisiteCollectionIds)||void 0===T?void 0:T.length)?`${function(e,t,n){var r,l,u,o,d,T,E,s;let v=`Buy ${e.prerequisiteQuantity} item`;if((null===(r=e.prerequisiteProductIds)||void 0===r?void 0:r.length)||(null===(l=e.prerequisiteCollectionIds)||void 0===l?void 0:l.length)){const r=i(null!==(u=e.prerequisiteProductIds)&&void 0!==u?u:[],t),l=i(null!==(o=e.prerequisiteCollectionIds)&&void 0!==o?o:[],n);v+=" from a selection of ",r.length>0&&(v+=`${r.join(", ")} or `),l.length>0&&(v+=`products in ${l.join(", ")} collection or `),v=v.slice(0,-4)}if(v+=` and get ${e.entitledQuantity} item`,(null===(d=e.entitledProductIds)||void 0===d?void 0:d.length)||(null===(T=e.entitledCollectionIds)||void 0===T?void 0:T.length)){const r=i(null!==(E=e.entitledProductIds)&&void 0!==E?E:[],t),l=i(null!==(s=e.entitledCollectionIds)&&void 0!==s?s:[],n);v+=" from ",r.length>0&&(v+=`${r.join(", ")} or `),l.length>0&&(v+=`products in ${l.join(", ")} collection or `),v=v.slice(0,-4)}return v}(n,l,u)} ${100===n.value?"for free":`at ${n.value}% off`} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():`${function(t,n,r,l){var u,o,d;let T=`Get ${t.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?l:""}${(null!==(u=t.value)&&void 0!==u?u:0).toString()}${t.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on `;const E=i(null!==(o=t.entitledProductIds)&&void 0!==o?o:[],n),s=i(null!==(d=t.entitledCollectionIds)&&void 0!==d?d:[],r);E.length>0&&(T+=`${E.join(", ")} or `);s.length>0&&(T+=`products in ${s.join(", ")} collection or `);return T.slice(0,-4)}(n,l,u,r)} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():void 0},exports.validateDiscountData=(t,i,n,r,l,u)=>{var o,d,T,E,s,v,a,p,I,f,c,_,A;if(!t.title||(null===(o=t.title)||void 0===o?void 0:o.length)>
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./type.js"),t=require("../../utils/DateUtils.js");function i(e,t){const i=[];return t.forEach((t=>{e.find((e=>e.toString()===t.id))&&i.push(t.name)})),i}exports.descriptionBuilder=(n,r,l,u)=>{var o,d,T;return(null==n?void 0:n.isStaticCoupon)&&(null==n?void 0:n.description)?n.description:n.targetType===e.DISCOUNT_TARGET_TYPES.LINE_ITEM&&n.targetSelection===e.DISCOUNT_TARGET_SELECTION.ALL?`${n.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?r:""}${(null!==(o=n.value)&&void 0!==o?o:0).toString()}${n.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on all products\n ${n.minAmount?`| Minimum purchase of ${r}${n.minAmount}`:""} ${n.minQuantity?`| Buy ${n.minQuantity} products`:""} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():n.targetType===e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?`\n Free shipping on your order ${n.minAmount?`| Minimum purchase of ${r}${n.minAmount}`:""} ${n.minQuantity?`| Buy ${n.minQuantity} products`:""} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():n.targetSelection===e.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(d=n.prerequisiteProductIds)||void 0===d?void 0:d.length)||(null===(T=n.prerequisiteCollectionIds)||void 0===T?void 0:T.length)?`${function(e,t,n){var r,l,u,o,d,T,E,s;let v=`Buy ${e.prerequisiteQuantity} item`;if((null===(r=e.prerequisiteProductIds)||void 0===r?void 0:r.length)||(null===(l=e.prerequisiteCollectionIds)||void 0===l?void 0:l.length)){const r=i(null!==(u=e.prerequisiteProductIds)&&void 0!==u?u:[],t),l=i(null!==(o=e.prerequisiteCollectionIds)&&void 0!==o?o:[],n);v+=" from a selection of ",r.length>0&&(v+=`${r.join(", ")} or `),l.length>0&&(v+=`products in ${l.join(", ")} collection or `),v=v.slice(0,-4)}if(v+=` and get ${e.entitledQuantity} item`,(null===(d=e.entitledProductIds)||void 0===d?void 0:d.length)||(null===(T=e.entitledCollectionIds)||void 0===T?void 0:T.length)){const r=i(null!==(E=e.entitledProductIds)&&void 0!==E?E:[],t),l=i(null!==(s=e.entitledCollectionIds)&&void 0!==s?s:[],n);v+=" from ",r.length>0&&(v+=`${r.join(", ")} or `),l.length>0&&(v+=`products in ${l.join(", ")} collection or `),v=v.slice(0,-4)}return v}(n,l,u)} ${100===n.value?"for free":`at ${n.value}% off`} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():`${function(t,n,r,l){var u,o,d;let T=`Get ${t.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?l:""}${(null!==(u=t.value)&&void 0!==u?u:0).toString()}${t.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on `;const E=i(null!==(o=t.entitledProductIds)&&void 0!==o?o:[],n),s=i(null!==(d=t.entitledCollectionIds)&&void 0!==d?d:[],r);E.length>0&&(T+=`${E.join(", ")} or `);s.length>0&&(T+=`products in ${s.join(", ")} collection or `);return T.slice(0,-4)}(n,l,u,r)} | One use per customer${n.expireAfter?` | Expires in ${n.expireAfter} day(s)`:n.expireAt?` | Expires at ${t.default.getStringFromDate(n.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():void 0},exports.validateDiscountData=(t,i,n,r,l,u)=>{var o,d,T,E,s,v,a,p,I,f,c,_,A;if(!t.title||(null===(o=t.title)||void 0===o?void 0:o.length)>30)return!0;if(!r){if(isNaN(t.probability))return!0;if((t.probability||0)>1)return!0;if((t.probability||0)<0)return!0;if(l>1)return!0}if(u){if(!(null==t?void 0:t.couponCode))return!0;if(!t.description)return!0}else{if(n&&n===e.DISCOUNT_TYPES.AMOUNT_OFF_ORDER){if((null==t?void 0:t.valueType)===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0)return!0}else if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0||(null==t?void 0:t.value)>100)return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!t.minAmount||(null==t?void 0:t.minAmount)<=0))return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==t?void 0:t.minQuantity)||(null==t?void 0:t.minQuantity)<=0))return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(n&&n===e.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS){if(!(null===(d=t.entitledProductIds)||void 0===d?void 0:d.length)&&!(null===(T=t.entitledCollectionIds)||void 0===T?void 0:T.length))return!0;if((null===(E=t.entitledProductIds)||void 0===E?void 0:E.length)&&(null===(s=t.entitledCollectionIds)||void 0===s?void 0:s.length))return!0;if(!t.value)return!0;if((null==t?void 0:t.valueType)===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0)return!0}else if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0||(null==t?void 0:t.value)>100)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else if(n&&n===e.DISCOUNT_TYPES.BUY_X_GET_Y){if(!t.entitledQuantity||t.entitledQuantity<0||!(null===(v=t.entitledProductIds)||void 0===v?void 0:v.length)&&!(null===(a=t.entitledCollectionIds)||void 0===a?void 0:a.length)||!t.prerequisiteQuantity||t.prerequisiteQuantity<0||!(null===(p=t.prerequisiteProductIds)||void 0===p?void 0:p.length)&&!(null===(I=t.prerequisiteCollectionIds)||void 0===I?void 0:I.length))return!0;if((null===(f=t.entitledProductIds)||void 0===f?void 0:f.length)&&(null===(c=t.entitledCollectionIds)||void 0===c?void 0:c.length))return!0;if((null===(_=t.prerequisiteCollectionIds)||void 0===_?void 0:_.length)&&(null===(A=t.prerequisiteProductIds)||void 0===A?void 0:A.length))return!0;if(t.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!t.value)return!0;if(t.value<=0||t.value>100)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else if(n&&e.DISCOUNT_TYPES.FREE_SHIPPING){if(t.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE)return!0;if(100!==t.value)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!t.minAmount||(null==t?void 0:t.minAmount)<=0))return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==t?void 0:t.minQuantity)||(null==t?void 0:t.minQuantity)<=0))return!0}if(null!==t.expireAfter&&void 0!==t.expireAfter&&t.expireAfter<=0)return!0;if(t.expireAt&&t.expireAt<new Date)return!0}return!1};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../checkBox/CheckBox.js"),a=require("../../TypographyStyle.js"),i=require("../../input/Input.js");exports.BackTrackComponent=s=>{const{backTrackMessage:n,setBackTrackMessage:c}=s,[l,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../checkBox/CheckBox.js"),a=require("../../TypographyStyle.js"),i=require("../../input/Input.js");exports.BackTrackComponent=s=>{const{backTrackMessage:n,setBackTrackMessage:c}=s,[l,x]=r.useState(!!n);return e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",marginLeft:10,marginTop:8,width:"300px",padding:"20px 0px"}},{children:[e.jsx(t.CheckBox,{isChecked:l,onValueChange:()=>{l&&c&&c(""),x(!l)}}),e.jsx(a.TitleSmall,Object.assign({style:{marginLeft:8}},{children:"Prevent BackTracking"}))]})),l&&e.jsx("div",Object.assign({style:{margin:10}},{children:e.jsx(i.Input,{type:"multiline",placeholder:"Enter your text here",labelText:"Message if user tries backtracking",onChangeText:e=>{c&&c(e)},height:"120px",maxCharLimit:1024,value:n,noErrorHint:!0,validate:e=>[!0,""]})}))]})};
|
|
@@ -18,4 +18,5 @@
|
|
|
18
18
|
overflow-y: auto;
|
|
19
19
|
background-image: ${e=>e.hideDeviceContainerInPreview&&e.channel===o.CHANNEL_TYPE.WHATSAPP?`url(${d.BACKGROUND_PREVIEW_IMAGE});`:"none"};
|
|
20
20
|
display: ${e=>e.hideDeviceContainerInPreview&&e.channel===o.CHANNEL_TYPE.WHATSAPP?"flex":"initial"};
|
|
21
|
+
align-items: flex-start;
|
|
21
22
|
`;exports.default=i=>{const{showVariableMapping:d,showOnlyContent:v,whatsappSpecificPickerMeta:P,showVariableModal:g,variableList:E,discountCode:b,setDiscountCode:A,variableListForImage:j,showSampleValues:N,fileName:T,setFileName:y}=i,L=t.useRef(),S=t.useRef(),{device:_,display_content:M,channel:W,template:H,setTemplate:O,isWhatsappCarousel:V,isProductCarouselType:I,hideDeviceContainerInPreview:q}=r.useTemplateModalContext();const k=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(w,{children:[e.jsx(x,Object.assign({showOnlyContent:v,showVariableMapping:d,isWhatsappCarousel:V,hideDeviceContainerInPreview:q,channel:W},{children:"mobile"===_?e.jsx(m.default,{ref:S,display_content:null!=M?M:"",channel:W,template:H,showSampleValues:N}):W===o.CHANNEL_TYPE.WHATSAPP&&V?e.jsx(a.CarouselPreview,{ref:L,channel:W,template:H,showSampleValues:N,isPreview:!1,showArrows:!0}):W!==o.CHANNEL_TYPE.MESSAGE?e.jsx(c.default,{ref:L,channel:W,display_content:null!=M?M:"",showSampleValues:N}):e.jsx(e.Fragment,{})})),(I||d)&&e.jsx(f,Object.assign({channel:W,isWhatsappCarousel:V,showVariableMapping:!0},{children:W!==o.CHANNEL_TYPE.WHATSAPP?e.jsx(C.default,{onFocus:W===o.CHANNEL_TYPE.EMAIL?function(e){var t,i,a;const l=null===document||void 0===document?void 0:document.getElementById("mobile"===_?"template_html_mobile":"template_html_desktop"),n=p.getVariableNameForEmailByIndex(e+1),r=W===o.CHANNEL_TYPE.EMAIL?null===(t=null==l?void 0:l.contentWindow)||void 0===t?void 0:t.document.getElementById(n):document.getElementById(n),d=k(r),c=null==r?void 0:r.offsetLeft;"desktop"===_?d&&L.current&&(null===(i=null==l?void 0:l.contentWindow)||void 0===i||i.scrollTo(null!=c?c:0,d),u.highlightFor(n,s.COLORS.background.warning.light,2,W,_)):d&&S.current&&(null===(a=null==l?void 0:l.contentWindow)||void 0===a||a.scrollTo(null!=c?c:0,d),u.highlightFor(n,s.COLORS.background.warning.light,2,W,_))}:void 0,showVariableModal:g,variableList:E,discountCode:b,setDiscountCode:A}):W===o.CHANNEL_TYPE.WHATSAPP&&V?e.jsx(l.default,{whatsappSpecificPickerMeta:P,template:H,showVariableModal:g,variableList:E,variableListForImage:j,discountCode:b,setDiscountCode:A}):e.jsx(h.default,{whatsappSpecificPickerMeta:P,template:H,onTemplateChange:e=>{null==O||O(e)},showVariableModal:g,variableList:E,variableListForImage:j,discountCode:b,setDiscountCode:A,fileName:T,setFileName:y})})),W===o.CHANNEL_TYPE.WHATSAPP&&!d&&!I&&e.jsx(f,{children:e.jsx(n.BodySecondary,Object.assign({color:s.COLORS.content.secondary,style:{fontStyle:"italic"}},{children:"Click on ‘Select template’ below to use it"}))})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DISCOUNT_TYPES as e,DISCOUNT_VALUE_TYPES as i,MIN_PURCHASE_REQUIREMENT as t,DISCOUNT_TARGET_TYPES as n,DISCOUNT_TARGET_SELECTION as r}from"./type.js";import l from"../../utils/DateUtils.js";const o=(l,o,u,d,v,s)=>{var a,p,f,c,y,g,m,I,A,E,T,$,h;if(!l.title||(null===(a=l.title)||void 0===a?void 0:a.length)>
|
|
1
|
+
import{DISCOUNT_TYPES as e,DISCOUNT_VALUE_TYPES as i,MIN_PURCHASE_REQUIREMENT as t,DISCOUNT_TARGET_TYPES as n,DISCOUNT_TARGET_SELECTION as r}from"./type.js";import l from"../../utils/DateUtils.js";const o=(l,o,u,d,v,s)=>{var a,p,f,c,y,g,m,I,A,E,T,$,h;if(!l.title||(null===(a=l.title)||void 0===a?void 0:a.length)>30)return!0;if(!d){if(isNaN(l.probability))return!0;if((l.probability||0)>1)return!0;if((l.probability||0)<0)return!0;if(v>1)return!0}if(s){if(!(null==l?void 0:l.couponCode))return!0;if(!l.description)return!0}else{if(u&&u===e.AMOUNT_OFF_ORDER){if((null==l?void 0:l.valueType)===i.FIXED_AMOUNT){if(!(null==l?void 0:l.value)||(null==l?void 0:l.value)<=0)return!0}else if(!(null==l?void 0:l.value)||(null==l?void 0:l.value)<=0||(null==l?void 0:l.value)>100)return!0;if(o===t.AMOUNT&&(!l.minAmount||(null==l?void 0:l.minAmount)<=0))return!0;if(o===t.QUANTITY&&(!(null==l?void 0:l.minQuantity)||(null==l?void 0:l.minQuantity)<=0))return!0;if(l.targetType!==n.LINE_ITEM)return!0;if(l.targetSelection!==r.ALL)return!0}else if(u&&u===e.AMOUNT_OFF_PRODUCTS){if(!(null===(p=l.entitledProductIds)||void 0===p?void 0:p.length)&&!(null===(f=l.entitledCollectionIds)||void 0===f?void 0:f.length))return!0;if((null===(c=l.entitledProductIds)||void 0===c?void 0:c.length)&&(null===(y=l.entitledCollectionIds)||void 0===y?void 0:y.length))return!0;if(!l.value)return!0;if((null==l?void 0:l.valueType)===i.FIXED_AMOUNT){if(!(null==l?void 0:l.value)||(null==l?void 0:l.value)<=0)return!0}else if(!(null==l?void 0:l.value)||(null==l?void 0:l.value)<=0||(null==l?void 0:l.value)>100)return!0;if(l.targetSelection!==r.ENTITLED)return!0;if(l.targetType!==n.LINE_ITEM)return!0}else if(u&&u===e.BUY_X_GET_Y){if(!l.entitledQuantity||l.entitledQuantity<0||!(null===(g=l.entitledProductIds)||void 0===g?void 0:g.length)&&!(null===(m=l.entitledCollectionIds)||void 0===m?void 0:m.length)||!l.prerequisiteQuantity||l.prerequisiteQuantity<0||!(null===(I=l.prerequisiteProductIds)||void 0===I?void 0:I.length)&&!(null===(A=l.prerequisiteCollectionIds)||void 0===A?void 0:A.length))return!0;if((null===(E=l.entitledProductIds)||void 0===E?void 0:E.length)&&(null===(T=l.entitledCollectionIds)||void 0===T?void 0:T.length))return!0;if((null===($=l.prerequisiteCollectionIds)||void 0===$?void 0:$.length)&&(null===(h=l.prerequisiteProductIds)||void 0===h?void 0:h.length))return!0;if(l.valueType!==i.PERCENTAGE)return!0;if(!l.value)return!0;if(l.value<=0||l.value>100)return!0;if(l.targetSelection!==r.ENTITLED)return!0;if(l.targetType!==n.LINE_ITEM)return!0}else if(u&&e.FREE_SHIPPING){if(l.valueType!==i.PERCENTAGE)return!0;if(l.targetType!==n.SHIPPING_LINE)return!0;if(100!==l.value)return!0;if(l.targetSelection!==r.ALL)return!0;if(o===t.AMOUNT&&(!l.minAmount||(null==l?void 0:l.minAmount)<=0))return!0;if(o===t.QUANTITY&&(!(null==l?void 0:l.minQuantity)||(null==l?void 0:l.minQuantity)<=0))return!0}if(null!==l.expireAfter&&void 0!==l.expireAfter&&l.expireAfter<=0)return!0;if(l.expireAt&&l.expireAt<new Date)return!0}return!1},u=(e,t,o,u)=>{var v,s,a;return(null==e?void 0:e.isStaticCoupon)&&(null==e?void 0:e.description)?e.description:e.targetType===n.LINE_ITEM&&e.targetSelection===r.ALL?`${e.valueType===i.FIXED_AMOUNT?t:""}${(null!==(v=e.value)&&void 0!==v?v:0).toString()}${e.valueType===i.PERCENTAGE?"% off":" off"} on all products\n ${e.minAmount?`| Minimum purchase of ${t}${e.minAmount}`:""} ${e.minQuantity?`| Buy ${e.minQuantity} products`:""} | One use per customer${e.expireAfter?` | Expires in ${e.expireAfter} day(s)`:e.expireAt?` | Expires at ${l.getStringFromDate(e.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():e.targetType===n.SHIPPING_LINE?`\n Free shipping on your order ${e.minAmount?`| Minimum purchase of ${t}${e.minAmount}`:""} ${e.minQuantity?`| Buy ${e.minQuantity} products`:""} | One use per customer${e.expireAfter?` | Expires in ${e.expireAfter} day(s)`:e.expireAt?` | Expires at ${l.getStringFromDate(e.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():e.targetSelection===r.ENTITLED?(null===(s=e.prerequisiteProductIds)||void 0===s?void 0:s.length)||(null===(a=e.prerequisiteCollectionIds)||void 0===a?void 0:a.length)?`${function(e,i,t){var n,r,l,o,u,v,s,a;let p=`Buy ${e.prerequisiteQuantity} item`;if((null===(n=e.prerequisiteProductIds)||void 0===n?void 0:n.length)||(null===(r=e.prerequisiteCollectionIds)||void 0===r?void 0:r.length)){const n=d(null!==(l=e.prerequisiteProductIds)&&void 0!==l?l:[],i),r=d(null!==(o=e.prerequisiteCollectionIds)&&void 0!==o?o:[],t);p+=" from a selection of ",n.length>0&&(p+=`${n.join(", ")} or `),r.length>0&&(p+=`products in ${r.join(", ")} collection or `),p=p.slice(0,-4)}if(p+=` and get ${e.entitledQuantity} item`,(null===(u=e.entitledProductIds)||void 0===u?void 0:u.length)||(null===(v=e.entitledCollectionIds)||void 0===v?void 0:v.length)){const n=d(null!==(s=e.entitledProductIds)&&void 0!==s?s:[],i),r=d(null!==(a=e.entitledCollectionIds)&&void 0!==a?a:[],t);p+=" from ",n.length>0&&(p+=`${n.join(", ")} or `),r.length>0&&(p+=`products in ${r.join(", ")} collection or `),p=p.slice(0,-4)}return p}(e,o,u)} ${100===e.value?"for free":`at ${e.value}% off`} | One use per customer${e.expireAfter?` | Expires in ${e.expireAfter} day(s)`:e.expireAt?` | Expires at ${l.getStringFromDate(e.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():`${function(e,t,n,r){var l,o,u;let v=`Get ${e.valueType===i.FIXED_AMOUNT?r:""}${(null!==(l=e.value)&&void 0!==l?l:0).toString()}${e.valueType===i.PERCENTAGE?"% off":" off"} on `;const s=d(null!==(o=e.entitledProductIds)&&void 0!==o?o:[],t),a=d(null!==(u=e.entitledCollectionIds)&&void 0!==u?u:[],n);s.length>0&&(v+=`${s.join(", ")} or `);a.length>0&&(v+=`products in ${a.join(", ")} collection or `);return v.slice(0,-4)}(e,o,u,t)} | One use per customer${e.expireAfter?` | Expires in ${e.expireAfter} day(s)`:e.expireAt?` | Expires at ${l.getStringFromDate(e.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():void 0};function d(e,i){const t=[];return i.forEach((i=>{e.find((e=>e.toString()===i.id))&&t.push(i.name)})),t}export{u as descriptionBuilder,o as validateDiscountData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{useState as i}from"react";import{CheckBox as a}from"../../checkBox/CheckBox.js";import{TitleSmall as n}from"../../TypographyStyle.js";import{Input as s}from"../../input/Input.js";const c=c=>{const{backTrackMessage:o,setBackTrackMessage:l}=c,[m
|
|
1
|
+
import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{useState as i}from"react";import{CheckBox as a}from"../../checkBox/CheckBox.js";import{TitleSmall as n}from"../../TypographyStyle.js";import{Input as s}from"../../input/Input.js";const c=c=>{const{backTrackMessage:o,setBackTrackMessage:l}=c,[p,m]=i(!!o);return e(r,{children:[e("div",Object.assign({style:{display:"flex",flexDirection:"row",marginLeft:10,marginTop:8,width:"300px",padding:"20px 0px"}},{children:[t(a,{isChecked:p,onValueChange:()=>{p&&l&&l(""),m(!p)}}),t(n,Object.assign({style:{marginLeft:8}},{children:"Prevent BackTracking"}))]})),p&&t("div",Object.assign({style:{margin:10}},{children:t(s,{type:"multiline",placeholder:"Enter your text here",labelText:"Message if user tries backtracking",onChangeText:e=>{l&&l(e)},height:"120px",maxCharLimit:1024,value:o,noErrorHint:!0,validate:e=>[!0,""]})}))]})};export{c as BackTrackComponent};
|
|
@@ -18,4 +18,5 @@ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{useRef as
|
|
|
18
18
|
overflow-y: auto;
|
|
19
19
|
background-image: ${e=>e.hideDeviceContainerInPreview&&e.channel===r.WHATSAPP?`url(${m});`:"none"};
|
|
20
20
|
display: ${e=>e.hideDeviceContainerInPreview&&e.channel===r.WHATSAPP?"flex":"initial"};
|
|
21
|
+
align-items: flex-start;
|
|
21
22
|
`,P=a=>{const{showVariableMapping:m,showOnlyContent:P,whatsappSpecificPickerMeta:x,showVariableModal:y,variableList:A,discountCode:S,setDiscountCode:W,variableListForImage:j,showSampleValues:M,fileName:T,setFileName:V}=a,I=i(),k=i(),{device:E,display_content:L,channel:$,template:D,setTemplate:F,isWhatsappCarousel:H,isProductCarouselType:_,hideDeviceContainerInPreview:O}=d();const N=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e(g,{children:[t(C,Object.assign({showOnlyContent:P,showVariableMapping:m,isWhatsappCarousel:H,hideDeviceContainerInPreview:O,channel:$},{children:"mobile"===E?t(f,{ref:k,display_content:null!=L?L:"",channel:$,template:D,showSampleValues:M}):$===r.WHATSAPP&&H?t(l,{ref:I,channel:$,template:D,showSampleValues:M,isPreview:!1,showArrows:!0}):$!==r.MESSAGE?t(u,{ref:I,channel:$,display_content:null!=L?L:"",showSampleValues:M}):t(o,{})})),(_||m)&&t(b,Object.assign({channel:$,isWhatsappCarousel:H,showVariableMapping:!0},{children:$!==r.WHATSAPP?t(w,{onFocus:$===r.EMAIL?function(e){var t,o,i;const a=null===document||void 0===document?void 0:document.getElementById("mobile"===E?"template_html_mobile":"template_html_desktop"),l=c(e+1),n=$===r.EMAIL?null===(t=null==a?void 0:a.contentWindow)||void 0===t?void 0:t.document.getElementById(l):document.getElementById(l),s=N(n),d=null==n?void 0:n.offsetLeft;"desktop"===E?s&&I.current&&(null===(o=null==a?void 0:a.contentWindow)||void 0===o||o.scrollTo(null!=d?d:0,s),h(l,p.background.warning.light,2,$,E)):s&&k.current&&(null===(i=null==a?void 0:a.contentWindow)||void 0===i||i.scrollTo(null!=d?d:0,s),h(l,p.background.warning.light,2,$,E))}:void 0,showVariableModal:y,variableList:A,discountCode:S,setDiscountCode:W}):$===r.WHATSAPP&&H?t(n,{whatsappSpecificPickerMeta:x,template:D,showVariableModal:y,variableList:A,variableListForImage:j,discountCode:S,setDiscountCode:W}):t(v,{whatsappSpecificPickerMeta:x,template:D,onTemplateChange:e=>{null==F||F(e)},showVariableModal:y,variableList:A,variableListForImage:j,discountCode:S,setDiscountCode:W,fileName:T,setFileName:V})})),$===r.WHATSAPP&&!m&&!_&&t(b,{children:t(s,Object.assign({color:p.content.secondary,style:{fontStyle:"italic"}},{children:"Click on ‘Select template’ below to use it"}))})]})};export{P as default};
|