@bikdotai/bik-component-library 0.0.211 → 0.0.212-beta-discount-modal
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
- 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/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
- 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/product-picker-v2/modal.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("./type.js"),i=require("../dropdown/Dropdown.js");require("../dropdown/DropdownPopover/index.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js"),r=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("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var s=require("../modals/styledModal.js"),d=require("../product-picker/ProductPickerModal.js"),a=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/triangle_error.svg.js"),l=require("./DiscountModal.styled.js"),T=require("./DiscountUtils.js"),p=require("./DynamicCoupon/DynamicCoupon.js"),E=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=S=>{var C,I,P
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("./type.js"),i=require("../dropdown/Dropdown.js");require("../dropdown/DropdownPopover/index.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js"),r=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("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var s=require("../modals/styledModal.js"),d=require("../product-picker/ProductPickerModal.js"),a=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/triangle_error.svg.js"),l=require("./DiscountModal.styled.js"),T=require("./DiscountUtils.js"),p=require("./DynamicCoupon/DynamicCoupon.js"),E=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=S=>{var C,I,P;const[_,y]=t.useState(),[b,O]=t.useState(null!==(C=S.data)&&void 0!==C?C:{isStaticCoupon:!1}),[D,N]=t.useState(!!(null===(I=S.data)||void 0===I?void 0:I.isStaticCoupon)),[j,v]=t.useState(!0),[U,g]=t.useState(),[m,q]=t.useState(o.MIN_PURCHASE_REQUIREMENT.NA),[h,A]=t.useState([]),[x,Y]=t.useState([]),[L,G]=t.useState(0);t.useEffect((()=>{let e;S.hideProbability||(e=w()),v(T.validateDiscountData(b,m,U,S.hideProbability||!1,e,D)),S.hideProbability||w()}),[]),t.useEffect((()=>{let e;S.hideProbability||(e=w()),v(T.validateDiscountData(b,m,U,S.hideProbability||!1,e,D))}),[D,b,L,U,m]),t.useEffect((()=>{var e,t;if(S.products){if(null===(e=S.data)||void 0===e?void 0:e.entitledProductIds){const e=S.products.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));Y(e)}if(null===(t=S.data)||void 0===t?void 0:t.prerequisiteProductIds){const e=S.products.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));A(e)}}}),[]),t.useEffect((()=>{const e=x.map((e=>parseInt(e.id)));O(Object.assign(Object.assign({},b),{entitledProductIds:e}))}),[x]),t.useEffect((()=>{const e=h.map((e=>parseInt(e.id)));O(Object.assign(Object.assign({},b),{prerequisiteProductIds:e}))}),[h]),t.useEffect((()=>{b.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?g(o.DISCOUNT_TYPES.FREE_SHIPPING):b.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?g(o.DISCOUNT_TYPES.BUY_X_GET_Y):b.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?g(o.DISCOUNT_TYPES.FIXED_AMOUNT):b.valueType===o.DISCOUNT_VALUE_TYPES.PERCENTAGE&&g(o.DISCOUNT_TYPES.PERCENTAGE)}),[]);const R=[{value:o.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:U===o.DISCOUNT_TYPES.FIXED_AMOUNT},{value:o.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:U===o.DISCOUNT_TYPES.PERCENTAGE},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:U===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:U===o.DISCOUNT_TYPES.FREE_SHIPPING}],w=()=>{if(!S.quadrant||!S.probability)return;const e=[...S.probability];let t=[];e.length>=S.quadrant&&e.splice(S.quadrant-1,1),t=e;const o=t.reduce(((e,t)=>e+t),0)+(b.probability||0);return G(o),o},M=e=>{const t=e.value;g(t),t===o.DISCOUNT_TYPES.FREE_SHIPPING?(A([]),Y([]),O(Object.assign(Object.assign({},b),{value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):t===o.DISCOUNT_TYPES.BUY_X_GET_Y?O(Object.assign(Object.assign({},b),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE})):t===o.DISCOUNT_TYPES.PERCENTAGE?(A([]),Y([]),O(Object.assign(Object.assign({},b),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):t===o.DISCOUNT_TYPES.FIXED_AMOUNT&&(A([]),Y([]),O(Object.assign(Object.assign({},b),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return e.jsxs(s.StyledModal,Object.assign({open:S.isOpen,headingTitle:_?"Select Products":S.title,headingSubtitle:_?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e.jsx(e.Fragment,{}):L<=1?e.jsx(a.Tag,{theme:"light",tagText:`Current probability sum: ${L}`,type:"white"}):e.jsx(u.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(a.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${L}`,type:"negative",LeadingIcon:c.default})})})),headerRightCustomElement:S.allowStaticCoupon||_?void 0:e.jsx(i.Dropdown,{options:R,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{M(e)}}),onClose:S.onClose,footerShadow:!0,primaryButton:_?{buttonType:"primary",onClick:()=>{y(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:j,onClick:()=>{b.isStaticCoupon?S.onSaveClicked({quadrant:b.quadrant,couponCode:b.couponCode,description:b.description,isStaticCoupon:b.isStaticCoupon,probability:b.probability,title:b.title}):S.onSaveClicked(b),O({})}},secondaryButton:_?{buttonType:"tertiaryGray",onClick:()=>{y(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!_&&e.jsxs(l.StyledDiscountDialogueContainer,{children:[S.allowStaticCoupon&&!_&&e.jsxs(l.CouponTypeContainerStyled,Object.assign({selectedDiv:D?1:2},{children:[e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{N(!0),O({isStaticCoupon:!0,couponCode:b.couponCode,description:b.description,quadrant:b.quadrant})}},{children:[e.jsx(n.TitleSmall,Object.assign({style:D?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"Static code"})),e.jsx(n.BodyCaption,Object.assign({style:D?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{O(Object.assign(Object.assign({},b),{isStaticCoupon:!1})),N(!1)}},{children:[e.jsx(n.TitleSmall,Object.assign({style:D?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic code"})),e.jsx(n.BodyCaption,Object.assign({style:D?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),D&&!_&&e.jsx(E.default,{discountData:b,setDiscountData:O,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!D&&!_&&e.jsx(p.default,{currency:S.currency,entitledProducts:x,prerequisiteProducts:h,setEntitledProducts:Y,setPrerequisiteProducts:A,discountData:b,productPickerOpen:_,setIsProductPickerOpen:y,setDiscountData:O,selectedCouponType:U,setSelectedCouponType:g,selectedMinimumRequirement:m,setSelectedMinimumRequirement:q,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:M})]}),!!_&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(d.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(P=S.products)&&void 0!==P?P:[],title:"Select Products",onClose:()=>{y(void 0)},selectedProducts:_===p.DISCOUNT_PRODUCTS.ENTITLED?x:h,setSelectedProducts:_===p.DISCOUNT_PRODUCTS.ENTITLED?Y:A,onSearchKeyChange:S.onProductSearch})}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./type.js");exports.validateDiscountData=(i,t,r,n,u,T)=>{var E,l;if(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./type.js");exports.validateDiscountData=(i,t,r,n,u,T)=>{var E,l;if(!i.title)return!0;if(!n){if(isNaN(i.probability))return!0;if((i.probability||0)>1)return!0;if((i.probability||0)<0)return!0;if(u>1)return!0}if(T){if(!(null==i?void 0:i.couponCode))return!0;if(!i.description)return!0}else{if(r&&r===e.DISCOUNT_TYPES.FIXED_AMOUNT){if(i.valueType!==e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT)return!0;if(!(null==i?void 0:i.value)||(null==i?void 0:i.value)<=0)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.PERCENTAGE){if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!(null==i?void 0:i.value)||(null==i?void 0:i.value)<=0||(null==i?void 0:i.value)>100)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.BUY_X_GET_Y){if(!(i.entitledQuantity&&(null===(E=i.entitledProductIds)||void 0===E?void 0:E.length)&&i.prerequisiteQuantity&&(null===(l=i.prerequisiteProductIds)||void 0===l?void 0:l.length)))return!0;if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!i.value)return!0;if(i.value<=0||i.value>100)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else{if(!r||!e.DISCOUNT_TYPES.FREE_SHIPPING)return!0;if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE)return!0;if(100!==i.value)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0}if(null!==i.expireAfter&&void 0!==i.expireAfter&&i.expireAfter<=0)return!0}return!1};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../button/Button.js"),i=require("../type.js"),n=require("../../dropdown/Dropdown.js");require("../../dropdown/DropdownPopover/index.js"),require("../../zeroState/ZeroState.js");var a=require("../../TypographyStyle.js"),r=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 o=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");var c=require("../DiscountModal.styled.js"),u=require("../CouponExpiration/CouponExpiration.js"),d=require("../../radioButton/RadioButton.js"),p=require("../../../assets/icons/cursor.svg.js"),j=require("../../../assets/icons/plus.svg.js");var T;function m(){return null}exports.DISCOUNT_PRODUCTS=void 0,(T=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",T.PREREQUISITE="prerequisite";exports.default=T=>{var D;t.useEffect((()=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{isStaticCoupon:!1}))}),[]);const E=[{value:i.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:T.selectedCouponType===i.DISCOUNT_TYPES.FIXED_AMOUNT},{value:i.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:T.selectedCouponType===i.DISCOUNT_TYPES.PERCENTAGE},{value:i.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:T.selectedCouponType===i.DISCOUNT_TYPES.BUY_X_GET_Y},{value:i.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:T.selectedCouponType===i.DISCOUNT_TYPES.FREE_SHIPPING}],x=[{selected:T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.NA,label:"No minimum requirements",value:i.MIN_PURCHASE_REQUIREMENT.NA},{selected:T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT,label:`Minimum purchase amount (${null!==(D=T.currency)&&void 0!==D?D:"₹"})`,value:i.MIN_PURCHASE_REQUIREMENT.AMOUNT},{selected:T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.QUANTITY,label:"Minimum quantity of items",value:i.MIN_PURCHASE_REQUIREMENT.QUANTITY}],g=()=>{var t,s,r,l;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:x,placement:"bottom-start",onSelect:e=>{const t=e.value;T.setSelectedMinimumRequirement(t),T.setDiscountData(Object.assign(Object.assign({},T.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:T.selectedMinimumRequirement!==i.MIN_PURCHASE_REQUIREMENT.NA&&e.jsx(o.Input,{value:T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(s=null===(t=T.discountData.minAmount)||void 0===t?void 0:t.toString())&&void 0!==s?s:"":null!==(l=null===(r=T.discountData.minQuantity)||void 0===r?void 0:r.toString())&&void 0!==l?l:"",onChangeText:e=>{T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?T.setDiscountData(Object.assign(Object.assign({},T.discountData),{minAmount:parseInt(e)})):T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.QUANTITY&&T.setDiscountData(Object.assign(Object.assign({},T.discountData),{minQuantity:parseInt(e)}))},labelText:T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",type:"number",placeholder:T.selectedMinimumRequirement===i.MIN_PURCHASE_REQUIREMENT.AMOUNT?"1000.00":"2"})}))]}))},b=t=>{var i,n;const c=t===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledProducts:T.prerequisiteProducts;return e.jsxs(e.Fragment,{children:[e.jsx(a.TitleRegular,{children:t===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer spends":"Customer gets"}),e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(o.Input,{value:t===exports.DISCOUNT_PRODUCTS.ENTITLED?null===(i=T.discountData.entitledQuantity)||void 0===i?void 0:i.toString():null===(n=T.discountData.prerequisiteQuantity)||void 0===n?void 0:n.toString(),type:"number",onChangeText:e=>{t===exports.DISCOUNT_PRODUCTS.ENTITLED?T.setDiscountData(Object.assign(Object.assign({},T.discountData),{entitledQuantity:parseInt(e)})):T.setDiscountData(Object.assign(Object.assign({},T.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),e.jsx("div",{className:"input__wrapper"})]})),e.jsx("div",{children:e.jsx(s.Button,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:j.default,onClick:()=>{T.setIsProductPickerOpen(t)}})}),c.map((s=>e.jsxs("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${r.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="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"},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:()=>{const e=c.filter((e=>e.id!==s.id));t===exports.DISCOUNT_PRODUCTS.ENTITLED?T.setEntitledProducts(e):T.setPrerequisiteProducts(e)}},{children:e.jsx(l.default,{width:14,color:r.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),s.id)))]})};return e.jsxs(c.DynamicCouponContainer,{children:[T.allowStaticCoupon&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(n.Dropdown,{options:E,width:"290px",placement:"bottom-start",onSelect:e=>{T.onChangeCouponType(e)}})})),e.jsx("div",{className:"input__wrapper"})]})),(T.selectedCouponType===i.DISCOUNT_TYPES.PERCENTAGE||T.selectedCouponType===i.DISCOUNT_TYPES.FIXED_AMOUNT)&&(()=>{var t,s,n,a;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(o.Input,{value:T.discountData.title,onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{title:e}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(o.Input,{value:null===(s=null===(t=T.discountData)||void 0===t?void 0:t.value)||void 0===s?void 0:s.toString(),labelText:"Discount code value",type:"number",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:parseInt(e)}))},placeholder:T.selectedCouponType===i.DISCOUNT_TYPES.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:T.selectedCouponType===i.DISCOUNT_TYPES.FIXED_AMOUNT?null!==(n=T.currency)&&void 0!==n?n:"₹":void 0,suffixText:T.selectedCouponType===i.DISCOUNT_TYPES.PERCENTAGE?"%":void 0})}))]})),g(),!T.hideProbability&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(o.Input,{type:"number",value:null===(a=T.discountData.probability)||void 0===a?void 0:a.toString(),onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})})),e.jsx("div",{className:"input__wrapper"})]}))]})})(),T.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(o.Input,{value:T.discountData.title,onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{title:e}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:18})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:!T.hideProbability&&e.jsx(o.Input,{value:null===(t=T.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})}))]})),g()]})})(),T.selectedCouponType===i.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var t;return e.jsxs(c.DynamicCouponContainer,{children:[e.jsx("div",Object.assign({className:"input__rows"},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:20,flex:1}},{children:[e.jsx(o.Input,{value:T.discountData.title,onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{title:e}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"}),!T.hideProbability&&e.jsx(o.Input,{value:null===(t=T.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})]}))})),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:"center"}},{children:[e.jsx(d.RadioButton,{isActive:100!==T.discountData.value,onValueChange:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:void 0}))}}),e.jsx(a.BodySecondary,{children:"Percentage"}),100!==T.discountData.value&&e.jsx(o.Input,{variant:"small",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),e.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[e.jsx(d.RadioButton,{isActive:100===T.discountData.value,onValueChange:e=>{e?T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:100})):T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:void 0}))}}),e.jsx(a.BodySecondary,{children:"Free"})]}))]})})(),T.selectedCouponType&&!T.hideExpiration&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:6,borderTop:`1px solid ${r.DEFAULT_THEME.colorsV2.stroke.primary}`,marginTop:12}}),e.jsx(u.CouponExpiration,{discountData:T.discountData,setDiscountData:T.setDiscountData})]}),!T.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:r.DEFAULT_THEME.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:e.jsx(p.default,{width:32,color:r.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("../../button/Button.js");require("react");var s=require("../type.js"),i=require("../../dropdown/Dropdown.js");require("../../dropdown/DropdownPopover/index.js"),require("../../zeroState/ZeroState.js");var n=require("../../TypographyStyle.js"),a=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"),o=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");var l=require("../DiscountModal.styled.js"),d=require("../CouponExpiration/CouponExpiration.js"),u=require("../../radioButton/RadioButton.js"),c=require("../../../assets/icons/cursor.svg.js"),p=require("../../../assets/icons/plus.svg.js");var j;function T(){return null}exports.DISCOUNT_PRODUCTS=void 0,(j=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",j.PREREQUISITE="prerequisite";exports.default=j=>{var m;const D=[{value:s.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:j.selectedCouponType===s.DISCOUNT_TYPES.FIXED_AMOUNT},{value:s.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:j.selectedCouponType===s.DISCOUNT_TYPES.PERCENTAGE},{value:s.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:j.selectedCouponType===s.DISCOUNT_TYPES.BUY_X_GET_Y},{value:s.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:j.selectedCouponType===s.DISCOUNT_TYPES.FREE_SHIPPING}],x=[{selected:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.NA,label:"No minimum requirements",value:s.MIN_PURCHASE_REQUIREMENT.NA},{selected:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT,label:`Minimum purchase amount (${null!==(m=j.currency)&&void 0!==m?m:"₹"})`,value:s.MIN_PURCHASE_REQUIREMENT.AMOUNT},{selected:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.QUANTITY,label:"Minimum quantity of items",value:s.MIN_PURCHASE_REQUIREMENT.QUANTITY}],E=()=>{var t,a,o,l;return e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsxs("div",Object.assign({className:"input__wrapper"},{children:[e.jsx(n.BodySecondary,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),e.jsx(i.Dropdown,{options:x,placement:"bottom-start",onSelect:e=>{const t=e.value;j.setSelectedMinimumRequirement(t),j.setDiscountData(Object.assign(Object.assign({},j.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:j.selectedMinimumRequirement!==s.MIN_PURCHASE_REQUIREMENT.NA&&e.jsx(r.Input,{value:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(a=null===(t=j.discountData.minAmount)||void 0===t?void 0:t.toString())&&void 0!==a?a:"":null!==(l=null===(o=j.discountData.minQuantity)||void 0===o?void 0:o.toString())&&void 0!==l?l:"",onChangeText:e=>{j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?j.setDiscountData(Object.assign(Object.assign({},j.discountData),{minAmount:parseInt(e)})):j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.QUANTITY&&j.setDiscountData(Object.assign(Object.assign({},j.discountData),{minQuantity:parseInt(e)}))},labelText:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",type:"number",placeholder:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?"1000.00":"2"})}))]}))},g=s=>{var i,l;const d=s===exports.DISCOUNT_PRODUCTS.ENTITLED?j.entitledProducts:j.prerequisiteProducts;return e.jsxs(e.Fragment,{children:[e.jsx(n.TitleRegular,{children:s===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer spends":"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:s===exports.DISCOUNT_PRODUCTS.ENTITLED?null===(i=j.discountData.entitledQuantity)||void 0===i?void 0:i.toString():null===(l=j.discountData.prerequisiteQuantity)||void 0===l?void 0:l.toString(),type:"number",onChangeText:e=>{s===exports.DISCOUNT_PRODUCTS.ENTITLED?j.setDiscountData(Object.assign(Object.assign({},j.discountData),{entitledQuantity:parseInt(e)})):j.setDiscountData(Object.assign(Object.assign({},j.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),e.jsx("div",{className:"input__wrapper"})]})),e.jsx("div",{children:e.jsx(t.Button,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:p.default,onClick:()=>{j.setIsProductPickerOpen(s)}})}),d.map((t=>e.jsxs("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${a.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:t.image,onError:e=>{e.target.onerror=null,e.target.src="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),e.jsx(n.TitleSmall,{children:t.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:()=>{const e=d.filter((e=>e.id!==t.id));s===exports.DISCOUNT_PRODUCTS.ENTITLED?j.setEntitledProducts(e):j.setPrerequisiteProducts(e)}},{children:e.jsx(o.default,{width:14,color:a.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),t.id)))]})};return e.jsxs(l.DynamicCouponContainer,{children:[j.allowStaticCoupon&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(i.Dropdown,{options:D,width:"290px",placement:"bottom-start",onSelect:e=>{j.onChangeCouponType(e)}})})),e.jsx("div",{className:"input__wrapper"})]})),(j.selectedCouponType===s.DISCOUNT_TYPES.PERCENTAGE||j.selectedCouponType===s.DISCOUNT_TYPES.FIXED_AMOUNT)&&(()=>{var t,i,n,a;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:j.discountData.title,onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{title:e}))},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===(i=null===(t=j.discountData)||void 0===t?void 0:t.value)||void 0===i?void 0:i.toString(),labelText:"Discount code value",type:"number",onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{value:parseInt(e)}))},placeholder:j.selectedCouponType===s.DISCOUNT_TYPES.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:j.selectedCouponType===s.DISCOUNT_TYPES.FIXED_AMOUNT?null!==(n=j.currency)&&void 0!==n?n:"₹":void 0,suffixText:j.selectedCouponType===s.DISCOUNT_TYPES.PERCENTAGE?"%":void 0})}))]})),E(),!j.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===(a=j.discountData.probability)||void 0===a?void 0:a.toString(),onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})})),e.jsx("div",{className:"input__wrapper"})]}))]})})(),j.selectedCouponType===s.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:j.discountData.title,onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{title:e}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:18})})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:!j.hideProbability&&e.jsx(r.Input,{value:null===(t=j.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})}))]})),E()]})})(),j.selectedCouponType===s.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var t;return e.jsxs(l.DynamicCouponContainer,{children:[e.jsx("div",Object.assign({className:"input__rows"},{children:e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:20,flex:1}},{children:[e.jsx(r.Input,{value:j.discountData.title,onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{title:e}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"}),!j.hideProbability&&e.jsx(r.Input,{value:null===(t=j.discountData.probability)||void 0===t?void 0:t.toString(),type:"number",onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})]}))})),e.jsx(T,{}),g(exports.DISCOUNT_PRODUCTS.PREREQUISITE),e.jsx(T,{}),g(exports.DISCOUNT_PRODUCTS.ENTITLED),e.jsx(T,{}),e.jsx(n.TitleRegular,{children:"At a discount value"}),e.jsxs("div",Object.assign({style:{display:"flex",gap:18,alignItems:"center"}},{children:[e.jsx(u.RadioButton,{isActive:100!==j.discountData.value,onValueChange:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{value:void 0}))}}),e.jsx(n.BodySecondary,{children:"Percentage"}),100!==j.discountData.value&&e.jsx(r.Input,{variant:"small",onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),e.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[e.jsx(u.RadioButton,{isActive:100===j.discountData.value,onValueChange:e=>{e?j.setDiscountData(Object.assign(Object.assign({},j.discountData),{value:100})):j.setDiscountData(Object.assign(Object.assign({},j.discountData),{value:void 0}))}}),e.jsx(n.BodySecondary,{children:"Free"})]}))]})})(),j.selectedCouponType&&!j.hideExpiration&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:6,borderTop:`1px solid ${a.DEFAULT_THEME.colorsV2.stroke.primary}`,marginTop:12}}),e.jsx(d.CouponExpiration,{discountData:j.discountData,setDiscountData:j.setDiscountData})]}),!j.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:a.DEFAULT_THEME.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:e.jsx(c.default,{width:32,color:a.DEFAULT_THEME.colorsV2.content.primaryInverse})})),e.jsx(n.TitleMedium,{children:"No discount has been selected"}),e.jsx(n.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"),s=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../../../assets/icons/info.svg.js"),s=require("../../input/Input.js"),a=require("../../TypographyStyle.js"),i=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(s.Input,{onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{couponCode:t}))},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(s.Input,{maxCharLimit:18,labelText:"Coupon title",value:o.discountData.title,onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{title:t}))},placeholder:"Enter coupon title"})}))]})),t.jsx(s.Input,{labelText:"Coupon description",value:o.discountData.description,onChangeText:t=>{o.setDiscountData(Object.assign(Object.assign({},o.discountData),{description:t}))},placeholder:"Enter coupon description"}),!o.hideProbability&&t.jsx(s.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(`0${t}`):parseFloat(t)}))},placeholder:"Enter probability"}),o.discountAdminUrl&&t.jsxs("div",Object.assign({className:"info__container"},{children:[t.jsx(e.default,{height:18,width:18,color:i.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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/search.svg.js"),c=require("react"),o=require("../../constants/Theme.js"),s=require("../button/Button.js"),r=require("../input/Input.js"),l=require("../modals/styledModal.js"),n=require("../spinner/Spinner.js"),i=require("../tag/Tag.js"),d=require("./collectionScreen.js"),a=require("./productScreen.js"),u=require("./reducers.js"),h=require("./searchScreen.js"),p=require("./selectedScreen.js"),S=require("./style.js");exports.ProductPickerModal=j=>{const{storeId:C,selectedItems:x,onClose:v,visible:y,zIndex:g,limit:b}=j,[m,f]=c.useReducer(u.collectionsReducer,{}),[I,q]=c.useState("collections"),[P,T]=c.useState(""),[E,F]=c.useState(0),[O,R]=c.useState(!1),[k,D]=c.useState(0),[B,w]=c.useState(""),[L,M]=c.useState(!1),[z,G]=c.useState(!1),[$,A]=c.useState(),[_,H]=c.useReducer(u.selectedColectionsReducer,Object.keys(x).length>0?x:{});c.useEffect((()=>{R(!0),G(!0),j.collectionFetcher(E,C).then((e=>{f({type:"fetched",data:(null==e?void 0:e.collections)||{}}),R(!1),F((e=>e+1)),G(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(_||[]).forEach((t=>{var c;Object.keys((null===(c=_[t])||void 0===c?void 0:c.products)||[]).forEach((c=>{var o,s;Object.keys((null===(s=null===(o=_[t].products)||void 0===o?void 0:o[c])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),D(e)})),c.useEffect((()=>{var e;P&&!(null===(e=null==m?void 0:m[P])||void 0===e?void 0:e.products)&&(R(!0),j.productFetcher(P,C).then((e=>{Object.keys(e).length&&f({type:"productsFetched",data:{collectionId:P,products:e}}),R(!1)})).catch())}),[P]),c.useEffect((()=>{const e=setTimeout((()=>{B.length&&(M(!0),j.searchFetcher(C,B).then((e=>{A(e),q("searchProducts"),R(!1),M(!1)})))}),800);return()=>clearTimeout(e)}),[B]);const Y=()=>{H({type:"reset",data:{}})};return e.jsx(l.StyledModal,Object.assign({zIndex:g,open:y,onClose:()=>{v(),Y()},headingTitle:"collections"===I||"products"===I?"Select Products":"view"===I?"Selected Products":"searchProducts"===I?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:O?"Loading...":"Add",disabled:O||b&&k>b||!1,onClick:()=>{j.onAdd(_,k),Y()}},footerLeftCustomElement:b&&k>b?e.jsx(i.Tag,{tagText:`You can only select ${b} products`,type:"negative"}):k>0?e.jsx(s.Button,{onClick:()=>{q("view")},buttonText:`${k} products selected`,buttonType:"tertiaryGray"}):e.jsx(s.Button,{disabled:!0,buttonText:`${k} products selected`,buttonType:"tertiaryGray"})},{children:e.jsxs(S.ContainerStyle,{children:[!j.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===I||"searchProducts"===I)&&e.jsx("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(r.Input,{noErrorHint:!0,rightIcon:{icon:()=>L?e.jsx(n.Spinner,{size:"small",color:o.COLORS.content.primary}):e.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:B,onChangeText:e=>{e.length&&e.trim().length&&w(e)},placeholder:"Search products..."})}))}),e.jsxs(S.ScrollContainerStyle,{children:["collections"===I&&e.jsx(d.CollectionsScreen,{customCollectionRestriction:j.customCollectionRestriction,dataLoading:z,collections:m,selectedCollectionsDispatch:H,setCollectionId:T,setScreen:q,selectedCollections:_,collectionFetcher:j.collectionFetcher,storeId:C,collectionsDispatch:f,setSaveDisabled:R,pagingControls:{curPage:E,setCurPage:F}}),"products"===I&&P&&e.jsx(u.CollectionIdContext.Provider,Object.assign({value:P},{children:e.jsx(a.ProductsScreen,{hideInCollectionSearch:j.hideInCollectionSearch,customCollectionRestriction:j.customCollectionRestriction,productFetcher:j.productFetcher,setScreen:q,storeId:C,data:m[P],collectionsDispatch:f,selectedCollectionsDispatch:H,selectedData:_,setSaveDisabled:R,searchInCollectionFetcher:j.searchInCollectionFetcher})})),"view"===I&&e.jsx(p.SelectedScreen,{selectedCollections:_||{},selectedCollectionsDispatch:H,setScreen:q,collections:m}),"searchProducts"===I&&e.jsx(h.SearchScreen,{customCollectionRestriction:j.customCollectionRestriction,selectedCollections:_||{},searchedCollections:$||{},selectedCollectionsDispatch:H,setScreen:q,collections:m,onBackPress:()=>{w(""),A({})}})]})]})}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/search.svg.js"),c=require("react"),o=require("../../constants/Theme.js"),s=require("../button/Button.js"),r=require("../input/Input.js"),l=require("../modals/styledModal.js"),n=require("../spinner/Spinner.js"),i=require("../tag/Tag.js"),d=require("./collectionScreen.js"),a=require("./productScreen.js"),u=require("./reducers.js"),h=require("./searchScreen.js"),p=require("./selectedScreen.js"),S=require("./style.js");exports.ProductPickerModal=j=>{const{storeId:C,selectedItems:x,onClose:v,visible:y,zIndex:g,limit:b}=j,[m,f]=c.useReducer(u.collectionsReducer,{}),[I,q]=c.useState("collections"),[P,T]=c.useState(""),[E,F]=c.useState(0),[O,R]=c.useState(!1),[k,D]=c.useState(0),[B,w]=c.useState(""),[L,M]=c.useState(!1),[z,G]=c.useState(!1),[$,A]=c.useState(),[_,H]=c.useReducer(u.selectedColectionsReducer,Object.keys(x).length>0?x:{});c.useEffect((()=>{R(!0),G(!0),j.collectionFetcher(E,C).then((e=>{f({type:"fetched",data:(null==e?void 0:e.collections)||{}}),R(!1),F((e=>e+1)),G(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(_||[]).forEach((t=>{var c;Object.keys((null===(c=_[t])||void 0===c?void 0:c.products)||[]).forEach((c=>{var o,s;Object.keys((null===(s=null===(o=_[t].products)||void 0===o?void 0:o[c])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),D(e)})),c.useEffect((()=>{var e;P&&!(null===(e=null==m?void 0:m[P])||void 0===e?void 0:e.products)&&(R(!0),j.productFetcher(P,C).then((e=>{Object.keys(e).length&&f({type:"productsFetched",data:{collectionId:P,products:e}}),R(!1)})).catch())}),[P]),c.useEffect((()=>{const e=setTimeout((()=>{B.length&&(M(!0),j.searchFetcher(C,B).then((e=>{A(e),q("searchProducts"),R(!1),M(!1)})))}),800);return()=>clearTimeout(e)}),[B]);const Y=()=>{H({type:"reset",data:{}})};return e.jsx(l.StyledModal,Object.assign({zIndex:g,open:y,onClose:()=>{v(),Y()},headingTitle:"collections"===I||"products"===I?"Select Products":"view"===I?"Selected Products":"searchProducts"===I?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:O?"Loading...":"Add",disabled:O||k<1||b&&k>b||!1,onClick:()=>{j.onAdd(_,k),Y()}},footerLeftCustomElement:b&&k>b?e.jsx(i.Tag,{tagText:`You can only select ${b} products`,type:"negative"}):k>0?e.jsx(s.Button,{onClick:()=>{q("view")},buttonText:`${k} products selected`,buttonType:"tertiaryGray"}):e.jsx(s.Button,{disabled:!0,buttonText:`${k} products selected`,buttonType:"tertiaryGray"})},{children:e.jsxs(S.ContainerStyle,{children:[!j.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===I||"searchProducts"===I)&&e.jsx("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(r.Input,{noErrorHint:!0,rightIcon:{icon:()=>L?e.jsx(n.Spinner,{size:"small",color:o.COLORS.content.primary}):e.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:B,onChangeText:e=>{e.length&&e.trim().length&&w(e)},placeholder:"Search products..."})}))}),e.jsxs(S.ScrollContainerStyle,{children:["collections"===I&&e.jsx(d.CollectionsScreen,{customCollectionRestriction:j.customCollectionRestriction,dataLoading:z,collections:m,selectedCollectionsDispatch:H,setCollectionId:T,setScreen:q,selectedCollections:_,collectionFetcher:j.collectionFetcher,storeId:C,collectionsDispatch:f,setSaveDisabled:R,pagingControls:{curPage:E,setCurPage:F}}),"products"===I&&P&&e.jsx(u.CollectionIdContext.Provider,Object.assign({value:P},{children:e.jsx(a.ProductsScreen,{hideInCollectionSearch:j.hideInCollectionSearch,customCollectionRestriction:j.customCollectionRestriction,productFetcher:j.productFetcher,setScreen:q,storeId:C,data:m[P],collectionsDispatch:f,selectedCollectionsDispatch:H,selectedData:_,setSaveDisabled:R,searchInCollectionFetcher:j.searchInCollectionFetcher})})),"view"===I&&e.jsx(p.SelectedScreen,{selectedCollections:_||{},selectedCollectionsDispatch:H,setScreen:q,collections:m}),"searchProducts"===I&&e.jsx(h.SearchScreen,{customCollectionRestriction:j.customCollectionRestriction,selectedCollections:_||{},searchedCollections:$||{},selectedCollectionsDispatch:H,setScreen:q,collections:m,onBackPress:()=>{w(""),A({})}})]})]})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import{useState as i,useEffect as n}from"react";import{MIN_PURCHASE_REQUIREMENT as r,DISCOUNT_TARGET_TYPES as d,DISCOUNT_TYPES as s,DISCOUNT_TARGET_SELECTION as a,DISCOUNT_VALUE_TYPES as c}from"./type.js";import{Dropdown as l}from"../dropdown/Dropdown.js";import"../dropdown/DropdownPopover/index.js";import"../zeroState/ZeroState.js";import{TitleSmall as p,BodyCaption as u}from"../TypographyStyle.js";import{DEFAULT_THEME as m}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"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as b}from"../modals/styledModal.js";import{ProductPickerContent as y}from"../product-picker/ProductPickerModal.js";import{Tag as E}from"../tag/Tag.js";import{Tooltip as v}from"../tooltips/Tooltip.js";import P from"../../assets/icons/triangle_error.svg.js";import{StyledDiscountDialogueContainer as T,CouponTypeContainerStyled as g}from"./DiscountModal.styled.js";import{validateDiscountData as I}from"./DiscountUtils.js";import j,{DISCOUNT_PRODUCTS as C}from"./DynamicCoupon/DynamicCoupon.js";import h from"./StaticCoupon/StaticCoupon.js";const S=S=>{var O,D,N
|
|
1
|
+
import{jsxs as t,jsx as e,Fragment as o}from"react/jsx-runtime";import{useState as i,useEffect as n}from"react";import{MIN_PURCHASE_REQUIREMENT as r,DISCOUNT_TARGET_TYPES as d,DISCOUNT_TYPES as s,DISCOUNT_TARGET_SELECTION as a,DISCOUNT_VALUE_TYPES as c}from"./type.js";import{Dropdown as l}from"../dropdown/Dropdown.js";import"../dropdown/DropdownPopover/index.js";import"../zeroState/ZeroState.js";import{TitleSmall as p,BodyCaption as u}from"../TypographyStyle.js";import{DEFAULT_THEME as m}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"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as b}from"../modals/styledModal.js";import{ProductPickerContent as y}from"../product-picker/ProductPickerModal.js";import{Tag as E}from"../tag/Tag.js";import{Tooltip as v}from"../tooltips/Tooltip.js";import P from"../../assets/icons/triangle_error.svg.js";import{StyledDiscountDialogueContainer as T,CouponTypeContainerStyled as g}from"./DiscountModal.styled.js";import{validateDiscountData as I}from"./DiscountUtils.js";import j,{DISCOUNT_PRODUCTS as C}from"./DynamicCoupon/DynamicCoupon.js";import h from"./StaticCoupon/StaticCoupon.js";const S=S=>{var O,D,N;const[_,w]=i(),[f,A]=i(null!==(O=S.data)&&void 0!==O?O:{isStaticCoupon:!1}),[q,G]=i(!!(null===(D=S.data)||void 0===D?void 0:D.isStaticCoupon)),[M,L]=i(!0),[x,R]=i(),[k,F]=i(r.NA),[B,U]=i([]),[X,Y]=i([]),[H,Q]=i(0);n((()=>{let t;S.hideProbability||(t=z()),L(I(f,k,x,S.hideProbability||!1,t,q)),S.hideProbability||z()}),[]),n((()=>{let t;S.hideProbability||(t=z()),L(I(f,k,x,S.hideProbability||!1,t,q))}),[q,f,H,x,k]),n((()=>{var t,e;if(S.products){if(null===(t=S.data)||void 0===t?void 0:t.entitledProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));Y(t)}if(null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));U(t)}}}),[]),n((()=>{const t=X.map((t=>parseInt(t.id)));A(Object.assign(Object.assign({},f),{entitledProductIds:t}))}),[X]),n((()=>{const t=B.map((t=>parseInt(t.id)));A(Object.assign(Object.assign({},f),{prerequisiteProductIds:t}))}),[B]),n((()=>{f.targetType===d.SHIPPING_LINE?R(s.FREE_SHIPPING):f.targetSelection===a.ENTITLED?R(s.BUY_X_GET_Y):f.valueType===c.FIXED_AMOUNT?R(s.FIXED_AMOUNT):f.valueType===c.PERCENTAGE&&R(s.PERCENTAGE)}),[]);const V=[{value:s.FIXED_AMOUNT,label:"Fixed Amount",selected:x===s.FIXED_AMOUNT},{value:s.PERCENTAGE,label:"Percentage",selected:x===s.PERCENTAGE},{value:s.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:x===s.BUY_X_GET_Y},{value:s.FREE_SHIPPING,label:"Free shipping",selected:x===s.FREE_SHIPPING}],z=()=>{if(!S.quadrant||!S.probability)return;const t=[...S.probability];let e=[];t.length>=S.quadrant&&t.splice(S.quadrant-1,1),e=t;const o=e.reduce(((t,e)=>t+e),0)+(f.probability||0);return Q(o),o},$=t=>{const e=t.value;R(e),e===s.FREE_SHIPPING?(U([]),Y([]),A(Object.assign(Object.assign({},f),{value:100,targetSelection:a.ALL,targetType:d.SHIPPING_LINE,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.BUY_X_GET_Y?A(Object.assign(Object.assign({},f),{targetSelection:a.ENTITLED,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE})):e===s.PERCENTAGE?(U([]),Y([]),A(Object.assign(Object.assign({},f),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.FIXED_AMOUNT&&(U([]),Y([]),A(Object.assign(Object.assign({},f),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return t(b,Object.assign({open:S.isOpen,headingTitle:_?"Select Products":S.title,headingSubtitle:_?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e(o,{}):H<=1?e(E,{theme:"light",tagText:`Current probability sum: ${H}`,type:"white"}):e(v,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(E,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${H}`,type:"negative",LeadingIcon:P})})})),headerRightCustomElement:S.allowStaticCoupon||_?void 0:e(l,{options:V,width:"200px",placement:"bottom-start",size:"small",onSelect:t=>{$(t)}}),onClose:S.onClose,footerShadow:!0,primaryButton:_?{buttonType:"primary",onClick:()=>{w(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:M,onClick:()=>{f.isStaticCoupon?S.onSaveClicked({quadrant:f.quadrant,couponCode:f.couponCode,description:f.description,isStaticCoupon:f.isStaticCoupon,probability:f.probability,title:f.title}):S.onSaveClicked(f),A({})}},secondaryButton:_?{buttonType:"tertiaryGray",onClick:()=>{w(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!_&&t(T,{children:[S.allowStaticCoupon&&!_&&t(g,Object.assign({selectedDiv:q?1:2},{children:[t("div",Object.assign({className:"coupon-type__container",onClick:()=>{G(!0),A({isStaticCoupon:!0,couponCode:f.couponCode,description:f.description,quadrant:f.quadrant})}},{children:[e(p,Object.assign({style:q?{color:m.colorsV2.content.brand}:{}},{children:"Static code"})),e(u,Object.assign({style:q?{color:m.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),t("div",Object.assign({className:"coupon-type__container",onClick:()=>{A(Object.assign(Object.assign({},f),{isStaticCoupon:!1})),G(!1)}},{children:[e(p,Object.assign({style:q?{}:{color:m.colorsV2.content.brand}},{children:"Dynamic code"})),e(u,Object.assign({style:q?{}:{color:m.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),q&&!_&&e(h,{discountData:f,setDiscountData:A,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!q&&!_&&e(j,{currency:S.currency,entitledProducts:X,prerequisiteProducts:B,setEntitledProducts:Y,setPrerequisiteProducts:U,discountData:f,productPickerOpen:_,setIsProductPickerOpen:w,setDiscountData:A,selectedCouponType:x,setSelectedCouponType:R,selectedMinimumRequirement:k,setSelectedMinimumRequirement:F,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:$})]}),!!_&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(y,{show:!0,onSave:()=>{},products:null!==(N=S.products)&&void 0!==N?N:[],title:"Select Products",onClose:()=>{w(void 0)},selectedProducts:_===C.ENTITLED?X:B,setSelectedProducts:_===C.ENTITLED?Y:U,onSearchKeyChange:S.onProductSearch})}))]}))};export{S as DiscountModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DISCOUNT_TYPES as e,DISCOUNT_VALUE_TYPES as i,MIN_PURCHASE_REQUIREMENT as t,DISCOUNT_TARGET_TYPES as r,DISCOUNT_TARGET_SELECTION as n}from"./type.js";const u=(u,l,o,f,a,v)=>{var T,d;if(
|
|
1
|
+
import{DISCOUNT_TYPES as e,DISCOUNT_VALUE_TYPES as i,MIN_PURCHASE_REQUIREMENT as t,DISCOUNT_TARGET_TYPES as r,DISCOUNT_TARGET_SELECTION as n}from"./type.js";const u=(u,l,o,f,a,v)=>{var T,d;if(!u.title)return!0;if(!f){if(isNaN(u.probability))return!0;if((u.probability||0)>1)return!0;if((u.probability||0)<0)return!0;if(a>1)return!0}if(v){if(!(null==u?void 0:u.couponCode))return!0;if(!u.description)return!0}else{if(o&&o===e.FIXED_AMOUNT){if(u.valueType!==i.FIXED_AMOUNT)return!0;if(!(null==u?void 0:u.value)||(null==u?void 0:u.value)<=0)return!0;if(l===t.AMOUNT&&(!u.minAmount||(null==u?void 0:u.minAmount)<=0))return!0;if(l===t.QUANTITY&&(!(null==u?void 0:u.minQuantity)||(null==u?void 0:u.minQuantity)<=0))return!0;if(u.targetType!==r.LINE_ITEM)return!0;if(u.targetSelection!==n.ALL)return!0}else if(o&&o===e.PERCENTAGE){if(u.valueType!==i.PERCENTAGE)return!0;if(!(null==u?void 0:u.value)||(null==u?void 0:u.value)<=0||(null==u?void 0:u.value)>100)return!0;if(l===t.AMOUNT&&(!u.minAmount||(null==u?void 0:u.minAmount)<=0))return!0;if(l===t.QUANTITY&&(!(null==u?void 0:u.minQuantity)||(null==u?void 0:u.minQuantity)<=0))return!0;if(u.targetType!==r.LINE_ITEM)return!0;if(u.targetSelection!==n.ALL)return!0}else if(o&&o===e.BUY_X_GET_Y){if(!(u.entitledQuantity&&(null===(T=u.entitledProductIds)||void 0===T?void 0:T.length)&&u.prerequisiteQuantity&&(null===(d=u.prerequisiteProductIds)||void 0===d?void 0:d.length)))return!0;if(u.valueType!==i.PERCENTAGE)return!0;if(!u.value)return!0;if(u.value<=0||u.value>100)return!0;if(u.targetSelection!==n.ENTITLED)return!0;if(u.targetType!==r.LINE_ITEM)return!0}else{if(!o||!e.FREE_SHIPPING)return!0;if(u.valueType!==i.PERCENTAGE)return!0;if(u.targetType!==r.SHIPPING_LINE)return!0;if(100!==u.value)return!0;if(u.targetSelection!==n.ALL)return!0;if(l===t.AMOUNT&&(!u.minAmount||(null==u?void 0:u.minAmount)<=0))return!0;if(l===t.QUANTITY&&(!(null==u?void 0:u.minQuantity)||(null==u?void 0:u.minQuantity)<=0))return!0}if(null!==u.expireAfter&&void 0!==u.expireAfter&&u.expireAfter<=0)return!0}return!1};export{u as validateDiscountData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{useEffect as n}from"react";import{Button as s}from"../../button/Button.js";import{DISCOUNT_TYPES as a,MIN_PURCHASE_REQUIREMENT as o}from"../type.js";import{Dropdown as r}from"../../dropdown/Dropdown.js";import"../../dropdown/DropdownPopover/index.js";import"../../zeroState/ZeroState.js";import{TitleRegular as l,BodySecondary as c,TitleMedium as d,BodyPrimary as u,TitleSmall as p}from"../../TypographyStyle.js";import{DEFAULT_THEME as m}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{DynamicCouponContainer as v}from"../DiscountModal.styled.js";import{CouponExpiration as j}from"../CouponExpiration/CouponExpiration.js";import{RadioButton as D}from"../../radioButton/RadioButton.js";import h from"../../../assets/icons/cursor.svg.js";import y from"../../../assets/icons/plus.svg.js";var T;function O(){return null}!function(e){e.ENTITLED="entitled",e.PREREQUISITE="prerequisite"}(T||(T={}));const x=x=>{var E;n((()=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{isStaticCoupon:!1}))}),[]);const _=[{value:a.FIXED_AMOUNT,label:"Fixed Amount",selected:x.selectedCouponType===a.FIXED_AMOUNT},{value:a.PERCENTAGE,label:"Percentage",selected:x.selectedCouponType===a.PERCENTAGE},{value:a.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:x.selectedCouponType===a.BUY_X_GET_Y},{value:a.FREE_SHIPPING,label:"Free shipping",selected:x.selectedCouponType===a.FREE_SHIPPING}],C=[{selected:x.selectedMinimumRequirement===o.NA,label:"No minimum requirements",value:o.NA},{selected:x.selectedMinimumRequirement===o.AMOUNT,label:`Minimum purchase amount (${null!==(E=x.currency)&&void 0!==E?E:"₹"})`,value:o.AMOUNT},{selected:x.selectedMinimumRequirement===o.QUANTITY,label:"Minimum quantity of items",value:o.QUANTITY}],N=()=>{var i,n,s,a;return e("div",Object.assign({className:"input__rows"},{children:[e("div",Object.assign({className:"input__wrapper"},{children:[t(c,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),t(r,{options:C,placement:"bottom-start",onSelect:e=>{const t=e.value;x.setSelectedMinimumRequirement(t),x.setDiscountData(Object.assign(Object.assign({},x.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),t("div",Object.assign({className:"input__wrapper"},{children:x.selectedMinimumRequirement!==o.NA&&t(b,{value:x.selectedMinimumRequirement===o.AMOUNT?null!==(n=null===(i=x.discountData.minAmount)||void 0===i?void 0:i.toString())&&void 0!==n?n:"":null!==(a=null===(s=x.discountData.minQuantity)||void 0===s?void 0:s.toString())&&void 0!==a?a:"",onChangeText:e=>{x.selectedMinimumRequirement===o.AMOUNT?x.setDiscountData(Object.assign(Object.assign({},x.discountData),{minAmount:parseInt(e)})):x.selectedMinimumRequirement===o.QUANTITY&&x.setDiscountData(Object.assign(Object.assign({},x.discountData),{minQuantity:parseInt(e)}))},labelText:x.selectedMinimumRequirement===o.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",type:"number",placeholder:x.selectedMinimumRequirement===o.AMOUNT?"1000.00":"2"})}))]}))},f=n=>{var a,o;const r=n===T.ENTITLED?x.entitledProducts:x.prerequisiteProducts;return e(i,{children:[t(l,{children:n===T.PREREQUISITE?"Customer spends":"Customer gets"}),e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:n===T.ENTITLED?null===(a=x.discountData.entitledQuantity)||void 0===a?void 0:a.toString():null===(o=x.discountData.prerequisiteQuantity)||void 0===o?void 0:o.toString(),type:"number",onChangeText:e=>{n===T.ENTITLED?x.setDiscountData(Object.assign(Object.assign({},x.discountData),{entitledQuantity:parseInt(e)})):x.setDiscountData(Object.assign(Object.assign({},x.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),t("div",{className:"input__wrapper"})]})),t("div",{children:t(s,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:y,onClick:()=>{x.setIsProductPickerOpen(n)}})}),r.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${m.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="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),t(p,{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:()=>{const e=r.filter((e=>e.id!==i.id));n===T.ENTITLED?x.setEntitledProducts(e):x.setPrerequisiteProducts(e)}},{children:t(g,{width:14,color:m.colorsV2.content.primary})}))}))]}),i.id)))]})};return e(v,{children:[x.allowStaticCoupon&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(r,{options:_,width:"290px",placement:"bottom-start",onSelect:e=>{x.onChangeCouponType(e)}})})),t("div",{className:"input__wrapper"})]})),(x.selectedCouponType===a.PERCENTAGE||x.selectedCouponType===a.FIXED_AMOUNT)&&(()=>{var n,s,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:x.discountData.title,onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{title:e}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:null===(s=null===(n=x.discountData)||void 0===n?void 0:n.value)||void 0===s?void 0:s.toString(),labelText:"Discount code value",type:"number",onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{value:parseInt(e)}))},placeholder:x.selectedCouponType===a.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:x.selectedCouponType===a.FIXED_AMOUNT?null!==(o=x.currency)&&void 0!==o?o:"₹":void 0,suffixText:x.selectedCouponType===a.PERCENTAGE?"%":void 0})}))]})),N(),!x.hideProbability&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{type:"number",value:null===(r=x.discountData.probability)||void 0===r?void 0:r.toString(),onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})})),t("div",{className:"input__wrapper"})]}))]})})(),x.selectedCouponType===a.FREE_SHIPPING&&(()=>{var n;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(b,{value:x.discountData.title,onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{title:e}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:18})})),t("div",Object.assign({className:"input__wrapper"},{children:!x.hideProbability&&t(b,{value:null===(n=x.discountData.probability)||void 0===n?void 0:n.toString(),type:"number",onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})}))]})),N()]})})(),x.selectedCouponType===a.BUY_X_GET_Y&&(()=>{var i;return e(v,{children:[t("div",Object.assign({className:"input__rows"},{children:e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:20,flex:1}},{children:[t(b,{value:x.discountData.title,onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{title:e}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"}),!x.hideProbability&&t(b,{value:null===(i=x.discountData.probability)||void 0===i?void 0:i.toString(),type:"number",onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})]}))})),t(O,{}),f(T.PREREQUISITE),t(O,{}),f(T.ENTITLED),t(O,{}),t(l,{children:"At a discount value"}),e("div",Object.assign({style:{display:"flex",gap:18,alignItems:"center"}},{children:[t(D,{isActive:100!==x.discountData.value,onValueChange:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{value:void 0}))}}),t(c,{children:"Percentage"}),100!==x.discountData.value&&t(b,{variant:"small",onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(D,{isActive:100===x.discountData.value,onValueChange:e=>{e?x.setDiscountData(Object.assign(Object.assign({},x.discountData),{value:100})):x.setDiscountData(Object.assign(Object.assign({},x.discountData),{value:void 0}))}}),t(c,{children:"Free"})]}))]})})(),x.selectedCouponType&&!x.hideExpiration&&e(i,{children:[t("div",{style:{height:6,borderTop:`1px solid ${m.colorsV2.stroke.primary}`,marginTop:12}}),t(j,{discountData:x.discountData,setDiscountData:x.setDiscountData})]}),!x.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:m.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:t(h,{width:32,color:m.colorsV2.content.primaryInverse})})),t(d,{children:"No discount has been selected"}),t(u,{children:"Please select a discount type"})]}))]})};export{T as DISCOUNT_PRODUCTS,x as default};
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{Button as n}from"../../button/Button.js";import"react";import{DISCOUNT_TYPES as s,MIN_PURCHASE_REQUIREMENT as a}from"../type.js";import{Dropdown as o}from"../../dropdown/Dropdown.js";import"../../dropdown/DropdownPopover/index.js";import"../../zeroState/ZeroState.js";import{TitleRegular as r,BodySecondary as l,TitleMedium as c,BodyPrimary as d,TitleSmall as u}from"../../TypographyStyle.js";import{DEFAULT_THEME as p}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 m}from"../../input/Input.js";import b 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{DynamicCouponContainer as g}from"../DiscountModal.styled.js";import{CouponExpiration as v}from"../CouponExpiration/CouponExpiration.js";import{RadioButton as h}from"../../radioButton/RadioButton.js";import j from"../../../assets/icons/cursor.svg.js";import y from"../../../assets/icons/plus.svg.js";var D;function T(){return null}!function(e){e.ENTITLED="entitled",e.PREREQUISITE="prerequisite"}(D||(D={}));const O=O=>{var x;const E=[{value:s.FIXED_AMOUNT,label:"Fixed Amount",selected:O.selectedCouponType===s.FIXED_AMOUNT},{value:s.PERCENTAGE,label:"Percentage",selected:O.selectedCouponType===s.PERCENTAGE},{value:s.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:O.selectedCouponType===s.BUY_X_GET_Y},{value:s.FREE_SHIPPING,label:"Free shipping",selected:O.selectedCouponType===s.FREE_SHIPPING}],_=[{selected:O.selectedMinimumRequirement===a.NA,label:"No minimum requirements",value:a.NA},{selected:O.selectedMinimumRequirement===a.AMOUNT,label:`Minimum purchase amount (${null!==(x=O.currency)&&void 0!==x?x:"₹"})`,value:a.AMOUNT},{selected:O.selectedMinimumRequirement===a.QUANTITY,label:"Minimum quantity of items",value:a.QUANTITY}],N=()=>{var i,n,s,r;return e("div",Object.assign({className:"input__rows"},{children:[e("div",Object.assign({className:"input__wrapper"},{children:[t(l,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),t(o,{options:_,placement:"bottom-start",onSelect:e=>{const t=e.value;O.setSelectedMinimumRequirement(t),O.setDiscountData(Object.assign(Object.assign({},O.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),t("div",Object.assign({className:"input__wrapper"},{children:O.selectedMinimumRequirement!==a.NA&&t(m,{value:O.selectedMinimumRequirement===a.AMOUNT?null!==(n=null===(i=O.discountData.minAmount)||void 0===i?void 0:i.toString())&&void 0!==n?n:"":null!==(r=null===(s=O.discountData.minQuantity)||void 0===s?void 0:s.toString())&&void 0!==r?r:"",onChangeText:e=>{O.selectedMinimumRequirement===a.AMOUNT?O.setDiscountData(Object.assign(Object.assign({},O.discountData),{minAmount:parseInt(e)})):O.selectedMinimumRequirement===a.QUANTITY&&O.setDiscountData(Object.assign(Object.assign({},O.discountData),{minQuantity:parseInt(e)}))},labelText:O.selectedMinimumRequirement===a.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",type:"number",placeholder:O.selectedMinimumRequirement===a.AMOUNT?"1000.00":"2"})}))]}))},C=s=>{var a,o;const l=s===D.ENTITLED?O.entitledProducts:O.prerequisiteProducts;return e(i,{children:[t(r,{children:s===D.PREREQUISITE?"Customer spends":"Customer gets"}),e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(m,{value:s===D.ENTITLED?null===(a=O.discountData.entitledQuantity)||void 0===a?void 0:a.toString():null===(o=O.discountData.prerequisiteQuantity)||void 0===o?void 0:o.toString(),type:"number",onChangeText:e=>{s===D.ENTITLED?O.setDiscountData(Object.assign(Object.assign({},O.discountData),{entitledQuantity:parseInt(e)})):O.setDiscountData(Object.assign(Object.assign({},O.discountData),{prerequisiteQuantity:parseInt(e)}))},labelText:"Add quantity",placeholder:"Add quantity"})})),t("div",{className:"input__wrapper"})]})),t("div",{children:t(n,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:y,onClick:()=>{O.setIsProductPickerOpen(s)}})}),l.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${p.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="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"},style:{height:40,width:40,objectFit:"cover",borderRadius:4}}),t(u,{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:()=>{const e=l.filter((e=>e.id!==i.id));s===D.ENTITLED?O.setEntitledProducts(e):O.setPrerequisiteProducts(e)}},{children:t(b,{width:14,color:p.colorsV2.content.primary})}))}))]}),i.id)))]})};return e(g,{children:[O.allowStaticCoupon&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(o,{options:E,width:"290px",placement:"bottom-start",onSelect:e=>{O.onChangeCouponType(e)}})})),t("div",{className:"input__wrapper"})]})),(O.selectedCouponType===s.PERCENTAGE||O.selectedCouponType===s.FIXED_AMOUNT)&&(()=>{var 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(m,{value:O.discountData.title,onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{title:e}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"})})),t("div",Object.assign({className:"input__wrapper"},{children:t(m,{value:null===(a=null===(n=O.discountData)||void 0===n?void 0:n.value)||void 0===a?void 0:a.toString(),labelText:"Discount code value",type:"number",onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{value:parseInt(e)}))},placeholder:O.selectedCouponType===s.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:O.selectedCouponType===s.FIXED_AMOUNT?null!==(o=O.currency)&&void 0!==o?o:"₹":void 0,suffixText:O.selectedCouponType===s.PERCENTAGE?"%":void 0})}))]})),N(),!O.hideProbability&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(m,{type:"number",value:null===(r=O.discountData.probability)||void 0===r?void 0:r.toString(),onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})})),t("div",{className:"input__wrapper"})]}))]})})(),O.selectedCouponType===s.FREE_SHIPPING&&(()=>{var n;return e(i,{children:[e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(m,{value:O.discountData.title,onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{title:e}))},labelText:"Code title",placeholder:"eg: Flat 50% Off",maxCharLimit:18})})),t("div",Object.assign({className:"input__wrapper"},{children:!O.hideProbability&&t(m,{value:null===(n=O.discountData.probability)||void 0===n?void 0:n.toString(),type:"number",onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})}))]})),N()]})})(),O.selectedCouponType===s.BUY_X_GET_Y&&(()=>{var i;return e(g,{children:[t("div",Object.assign({className:"input__rows"},{children:e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:20,flex:1}},{children:[t(m,{value:O.discountData.title,onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{title:e}))},maxCharLimit:18,labelText:"Code title",placeholder:"eg: Flat 50% Off"}),!O.hideProbability&&t(m,{value:null===(i=O.discountData.probability)||void 0===i?void 0:i.toString(),type:"number",onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals eg: 0.2, 0.5, 0.75"})]}))})),t(T,{}),C(D.PREREQUISITE),t(T,{}),C(D.ENTITLED),t(T,{}),t(r,{children:"At a discount value"}),e("div",Object.assign({style:{display:"flex",gap:18,alignItems:"center"}},{children:[t(h,{isActive:100!==O.discountData.value,onValueChange:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{value:void 0}))}}),t(l,{children:"Percentage"}),100!==O.discountData.value&&t(m,{variant:"small",onChangeText:e=>{O.setDiscountData(Object.assign(Object.assign({},O.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Enter percentage eg: 10%",suffixText:"%",width:"238px"})]})),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(h,{isActive:100===O.discountData.value,onValueChange:e=>{e?O.setDiscountData(Object.assign(Object.assign({},O.discountData),{value:100})):O.setDiscountData(Object.assign(Object.assign({},O.discountData),{value:void 0}))}}),t(l,{children:"Free"})]}))]})})(),O.selectedCouponType&&!O.hideExpiration&&e(i,{children:[t("div",{style:{height:6,borderTop:`1px solid ${p.colorsV2.stroke.primary}`,marginTop:12}}),t(v,{discountData:O.discountData,setDiscountData:O.setDiscountData})]}),!O.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:p.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:t(j,{width:32,color:p.colorsV2.content.primaryInverse})})),t(c,{children:"No discount has been selected"}),t(d,{children:"Please select a discount type"})]}))]})};export{D as DISCOUNT_PRODUCTS,O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as
|
|
1
|
+
import{jsxs as t,jsx as e}from"react/jsx-runtime";import i from"../../../assets/icons/info.svg.js";import{Input as a}from"../../input/Input.js";import{BodySecondaryLink as o,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:[e("div",Object.assign({className:"static-input__wrapper"},{children:e(a,{onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{couponCode:t}))},labelText:"Coupon code",value:r.discountData.couponCode,placeholder:"Enter code created on shopify"})})),e("div",Object.assign({className:"static-input__wrapper"},{children:e(a,{maxCharLimit:18,labelText:"Coupon title",value:r.discountData.title,onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{title:t}))},placeholder:"Enter coupon title"})}))]})),e(a,{labelText:"Coupon description",value:r.discountData.description,onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{description:t}))},placeholder:"Enter coupon description"}),!r.hideProbability&&e(a,{labelText:"Probability",value:r.discountData.probability?r.discountData.probability.toString():"",onChangeText:t=>{r.setDiscountData(Object.assign(Object.assign({},r.discountData),{probability:t.startsWith(".")?parseFloat(`0${t}`):parseFloat(t)}))},placeholder:"Enter probability"}),r.discountAdminUrl&&t("div",Object.assign({className:"info__container"},{children:[e(i,{height:18,width:18,color:s.colorsV2.content.secondary}),e(o,Object.assign({onClick:()=>{window.open(r.discountAdminUrl,"_blank")}},{children:"Click here"})),e(n,{children:"to create discount code on Shopify"})]}))]});export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as s,useState as r,useEffect as l}from"react";import{COLORS as i}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 p}from"../tag/Tag.js";import{CollectionsScreen as u}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{collectionsReducer as C,selectedColectionsReducer as v,CollectionIdContext as g}from"./reducers.js";import{SearchScreen as y}from"./searchScreen.js";import{SelectedScreen as f}from"./selectedScreen.js";import{ContainerStyle as j,ScrollContainerStyle as b}from"./style.js";const S=S=>{const{storeId:x,selectedItems:I,onClose:T,visible:P,zIndex:F,limit:D}=S,[k,E]=s(C,{}),[O,R]=r("collections"),[w,B]=r(""),[z,G]=r(0),[L,$]=r(!1),[A,H]=r(0),[M,Y]=r(""),[q,J]=r(!1),[K,N]=r(!1),[Q,U]=r(),[V,W]=s(v,Object.keys(I).length>0?I:{});l((()=>{$(!0),N(!0),S.collectionFetcher(z,x).then((e=>{E({type:"fetched",data:(null==e?void 0:e.collections)||{}}),$(!1),G((e=>e+1)),N(!1)})).catch()}),[]),l((()=>{let e=0;Object.keys(V||[]).forEach((t=>{var o;Object.keys((null===(o=V[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=V[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),H(e)})),l((()=>{var e;w&&!(null===(e=null==k?void 0:k[w])||void 0===e?void 0:e.products)&&($(!0),S.productFetcher(w,x).then((e=>{Object.keys(e).length&&E({type:"productsFetched",data:{collectionId:w,products:e}}),$(!1)})).catch())}),[w]),l((()=>{const e=setTimeout((()=>{M.length&&(J(!0),S.searchFetcher(x,M).then((e=>{U(e),R("searchProducts"),$(!1),J(!1)})))}),800);return()=>clearTimeout(e)}),[M]);const X=()=>{W({type:"reset",data:{}})};return e(a,Object.assign({zIndex:F,open:P,onClose:()=>{T(),X()},headingTitle:"collections"===O||"products"===O?"Select Products":"view"===O?"Selected Products":"searchProducts"===O?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:L?"Loading...":"Add",disabled:L||D&&A>D||!1,onClick:()=>{S.onAdd(V,A),X()}},footerLeftCustomElement:D&&A>D?e(p,{tagText:`You can only select ${D} products`,type:"negative"}):e(n,A>0?{onClick:()=>{R("view")},buttonText:`${A} products selected`,buttonType:"tertiaryGray"}:{disabled:!0,buttonText:`${A} products selected`,buttonType:"tertiaryGray"})},{children:t(j,{children:[!S.hideGlobalSearch&&e(o,{children:("collections"===O||"searchProducts"===O)&&e("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e(d,{noErrorHint:!0,rightIcon:{icon:()=>q?e(h,{size:"small",color:i.content.primary}):e(c,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length&&Y(e)},placeholder:"Search products..."})}))}),t(b,{children:["collections"===O&&e(u,{customCollectionRestriction:S.customCollectionRestriction,dataLoading:K,collections:k,selectedCollectionsDispatch:W,setCollectionId:B,setScreen:R,selectedCollections:V,collectionFetcher:S.collectionFetcher,storeId:x,collectionsDispatch:E,setSaveDisabled:$,pagingControls:{curPage:z,setCurPage:G}}),"products"===O&&w&&e(g.Provider,Object.assign({value:w},{children:e(m,{hideInCollectionSearch:S.hideInCollectionSearch,customCollectionRestriction:S.customCollectionRestriction,productFetcher:S.productFetcher,setScreen:R,storeId:x,data:k[w],collectionsDispatch:E,selectedCollectionsDispatch:W,selectedData:V,setSaveDisabled:$,searchInCollectionFetcher:S.searchInCollectionFetcher})})),"view"===O&&e(f,{selectedCollections:V||{},selectedCollectionsDispatch:W,setScreen:R,collections:k}),"searchProducts"===O&&e(y,{customCollectionRestriction:S.customCollectionRestriction,selectedCollections:V||{},searchedCollections:Q||{},selectedCollectionsDispatch:W,setScreen:R,collections:k,onBackPress:()=>{Y(""),U({})}})]})]})}))};export{S as ProductPickerModal};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as s,useState as r,useEffect as l}from"react";import{COLORS as i}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 p}from"../tag/Tag.js";import{CollectionsScreen as u}from"./collectionScreen.js";import{ProductsScreen as m}from"./productScreen.js";import{collectionsReducer as C,selectedColectionsReducer as v,CollectionIdContext as g}from"./reducers.js";import{SearchScreen as y}from"./searchScreen.js";import{SelectedScreen as f}from"./selectedScreen.js";import{ContainerStyle as j,ScrollContainerStyle as b}from"./style.js";const S=S=>{const{storeId:x,selectedItems:I,onClose:T,visible:P,zIndex:F,limit:D}=S,[k,E]=s(C,{}),[O,R]=r("collections"),[w,B]=r(""),[z,G]=r(0),[L,$]=r(!1),[A,H]=r(0),[M,Y]=r(""),[q,J]=r(!1),[K,N]=r(!1),[Q,U]=r(),[V,W]=s(v,Object.keys(I).length>0?I:{});l((()=>{$(!0),N(!0),S.collectionFetcher(z,x).then((e=>{E({type:"fetched",data:(null==e?void 0:e.collections)||{}}),$(!1),G((e=>e+1)),N(!1)})).catch()}),[]),l((()=>{let e=0;Object.keys(V||[]).forEach((t=>{var o;Object.keys((null===(o=V[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=V[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),H(e)})),l((()=>{var e;w&&!(null===(e=null==k?void 0:k[w])||void 0===e?void 0:e.products)&&($(!0),S.productFetcher(w,x).then((e=>{Object.keys(e).length&&E({type:"productsFetched",data:{collectionId:w,products:e}}),$(!1)})).catch())}),[w]),l((()=>{const e=setTimeout((()=>{M.length&&(J(!0),S.searchFetcher(x,M).then((e=>{U(e),R("searchProducts"),$(!1),J(!1)})))}),800);return()=>clearTimeout(e)}),[M]);const X=()=>{W({type:"reset",data:{}})};return e(a,Object.assign({zIndex:F,open:P,onClose:()=>{T(),X()},headingTitle:"collections"===O||"products"===O?"Select Products":"view"===O?"Selected Products":"searchProducts"===O?"Searched Products":void 0,footerShadow:!0,centralContainerStyles:{width:"480px"},primaryButton:{buttonText:L?"Loading...":"Add",disabled:L||A<1||D&&A>D||!1,onClick:()=>{S.onAdd(V,A),X()}},footerLeftCustomElement:D&&A>D?e(p,{tagText:`You can only select ${D} products`,type:"negative"}):e(n,A>0?{onClick:()=>{R("view")},buttonText:`${A} products selected`,buttonType:"tertiaryGray"}:{disabled:!0,buttonText:`${A} products selected`,buttonType:"tertiaryGray"})},{children:t(j,{children:[!S.hideGlobalSearch&&e(o,{children:("collections"===O||"searchProducts"===O)&&e("div",Object.assign({style:{padding:"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e(d,{noErrorHint:!0,rightIcon:{icon:()=>q?e(h,{size:"small",color:i.content.primary}):e(c,{})},id:"listInput",height:"24px",type:"text",value:M,onChangeText:e=>{e.length&&e.trim().length&&Y(e)},placeholder:"Search products..."})}))}),t(b,{children:["collections"===O&&e(u,{customCollectionRestriction:S.customCollectionRestriction,dataLoading:K,collections:k,selectedCollectionsDispatch:W,setCollectionId:B,setScreen:R,selectedCollections:V,collectionFetcher:S.collectionFetcher,storeId:x,collectionsDispatch:E,setSaveDisabled:$,pagingControls:{curPage:z,setCurPage:G}}),"products"===O&&w&&e(g.Provider,Object.assign({value:w},{children:e(m,{hideInCollectionSearch:S.hideInCollectionSearch,customCollectionRestriction:S.customCollectionRestriction,productFetcher:S.productFetcher,setScreen:R,storeId:x,data:k[w],collectionsDispatch:E,selectedCollectionsDispatch:W,selectedData:V,setSaveDisabled:$,searchInCollectionFetcher:S.searchInCollectionFetcher})})),"view"===O&&e(f,{selectedCollections:V||{},selectedCollectionsDispatch:W,setScreen:R,collections:k}),"searchProducts"===O&&e(y,{customCollectionRestriction:S.customCollectionRestriction,selectedCollections:V||{},searchedCollections:Q||{},selectedCollectionsDispatch:W,setScreen:R,collections:k,onBackPress:()=>{Y(""),U({})}})]})]})}))};export{S as ProductPickerModal};
|