@bikdotai/bik-component-library 0.0.375-beta.5 → 0.0.375
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/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/discount-modal/DiscountUtils.js +1 -1
- package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
- package/dist/cjs/components/discount-modal/StaticCoupon/StaticCoupon.js +1 -1
- package/dist/cjs/components/input-with-vars/InputWithVariables.d.ts +0 -1
- package/dist/cjs/components/input-with-vars/InputWithVariables.js +3 -3
- package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +0 -2
- package/dist/cjs/components/product-picker-v2/collectionScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/modal.d.ts +1 -5
- package/dist/cjs/components/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/productScreen.d.ts +0 -7
- package/dist/cjs/components/product-picker-v2/productScreen.js +1 -1
- package/dist/cjs/components/product-picker-v2/style.d.ts +0 -2
- package/dist/cjs/components/product-picker-v2/style.js +13 -13
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/discount-modal/DiscountUtils.js +1 -1
- package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
- package/dist/esm/components/discount-modal/StaticCoupon/StaticCoupon.js +1 -1
- package/dist/esm/components/input-with-vars/InputWithVariables.d.ts +0 -1
- package/dist/esm/components/input-with-vars/InputWithVariables.js +3 -3
- package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +0 -2
- package/dist/esm/components/product-picker-v2/collectionScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/modal.d.ts +1 -5
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/productScreen.d.ts +0 -7
- package/dist/esm/components/product-picker-v2/productScreen.js +1 -1
- package/dist/esm/components/product-picker-v2/style.d.ts +0 -2
- package/dist/esm/components/product-picker-v2/style.js +5 -5
- 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)>22)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"),t=require("lodash"),s=require("../../button/Button.js");require("react");var i=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var n=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("../../zeroState/ZeroState.js");var a=require("../../TypographyStyle.js"),o=require("../../../constants/Theme.js");require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../checkBox/CheckBox.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js");var r=require("../../input/Input.js"),l=require("../../../assets/icons/cross.svg.js");require("../../dropdown/MenuItem/MenuItem.js"),require("../../modals/styledModal.js"),require("../../../node_modules/lodash.debounce/index.js"),require("../../bik-layout/CommonStyles.js"),require("../../product-picker/ProductPicker.styled.js"),require("../../../utils/DateUtils.js"),require("../../tag/Tag.js"),require("@tippyjs/react"),require("../../tooltips/TooltipInternal.js"),require("../../spinner/Spinner.js"),require("../../icon-button/IconButton.js"),require("../../shimmer/ShimmerComponent/ShimmerStyled.js"),require("../../product-picker-v2/emptyState.js"),require("../../product-picker-v2/style.js"),require("../../product-picker-v2/type.js");var d=require("../DiscountModal.styled.js"),u=require("../CouponExpiration/CouponExpiration.js"),c=require("../../radioButton/RadioButton.js"),p=require("../../../assets/icons/cursor.svg.js"),T=require("../../../assets/icons/plus.svg.js");const j="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg";var D;function m(){return null}exports.DISCOUNT_PRODUCTS=void 0,(D=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",D.PREREQUISITE="prerequisite";exports.default=D=>{var v;const x=[{value:i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER},{value:i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS},{value:i.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:D.selectedCouponType===i.DISCOUNT_TYPES.BUY_X_GET_Y},{value:i.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:D.selectedCouponType===i.DISCOUNT_TYPES.FREE_SHIPPING}],E=[{selected:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.NA,label:"No minimum requirements",value:i.MIN_PURCHASE_REQUIREMENT.NA},{selected:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT,label:`Minimum purchase amount (${null!==(v=D.currency)&&void 0!==v?v:"₹"})`,value:i.MIN_PURCHASE_REQUIREMENT.AMOUNT},{selected:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.QUANTITY,label:"Minimum quantity of items",value:i.MIN_PURCHASE_REQUIREMENT.QUANTITY}],O=()=>{var e,t,s,n,a;if(D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if((null===(e=D.discountData)||void 0===e?void 0:e.value)&&(null===(t=D.discountData)||void 0===t?void 0:t.value)<=0)return"Enter a valid input"}else if((null===(s=D.discountData)||void 0===s?void 0:s.value)&&((null===(n=D.discountData)||void 0===n?void 0:n.value)<=0||(null===(a=D.discountData)||void 0===a?void 0:a.value)>100))return"Enter a valid input"},g=()=>{var t,s,o,l,d;return e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsxs("div",Object.assign({className:"input__wrapper"},{children:[e.jsx(a.BodySecondary,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),e.jsx(n.Dropdown,{options:E,placement:"bottom-start",onSelect:e=>{const t=e.value;D.setSelectedMinimumRequirement(t),D.setDiscountData(Object.assign(Object.assign({},D.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:D.selectedMinimumRequirement!==i.MIN_PURCHASE_REQUIREMENT.NA&&e.jsx(r.Input,{value:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(s=null===(t=D.discountData.minAmount)||void 0===t?void 0:t.toString())&&void 0!==s?s:"":null!==(l=null===(o=D.discountData.minQuantity)||void 0===o?void 0:o.toString())&&void 0!==l?l:"",onChangeText:e=>{D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?D.setDiscountData(Object.assign(Object.assign({},D.discountData),{minAmount:parseInt(e)})):D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.QUANTITY&&D.setDiscountData(Object.assign(Object.assign({},D.discountData),{minQuantity:parseInt(e)}))},labelText:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",prefixText:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(d=D.currency)&&void 0!==d?d:"₹":void 0,type:"number",placeholder:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?"1000.00":"2"})}))]}))},b=(i,n)=>{var d,u,c,p;let m=[],v=[],x={},E={};return D.useNewPicker?(x=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledProducts:D.prerequisiteProducts,E=null!==(d=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledCollections:D.prerequisiteCollections)&&void 0!==d?d:[],(null==x?void 0:x.isCustom)&&delete x.isCustom,(null==E?void 0:E.isCustom)&&delete E.isCustom,Object.values(x).forEach((e=>{Object.keys(e.products).forEach((t=>{m.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(E).forEach((e=>{"isCustom"!==e&&v.push({id:e,name:E[e].name,image:E[e].image})}))):(m=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledProducts:D.prerequisiteProducts,v=null!==(u=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledCollections:D.prerequisiteCollections)&&void 0!==u?u:[]),e.jsxs(e.Fragment,{children:[!n&&e.jsxs(e.Fragment,{children:[e.jsx(a.TitleRegular,{children:i===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer buys":"Customer gets"}),e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:i===exports.DISCOUNT_PRODUCTS.ENTITLED?null===(c=D.discountData.entitledQuantity)||void 0===c?void 0:c.toString():null===(p=D.discountData.prerequisiteQuantity)||void 0===p?void 0:p.toString(),type:"number",onChangeText:e=>{i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setDiscountData(Object.assign(Object.assign({},D.discountData),{entitledQuantity:parseInt(e)})):D.setDiscountData(Object.assign(Object.assign({},D.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),e.jsx("div",{className:"input__wrapper"})]}))]}),e.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[!(null==v?void 0:v.length)&&e.jsx(s.Button,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:T.default,onClick:()=>{D.setIsProductPickerOpen(i)}}),!(null==m?void 0:m.length)&&e.jsx(s.Button,{buttonText:"Add collection",buttonType:"tertiary",LeadingIcon:T.default,onClick:()=>{D.setIsCollectionPickerOpen(i)}})]})),!!m.length&&e.jsxs("div",Object.assign({style:{margin:"8px 0"}},{children:[e.jsx(a.TitleSmall,{children:"Products"}),m.map((s=>e.jsxs("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${o.DEFAULT_THEME.colorsV2.stroke.primary}`,display:"flex"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[e.jsx("img",{src:s.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),e.jsx(a.TitleSmall,{children:s.name})]})),e.jsx("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:e.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(D.useNewPicker){const e=t.cloneDeep(x);Object.values(e).forEach((e=>{var t,i;(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t[s.id])&&(null===(i=null==e?void 0:e.products)||void 0===i||delete i[s.id])})),i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledProducts(e):D.setPrerequisiteProducts(e)}else{const e=m.filter((e=>e.id!==s.id));i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledProducts(e):D.setPrerequisiteProducts(e)}}},{children:e.jsx(l.default,{width:14,color:o.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),s.id)))]})),!!v.length&&e.jsxs("div",Object.assign({style:{margin:"8px 0"}},{children:[e.jsx(a.TitleSmall,{children:"Collections"}),v.map((s=>e.jsxs("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${o.DEFAULT_THEME.colorsV2.stroke.primary}`,display:"flex"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[e.jsx("img",{src:s.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),e.jsx(a.TitleSmall,{children:s.name})]})),e.jsx("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:e.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(D.useNewPicker){const e=t.cloneDeep(E);delete e[s.id],i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledCollections(e):D.setPrerequisiteCollections(e)}else{const e=v.filter((e=>e.id!==s.id));i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledCollections(e):D.setPrerequisiteCollections(e)}}},{children:e.jsx(l.default,{width:14,color:o.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),s.id)))]}))]})};return e.jsxs(d.DynamicCouponContainer,{children:[D.allowStaticCoupon&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(n.Dropdown,{options:x,width:"338px",placement:"bottom-start",onSelect:e=>{D.onChangeCouponType(e)}})})),e.jsx("div",Object.assign({className:"input__wrapper",style:{display:"flex",alignItems:"center",gap:8}},{children:(D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER)&&e.jsxs(e.Fragment,{children:[e.jsx(c.RadioButton,{isActive:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,onValueChange:()=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{valueType:i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,value:void 0}))},label:"Fixed amount"}),e.jsx(c.RadioButton,{isActive:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.PERCENTAGE,onValueChange:()=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{valueType:i.DISCOUNT_VALUE_TYPES.PERCENTAGE,value:void 0}))},label:"Percentage"})]})}))]})),D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&(()=>{var t,s,n,a,o;return e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:null!==(n=null===(s=null===(t=D.discountData)||void 0===t?void 0:t.value)||void 0===s?void 0:s.toString())&&void 0!==n?n:"",labelText:"Discount code value",type:"number",errorMessage:O(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:parseInt(e)}))},placeholder:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(a=D.currency)&&void 0!==a?a:"₹":void 0,suffixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0})}))]})),g(),!D.hideProbability&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{type:"number",value:null===(o=D.discountData.probability)||void 0===o?void 0:o.toString(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),e.jsx("div",{className:"input__wrapper"})]}))]})})(),D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS&&(()=>{var t,s,n,a,o;return e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:null!==(n=null===(s=null===(t=D.discountData)||void 0===t?void 0:t.value)||void 0===s?void 0:s.toString())&&void 0!==n?n:"",labelText:"Discount code value",type:"number",errorMessage:O(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:parseInt(e)}))},placeholder:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(a=D.currency)&&void 0!==a?a:"₹":void 0,suffixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0})}))]})),b(exports.DISCOUNT_PRODUCTS.ENTITLED,!0),!D.hideProbability&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{type:"number",value:null===(o=D.discountData.probability)||void 0===o?void 0:o.toString(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),e.jsx("div",{className:"input__wrapper"})]}))]})})(),D.selectedCouponType===i.DISCOUNT_TYPES.FREE_SHIPPING&&(()=>{var t;return e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:18})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:!D.hideProbability&&e.jsx(r.Input,{value:null===(t=D.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]})),g()]})})(),D.selectedCouponType===i.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var t,s,i,n;return e.jsxs(d.DynamicCouponContainer,{children:[e.jsx("div",Object.assign({className:"input__rows"},{children:e.jsxs("div",Object.assign({style:{display:"flex",gap:20,flex:1}},{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),!D.hideProbability&&e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(r.Input,{value:null===(t=D.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]}))})),e.jsx(m,{}),b(exports.DISCOUNT_PRODUCTS.PREREQUISITE),e.jsx(m,{}),b(exports.DISCOUNT_PRODUCTS.ENTITLED),e.jsx(m,{}),e.jsx(a.TitleRegular,{children:"At a discount value"}),e.jsxs("div",Object.assign({style:{display:"flex",gap:18,alignItems:"flex-start"}},{children:[e.jsx(c.RadioButton,{label:"Percentage",isActive:100!==D.discountData.value,onValueChange:()=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:void 0}))}}),100!==D.discountData.value&&e.jsx(r.Input,{variant:"small",value:null!==(n=null===(i=null===(s=D.discountData)||void 0===s?void 0:s.value)||void 0===i?void 0:i.toString())&&void 0!==n?n:"",onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:parseInt(e)}))},errorMessage:O(),type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),e.jsx("div",{children:e.jsx(c.RadioButton,{label:"Free",isActive:100===D.discountData.value,onValueChange:e=>{e?D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:100})):D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:void 0}))}})})]})})(),D.selectedCouponType&&!D.hideExpiration&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:D.selectedCouponType!==i.DISCOUNT_TYPES.BUY_X_GET_Y&&D.selectedCouponType!==i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||!D.hideProbability?{height:6,borderTop:`1px solid ${o.DEFAULT_THEME.colorsV2.stroke.primary}`,marginTop:12}:{}}),e.jsx(u.CouponExpiration,{discountData:D.discountData,setDiscountData:D.setDiscountData})]}),!D.selectedCouponType&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:10,padding:"40px 0",justifyContent:"center",alignItems:"center"}},{children:[e.jsx("div",Object.assign({style:{height:52,width:52,backgroundColor:o.DEFAULT_THEME.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:e.jsx(p.default,{width:32,color:o.DEFAULT_THEME.colorsV2.content.primaryInverse})})),e.jsx(a.TitleMedium,{children:"No discount has been selected"}),e.jsx(a.BodyPrimary,{children:"Please select a discount type"})]}))]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),s=require("../../button/Button.js");require("react");var i=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var n=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("../../zeroState/ZeroState.js");var a=require("../../TypographyStyle.js"),o=require("../../../constants/Theme.js");require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../checkBox/CheckBox.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js");var r=require("../../input/Input.js"),l=require("../../../assets/icons/cross.svg.js");require("../../dropdown/MenuItem/MenuItem.js"),require("../../modals/styledModal.js"),require("../../../node_modules/lodash.debounce/index.js"),require("../../bik-layout/CommonStyles.js"),require("../../product-picker/ProductPicker.styled.js"),require("../../../utils/DateUtils.js"),require("../../tag/Tag.js"),require("@tippyjs/react"),require("../../tooltips/TooltipInternal.js"),require("../../spinner/Spinner.js"),require("../../icon-button/IconButton.js"),require("../../shimmer/ShimmerComponent/ShimmerStyled.js"),require("../../product-picker-v2/emptyState.js"),require("../../product-picker-v2/style.js"),require("../../product-picker-v2/type.js");var d=require("../DiscountModal.styled.js"),u=require("../CouponExpiration/CouponExpiration.js"),c=require("../../radioButton/RadioButton.js"),p=require("../../../assets/icons/cursor.svg.js"),T=require("../../../assets/icons/plus.svg.js");const j="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg";var D;function m(){return null}exports.DISCOUNT_PRODUCTS=void 0,(D=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",D.PREREQUISITE="prerequisite";exports.default=D=>{var v;const x=[{value:i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER},{value:i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS},{value:i.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:D.selectedCouponType===i.DISCOUNT_TYPES.BUY_X_GET_Y},{value:i.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:D.selectedCouponType===i.DISCOUNT_TYPES.FREE_SHIPPING}],E=[{selected:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.NA,label:"No minimum requirements",value:i.MIN_PURCHASE_REQUIREMENT.NA},{selected:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT,label:`Minimum purchase amount (${null!==(v=D.currency)&&void 0!==v?v:"₹"})`,value:i.MIN_PURCHASE_REQUIREMENT.AMOUNT},{selected:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.QUANTITY,label:"Minimum quantity of items",value:i.MIN_PURCHASE_REQUIREMENT.QUANTITY}],O=()=>{var e,t,s,n,a;if(D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if((null===(e=D.discountData)||void 0===e?void 0:e.value)&&(null===(t=D.discountData)||void 0===t?void 0:t.value)<=0)return"Enter a valid input"}else if((null===(s=D.discountData)||void 0===s?void 0:s.value)&&((null===(n=D.discountData)||void 0===n?void 0:n.value)<=0||(null===(a=D.discountData)||void 0===a?void 0:a.value)>100))return"Enter a valid input"},g=()=>{var t,s,o,l,d;return e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsxs("div",Object.assign({className:"input__wrapper"},{children:[e.jsx(a.BodySecondary,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),e.jsx(n.Dropdown,{options:E,placement:"bottom-start",onSelect:e=>{const t=e.value;D.setSelectedMinimumRequirement(t),D.setDiscountData(Object.assign(Object.assign({},D.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:D.selectedMinimumRequirement!==i.MIN_PURCHASE_REQUIREMENT.NA&&e.jsx(r.Input,{value:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(s=null===(t=D.discountData.minAmount)||void 0===t?void 0:t.toString())&&void 0!==s?s:"":null!==(l=null===(o=D.discountData.minQuantity)||void 0===o?void 0:o.toString())&&void 0!==l?l:"",onChangeText:e=>{D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?D.setDiscountData(Object.assign(Object.assign({},D.discountData),{minAmount:parseInt(e)})):D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.QUANTITY&&D.setDiscountData(Object.assign(Object.assign({},D.discountData),{minQuantity:parseInt(e)}))},labelText:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",prefixText:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(d=D.currency)&&void 0!==d?d:"₹":void 0,type:"number",placeholder:D.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?"1000.00":"2"})}))]}))},b=(i,n)=>{var d,u,c,p;let m=[],v=[],x={},E={};return D.useNewPicker?(x=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledProducts:D.prerequisiteProducts,E=null!==(d=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledCollections:D.prerequisiteCollections)&&void 0!==d?d:[],(null==x?void 0:x.isCustom)&&delete x.isCustom,(null==E?void 0:E.isCustom)&&delete E.isCustom,Object.values(x).forEach((e=>{Object.keys(e.products).forEach((t=>{m.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(E).forEach((e=>{"isCustom"!==e&&v.push({id:e,name:E[e].name,image:E[e].image})}))):(m=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledProducts:D.prerequisiteProducts,v=null!==(u=i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.entitledCollections:D.prerequisiteCollections)&&void 0!==u?u:[]),e.jsxs(e.Fragment,{children:[!n&&e.jsxs(e.Fragment,{children:[e.jsx(a.TitleRegular,{children:i===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer buys":"Customer gets"}),e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:i===exports.DISCOUNT_PRODUCTS.ENTITLED?null===(c=D.discountData.entitledQuantity)||void 0===c?void 0:c.toString():null===(p=D.discountData.prerequisiteQuantity)||void 0===p?void 0:p.toString(),type:"number",onChangeText:e=>{i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setDiscountData(Object.assign(Object.assign({},D.discountData),{entitledQuantity:parseInt(e)})):D.setDiscountData(Object.assign(Object.assign({},D.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),e.jsx("div",{className:"input__wrapper"})]}))]}),e.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[!(null==v?void 0:v.length)&&e.jsx(s.Button,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:T.default,onClick:()=>{D.setIsProductPickerOpen(i)}}),!(null==m?void 0:m.length)&&e.jsx(s.Button,{buttonText:"Add collection",buttonType:"tertiary",LeadingIcon:T.default,onClick:()=>{D.setIsCollectionPickerOpen(i)}})]})),!!m.length&&e.jsxs("div",Object.assign({style:{margin:"8px 0"}},{children:[e.jsx(a.TitleSmall,{children:"Products"}),m.map((s=>e.jsxs("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${o.DEFAULT_THEME.colorsV2.stroke.primary}`,display:"flex"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[e.jsx("img",{src:s.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),e.jsx(a.TitleSmall,{children:s.name})]})),e.jsx("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:e.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(D.useNewPicker){const e=t.cloneDeep(x);Object.values(e).forEach((e=>{var t,i;(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t[s.id])&&(null===(i=null==e?void 0:e.products)||void 0===i||delete i[s.id])})),i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledProducts(e):D.setPrerequisiteProducts(e)}else{const e=m.filter((e=>e.id!==s.id));i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledProducts(e):D.setPrerequisiteProducts(e)}}},{children:e.jsx(l.default,{width:14,color:o.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),s.id)))]})),!!v.length&&e.jsxs("div",Object.assign({style:{margin:"8px 0"}},{children:[e.jsx(a.TitleSmall,{children:"Collections"}),v.map((s=>e.jsxs("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${o.DEFAULT_THEME.colorsV2.stroke.primary}`,display:"flex"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[e.jsx("img",{src:s.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),e.jsx(a.TitleSmall,{children:s.name})]})),e.jsx("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:e.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(D.useNewPicker){const e=t.cloneDeep(E);delete e[s.id],i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledCollections(e):D.setPrerequisiteCollections(e)}else{const e=v.filter((e=>e.id!==s.id));i===exports.DISCOUNT_PRODUCTS.ENTITLED?D.setEntitledCollections(e):D.setPrerequisiteCollections(e)}}},{children:e.jsx(l.default,{width:14,color:o.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),s.id)))]}))]})};return e.jsxs(d.DynamicCouponContainer,{children:[D.allowStaticCoupon&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(n.Dropdown,{options:x,width:"338px",placement:"bottom-start",onSelect:e=>{D.onChangeCouponType(e)}})})),e.jsx("div",Object.assign({className:"input__wrapper",style:{display:"flex",alignItems:"center",gap:8}},{children:(D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER)&&e.jsxs(e.Fragment,{children:[e.jsx(c.RadioButton,{isActive:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,onValueChange:()=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{valueType:i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,value:void 0}))},label:"Fixed amount"}),e.jsx(c.RadioButton,{isActive:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.PERCENTAGE,onValueChange:()=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{valueType:i.DISCOUNT_VALUE_TYPES.PERCENTAGE,value:void 0}))},label:"Percentage"})]})}))]})),D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&(()=>{var t,s,n,a,o;return e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},maxCharLimit:22,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:null!==(n=null===(s=null===(t=D.discountData)||void 0===t?void 0:t.value)||void 0===s?void 0:s.toString())&&void 0!==n?n:"",labelText:"Discount code value",type:"number",errorMessage:O(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:parseInt(e)}))},placeholder:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(a=D.currency)&&void 0!==a?a:"₹":void 0,suffixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0})}))]})),g(),!D.hideProbability&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{type:"number",value:null===(o=D.discountData.probability)||void 0===o?void 0:o.toString(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),e.jsx("div",{className:"input__wrapper"})]}))]})})(),D.selectedCouponType===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS&&(()=>{var t,s,n,a,o;return e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},maxCharLimit:22,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:null!==(n=null===(s=null===(t=D.discountData)||void 0===t?void 0:t.value)||void 0===s?void 0:s.toString())&&void 0!==n?n:"",labelText:"Discount code value",type:"number",errorMessage:O(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:parseInt(e)}))},placeholder:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(a=D.currency)&&void 0!==a?a:"₹":void 0,suffixText:D.discountData.valueType===i.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0})}))]})),b(exports.DISCOUNT_PRODUCTS.ENTITLED,!0),!D.hideProbability&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{type:"number",value:null===(o=D.discountData.probability)||void 0===o?void 0:o.toString(),onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),e.jsx("div",{className:"input__wrapper"})]}))]})})(),D.selectedCouponType===i.DISCOUNT_TYPES.FREE_SHIPPING&&(()=>{var t;return e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:22})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:!D.hideProbability&&e.jsx(r.Input,{value:null===(t=D.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]})),g()]})})(),D.selectedCouponType===i.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var t,s,i,n;return e.jsxs(d.DynamicCouponContainer,{children:[e.jsx("div",Object.assign({className:"input__rows"},{children:e.jsxs("div",Object.assign({style:{display:"flex",gap:20,flex:1}},{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(r.Input,{value:D.discountData.title,onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{title:e.trim()}))},maxCharLimit:22,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),!D.hideProbability&&e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(r.Input,{value:null===(t=D.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]}))})),e.jsx(m,{}),b(exports.DISCOUNT_PRODUCTS.PREREQUISITE),e.jsx(m,{}),b(exports.DISCOUNT_PRODUCTS.ENTITLED),e.jsx(m,{}),e.jsx(a.TitleRegular,{children:"At a discount value"}),e.jsxs("div",Object.assign({style:{display:"flex",gap:18,alignItems:"flex-start"}},{children:[e.jsx(c.RadioButton,{label:"Percentage",isActive:100!==D.discountData.value,onValueChange:()=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:void 0}))}}),100!==D.discountData.value&&e.jsx(r.Input,{variant:"small",value:null!==(n=null===(i=null===(s=D.discountData)||void 0===s?void 0:s.value)||void 0===i?void 0:i.toString())&&void 0!==n?n:"",onChangeText:e=>{D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:parseInt(e)}))},errorMessage:O(),type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),e.jsx("div",{children:e.jsx(c.RadioButton,{label:"Free",isActive:100===D.discountData.value,onValueChange:e=>{e?D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:100})):D.setDiscountData(Object.assign(Object.assign({},D.discountData),{value:void 0}))}})})]})})(),D.selectedCouponType&&!D.hideExpiration&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:D.selectedCouponType!==i.DISCOUNT_TYPES.BUY_X_GET_Y&&D.selectedCouponType!==i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||!D.hideProbability?{height:6,borderTop:`1px solid ${o.DEFAULT_THEME.colorsV2.stroke.primary}`,marginTop:12}:{}}),e.jsx(u.CouponExpiration,{discountData:D.discountData,setDiscountData:D.setDiscountData})]}),!D.selectedCouponType&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:10,padding:"40px 0",justifyContent:"center",alignItems:"center"}},{children:[e.jsx("div",Object.assign({style:{height:52,width:52,backgroundColor:o.DEFAULT_THEME.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:e.jsx(p.default,{width:32,color:o.DEFAULT_THEME.colorsV2.content.primaryInverse})})),e.jsx(a.TitleMedium,{children:"No discount has been selected"}),e.jsx(a.BodyPrimary,{children:"Please select a discount type"})]}))]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../../../assets/icons/info.svg.js"),i=require("../../input/Input.js"),a=require("../../TypographyStyle.js"),s=require("../../../constants/Theme.js"),n=require("../DiscountModal.styled.js");exports.default=o=>t.jsxs(n.StaticCouponContainerStyled,{children:[t.jsxs("div",Object.assign({className:"static-coupon__data"},{children:[t.jsx("div",Object.assign({className:"static-input__wrapper"},{children:t.jsx(i.Input,{onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{couponCode:null==t?void 0:t.trim()}))},labelText:"Coupon code",value:o.discountData.couponCode,placeholder:"Enter code created on shopify"})})),t.jsx("div",Object.assign({className:"static-input__wrapper"},{children:t.jsx(i.Input,{maxCharLimit:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../../../assets/icons/info.svg.js"),i=require("../../input/Input.js"),a=require("../../TypographyStyle.js"),s=require("../../../constants/Theme.js"),n=require("../DiscountModal.styled.js");exports.default=o=>t.jsxs(n.StaticCouponContainerStyled,{children:[t.jsxs("div",Object.assign({className:"static-coupon__data"},{children:[t.jsx("div",Object.assign({className:"static-input__wrapper"},{children:t.jsx(i.Input,{onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{couponCode:null==t?void 0:t.trim()}))},labelText:"Coupon code",value:o.discountData.couponCode,placeholder:"Enter code created on shopify"})})),t.jsx("div",Object.assign({className:"static-input__wrapper"},{children:t.jsx(i.Input,{maxCharLimit:22,labelText:"Coupon title",value:o.discountData.title,onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{title:null==t?void 0:t.trim()}))},placeholder:"Enter coupon title"})}))]})),t.jsx(i.Input,{labelText:"Coupon description",value:o.discountData.description,onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{description:null==t?void 0:t.trim()}))},placeholder:"Enter coupon description"}),!o.hideProbability&&t.jsx(i.Input,{labelText:"Probability",value:o.discountData.probability?o.discountData.probability.toString():"",onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{probability:t.startsWith(".")?parseFloat(parseFloat(`0${t}`).toFixed(2)):parseFloat(parseFloat(t).toFixed(2))}))},placeholder:"Enter probability in decimals (0 - 1)"}),o.discountAdminUrl&&t.jsxs("div",Object.assign({className:"info__container"},{children:[t.jsx(e.default,{height:18,width:18,color:s.DEFAULT_THEME.colorsV2.content.secondary}),t.jsx(a.BodySecondaryLink,Object.assign({onClick:()=>{window.open(o.discountAdminUrl,"_blank")}},{children:"Click here"})),t.jsx(a.BodySecondary,{children:"to create discount code on Shopify"})]}))]});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../assets/icons/PlusIcon.js"),l=require("react"),r=require("styled-components"),i=require("uuid"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../assets/icons/PlusIcon.js"),l=require("react"),r=require("styled-components"),i=require("uuid"),t=require("../../constants/Theme.js"),s=require("../add-variableV2/AddVariableBox.styled.js"),d=require("../add-variableV2/AddVariableV2.js"),u=require("../input/Input.js"),o=require("../TypographyStyle.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const c=n(r).default.div`
|
|
2
2
|
margin-bottom: 32px;
|
|
3
3
|
input {
|
|
4
|
-
color: ${e=>e.isVar?
|
|
4
|
+
color: ${e=>e.isVar?t.COLORS.stroke.brand:"black"};
|
|
5
5
|
}
|
|
6
|
-
`;exports.InputWithVariables=r=>{
|
|
6
|
+
`;exports.InputWithVariables=r=>{const t=l.useRef(null),[n,v]=l.useState(!1),[b]=l.useState(i.v4()),[p,V]=l.useState(),[g,h]=l.useState(r.prevVariable),[j,x]=l.useState(!1),[y,T]=l.useState(!1);return l.useEffect((()=>{p&&p.actualValue&&(r.allowMix?h((e=>({actualValue:e.actualValue+p.actualValue,variableType:"string"}))):h((e=>({actualValue:p.actualValue,variableType:p.variableType,needsFetching:p.needsFetching}))))}),[p]),l.useEffect((()=>{r.onChange(g)}),[g]),e.jsxs(c,Object.assign({isVar:/^{{.*}}$/.test(g.actualValue)},{children:[e.jsx(u.Input,{id:b,ref:t,skipFocus:!0,textControl:!0,isActive:n,value:g.actualValue,validate:e=>[!0,""],errorMessage:"",placeholder:"Add a value",onChangeText:function(e,a){if(r.onlyVariables){const e=(null==a?void 0:a.keyCode)||(null==a?void 0:a.charCode);8!=e&&46!=e||h({actualValue:"",variableType:"string"})}else r.allowMix?h({actualValue:e,variableType:"string"}):h({actualValue:e.replace(/{{.*}}/,""),variableType:"string"})},onReferenceInit:()=>{},onFocus:e=>{var a;v(!0),T(!0),"Search..."!==(null===(a=e.relatedTarget)||void 0===a?void 0:a.placeholder)||j||x(!0)},onBlur:e=>{var a,l,r,i,s,d,u;"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||"varList"===(null===(l=e.relatedTarget)||void 0===l?void 0:l.id)||(null===(i=null===(r=e.relatedTarget)||void 0===r?void 0:r.className)||void 0===i?void 0:i.includes("exlualr0"))||(null===(d=null===(s=e.relatedTarget)||void 0===s?void 0:s.className)||void 0===d?void 0:d.includes("sc-dZoequ "))?(t.current&&t.current.focus(),v(!0)):"Search..."===(null===(u=e.relatedTarget)||void 0===u?void 0:u.placeholder)?v(!0):(v(!1),x(!1),T(!1))}}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"space-between"}},{children:[g.actualValue&&r.showHelp?e.jsx("div",Object.assign({style:{marginTop:4}},{children:e.jsx(o.BodyCaption,{children:`This value is of type ${g.variableType}`})})):e.jsx("div",{}),y&&e.jsx(s.AddVariableStyled,Object.assign({right:r.addVarBoxRight,id:"addVar",onClick:()=>{x(!j)}},{children:e.jsxs("div",Object.assign({className:"add"},{children:[e.jsx(a.default,{color:"white"}),e.jsx("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),j&&e.jsx(d.AddVariableV2,{data:r.variablesList,showVariable:!0,setShowVariable:()=>{x(!1)},variableValue:p,setVariableValue:V,placeholder:"",pickerSize:"large",enableVariable:!0,selectWithTypes:!0,onSearchBlur:e=>{var a,l,r,i,s,d;"varList"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||(null===(r=null===(l=e.relatedTarget)||void 0===l?void 0:l.className)||void 0===r?void 0:r.includes("exlualr0"))||(null===(s=null===(i=e.relatedTarget)||void 0===i?void 0:i.className)||void 0===s?void 0:s.includes("sc-dZoequ "))?t.current.focus():"Enter here"===(null===(d=e.relatedTarget)||void 0===d?void 0:d.placeholder)?e.relatedTarget.id!==b&&(x(!1),T(!1),v(!1)):(x(!1),T(!1),v(!1))}})]}))};
|
|
@@ -21,8 +21,6 @@ interface CollectionsScreenInterface {
|
|
|
21
21
|
setCurPage: React.Dispatch<React.SetStateAction<number>>;
|
|
22
22
|
};
|
|
23
23
|
hideCollectionCheckbox?: boolean;
|
|
24
|
-
renderCoreComponent?: boolean;
|
|
25
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
26
24
|
}
|
|
27
25
|
export declare const CollectionsScreen: (props: CollectionsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
28
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/chevronRight.svg.js"),s=require("react"),i=require("../checkBox/CheckBox.js"),o=require("../icon-button/IconButton.js"),c=require("../shimmer/ShimmerComponent/BikShimmer.js"),r=require("../tag/Tag.js"),l=require("../TypographyStyle.js"),n=require("./emptyState.js"),a=require("./style.js");const d=(e,t,s)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(s?i.slice(0,i.lastIndexOf(" ")):i)+"..."},u=s=>{const{customCollectionRestriction:c,data:n,selectedCollectionsDispatch:u,setCollectionId:h,isPartiallyChecked:C,setScreen:x,id:j,isChecked:p,isDisabled:g,hideCollectionCheckbox:m}=s;return e.jsxs(a.CollectionCardStyle,Object.assign({isDisabled:g,onClick:()=>{g||(h(j),x("products"))}},{children:[e.jsxs(a.CollectionCardInfoStyle,{children:[!m&&e.jsx(i.CheckBox,{isDisabled:g,isChecked:p,isPartiallyChecked:C,onValueChange:function(e,t,s){null==s||s.stopPropagation(),u(e?{type:"selected",data:{id:j,val:n,isRestricted:c}}:{type:"unselected",data:{id:j}}),h(e?j:"")}}),e.jsx(a.CollectionCardDetailStyle,{children:e.jsxs(a.CollectionNameHolder,{children:[e.jsx(l.TitleRegular,{children:d(n.name,40,!0)}),n.isSmartCollection?e.jsx(r.Tag,{tagText:"Smart Collection",type:"warning"}):e.jsx(e.Fragment,{})]})})]}),e.jsx(o.IconButton,{height:12,width:12,disabled:g,Icon:t.default})]}))};exports.CollectionsScreen=t=>{const{customCollectionRestriction:i,dataLoading:o,collections:r,selectedCollectionsDispatch:l,setCollectionId:a,selectedCollections:d,setScreen:h,collectionFetcher:C,collectionsDispatch:x,pagingControls:j,storeId:p,setSaveDisabled:g,hideCollectionCheckbox:m}=t,v=s.useRef(null),b=s.useRef(j.curPage),y=!!i&&(null==d?void 0:d.isCustom),[k,f]=s.useState(!1);s.useEffect((()=>{b.current=j.curPage}),[j.curPage]),s.useEffect((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&b.current>0&&(g(!0),f(!0),C(b.current,p).then((e=>{x({type:"paged",data:(null==e?void 0:e.collections)||{}}),j.setCurPage(b.current+1),f(!1),g(!1)})).catch())}),{threshold:1});return v.current&&e.observe(v.current),()=>{v.current&&e.unobserve(v.current)}}),[v]);const S=e=>{var t,s;let i=0,o=0;if(d[e]){const c=null===(t=r[e])||void 0===t?void 0:t.products;c&&Object.keys(c).forEach((e=>{var t;const s=null===(t=c[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>i+=1))}));const l=null===(s=d[e])||void 0===s?void 0:s.products;return l&&Object.keys(l).forEach((e=>{var t;const s=null===(t=l[e])||void 0===t?void 0:t.variants;s&&Object.keys(s).forEach((e=>o+=1))})),!(i<=0&&o>0)&&(o>0&&i!==o)}return!1};return e.jsxs("div",{children:[Object.keys(r).length?Object.keys(r).map((t=>e.jsx(u,{customCollectionRestriction:i,data:r[t],isDisabled:y&&!(null==d?void 0:d[t]),isChecked:!!(null==d?void 0:d[t]),isPartiallyChecked:S(t),selectedCollectionsDispatch:l,setCollectionId:a,setScreen:h,id:t,hideCollectionCheckbox:m},t))):o?[1,2,3,4,5,6,7,8,9,10].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s))):e.jsx(n.EmptyState,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),e.jsx("div",{ref:v}),k&&[1,2,3,4,5].map(((t,s)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(c.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),s)))]})},exports.truncate=d;
|
|
@@ -48,7 +48,7 @@ export interface ProductPickerInterface {
|
|
|
48
48
|
storeId: string;
|
|
49
49
|
selectedItems: SelectedItems;
|
|
50
50
|
onAdd: (items: SelectedItems, total: number) => void;
|
|
51
|
-
onClose
|
|
51
|
+
onClose: () => void;
|
|
52
52
|
visible: boolean;
|
|
53
53
|
zIndex?: number;
|
|
54
54
|
limit?: number;
|
|
@@ -61,9 +61,5 @@ export interface ProductPickerInterface {
|
|
|
61
61
|
title?: string;
|
|
62
62
|
postHeader?: React.ReactNode;
|
|
63
63
|
width?: string;
|
|
64
|
-
renderCoreComponent?: boolean;
|
|
65
|
-
onClickSave?: number;
|
|
66
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
67
|
-
hideProductVariants?: boolean;
|
|
68
64
|
}
|
|
69
65
|
export declare const ProductPickerModal: (props: ProductPickerInterface) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/search.svg.js"),o=require("react"),c=require("../../constants/Theme.js"),s=require("../button/Button.js"),r=require("../input/Input.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/search.svg.js"),o=require("react"),c=require("../../constants/Theme.js"),s=require("../button/Button.js"),r=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),n=require("../tag/Tag.js"),d=require("./collectionScreen.js"),a=require("./productScreen.js"),u=require("./reducers.js"),h=require("./searchScreen.js"),p=require("./selectedScreen.js"),C=require("./style.js"),j=require("./type.js");exports.ProductPickerModal=S=>{const{storeId:x,selectedItems:g,onClose:b,visible:v,zIndex:y,limit:m,hideCollectionCheckbox:f,hideProductCheckbox:O,outOfStockAction:P=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:I,selectProductsFromCustomCollection:k,hideSelectionCount:q,title:T,width:F}=S,[E,R]=o.useReducer(u.collectionsReducer,{}),[D,w]=o.useState("collections"),[B,A]=o.useState(""),[L,_]=o.useState(0),[M,z]=o.useState(!1),[G,H]=o.useState(0),[$,K]=o.useState(""),[U,V]=o.useState(!1),[N,Y]=o.useState(!1),[J,Q]=o.useState(),[W,X]=o.useReducer(u.selectedColectionsReducer,Object.keys(g).length>0?g:{});o.useEffect((()=>{z(!0),Y(!0),S.collectionFetcher(L,x).then((e=>{R({type:"fetched",data:(null==e?void 0:e.collections)||{}}),z(!1),_((e=>e+1)),Y(!1)})).catch()}),[]),o.useEffect((()=>{let e=0;Object.keys(W||[]).forEach((t=>{var o;Object.keys((null===(o=W[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=W[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),H(e)})),o.useEffect((()=>{var e;B&&!(null===(e=null==E?void 0:E[B])||void 0===e?void 0:e.products)&&(z(!0),S.productFetcher(B,x).then((e=>{Object.keys(e).length&&R({type:"productsFetched",data:{collectionId:B,products:e}}),z(!1)})).catch())}),[B]),o.useEffect((()=>{const e=setTimeout((()=>{$.length?(V(!0),S.searchFetcher(x,$).then((e=>{Q(Object.assign({},e)),w("searchProducts"),z(!1),V(!1)}))):w("collections")}),800);return()=>clearTimeout(e)}),[$]);const Z=()=>{X({type:"reset",data:{}})};return e.jsx(l.StyledModal,Object.assign({zIndex:y,open:v,onClose:()=>{b(),Z()},headingTitle:T||("collections"===D||"products"===D?"Select Products":"view"===D?"Selected Products":"searchProducts"===D?"Searched Products":void 0),footerShadow:!0,centralContainerStyles:{width:F||"480px"},primaryButton:{buttonText:M?"Loading...":"Add",disabled:M||G<1||m&&G>m||!1,onClick:()=>{S.onAdd(W,G),Z()}},footerLeftCustomElement:q?e.jsx(e.Fragment,{}):m&&G>m?e.jsx(n.Tag,{tagText:`You can only select ${m} products`,type:"negative"}):G>0?e.jsx(s.Button,{onClick:()=>{w("view")},buttonText:`${G} products selected`,buttonType:"tertiaryGray"}):e.jsx(s.Button,{disabled:!0,buttonText:`${G} products selected`,buttonType:"tertiaryGray"})},{children:e.jsxs(C.ContainerStyle,{children:[S.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:S.postHeader})),!S.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===D||"searchProducts"===D)&&e.jsx("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(r.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>U?e.jsx(i.Spinner,{size:"small",color:c.COLORS.content.primary}):e.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:$,onChangeText:e=>{e.length&&e.trim().length?K(e):K("")}})}))}),e.jsxs(C.ScrollContainerStyle,{children:["collections"===D&&e.jsx(d.CollectionsScreen,{customCollectionRestriction:S.customCollectionRestriction,dataLoading:N,collections:E,selectedCollectionsDispatch:X,setCollectionId:A,setScreen:w,selectedCollections:W,collectionFetcher:S.collectionFetcher,storeId:x,collectionsDispatch:R,setSaveDisabled:z,pagingControls:{curPage:L,setCurPage:_},hideCollectionCheckbox:f}),"products"===D&&B&&e.jsx(u.CollectionIdContext.Provider,Object.assign({value:B},{children:e.jsx(a.ProductsScreen,{hideInCollectionSearch:S.hideInCollectionSearch,customCollectionRestriction:S.customCollectionRestriction,productFetcher:S.productFetcher,setScreen:w,storeId:x,data:E[B],collectionsDispatch:R,selectedCollectionsDispatch:X,selectedData:W,setSaveDisabled:z,searchInCollectionFetcher:S.searchInCollectionFetcher,hideProductCheckbox:O,outOfStockAction:P,hideVariantCheckbox:I,selectProductsFromCustomCollection:k})})),"view"===D&&e.jsx(p.SelectedScreen,{selectedCollections:W||{},selectedCollectionsDispatch:X,setScreen:w,collections:E}),"searchProducts"===D&&e.jsx(h.SearchScreen,{customCollectionRestriction:S.customCollectionRestriction,selectedCollections:W||{},searchedCollections:J||{},selectedCollectionsDispatch:X,setScreen:w,collections:E,onBackPress:()=>{K(""),Q({})}})]})]})}))};
|
|
@@ -18,9 +18,6 @@ interface ProductsScreenInterface {
|
|
|
18
18
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
19
19
|
hideVariantCheckbox?: boolean;
|
|
20
20
|
selectProductsFromCustomCollection?: boolean;
|
|
21
|
-
renderCoreComponent?: boolean;
|
|
22
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
23
|
-
hideProductVariants?: boolean;
|
|
24
21
|
}
|
|
25
22
|
export declare const ProductsScreen: (props: ProductsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
26
23
|
interface ProductGroupInterface {
|
|
@@ -35,8 +32,6 @@ interface ProductGroupInterface {
|
|
|
35
32
|
hideProductCheckbox?: boolean;
|
|
36
33
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
37
34
|
hideVariantCheckbox?: boolean;
|
|
38
|
-
hideProductVariants?: boolean;
|
|
39
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
40
35
|
}
|
|
41
36
|
export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
|
|
42
37
|
interface ProductCardInterface {
|
|
@@ -53,8 +48,6 @@ interface ProductCardInterface {
|
|
|
53
48
|
hideProductCheckbox?: boolean;
|
|
54
49
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
55
50
|
hideVariantCheckbox?: boolean;
|
|
56
|
-
hideProductVariants?: boolean;
|
|
57
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
58
51
|
}
|
|
59
52
|
export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
|
|
60
53
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/arrow_left.svg.js"),i=require("../../assets/icons/box.svg.js"),o=require("../../assets/icons/search.svg.js"),c=require("lodash"),s=require("react"),r=require("../tag/Tag.js"),d=require("../../constants/Theme.js"),l=require("../checkBox/CheckBox.js"),n=require("../icon-button/IconButton.js"),a=require("../input/Input.js"),u=require("../shimmer/ShimmerComponent/BikShimmer.js"),h=require("../shimmer-image/ShimmerImage.js"),p=require("../spinner/Spinner.js"),v=require("../TypographyStyle.js"),j=require("./collectionScreen.js"),x=require("./emptyState.js"),y=require("./helpers/ProductHelper.js"),g=require("./reducers.js"),C=require("./style.js"),m=require("./type.js"),b=require("./utility.js");const k=t=>{const{collectionId:i,productId:o,data:c,selectedData:s,selectedCollectionsDispatch:r,viewOnly:d,upliftAdditions:l,isProductPartiallyChecked:n,hideProductCheckbox:a,outOfStockAction:u,hideVariantCheckbox:h}=t,p=e=>{var t,c,r,d,l,n;if(!(null===(c=null===(t=null==s?void 0:s[i])||void 0===t?void 0:t.products)||void 0===c?void 0:c[o]))return!1;return!!(null===(n=null===(l=null===(d=null===(r=null==s?void 0:s[i])||void 0===r?void 0:r.products)||void 0===d?void 0:d[o])||void 0===l?void 0:l.variants)||void 0===n?void 0:n[e])};return e.jsxs("div",{children:[e.jsx(O,{isVariant:!1,data:c,productId:o,collectionId:i,isSelected:!!(null===(j=null===(v=null==s?void 0:s[i])||void 0===v?void 0:v.products)||void 0===j?void 0:j[o]),isPartiallyChecked:n,selectedCollectionsDispatch:r,upliftAdditions:l,viewOnly:d,hideProductCheckbox:a,hideVariantCheckbox:h},o),Object.keys(c.variants||[]).map((t=>e.jsx(O,{isVariant:!0,hideVariantCheckbox:h,data:c.variants[t],variantId:t,productId:o,viewOnly:d,upliftAdditions:l,collectionId:i,isSelected:p(t),selectedCollectionsDispatch:r,outOfStockAction:u},t)))]});var v,j},O=t=>{const{isVariant:i,data:o,productId:c,collectionId:s,variantId:d,isSelected:n,selectedCollectionsDispatch:a,viewOnly:u,upliftAdditions:p,isPartiallyChecked:x,hideProductCheckbox:g,outOfStockAction:m,hideVariantCheckbox:b}=t,k=y.ProductHelper.getProductLabels(o,m);return e.jsxs(C.ProductCardStyle,Object.assign({isVariant:i},{children:[i&&!u&&!b||!i&&!u&&!g?e.jsx(l.CheckBox,{isChecked:n,isPartiallyChecked:x||!1,onValueChange:function(e){i?e?p("variantSelected",{productId:c,variantId:d,collectionId:s,variant:o}):a({type:"variantUnselected",data:{productId:c,variantId:d,collectionId:s}}):e?p("productSelected",{productId:c,collectionId:s,product:o}):a({type:"productUnselected",data:{productId:c,collectionId:s}})}}):e.jsx(e.Fragment,{}),e.jsx("div",{children:e.jsx(h.ShimmerImage,{width:40,height:40,imageUrl:o.image,alt:"Item",borderRadius:4})}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e.jsx(v.TitleRegular,{children:j.truncate(o.name,40,!0)}),k?e.jsx("div",Object.assign({style:{width:90,display:"flex"}},{children:e.jsx(r.Tag,{tagText:k,type:"warning",theme:"light"})})):e.jsx(e.Fragment,{})]}))]}))};exports.ProductCard=O,exports.ProductGroup=k,exports.ProductsScreen=r=>{const h=s.useContext(g.CollectionIdContext),{data:j,collectionsDispatch:y,selectedData:O,selectedCollectionsDispatch:f,productFetcher:I,storeId:S,setScreen:P,setSaveDisabled:q,hideInCollectionSearch:E,customCollectionRestriction:T,hideProductCheckbox:w,outOfStockAction:D=m.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:A=!1,selectProductsFromCustomCollection:B=!1}=r,[V,R]=s.useState(""),[F,U]=s.useState(!1),[_,H]=s.useState(j);s.useEffect((()=>{const e=setTimeout((()=>{V.length?(U(!0),r.searchInCollectionFetcher(S,h,V).then((e=>{var t;const i=c.cloneDeep(j);i.products={};for(const o of e)(null===(t=null==j?void 0:j.products)||void 0===t?void 0:t[o])&&(i.products[o]=j.products[o]);H(i),q(!1),U(!1)}))):H(j)}),800);return()=>clearTimeout(e)}),[V]);const L=!!T&&j.isSmartCollection,K=e=>{var t,i,o,c,s,r,d,l;let n=0,a=0;return!!((null===(i=null===(t=null==O?void 0:O[h])||void 0===t?void 0:t.products)||void 0===i?void 0:i[e])&&(null===(s=Object.keys((null===(c=null===(o=null==j?void 0:j.products)||void 0===o?void 0:o[e])||void 0===c?void 0:c.variants)||[]))||void 0===s||s.forEach((()=>a++)),Object.keys((null===(l=null===(d=null===(r=null==O?void 0:O[h])||void 0===r?void 0:r.products)||void 0===d?void 0:d[e])||void 0===l?void 0:l.variants)||[]).forEach((()=>n++)),n>0&&a!==n))};s.useEffect((()=>{(null==j?void 0:j.products)||N()}),[]);const N=()=>{q(!0),U(!0),I(h,S).then((e=>{Object.keys(e).length&&(y({type:"productsFetched",data:{collectionId:h,products:e}}),H(Object.assign(Object.assign({},_),{products:e}))),q(!1),U(!1)})).catch()},W=(e,t)=>{const i=b.liftTheStateUp(t,j);f({type:e,data:Object.assign(Object.assign({},i),{isRestricted:T})})};return e.jsxs("div",{children:[e.jsxs(C.ProductScreenHeader,{children:[e.jsx(n.IconButton,{Icon:t.default,height:16,onClick:()=>{P("collections")}}),e.jsx(v.BodyCaption,Object.assign({style:{color:d.COLORS.content.secondary}},{children:j.name}))]}),!E&&e.jsx("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>F&&V.length?e.jsx(p.Spinner,{size:"small",color:d.COLORS.content.primary}):e.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:V,onChangeText:e=>{e.length&&e.trim().length?R(e):R("")},placeholder:"Search products in this collection..."})})),e.jsxs("div",{children:[Object.keys((null==_?void 0:_.products)||[]).length>0&&!L&&!V.length&&!w&&e.jsxs(C.ProductScreenCollectionCardStyle,{children:[e.jsx(l.CheckBox,{isChecked:!!(null==O?void 0:O[h]),isPartiallyChecked:(e=>{var t;let i=0,o=0;if(O[e]){const c=null==j?void 0:j.products;c&&Object.keys(c).forEach((e=>{var t;const o=null===(t=c[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const s=null===(t=O[e])||void 0===t?void 0:t.products;return s&&Object.keys(s).forEach((e=>{var t;const i=null===(t=s[e])||void 0===t?void 0:t.variants;i&&Object.keys(i).forEach((()=>o+=1))})),o>0&&i!==o}return!1})(h),onValueChange:function(e){f(e?{type:"selected",data:{id:h,val:j}}:{type:"unselected",data:{id:h}})}}),e.jsx("div",Object.assign({style:{width:40,height:40}},{children:e.jsx(i.default,{})})),e.jsx(v.TitleRegular,{children:"All Products"})]}),Object.keys((null==_?void 0:_.products)||[]).length?Object.keys(_.products||[]).map((t=>e.jsx(k,{outOfStockAction:D,collectionId:h,isProductPartiallyChecked:K(t),productId:t,data:_.products[t],selectedData:O,selectedCollectionsDispatch:f,viewOnly:!B&&!!L,upliftAdditions:W,hideProductCheckbox:w,hideVariantCheckbox:A},t))):F?[1,2,3,4,5,6,7,8,9,10].map(((t,i)=>e.jsx("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(u.BikShimmer,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),i))):e.jsx(x.EmptyState,{title:"No products to show",subtitle:V.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})};
|
|
@@ -2,7 +2,6 @@ export declare const ContainerStyle: import("styled-components").StyledComponent
|
|
|
2
2
|
export declare const ScrollContainerStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export declare const CollectionCardStyle: import("styled-components").StyledComponent<"div", any, {
|
|
4
4
|
isDisabled: boolean;
|
|
5
|
-
isActive: boolean;
|
|
6
5
|
}, never>;
|
|
7
6
|
export declare const CollectionCardInfoStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
7
|
export declare const CollectionCardDetailStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -10,7 +9,6 @@ export declare const ProductScreenHeader: import("styled-components").StyledComp
|
|
|
10
9
|
export declare const ProductScreenCollectionCardStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
10
|
export declare const ProductCardStyle: import("styled-components").StyledComponent<"div", any, {
|
|
12
11
|
isVariant: boolean;
|
|
13
|
-
isActive: boolean;
|
|
14
12
|
}, never>;
|
|
15
13
|
export declare const SelectedScreenHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
14
|
export declare const CollectionNameHolder: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(e);const l=i.default.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
background-color: white;
|
|
4
4
|
max-height: 600px;
|
|
5
5
|
min-height: 600px;
|
|
6
6
|
flex-direction: column;
|
|
7
|
-
`,r=
|
|
7
|
+
`,r=i.default.div`
|
|
8
8
|
overflow-y: scroll;
|
|
9
9
|
overflow-x: hidden;
|
|
10
|
-
`,n=
|
|
10
|
+
`,n=i.default.div`
|
|
11
11
|
height: 64px;
|
|
12
|
-
background-color: ${e=>e.isDisabled?"#F0F0F0":
|
|
12
|
+
background-color: ${e=>e.isDisabled?"#F0F0F0":"white"};
|
|
13
13
|
border-bottom: 1px solid #e0e0e0;
|
|
14
14
|
padding: 12px 24px;
|
|
15
15
|
display: flex;
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
column-gap: 16px;
|
|
18
18
|
justify-content: space-between;
|
|
19
19
|
align-items: center;
|
|
20
|
-
`,d=
|
|
20
|
+
`,d=i.default.div`
|
|
21
21
|
display: flex;
|
|
22
22
|
flex-direction: row;
|
|
23
23
|
justify-content: center;
|
|
24
24
|
align-items: center;
|
|
25
25
|
column-gap: 18px;
|
|
26
|
-
`,a=
|
|
26
|
+
`,a=i.default.div`
|
|
27
27
|
display: flex;
|
|
28
28
|
flex-direction: column;
|
|
29
29
|
justify-content: center;
|
|
30
|
-
`,c=
|
|
30
|
+
`,c=i.default.div`
|
|
31
31
|
display: flex;
|
|
32
32
|
flex-direction: row;
|
|
33
33
|
max-height: 32px;
|
|
@@ -37,16 +37,16 @@
|
|
|
37
37
|
align-items: center;
|
|
38
38
|
padding: 8px 16px;
|
|
39
39
|
margin-top: 16px;
|
|
40
|
-
`,
|
|
40
|
+
`,x=i.default.div`
|
|
41
41
|
display: flex;
|
|
42
42
|
flex-direction: row;
|
|
43
43
|
column-gap: 16px;
|
|
44
44
|
padding: 12px 16px;
|
|
45
45
|
border-bottom: 1px solid #e0e0e0;
|
|
46
46
|
align-items: center;
|
|
47
|
-
`,
|
|
47
|
+
`,p=i.default.div`
|
|
48
48
|
height: 64px;
|
|
49
|
-
background-color:
|
|
49
|
+
background-color: white;
|
|
50
50
|
border-bottom: 1px solid #e0e0e0;
|
|
51
51
|
padding: 12px 16px;
|
|
52
52
|
display: flex;
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
justify-content: flex-start;
|
|
56
56
|
align-items: center;
|
|
57
57
|
padding-left: ${e=>e.isVariant?"42px":"16px"};
|
|
58
|
-
`,s=
|
|
58
|
+
`,s=i.default.div`
|
|
59
59
|
display: flex;
|
|
60
60
|
flex-direction: row;
|
|
61
61
|
max-height: 32px;
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
justify-content: flex-start;
|
|
65
65
|
align-items: center;
|
|
66
66
|
padding: 8px 16px;
|
|
67
|
-
`,f=
|
|
67
|
+
`,f=i.default.div`
|
|
68
68
|
display: flex;
|
|
69
69
|
flex-direction: column;
|
|
70
|
-
`;exports.CollectionCardDetailStyle=a,exports.CollectionCardInfoStyle=d,exports.CollectionCardStyle=n,exports.CollectionNameHolder=f,exports.ContainerStyle=l,exports.ProductCardStyle=
|
|
70
|
+
`;exports.CollectionCardDetailStyle=a,exports.CollectionCardInfoStyle=d,exports.CollectionCardStyle=n,exports.CollectionNameHolder=f,exports.ContainerStyle=l,exports.ProductCardStyle=p,exports.ProductScreenCollectionCardStyle=x,exports.ProductScreenHeader=c,exports.ScrollContainerStyle=r,exports.SelectedScreenHeader=s;
|
|
@@ -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)>22)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,jsx as t,Fragment as i}from"react/jsx-runtime";import{cloneDeep as s}from"lodash";import{Button as n}from"../../button/Button.js";import"react";import{DISCOUNT_TYPES as a,MIN_PURCHASE_REQUIREMENT as o,DISCOUNT_VALUE_TYPES as l}from"../type.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as r}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"../../zeroState/ZeroState.js";import{TitleRegular as d,TitleSmall as c,TitleMedium as u,BodyPrimary as p,BodySecondary as m}from"../../TypographyStyle.js";import{DEFAULT_THEME as v}from"../../../constants/Theme.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../checkBox/CheckBox.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import{Input as b}from"../../input/Input.js";import g from"../../../assets/icons/cross.svg.js";import"../../dropdown/MenuItem/MenuItem.js";import"../../modals/styledModal.js";import"../../../node_modules/lodash.debounce/index.js";import"../../bik-layout/CommonStyles.js";import"../../product-picker/ProductPicker.styled.js";import"../../../utils/DateUtils.js";import"../../tag/Tag.js";import"@tippyjs/react";import"../../tooltips/TooltipInternal.js";import"../../spinner/Spinner.js";import"../../icon-button/IconButton.js";import"../../shimmer/ShimmerComponent/ShimmerStyled.js";import"../../product-picker-v2/emptyState.js";import"../../product-picker-v2/style.js";import"../../product-picker-v2/type.js";import{DynamicCouponContainer as D}from"../DiscountModal.styled.js";import{CouponExpiration as h}from"../CouponExpiration/CouponExpiration.js";import{RadioButton as y}from"../../radioButton/RadioButton.js";import O from"../../../assets/icons/cursor.svg.js";import T from"../../../assets/icons/plus.svg.js";const j="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg";var x;function E(){return null}!function(e){e.ENTITLED="entitled",e.PREREQUISITE="prerequisite"}(x||(x={}));const _=_=>{var C;const f=[{value:a.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:_.selectedCouponType===a.AMOUNT_OFF_ORDER},{value:a.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:_.selectedCouponType===a.AMOUNT_OFF_PRODUCTS},{value:a.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:_.selectedCouponType===a.BUY_X_GET_Y},{value:a.FREE_SHIPPING,label:"Free shipping",selected:_.selectedCouponType===a.FREE_SHIPPING}],N=[{selected:_.selectedMinimumRequirement===o.NA,label:"No minimum requirements",value:o.NA},{selected:_.selectedMinimumRequirement===o.AMOUNT,label:`Minimum purchase amount (${null!==(C=_.currency)&&void 0!==C?C:"₹"})`,value:o.AMOUNT},{selected:_.selectedMinimumRequirement===o.QUANTITY,label:"Minimum quantity of items",value:o.QUANTITY}],F=()=>{var e,t,i,s,n;if(_.discountData.valueType===l.FIXED_AMOUNT){if((null===(e=_.discountData)||void 0===e?void 0:e.value)&&(null===(t=_.discountData)||void 0===t?void 0:t.value)<=0)return"Enter a valid input"}else if((null===(i=_.discountData)||void 0===i?void 0:i.value)&&((null===(s=_.discountData)||void 0===s?void 0:s.value)<=0||(null===(n=_.discountData)||void 0===n?void 0:n.value)>100))return"Enter a valid input"},I=()=>{var i,s,n,a,l;return e("div",Object.assign({className:"input__rows"},{children:[e("div",Object.assign({className:"input__wrapper"},{children:[t(m,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),t(r,{options:N,placement:"bottom-start",onSelect:e=>{const t=e.value;_.setSelectedMinimumRequirement(t),_.setDiscountData(Object.assign(Object.assign({},_.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),t("div",Object.assign({className:"input__wrapper"},{children:_.selectedMinimumRequirement!==o.NA&&t(b,{value:_.selectedMinimumRequirement===o.AMOUNT?null!==(s=null===(i=_.discountData.minAmount)||void 0===i?void 0:i.toString())&&void 0!==s?s:"":null!==(a=null===(n=_.discountData.minQuantity)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",onChangeText:e=>{_.selectedMinimumRequirement===o.AMOUNT?_.setDiscountData(Object.assign(Object.assign({},_.discountData),{minAmount:parseInt(e)})):_.selectedMinimumRequirement===o.QUANTITY&&_.setDiscountData(Object.assign(Object.assign({},_.discountData),{minQuantity:parseInt(e)}))},labelText:_.selectedMinimumRequirement===o.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",prefixText:_.selectedMinimumRequirement===o.AMOUNT?null!==(l=_.currency)&&void 0!==l?l:"₹":void 0,type:"number",placeholder:_.selectedMinimumRequirement===o.AMOUNT?"1000.00":"2"})}))]}))},w=(a,o)=>{var l,r,u,p;let m=[],D=[],h={},y={};return _.useNewPicker?(h=a===x.ENTITLED?_.entitledProducts:_.prerequisiteProducts,y=null!==(l=a===x.ENTITLED?_.entitledCollections:_.prerequisiteCollections)&&void 0!==l?l:[],(null==h?void 0:h.isCustom)&&delete h.isCustom,(null==y?void 0:y.isCustom)&&delete y.isCustom,Object.values(h).forEach((e=>{Object.keys(e.products).forEach((t=>{m.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(y).forEach((e=>{"isCustom"!==e&&D.push({id:e,name:y[e].name,image:y[e].image})}))):(m=a===x.ENTITLED?_.entitledProducts:_.prerequisiteProducts,D=null!==(r=a===x.ENTITLED?_.entitledCollections:_.prerequisiteCollections)&&void 0!==r?r:[]),e(i,{children:[!o&&e(i,{children:[t(d,{children:a===x.PREREQUISITE?"Customer buys":"Customer gets"}),e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:a===x.ENTITLED?null===(u=_.discountData.entitledQuantity)||void 0===u?void 0:u.toString():null===(p=_.discountData.prerequisiteQuantity)||void 0===p?void 0:p.toString(),type:"number",onChangeText:e=>{a===x.ENTITLED?_.setDiscountData(Object.assign(Object.assign({},_.discountData),{entitledQuantity:parseInt(e)})):_.setDiscountData(Object.assign(Object.assign({},_.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),t("div",{className:"input__wrapper"})]}))]}),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[!(null==D?void 0:D.length)&&t(n,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:T,onClick:()=>{_.setIsProductPickerOpen(a)}}),!(null==m?void 0:m.length)&&t(n,{buttonText:"Add collection",buttonType:"tertiary",LeadingIcon:T,onClick:()=>{_.setIsCollectionPickerOpen(a)}})]})),!!m.length&&e("div",Object.assign({style:{margin:"8px 0"}},{children:[t(c,{children:"Products"}),m.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${v.colorsV2.stroke.primary}`,display:"flex"}},{children:[e("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[t("img",{src:i.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),t(c,{children:i.name})]})),t("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:t("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(_.useNewPicker){const e=s(h);Object.values(e).forEach((e=>{var t,s;(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t[i.id])&&(null===(s=null==e?void 0:e.products)||void 0===s||delete s[i.id])})),a===x.ENTITLED?_.setEntitledProducts(e):_.setPrerequisiteProducts(e)}else{const e=m.filter((e=>e.id!==i.id));a===x.ENTITLED?_.setEntitledProducts(e):_.setPrerequisiteProducts(e)}}},{children:t(g,{width:14,color:v.colorsV2.content.primary})}))}))]}),i.id)))]})),!!D.length&&e("div",Object.assign({style:{margin:"8px 0"}},{children:[t(c,{children:"Collections"}),D.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${v.colorsV2.stroke.primary}`,display:"flex"}},{children:[e("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[t("img",{src:i.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),t(c,{children:i.name})]})),t("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:t("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(_.useNewPicker){const e=s(y);delete e[i.id],a===x.ENTITLED?_.setEntitledCollections(e):_.setPrerequisiteCollections(e)}else{const e=D.filter((e=>e.id!==i.id));a===x.ENTITLED?_.setEntitledCollections(e):_.setPrerequisiteCollections(e)}}},{children:t(g,{width:14,color:v.colorsV2.content.primary})}))}))]}),i.id)))]}))]})};return e(D,{children:[_.allowStaticCoupon&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(r,{options:f,width:"338px",placement:"bottom-start",onSelect:e=>{_.onChangeCouponType(e)}})})),t("div",Object.assign({className:"input__wrapper",style:{display:"flex",alignItems:"center",gap:8}},{children:(_.selectedCouponType===a.AMOUNT_OFF_PRODUCTS||_.selectedCouponType===a.AMOUNT_OFF_ORDER)&&e(i,{children:[t(y,{isActive:_.discountData.valueType===l.FIXED_AMOUNT,onValueChange:()=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{valueType:l.FIXED_AMOUNT,value:void 0}))},label:"Fixed amount"}),t(y,{isActive:_.discountData.valueType===l.PERCENTAGE,onValueChange:()=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{valueType:l.PERCENTAGE,value:void 0}))},label:"Percentage"})]})}))]})),_.selectedCouponType===a.AMOUNT_OFF_ORDER&&(()=>{var s,n,a,o,r;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:null!==(a=null===(n=null===(s=_.discountData)||void 0===s?void 0:s.value)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",labelText:"Discount code value",type:"number",errorMessage:F(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:parseInt(e)}))},placeholder:_.discountData.valueType===l.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:_.discountData.valueType===l.FIXED_AMOUNT?null!==(o=_.currency)&&void 0!==o?o:"₹":void 0,suffixText:_.discountData.valueType===l.PERCENTAGE?"%":void 0})}))]})),I(),!_.hideProbability&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{type:"number",value:null===(r=_.discountData.probability)||void 0===r?void 0:r.toString(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),t("div",{className:"input__wrapper"})]}))]})})(),_.selectedCouponType===a.AMOUNT_OFF_PRODUCTS&&(()=>{var s,n,a,o,r;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:null!==(a=null===(n=null===(s=_.discountData)||void 0===s?void 0:s.value)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",labelText:"Discount code value",type:"number",errorMessage:F(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:parseInt(e)}))},placeholder:_.discountData.valueType===l.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:_.discountData.valueType===l.FIXED_AMOUNT?null!==(o=_.currency)&&void 0!==o?o:"₹":void 0,suffixText:_.discountData.valueType===l.PERCENTAGE?"%":void 0})}))]})),w(x.ENTITLED,!0),!_.hideProbability&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{type:"number",value:null===(r=_.discountData.probability)||void 0===r?void 0:r.toString(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),t("div",{className:"input__wrapper"})]}))]})})(),_.selectedCouponType===a.FREE_SHIPPING&&(()=>{var s;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:18})})),t("div",Object.assign({className:"input__wrapper"},{children:!_.hideProbability&&t(b,{value:null===(s=_.discountData.probability)||void 0===s?void 0:s.toString(),type:"number",onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]})),I()]})})(),_.selectedCouponType===a.BUY_X_GET_Y&&(()=>{var i,s,n,a;return e(D,{children:[t("div",Object.assign({className:"input__rows"},{children:e("div",Object.assign({style:{display:"flex",gap:20,flex:1}},{children:[t("div",Object.assign({style:{flex:1}},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),!_.hideProbability&&t("div",Object.assign({style:{flex:1}},{children:t(b,{value:null===(i=_.discountData.probability)||void 0===i?void 0:i.toString(),type:"number",onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]}))})),t(E,{}),w(x.PREREQUISITE),t(E,{}),w(x.ENTITLED),t(E,{}),t(d,{children:"At a discount value"}),e("div",Object.assign({style:{display:"flex",gap:18,alignItems:"flex-start"}},{children:[t(y,{label:"Percentage",isActive:100!==_.discountData.value,onValueChange:()=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:void 0}))}}),100!==_.discountData.value&&t(b,{variant:"small",value:null!==(a=null===(n=null===(s=_.discountData)||void 0===s?void 0:s.value)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:parseInt(e)}))},errorMessage:F(),type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),t("div",{children:t(y,{label:"Free",isActive:100===_.discountData.value,onValueChange:e=>{e?_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:100})):_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:void 0}))}})})]})})(),_.selectedCouponType&&!_.hideExpiration&&e(i,{children:[t("div",{style:_.selectedCouponType!==a.BUY_X_GET_Y&&_.selectedCouponType!==a.AMOUNT_OFF_PRODUCTS||!_.hideProbability?{height:6,borderTop:`1px solid ${v.colorsV2.stroke.primary}`,marginTop:12}:{}}),t(h,{discountData:_.discountData,setDiscountData:_.setDiscountData})]}),!_.selectedCouponType&&e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:10,padding:"40px 0",justifyContent:"center",alignItems:"center"}},{children:[t("div",Object.assign({style:{height:52,width:52,backgroundColor:v.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:t(O,{width:32,color:v.colorsV2.content.primaryInverse})})),t(u,{children:"No discount has been selected"}),t(p,{children:"Please select a discount type"})]}))]})};export{x as DISCOUNT_PRODUCTS,_ as default};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{cloneDeep as s}from"lodash";import{Button as n}from"../../button/Button.js";import"react";import{DISCOUNT_TYPES as a,MIN_PURCHASE_REQUIREMENT as o,DISCOUNT_VALUE_TYPES as l}from"../type.js";import"../../dropdown/DropdownPopover/index.js";import{Dropdown as r}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"../../zeroState/ZeroState.js";import{TitleRegular as d,TitleSmall as c,TitleMedium as u,BodyPrimary as p,BodySecondary as m}from"../../TypographyStyle.js";import{DEFAULT_THEME as v}from"../../../constants/Theme.js";import"../../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../../checkBox/CheckBox.styled.js";import"../../list-item/ListItem.js";import"../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import{Input as b}from"../../input/Input.js";import g from"../../../assets/icons/cross.svg.js";import"../../dropdown/MenuItem/MenuItem.js";import"../../modals/styledModal.js";import"../../../node_modules/lodash.debounce/index.js";import"../../bik-layout/CommonStyles.js";import"../../product-picker/ProductPicker.styled.js";import"../../../utils/DateUtils.js";import"../../tag/Tag.js";import"@tippyjs/react";import"../../tooltips/TooltipInternal.js";import"../../spinner/Spinner.js";import"../../icon-button/IconButton.js";import"../../shimmer/ShimmerComponent/ShimmerStyled.js";import"../../product-picker-v2/emptyState.js";import"../../product-picker-v2/style.js";import"../../product-picker-v2/type.js";import{DynamicCouponContainer as D}from"../DiscountModal.styled.js";import{CouponExpiration as h}from"../CouponExpiration/CouponExpiration.js";import{RadioButton as y}from"../../radioButton/RadioButton.js";import O from"../../../assets/icons/cursor.svg.js";import T from"../../../assets/icons/plus.svg.js";const j="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg";var x;function E(){return null}!function(e){e.ENTITLED="entitled",e.PREREQUISITE="prerequisite"}(x||(x={}));const _=_=>{var C;const f=[{value:a.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:_.selectedCouponType===a.AMOUNT_OFF_ORDER},{value:a.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:_.selectedCouponType===a.AMOUNT_OFF_PRODUCTS},{value:a.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:_.selectedCouponType===a.BUY_X_GET_Y},{value:a.FREE_SHIPPING,label:"Free shipping",selected:_.selectedCouponType===a.FREE_SHIPPING}],N=[{selected:_.selectedMinimumRequirement===o.NA,label:"No minimum requirements",value:o.NA},{selected:_.selectedMinimumRequirement===o.AMOUNT,label:`Minimum purchase amount (${null!==(C=_.currency)&&void 0!==C?C:"₹"})`,value:o.AMOUNT},{selected:_.selectedMinimumRequirement===o.QUANTITY,label:"Minimum quantity of items",value:o.QUANTITY}],F=()=>{var e,t,i,s,n;if(_.discountData.valueType===l.FIXED_AMOUNT){if((null===(e=_.discountData)||void 0===e?void 0:e.value)&&(null===(t=_.discountData)||void 0===t?void 0:t.value)<=0)return"Enter a valid input"}else if((null===(i=_.discountData)||void 0===i?void 0:i.value)&&((null===(s=_.discountData)||void 0===s?void 0:s.value)<=0||(null===(n=_.discountData)||void 0===n?void 0:n.value)>100))return"Enter a valid input"},I=()=>{var i,s,n,a,l;return e("div",Object.assign({className:"input__rows"},{children:[e("div",Object.assign({className:"input__wrapper"},{children:[t(m,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),t(r,{options:N,placement:"bottom-start",onSelect:e=>{const t=e.value;_.setSelectedMinimumRequirement(t),_.setDiscountData(Object.assign(Object.assign({},_.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),t("div",Object.assign({className:"input__wrapper"},{children:_.selectedMinimumRequirement!==o.NA&&t(b,{value:_.selectedMinimumRequirement===o.AMOUNT?null!==(s=null===(i=_.discountData.minAmount)||void 0===i?void 0:i.toString())&&void 0!==s?s:"":null!==(a=null===(n=_.discountData.minQuantity)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",onChangeText:e=>{_.selectedMinimumRequirement===o.AMOUNT?_.setDiscountData(Object.assign(Object.assign({},_.discountData),{minAmount:parseInt(e)})):_.selectedMinimumRequirement===o.QUANTITY&&_.setDiscountData(Object.assign(Object.assign({},_.discountData),{minQuantity:parseInt(e)}))},labelText:_.selectedMinimumRequirement===o.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",prefixText:_.selectedMinimumRequirement===o.AMOUNT?null!==(l=_.currency)&&void 0!==l?l:"₹":void 0,type:"number",placeholder:_.selectedMinimumRequirement===o.AMOUNT?"1000.00":"2"})}))]}))},w=(a,o)=>{var l,r,u,p;let m=[],D=[],h={},y={};return _.useNewPicker?(h=a===x.ENTITLED?_.entitledProducts:_.prerequisiteProducts,y=null!==(l=a===x.ENTITLED?_.entitledCollections:_.prerequisiteCollections)&&void 0!==l?l:[],(null==h?void 0:h.isCustom)&&delete h.isCustom,(null==y?void 0:y.isCustom)&&delete y.isCustom,Object.values(h).forEach((e=>{Object.keys(e.products).forEach((t=>{m.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(y).forEach((e=>{"isCustom"!==e&&D.push({id:e,name:y[e].name,image:y[e].image})}))):(m=a===x.ENTITLED?_.entitledProducts:_.prerequisiteProducts,D=null!==(r=a===x.ENTITLED?_.entitledCollections:_.prerequisiteCollections)&&void 0!==r?r:[]),e(i,{children:[!o&&e(i,{children:[t(d,{children:a===x.PREREQUISITE?"Customer buys":"Customer gets"}),e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:a===x.ENTITLED?null===(u=_.discountData.entitledQuantity)||void 0===u?void 0:u.toString():null===(p=_.discountData.prerequisiteQuantity)||void 0===p?void 0:p.toString(),type:"number",onChangeText:e=>{a===x.ENTITLED?_.setDiscountData(Object.assign(Object.assign({},_.discountData),{entitledQuantity:parseInt(e)})):_.setDiscountData(Object.assign(Object.assign({},_.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),t("div",{className:"input__wrapper"})]}))]}),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[!(null==D?void 0:D.length)&&t(n,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:T,onClick:()=>{_.setIsProductPickerOpen(a)}}),!(null==m?void 0:m.length)&&t(n,{buttonText:"Add collection",buttonType:"tertiary",LeadingIcon:T,onClick:()=>{_.setIsCollectionPickerOpen(a)}})]})),!!m.length&&e("div",Object.assign({style:{margin:"8px 0"}},{children:[t(c,{children:"Products"}),m.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${v.colorsV2.stroke.primary}`,display:"flex"}},{children:[e("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[t("img",{src:i.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),t(c,{children:i.name})]})),t("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:t("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(_.useNewPicker){const e=s(h);Object.values(e).forEach((e=>{var t,s;(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t[i.id])&&(null===(s=null==e?void 0:e.products)||void 0===s||delete s[i.id])})),a===x.ENTITLED?_.setEntitledProducts(e):_.setPrerequisiteProducts(e)}else{const e=m.filter((e=>e.id!==i.id));a===x.ENTITLED?_.setEntitledProducts(e):_.setPrerequisiteProducts(e)}}},{children:t(g,{width:14,color:v.colorsV2.content.primary})}))}))]}),i.id)))]})),!!D.length&&e("div",Object.assign({style:{margin:"8px 0"}},{children:[t(c,{children:"Collections"}),D.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${v.colorsV2.stroke.primary}`,display:"flex"}},{children:[e("div",Object.assign({style:{display:"flex",gap:16,alignItems:"center",flex:.8}},{children:[t("img",{src:i.image,onError:e=>{e.target.onerror=null,e.target.src=j},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),t(c,{children:i.name})]})),t("div",Object.assign({style:{flex:.2,display:"flex",justifyContent:"flex-end",alignItems:"center"}},{children:t("div",Object.assign({style:{cursor:"pointer"},onClick:()=>{if(_.useNewPicker){const e=s(y);delete e[i.id],a===x.ENTITLED?_.setEntitledCollections(e):_.setPrerequisiteCollections(e)}else{const e=D.filter((e=>e.id!==i.id));a===x.ENTITLED?_.setEntitledCollections(e):_.setPrerequisiteCollections(e)}}},{children:t(g,{width:14,color:v.colorsV2.content.primary})}))}))]}),i.id)))]}))]})};return e(D,{children:[_.allowStaticCoupon&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(r,{options:f,width:"338px",placement:"bottom-start",onSelect:e=>{_.onChangeCouponType(e)}})})),t("div",Object.assign({className:"input__wrapper",style:{display:"flex",alignItems:"center",gap:8}},{children:(_.selectedCouponType===a.AMOUNT_OFF_PRODUCTS||_.selectedCouponType===a.AMOUNT_OFF_ORDER)&&e(i,{children:[t(y,{isActive:_.discountData.valueType===l.FIXED_AMOUNT,onValueChange:()=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{valueType:l.FIXED_AMOUNT,value:void 0}))},label:"Fixed amount"}),t(y,{isActive:_.discountData.valueType===l.PERCENTAGE,onValueChange:()=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{valueType:l.PERCENTAGE,value:void 0}))},label:"Percentage"})]})}))]})),_.selectedCouponType===a.AMOUNT_OFF_ORDER&&(()=>{var s,n,a,o,r;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},maxCharLimit:22,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:null!==(a=null===(n=null===(s=_.discountData)||void 0===s?void 0:s.value)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",labelText:"Discount code value",type:"number",errorMessage:F(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:parseInt(e)}))},placeholder:_.discountData.valueType===l.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:_.discountData.valueType===l.FIXED_AMOUNT?null!==(o=_.currency)&&void 0!==o?o:"₹":void 0,suffixText:_.discountData.valueType===l.PERCENTAGE?"%":void 0})}))]})),I(),!_.hideProbability&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{type:"number",value:null===(r=_.discountData.probability)||void 0===r?void 0:r.toString(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),t("div",{className:"input__wrapper"})]}))]})})(),_.selectedCouponType===a.AMOUNT_OFF_PRODUCTS&&(()=>{var s,n,a,o,r;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},maxCharLimit:22,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:null!==(a=null===(n=null===(s=_.discountData)||void 0===s?void 0:s.value)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",labelText:"Discount code value",type:"number",errorMessage:F(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:parseInt(e)}))},placeholder:_.discountData.valueType===l.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:_.discountData.valueType===l.FIXED_AMOUNT?null!==(o=_.currency)&&void 0!==o?o:"₹":void 0,suffixText:_.discountData.valueType===l.PERCENTAGE?"%":void 0})}))]})),w(x.ENTITLED,!0),!_.hideProbability&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{type:"number",value:null===(r=_.discountData.probability)||void 0===r?void 0:r.toString(),onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})})),t("div",{className:"input__wrapper"})]}))]})})(),_.selectedCouponType===a.FREE_SHIPPING&&(()=>{var s;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:22})})),t("div",Object.assign({className:"input__wrapper"},{children:!_.hideProbability&&t(b,{value:null===(s=_.discountData.probability)||void 0===s?void 0:s.toString(),type:"number",onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]})),I()]})})(),_.selectedCouponType===a.BUY_X_GET_Y&&(()=>{var i,s,n,a;return e(D,{children:[t("div",Object.assign({className:"input__rows"},{children:e("div",Object.assign({style:{display:"flex",gap:20,flex:1}},{children:[t("div",Object.assign({style:{flex:1}},{children:t(b,{value:_.discountData.title,onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{title:e.trim()}))},maxCharLimit:22,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),!_.hideProbability&&t("div",Object.assign({style:{flex:1}},{children:t(b,{value:null===(i=_.discountData.probability)||void 0===i?void 0:i.toString(),type:"number",onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability",placeholder:"Enter probability in decimals (0 - 1)"})}))]}))})),t(E,{}),w(x.PREREQUISITE),t(E,{}),w(x.ENTITLED),t(E,{}),t(d,{children:"At a discount value"}),e("div",Object.assign({style:{display:"flex",gap:18,alignItems:"flex-start"}},{children:[t(y,{label:"Percentage",isActive:100!==_.discountData.value,onValueChange:()=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:void 0}))}}),100!==_.discountData.value&&t(b,{variant:"small",value:null!==(a=null===(n=null===(s=_.discountData)||void 0===s?void 0:s.value)||void 0===n?void 0:n.toString())&&void 0!==a?a:"",onChangeText:e=>{_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:parseInt(e)}))},errorMessage:F(),type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),t("div",{children:t(y,{label:"Free",isActive:100===_.discountData.value,onValueChange:e=>{e?_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:100})):_.setDiscountData(Object.assign(Object.assign({},_.discountData),{value:void 0}))}})})]})})(),_.selectedCouponType&&!_.hideExpiration&&e(i,{children:[t("div",{style:_.selectedCouponType!==a.BUY_X_GET_Y&&_.selectedCouponType!==a.AMOUNT_OFF_PRODUCTS||!_.hideProbability?{height:6,borderTop:`1px solid ${v.colorsV2.stroke.primary}`,marginTop:12}:{}}),t(h,{discountData:_.discountData,setDiscountData:_.setDiscountData})]}),!_.selectedCouponType&&e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:10,padding:"40px 0",justifyContent:"center",alignItems:"center"}},{children:[t("div",Object.assign({style:{height:52,width:52,backgroundColor:v.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:t(O,{width:32,color:v.colorsV2.content.primaryInverse})})),t(u,{children:"No discount has been selected"}),t(p,{children:"Please select a discount type"})]}))]})};export{x as DISCOUNT_PRODUCTS,_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as i}from"react/jsx-runtime";import e from"../../../assets/icons/info.svg.js";import{Input as o}from"../../input/Input.js";import{BodySecondaryLink as a,BodySecondary as n}from"../../TypographyStyle.js";import{DEFAULT_THEME as s}from"../../../constants/Theme.js";import{StaticCouponContainerStyled as c}from"../DiscountModal.styled.js";const r=r=>t(c,{children:[t("div",Object.assign({className:"static-coupon__data"},{children:[i("div",Object.assign({className:"static-input__wrapper"},{children:i(o,{onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{couponCode:null==t?void 0:t.trim()}))},labelText:"Coupon code",value:r.discountData.couponCode,placeholder:"Enter code created on shopify"})})),i("div",Object.assign({className:"static-input__wrapper"},{children:i(o,{maxCharLimit:
|
|
1
|
+
import{jsxs as t,jsx as i}from"react/jsx-runtime";import e from"../../../assets/icons/info.svg.js";import{Input as o}from"../../input/Input.js";import{BodySecondaryLink as a,BodySecondary as n}from"../../TypographyStyle.js";import{DEFAULT_THEME as s}from"../../../constants/Theme.js";import{StaticCouponContainerStyled as c}from"../DiscountModal.styled.js";const r=r=>t(c,{children:[t("div",Object.assign({className:"static-coupon__data"},{children:[i("div",Object.assign({className:"static-input__wrapper"},{children:i(o,{onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{couponCode:null==t?void 0:t.trim()}))},labelText:"Coupon code",value:r.discountData.couponCode,placeholder:"Enter code created on shopify"})})),i("div",Object.assign({className:"static-input__wrapper"},{children:i(o,{maxCharLimit:22,labelText:"Coupon title",value:r.discountData.title,onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{title:null==t?void 0:t.trim()}))},placeholder:"Enter coupon title"})}))]})),i(o,{labelText:"Coupon description",value:r.discountData.description,onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{description:null==t?void 0:t.trim()}))},placeholder:"Enter coupon description"}),!r.hideProbability&&i(o,{labelText:"Probability",value:r.discountData.probability?r.discountData.probability.toString():"",onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{probability:t.startsWith(".")?parseFloat(parseFloat(`0${t}`).toFixed(2)):parseFloat(parseFloat(t).toFixed(2))}))},placeholder:"Enter probability in decimals (0 - 1)"}),r.discountAdminUrl&&t("div",Object.assign({className:"info__container"},{children:[i(e,{height:18,width:18,color:s.colorsV2.content.secondary}),i(a,Object.assign({onClick:()=>{window.open(r.discountAdminUrl,"_blank")}},{children:"Click here"})),i(n,{children:"to create discount code on Shopify"})]}))]});export{r as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{jsxs as e,jsx as a}from"react/jsx-runtime";import l from"../../assets/icons/PlusIcon.js";import{useRef as r,useState as i,useEffect as
|
|
1
|
+
import{jsxs as e,jsx as a}from"react/jsx-runtime";import l from"../../assets/icons/PlusIcon.js";import{useRef as r,useState as i,useEffect as t}from"react";import o from"styled-components";import{v4 as d}from"uuid";import{COLORS as s}from"../../constants/Theme.js";import{AddVariableStyled as n}from"../add-variableV2/AddVariableBox.styled.js";import{AddVariableV2 as c}from"../add-variableV2/AddVariableV2.js";import{Input as u}from"../input/Input.js";import{BodyCaption as v}from"../TypographyStyle.js";const p=o=>{const s=r(null),[p,g]=i(!1),[m]=i(d()),[h,V]=i(),[T,f]=i(o.prevVariable),[y,j]=i(!1),[x,w]=i(!1);return t((()=>{h&&h.actualValue&&(o.allowMix?f((e=>({actualValue:e.actualValue+h.actualValue,variableType:"string"}))):f((e=>({actualValue:h.actualValue,variableType:h.variableType,needsFetching:h.needsFetching}))))}),[h]),t((()=>{o.onChange(T)}),[T]),e(b,Object.assign({isVar:/^{{.*}}$/.test(T.actualValue)},{children:[a(u,{id:m,ref:s,skipFocus:!0,textControl:!0,isActive:p,value:T.actualValue,validate:e=>[!0,""],errorMessage:"",placeholder:"Add a value",onChangeText:function(e,a){if(o.onlyVariables){const e=(null==a?void 0:a.keyCode)||(null==a?void 0:a.charCode);8!=e&&46!=e||f({actualValue:"",variableType:"string"})}else o.allowMix?f({actualValue:e,variableType:"string"}):f({actualValue:e.replace(/{{.*}}/,""),variableType:"string"})},onReferenceInit:()=>{},onFocus:e=>{var a;g(!0),w(!0),"Search..."!==(null===(a=e.relatedTarget)||void 0===a?void 0:a.placeholder)||y||j(!0)},onBlur:e=>{var a,l,r,i,t,o,d;"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||"varList"===(null===(l=e.relatedTarget)||void 0===l?void 0:l.id)||(null===(i=null===(r=e.relatedTarget)||void 0===r?void 0:r.className)||void 0===i?void 0:i.includes("exlualr0"))||(null===(o=null===(t=e.relatedTarget)||void 0===t?void 0:t.className)||void 0===o?void 0:o.includes("sc-dZoequ "))?(s.current&&s.current.focus(),g(!0)):"Search..."===(null===(d=e.relatedTarget)||void 0===d?void 0:d.placeholder)?g(!0):(g(!1),j(!1),w(!1))}}),e("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"space-between"}},{children:[T.actualValue&&o.showHelp?a("div",Object.assign({style:{marginTop:4}},{children:a(v,{children:`This value is of type ${T.variableType}`})})):a("div",{}),x&&a(n,Object.assign({right:o.addVarBoxRight,id:"addVar",onClick:()=>{j(!y)}},{children:e("div",Object.assign({className:"add"},{children:[a(l,{color:"white"}),a("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),y&&a(c,{data:o.variablesList,showVariable:!0,setShowVariable:()=>{j(!1)},variableValue:h,setVariableValue:V,placeholder:"",pickerSize:"large",enableVariable:!0,selectWithTypes:!0,onSearchBlur:e=>{var a,l,r,i,t,o;"varList"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||(null===(r=null===(l=e.relatedTarget)||void 0===l?void 0:l.className)||void 0===r?void 0:r.includes("exlualr0"))||(null===(t=null===(i=e.relatedTarget)||void 0===i?void 0:i.className)||void 0===t?void 0:t.includes("sc-dZoequ "))?s.current.focus():"Enter here"===(null===(o=e.relatedTarget)||void 0===o?void 0:o.placeholder)?e.relatedTarget.id!==m&&(j(!1),w(!1),g(!1)):(j(!1),w(!1),g(!1))}})]}))},b=o.div`
|
|
2
2
|
margin-bottom: 32px;
|
|
3
3
|
input {
|
|
4
|
-
color: ${e=>e.isVar?
|
|
4
|
+
color: ${e=>e.isVar?s.stroke.brand:"black"};
|
|
5
5
|
}
|
|
6
|
-
`;export{
|
|
6
|
+
`;export{p as InputWithVariables};
|
|
@@ -21,8 +21,6 @@ interface CollectionsScreenInterface {
|
|
|
21
21
|
setCurPage: React.Dispatch<React.SetStateAction<number>>;
|
|
22
22
|
};
|
|
23
23
|
hideCollectionCheckbox?: boolean;
|
|
24
|
-
renderCoreComponent?: boolean;
|
|
25
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
26
24
|
}
|
|
27
25
|
export declare const CollectionsScreen: (props: CollectionsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
28
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/chevronRight.svg.js";import{useRef as c,useState as s,useEffect as r}from"react";import{CheckBox as n}from"../checkBox/CheckBox.js";import{IconButton as l}from"../icon-button/IconButton.js";import{BikShimmer as d}from"../shimmer/ShimmerComponent/BikShimmer.js";import{Tag as a}from"../tag/Tag.js";import{TitleRegular as h}from"../TypographyStyle.js";import{EmptyState as u}from"./emptyState.js";import{CollectionCardStyle as m,CollectionCardInfoStyle as p,CollectionCardDetailStyle as C,CollectionNameHolder as g}from"./style.js";const v=(e,t,o)=>{if(e.length<=t)return e;const i=e.slice(0,t-1);return(o?i.slice(0,i.lastIndexOf(" ")):i)+"..."},b=o=>{const{customCollectionRestriction:i,dataLoading:n,collections:l,selectedCollectionsDispatch:a,setCollectionId:h,selectedCollections:m,setScreen:p,collectionFetcher:C,collectionsDispatch:g,pagingControls:v,storeId:b,setSaveDisabled:f,hideCollectionCheckbox:k}=o,j=c(null),x=c(v.curPage),O=!!i&&(null==m?void 0:m.isCustom),[E,S]=s(!1);r((()=>{x.current=v.curPage}),[v.curPage]),r((()=>{const e=new IntersectionObserver((e=>{e[0].isIntersecting&&x.current>0&&(f(!0),S(!0),C(x.current,b).then((e=>{g({type:"paged",data:(null==e?void 0:e.collections)||{}}),v.setCurPage(x.current+1),S(!1),f(!1)})).catch())}),{threshold:1});return j.current&&e.observe(j.current),()=>{j.current&&e.unobserve(j.current)}}),[j]);const D=e=>{var t,o;let i=0,c=0;if(m[e]){const s=null===(t=l[e])||void 0===t?void 0:t.products;s&&Object.keys(s).forEach((e=>{var t;const o=null===(t=s[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>i+=1))}));const r=null===(o=m[e])||void 0===o?void 0:o.products;return r&&Object.keys(r).forEach((e=>{var t;const o=null===(t=r[e])||void 0===t?void 0:t.variants;o&&Object.keys(o).forEach((e=>c+=1))})),!(i<=0&&c>0)&&(c>0&&i!==c)}return!1};return e("div",{children:[Object.keys(l).length?Object.keys(l).map((e=>t(y,{customCollectionRestriction:i,data:l[e],isDisabled:O&&!(null==m?void 0:m[e]),isChecked:!!(null==m?void 0:m[e]),isPartiallyChecked:D(e),selectedCollectionsDispatch:a,setCollectionId:h,setScreen:p,id:e,hideCollectionCheckbox:k},e))):n?[1,2,3,4,5,6,7,8,9,10].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):t(u,{title:"No collections to show",subtitle:"We couldn’t find any collection."}),t("div",{ref:j}),E&&[1,2,3,4,5].map(((e,o)=>t("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:t(d,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o)))]})},y=c=>{const{customCollectionRestriction:s,data:r,selectedCollectionsDispatch:d,setCollectionId:u,isPartiallyChecked:b,setScreen:y,id:f,isChecked:k,isDisabled:j,hideCollectionCheckbox:x}=c;return e(m,Object.assign({isDisabled:j,onClick:()=>{j||(u(f),y("products"))}},{children:[e(p,{children:[!x&&t(n,{isDisabled:j,isChecked:k,isPartiallyChecked:b,onValueChange:function(e,t,o){null==o||o.stopPropagation(),d(e?{type:"selected",data:{id:f,val:r,isRestricted:s}}:{type:"unselected",data:{id:f}}),u(e?f:"")}}),t(C,{children:e(g,{children:[t(h,{children:v(r.name,40,!0)}),r.isSmartCollection?t(a,{tagText:"Smart Collection",type:"warning"}):t(o,{})]})})]}),t(l,{height:12,width:12,disabled:j,Icon:i})]}))};export{b as CollectionsScreen,v as truncate};
|
|
@@ -48,7 +48,7 @@ export interface ProductPickerInterface {
|
|
|
48
48
|
storeId: string;
|
|
49
49
|
selectedItems: SelectedItems;
|
|
50
50
|
onAdd: (items: SelectedItems, total: number) => void;
|
|
51
|
-
onClose
|
|
51
|
+
onClose: () => void;
|
|
52
52
|
visible: boolean;
|
|
53
53
|
zIndex?: number;
|
|
54
54
|
limit?: number;
|
|
@@ -61,9 +61,5 @@ export interface ProductPickerInterface {
|
|
|
61
61
|
title?: string;
|
|
62
62
|
postHeader?: React.ReactNode;
|
|
63
63
|
width?: string;
|
|
64
|
-
renderCoreComponent?: boolean;
|
|
65
|
-
onClickSave?: number;
|
|
66
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
67
|
-
hideProductVariants?: boolean;
|
|
68
64
|
}
|
|
69
65
|
export declare const ProductPickerModal: (props: ProductPickerInterface) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as s,useState as i,useEffect as r}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as n}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as a}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as u}from"../tag/Tag.js";import{CollectionsScreen as p}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{collectionsReducer as C,selectedColectionsReducer as b,CollectionIdContext as g}from"./reducers.js";import{SearchScreen as v}from"./searchScreen.js";import{SelectedScreen as y}from"./selectedScreen.js";import{ContainerStyle as f,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as x}from"./type.js";const S=S=>{const{storeId:k,selectedItems:I,onClose:P,visible:F,zIndex:O,limit:T,hideCollectionCheckbox:D,hideProductCheckbox:E,outOfStockAction:w=x.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:B,hideSelectionCount:A,title:L,width:z}=S,[G,H]=s(C,{}),[$,V]=i("collections"),[K,M]=i(""),[U,Y]=i(0),[q,J]=i(!1),[N,Q]=i(0),[W,X]=i(""),[Z,_]=i(!1),[ee,te]=i(!1),[oe,ce]=i(),[se,ie]=s(b,Object.keys(I).length>0?I:{});r((()=>{J(!0),te(!0),S.collectionFetcher(U,k).then((e=>{H({type:"fetched",data:(null==e?void 0:e.collections)||{}}),J(!1),Y((e=>e+1)),te(!1)})).catch()}),[]),r((()=>{let e=0;Object.keys(se||[]).forEach((t=>{var o;Object.keys((null===(o=se[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=se[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),Q(e)})),r((()=>{var e;K&&!(null===(e=null==G?void 0:G[K])||void 0===e?void 0:e.products)&&(J(!0),S.productFetcher(K,k).then((e=>{Object.keys(e).length&&H({type:"productsFetched",data:{collectionId:K,products:e}}),J(!1)})).catch())}),[K]),r((()=>{const e=setTimeout((()=>{W.length?(_(!0),S.searchFetcher(k,W).then((e=>{ce(Object.assign({},e)),V("searchProducts"),J(!1),_(!1)}))):V("collections")}),800);return()=>clearTimeout(e)}),[W]);const re=()=>{ie({type:"reset",data:{}})};return e(a,Object.assign({zIndex:O,open:F,onClose:()=>{P(),re()},headingTitle:L||("collections"===$||"products"===$?"Select Products":"view"===$?"Selected Products":"searchProducts"===$?"Searched Products":void 0),footerShadow:!0,centralContainerStyles:{width:z||"480px"},primaryButton:{buttonText:q?"Loading...":"Add",disabled:q||N<1||T&&N>T||!1,onClick:()=>{S.onAdd(se,N),re()}},footerLeftCustomElement:A?e(t,{}):T&&N>T?e(u,{tagText:`You can only select ${T} products`,type:"negative"}):e(n,N>0?{onClick:()=>{V("view")},buttonText:`${N} products selected`,buttonType:"tertiaryGray"}:{disabled:!0,buttonText:`${N} products selected`,buttonType:"tertiaryGray"})},{children:o(f,{children:[S.postHeader&&e("div",Object.assign({style:{padding:"0 24px"}},{children:S.postHeader})),!S.hideGlobalSearch&&e(t,{children:("collections"===$||"searchProducts"===$)&&e("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e(d,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Z?e(h,{size:"small",color:l.content.primary}):e(c,{})},id:"listInput",height:"24px",type:"text",value:W,onChangeText:e=>{e.length&&e.trim().length?X(e):X("")}})}))}),o(j,{children:["collections"===$&&e(p,{customCollectionRestriction:S.customCollectionRestriction,dataLoading:ee,collections:G,selectedCollectionsDispatch:ie,setCollectionId:M,setScreen:V,selectedCollections:se,collectionFetcher:S.collectionFetcher,storeId:k,collectionsDispatch:H,setSaveDisabled:J,pagingControls:{curPage:U,setCurPage:Y},hideCollectionCheckbox:D}),"products"===$&&K&&e(g.Provider,Object.assign({value:K},{children:e(m,{hideInCollectionSearch:S.hideInCollectionSearch,customCollectionRestriction:S.customCollectionRestriction,productFetcher:S.productFetcher,setScreen:V,storeId:k,data:G[K],collectionsDispatch:H,selectedCollectionsDispatch:ie,selectedData:se,setSaveDisabled:J,searchInCollectionFetcher:S.searchInCollectionFetcher,hideProductCheckbox:E,outOfStockAction:w,hideVariantCheckbox:R,selectProductsFromCustomCollection:B})})),"view"===$&&e(y,{selectedCollections:se||{},selectedCollectionsDispatch:ie,setScreen:V,collections:G}),"searchProducts"===$&&e(v,{customCollectionRestriction:S.customCollectionRestriction,selectedCollections:se||{},searchedCollections:oe||{},selectedCollectionsDispatch:ie,setScreen:V,collections:G,onBackPress:()=>{X(""),ce({})}})]})]})}))};export{S as ProductPickerModal};
|
|
@@ -18,9 +18,6 @@ interface ProductsScreenInterface {
|
|
|
18
18
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
19
19
|
hideVariantCheckbox?: boolean;
|
|
20
20
|
selectProductsFromCustomCollection?: boolean;
|
|
21
|
-
renderCoreComponent?: boolean;
|
|
22
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
23
|
-
hideProductVariants?: boolean;
|
|
24
21
|
}
|
|
25
22
|
export declare const ProductsScreen: (props: ProductsScreenInterface) => import("react/jsx-runtime").JSX.Element;
|
|
26
23
|
interface ProductGroupInterface {
|
|
@@ -35,8 +32,6 @@ interface ProductGroupInterface {
|
|
|
35
32
|
hideProductCheckbox?: boolean;
|
|
36
33
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
37
34
|
hideVariantCheckbox?: boolean;
|
|
38
|
-
hideProductVariants?: boolean;
|
|
39
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
40
35
|
}
|
|
41
36
|
export declare const ProductGroup: (props: ProductGroupInterface) => import("react/jsx-runtime").JSX.Element;
|
|
42
37
|
interface ProductCardInterface {
|
|
@@ -53,8 +48,6 @@ interface ProductCardInterface {
|
|
|
53
48
|
hideProductCheckbox?: boolean;
|
|
54
49
|
outOfStockAction?: OUT_OF_STOCK_ACTION;
|
|
55
50
|
hideVariantCheckbox?: boolean;
|
|
56
|
-
hideProductVariants?: boolean;
|
|
57
|
-
pickerType?: 'COLLECTION' | 'PRODUCT';
|
|
58
51
|
}
|
|
59
52
|
export declare const ProductCard: (props: ProductCardInterface) => import("react/jsx-runtime").JSX.Element;
|
|
60
53
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import d from"../../assets/icons/search.svg.js";import{cloneDeep as
|
|
1
|
+
import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import i from"../../assets/icons/arrow_left.svg.js";import c from"../../assets/icons/box.svg.js";import d from"../../assets/icons/search.svg.js";import{cloneDeep as l}from"lodash";import{useContext as n,useState as r,useEffect as s}from"react";import{Tag as a}from"../tag/Tag.js";import{COLORS as u}from"../../constants/Theme.js";import{CheckBox as h}from"../checkBox/CheckBox.js";import{IconButton as p}from"../icon-button/IconButton.js";import{Input as v}from"../input/Input.js";import{BikShimmer as m}from"../shimmer/ShimmerComponent/BikShimmer.js";import{ShimmerImage as f}from"../shimmer-image/ShimmerImage.js";import{Spinner as y}from"../spinner/Spinner.js";import{BodyCaption as g,TitleRegular as b}from"../TypographyStyle.js";import{truncate as j}from"./collectionScreen.js";import{EmptyState as k}from"./emptyState.js";import{ProductHelper as C}from"./helpers/ProductHelper.js";import{CollectionIdContext as I}from"./reducers.js";import{ProductScreenHeader as O,ProductScreenCollectionCardStyle as x,ProductCardStyle as S}from"./style.js";import{OUT_OF_STOCK_ACTION as P}from"./type.js";import{liftTheStateUp as w}from"./utility.js";const D=o=>{const a=n(I),{data:f,collectionsDispatch:j,selectedData:C,selectedCollectionsDispatch:S,productFetcher:D,storeId:V,setScreen:A,setSaveDisabled:T,hideInCollectionSearch:B,customCollectionRestriction:F,hideProductCheckbox:R,outOfStockAction:U=P.BLUR,hideVariantCheckbox:H=!1,selectProductsFromCustomCollection:L=!1}=o,[W,z]=r(""),[K,N]=r(!1),[_,q]=r(f);s((()=>{const t=setTimeout((()=>{W.length?(N(!0),o.searchInCollectionFetcher(V,a,W).then((t=>{var e;const o=l(f);o.products={};for(const i of t)(null===(e=null==f?void 0:f.products)||void 0===e?void 0:e[i])&&(o.products[i]=f.products[i]);q(o),T(!1),N(!1)}))):q(f)}),800);return()=>clearTimeout(t)}),[W]);const G=!!F&&f.isSmartCollection,J=t=>{var e,o,i,c,d,l,n,r;let s=0,u=0;return!!((null===(o=null===(e=null==C?void 0:C[a])||void 0===e?void 0:e.products)||void 0===o?void 0:o[t])&&(null===(d=Object.keys((null===(c=null===(i=null==f?void 0:f.products)||void 0===i?void 0:i[t])||void 0===c?void 0:c.variants)||[]))||void 0===d||d.forEach((()=>u++)),Object.keys((null===(r=null===(n=null===(l=null==C?void 0:C[a])||void 0===l?void 0:l.products)||void 0===n?void 0:n[t])||void 0===r?void 0:r.variants)||[]).forEach((()=>s++)),s>0&&u!==s))};s((()=>{(null==f?void 0:f.products)||M()}),[]);const M=()=>{T(!0),N(!0),D(a,V).then((t=>{Object.keys(t).length&&(j({type:"productsFetched",data:{collectionId:a,products:t}}),q(Object.assign(Object.assign({},_),{products:t}))),T(!1),N(!1)})).catch()},Q=(t,e)=>{const o=w(e,f);S({type:t,data:Object.assign(Object.assign({},o),{isRestricted:F})})};return t("div",{children:[t(O,{children:[e(p,{Icon:i,height:16,onClick:()=>{A("collections")}}),e(g,Object.assign({style:{color:u.content.secondary}},{children:f.name}))]}),!B&&e("div",Object.assign({style:{padding:16,height:"76px",borderBottom:"1px solid #E0E0E0"}},{children:e(v,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>K&&W.length?e(y,{size:"small",color:u.content.primary}):e(d,{})},id:"listInput",height:"24px",type:"text",value:W,onChangeText:t=>{t.length&&t.trim().length?z(t):z("")},placeholder:"Search products in this collection..."})})),t("div",{children:[Object.keys((null==_?void 0:_.products)||[]).length>0&&!G&&!W.length&&!R&&t(x,{children:[e(h,{isChecked:!!(null==C?void 0:C[a]),isPartiallyChecked:(t=>{var e;let o=0,i=0;if(C[t]){const c=null==f?void 0:f.products;c&&Object.keys(c).forEach((t=>{var e;const i=null===(e=c[t])||void 0===e?void 0:e.variants;i&&Object.keys(i).forEach((t=>o+=1))}));const d=null===(e=C[t])||void 0===e?void 0:e.products;return d&&Object.keys(d).forEach((t=>{var e;const o=null===(e=d[t])||void 0===e?void 0:e.variants;o&&Object.keys(o).forEach((()=>i+=1))})),i>0&&o!==i}return!1})(a),onValueChange:function(t){S(t?{type:"selected",data:{id:a,val:f}}:{type:"unselected",data:{id:a}})}}),e("div",Object.assign({style:{width:40,height:40}},{children:e(c,{})})),e(b,{children:"All Products"})]}),Object.keys((null==_?void 0:_.products)||[]).length?Object.keys(_.products||[]).map((t=>e(E,{outOfStockAction:U,collectionId:a,isProductPartiallyChecked:J(t),productId:t,data:_.products[t],selectedData:C,selectedCollectionsDispatch:S,viewOnly:!L&&!!G,upliftAdditions:Q,hideProductCheckbox:R,hideVariantCheckbox:H},t))):K?[1,2,3,4,5,6,7,8,9,10].map(((t,o)=>e("div",Object.assign({style:{borderBottom:"1px solid #E0E0E0"}},{children:e(m,{boxes:[{height:"64px",width:"100%",marginTop:"0px"}]})}),o))):e(k,{title:"No products to show",subtitle:W.length?"We couldn't find the product you were looking for":"We couldn’t find any product in this collection."})]})]})},E=o=>{const{collectionId:i,productId:c,data:d,selectedData:l,selectedCollectionsDispatch:n,viewOnly:r,upliftAdditions:s,isProductPartiallyChecked:a,hideProductCheckbox:u,outOfStockAction:h,hideVariantCheckbox:p}=o,v=t=>{var e,o,d,n,r,s;if(!(null===(o=null===(e=null==l?void 0:l[i])||void 0===e?void 0:e.products)||void 0===o?void 0:o[c]))return!1;return!!(null===(s=null===(r=null===(n=null===(d=null==l?void 0:l[i])||void 0===d?void 0:d.products)||void 0===n?void 0:n[c])||void 0===r?void 0:r.variants)||void 0===s?void 0:s[t])};return t("div",{children:[e(V,{isVariant:!1,data:d,productId:c,collectionId:i,isSelected:!!(null===(f=null===(m=null==l?void 0:l[i])||void 0===m?void 0:m.products)||void 0===f?void 0:f[c]),isPartiallyChecked:a,selectedCollectionsDispatch:n,upliftAdditions:s,viewOnly:r,hideProductCheckbox:u,hideVariantCheckbox:p},c),Object.keys(d.variants||[]).map((t=>e(V,{isVariant:!0,hideVariantCheckbox:p,data:d.variants[t],variantId:t,productId:c,viewOnly:r,upliftAdditions:s,collectionId:i,isSelected:v(t),selectedCollectionsDispatch:n,outOfStockAction:h},t)))]});var m,f},V=i=>{const{isVariant:c,data:d,productId:l,collectionId:n,variantId:r,isSelected:s,selectedCollectionsDispatch:u,viewOnly:p,upliftAdditions:v,isPartiallyChecked:m,hideProductCheckbox:y,outOfStockAction:g,hideVariantCheckbox:k}=i,I=C.getProductLabels(d,g);return t(S,Object.assign({isVariant:c},{children:[c&&!p&&!k||!c&&!p&&!y?e(h,{isChecked:s,isPartiallyChecked:m||!1,onValueChange:function(t){c?t?v("variantSelected",{productId:l,variantId:r,collectionId:n,variant:d}):u({type:"variantUnselected",data:{productId:l,variantId:r,collectionId:n}}):t?v("productSelected",{productId:l,collectionId:n,product:d}):u({type:"productUnselected",data:{productId:l,collectionId:n}})}}):e(o,{}),e("div",{children:e(f,{width:40,height:40,imageUrl:d.image,alt:"Item",borderRadius:4})}),t("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[e(b,{children:j(d.name,40,!0)}),I?e("div",Object.assign({style:{width:90,display:"flex"}},{children:e(a,{tagText:I,type:"warning",theme:"light"})})):e(o,{})]}))]}))};export{V as ProductCard,E as ProductGroup,D as ProductsScreen};
|
|
@@ -2,7 +2,6 @@ export declare const ContainerStyle: import("styled-components").StyledComponent
|
|
|
2
2
|
export declare const ScrollContainerStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export declare const CollectionCardStyle: import("styled-components").StyledComponent<"div", any, {
|
|
4
4
|
isDisabled: boolean;
|
|
5
|
-
isActive: boolean;
|
|
6
5
|
}, never>;
|
|
7
6
|
export declare const CollectionCardInfoStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
7
|
export declare const CollectionCardDetailStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -10,7 +9,6 @@ export declare const ProductScreenHeader: import("styled-components").StyledComp
|
|
|
10
9
|
export declare const ProductScreenCollectionCardStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
10
|
export declare const ProductCardStyle: import("styled-components").StyledComponent<"div", any, {
|
|
12
11
|
isVariant: boolean;
|
|
13
|
-
isActive: boolean;
|
|
14
12
|
}, never>;
|
|
15
13
|
export declare const SelectedScreenHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
14
|
export declare const CollectionNameHolder: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -9,7 +9,7 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
9
9
|
overflow-x: hidden;
|
|
10
10
|
`,n=e.div`
|
|
11
11
|
height: 64px;
|
|
12
|
-
background-color: ${e=>e.isDisabled?"#F0F0F0":
|
|
12
|
+
background-color: ${e=>e.isDisabled?"#F0F0F0":"white"};
|
|
13
13
|
border-bottom: 1px solid #e0e0e0;
|
|
14
14
|
padding: 12px 24px;
|
|
15
15
|
display: flex;
|
|
@@ -37,16 +37,16 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
37
37
|
align-items: center;
|
|
38
38
|
padding: 8px 16px;
|
|
39
39
|
margin-top: 16px;
|
|
40
|
-
`,
|
|
40
|
+
`,x=e.div`
|
|
41
41
|
display: flex;
|
|
42
42
|
flex-direction: row;
|
|
43
43
|
column-gap: 16px;
|
|
44
44
|
padding: 12px 16px;
|
|
45
45
|
border-bottom: 1px solid #e0e0e0;
|
|
46
46
|
align-items: center;
|
|
47
|
-
`,
|
|
47
|
+
`,p=e.div`
|
|
48
48
|
height: 64px;
|
|
49
|
-
background-color:
|
|
49
|
+
background-color: white;
|
|
50
50
|
border-bottom: 1px solid #e0e0e0;
|
|
51
51
|
padding: 12px 16px;
|
|
52
52
|
display: flex;
|
|
@@ -67,4 +67,4 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
|
|
|
67
67
|
`,a=e.div`
|
|
68
68
|
display: flex;
|
|
69
69
|
flex-direction: column;
|
|
70
|
-
`;export{d as CollectionCardDetailStyle,l as CollectionCardInfoStyle,n as CollectionCardStyle,a as CollectionNameHolder,t as ContainerStyle,
|
|
70
|
+
`;export{d as CollectionCardDetailStyle,l as CollectionCardInfoStyle,n as CollectionCardStyle,a as CollectionNameHolder,t as ContainerStyle,p as ProductCardStyle,x as ProductScreenCollectionCardStyle,r as ProductScreenHeader,o as ScrollContainerStyle,c as SelectedScreenHeader};
|