@bikdotai/bik-component-library 0.0.291 → 0.0.292-beta-discount-collection
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/QueryBuilder/helpers/MetaCustomProcessor.d.ts +1 -1
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/discount-modal/DiscountModal.d.ts +3 -1
- 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.d.ts +7 -1
- package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
- package/dist/cjs/components/product-picker/type.d.ts +15 -5
- package/dist/cjs/components/stepper/WorkingStepper.d.ts +1 -0
- package/dist/cjs/components/tooltips/Tooltip.d.ts +1 -0
- package/dist/cjs/components/tooltips/Tooltip.js +1 -1
- package/dist/esm/components/QueryBuilder/helpers/MetaCustomProcessor.d.ts +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/discount-modal/DiscountModal.d.ts +3 -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.d.ts +7 -1
- package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
- package/dist/esm/components/product-picker/type.d.ts +15 -5
- package/dist/esm/components/stepper/WorkingStepper.d.ts +1 -0
- package/dist/esm/components/tooltips/Tooltip.d.ts +1 -0
- package/dist/esm/components/tooltips/Tooltip.js +1 -1
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ export declare class MetaCustomProcessor {
|
|
|
36
36
|
value: {
|
|
37
37
|
operator: string;
|
|
38
38
|
dataType: import("../types").QueryBuilderConnectorType;
|
|
39
|
-
value?: string | number |
|
|
39
|
+
value?: string | number | string[] | number[] | Date | Date[] | undefined;
|
|
40
40
|
};
|
|
41
41
|
key: string;
|
|
42
42
|
refresh?: boolean | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ICouponData } from "./type";
|
|
3
|
-
import { Product } from "../product-picker/type";
|
|
3
|
+
import { Collection, Product } from "../product-picker/type";
|
|
4
4
|
export interface DiscountDialogueI {
|
|
5
5
|
hideOption?: 'static' | 'dynamic';
|
|
6
6
|
isOpen: boolean;
|
|
@@ -11,11 +11,13 @@ export interface DiscountDialogueI {
|
|
|
11
11
|
data?: ICouponData;
|
|
12
12
|
onSaveClicked: (discountData: ICouponData) => void;
|
|
13
13
|
onProductSearch: (key: string) => Promise<Product[]>;
|
|
14
|
+
onCollectionSearch: (key: string) => Promise<Collection[]>;
|
|
14
15
|
hideExpiration?: boolean;
|
|
15
16
|
hideProbability?: boolean;
|
|
16
17
|
probability?: number[];
|
|
17
18
|
quadrant?: number;
|
|
18
19
|
products?: Product[];
|
|
20
|
+
collection?: Collection[];
|
|
19
21
|
discountAdminUrl?: string;
|
|
20
22
|
currency?: string;
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("./type.js");require("../dropdown/DropdownPopover/index.js");var i=require("../dropdown/Dropdown.js");require("../dropdown/ChipDropdown.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"),p=require("./DiscountUtils.js"),T=require("./DynamicCoupon/DynamicCoupon.js"),E=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=S=>{var C,I,P,_;const[y,O]=t.useState(),[b,D]=t.useState(null!==(C=S.data)&&void 0!==C?C:"string"==typeof S.hideOption?{isStaticCoupon:"dynamic"===S.hideOption}:{isStaticCoupon:!1}),[N,j]=t.useState(!0),[v,U]=t.useState(),[m,g]=t.useState((null===(I=S.data)||void 0===I?void 0:I.minAmount)?o.MIN_PURCHASE_REQUIREMENT.AMOUNT:(null===(P=S.data)||void 0===P?void 0:P.minQuantity)?o.MIN_PURCHASE_REQUIREMENT.QUANTITY:o.MIN_PURCHASE_REQUIREMENT.NA),[h,q]=t.useState([]),[A,x]=t.useState([]),[R,Y]=t.useState(0);t.useEffect((()=>{let e;S.hideProbability||(e=M()),j(p.validateDiscountData(b,m,v,S.hideProbability||!1,e,!!b.isStaticCoupon)),S.hideProbability||M()}),[]),t.useEffect((()=>{let e;S.hideProbability||(e=M()),j(p.validateDiscountData(b,m,v,S.hideProbability||!1,e,!!b.isStaticCoupon))}),[b,R,v,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))}));x(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))}));q(e)}}}),[]),t.useEffect((()=>{const e=A.map((e=>parseInt(e.id)));D(Object.assign(Object.assign({},b),{entitledProductIds:e}))}),[A]),t.useEffect((()=>{const e=h.map((e=>parseInt(e.id)));D(Object.assign(Object.assign({},b),{prerequisiteProductIds:e}))}),[h]),t.useEffect((()=>{b.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?U(o.DISCOUNT_TYPES.FREE_SHIPPING):b.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?U(o.DISCOUNT_TYPES.BUY_X_GET_Y):b.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?U(o.DISCOUNT_TYPES.FIXED_AMOUNT):b.valueType===o.DISCOUNT_VALUE_TYPES.PERCENTAGE&&U(o.DISCOUNT_TYPES.PERCENTAGE)}),[]);const L=[{value:o.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:v===o.DISCOUNT_TYPES.FIXED_AMOUNT},{value:o.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:v===o.DISCOUNT_TYPES.PERCENTAGE},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:v===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:v===o.DISCOUNT_TYPES.FREE_SHIPPING}],M=()=>{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 Y(parseFloat(o.toFixed(4))),parseFloat(o.toFixed(4))},w=e=>{const t=e.value;U(t),t===o.DISCOUNT_TYPES.FREE_SHIPPING?(q([]),x([]),D(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?D(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?(q([]),x([]),D(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&&(q([]),x([]),D(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:y?"Select Products":S.title,headingSubtitle:y?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e.jsx(e.Fragment,{}):R<=1?e.jsx(a.Tag,{theme:"light",tagText:`Current probability sum: ${R}`,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: ${R}`,type:"negative",LeadingIcon:c.default})})})),headerRightCustomElement:S.allowStaticCoupon||y?void 0:e.jsx(i.Dropdown,{options:L,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{w(e)}}),onClose:S.onClose,footerShadow:!0,primaryButton:y?{buttonType:"primary",onClick:()=>{O(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:N,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),D({})}},secondaryButton:y?{buttonType:"tertiaryGray",onClick:()=>{O(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!y&&e.jsxs(l.StyledDiscountDialogueContainer,{children:[S.allowStaticCoupon&&!y&&e.jsxs(l.CouponTypeContainerStyled,Object.assign({selectedDiv:b.isStaticCoupon?1:2},{children:["static"===S.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{D({isStaticCoupon:!0,couponCode:b.couponCode,description:b.description,quadrant:b.quadrant})}},{children:[e.jsx(n.TitleSmall,Object.assign({style:b.isStaticCoupon?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"Static code"})),e.jsx(n.BodyCaption,Object.assign({style:b.isStaticCoupon?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),"dynamic"===S.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{D(Object.assign(Object.assign({},b),{isStaticCoupon:!1}))}},{children:[e.jsx(n.TitleSmall,Object.assign({style:b.isStaticCoupon?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic code"})),e.jsx(n.BodyCaption,Object.assign({style:b.isStaticCoupon?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),b.isStaticCoupon&&!y&&e.jsx(E.default,{discountData:b,setDiscountData:D,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!b.isStaticCoupon&&!y&&e.jsx(T.default,{currency:S.currency,entitledProducts:A,prerequisiteProducts:h,setEntitledProducts:x,setPrerequisiteProducts:q,discountData:b,productPickerOpen:y,setIsProductPickerOpen:O,setDiscountData:D,selectedCouponType:v,setSelectedCouponType:U,selectedMinimumRequirement:m,setSelectedMinimumRequirement:g,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:w})]}),!!y&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(d.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(_=S.products)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{O(void 0)},selectedProducts:y===T.DISCOUNT_PRODUCTS.ENTITLED?A:h,setSelectedProducts:y===T.DISCOUNT_PRODUCTS.ENTITLED?x:q,onSearchKeyChange:S.onProductSearch})}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("./type.js");require("../dropdown/DropdownPopover/index.js");var i=require("../dropdown/Dropdown.js");require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js"),s=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 r=require("../modals/styledModal.js"),d=require("../product-picker/ProductPickerModal.js"),a=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),l=require("../../assets/icons/triangle_error.svg.js"),u=require("./DiscountModal.styled.js"),p=require("./DiscountUtils.js"),T=require("./DynamicCoupon/DynamicCoupon.js"),E=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=S=>{var C,I,P,y,O;const[_,b]=t.useState(),[v,D]=t.useState(),[N,j]=t.useState(null!==(C=S.data)&&void 0!==C?C:"string"==typeof S.hideOption?{isStaticCoupon:"dynamic"===S.hideOption}:{isStaticCoupon:!1}),[U,g]=t.useState(!0),[m,h]=t.useState(),[q,A]=t.useState((null===(I=S.data)||void 0===I?void 0:I.minAmount)?o.MIN_PURCHASE_REQUIREMENT.AMOUNT:(null===(P=S.data)||void 0===P?void 0:P.minQuantity)?o.MIN_PURCHASE_REQUIREMENT.QUANTITY:o.MIN_PURCHASE_REQUIREMENT.NA),[x,R]=t.useState([]),[f,Y]=t.useState([]),[L,M]=t.useState([]),[w,G]=t.useState([]),[F,k]=t.useState(0);t.useEffect((()=>{let e;S.hideProbability||(e=H()),g(p.validateDiscountData(N,q,m,S.hideProbability||!1,e,!!N.isStaticCoupon)),S.hideProbability||H()}),[]),t.useEffect((()=>{let e;S.hideProbability||(e=H()),g(p.validateDiscountData(N,q,m,S.hideProbability||!1,e,!!N.isStaticCoupon))}),[N,F,m,q]),t.useEffect((()=>{var e,t,o,i;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))}));R(e)}}if(S.collection){if(null===(o=S.data)||void 0===o?void 0:o.entitledCollectionIds){const e=S.collection.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.entitledCollectionIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));G(e)}if(null===(i=S.data)||void 0===i?void 0:i.prerequisiteCollectionIds){const e=S.collection.filter((e=>{var t,o;return null===(o=null===(t=S.data)||void 0===t?void 0:t.prerequisiteCollectionIds)||void 0===o?void 0:o.includes(parseInt(e.id))}));M(e)}}}),[]),t.useEffect((()=>{const e=f.map((e=>parseInt(e.id)));j(Object.assign(Object.assign({},N),{entitledProductIds:e}))}),[f]),t.useEffect((()=>{const e=x.map((e=>parseInt(e.id)));j(Object.assign(Object.assign({},N),{prerequisiteProductIds:e}))}),[x]),t.useEffect((()=>{const e=w.map((e=>parseInt(e.id)));j(Object.assign(Object.assign({},N),{entitledCollectionIds:e}))}),[w]),t.useEffect((()=>{const e=L.map((e=>parseInt(e.id)));j(Object.assign(Object.assign({},N),{prerequisiteCollectionIds:e}))}),[L]),t.useEffect((()=>{N.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?h(o.DISCOUNT_TYPES.FREE_SHIPPING):N.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?h(o.DISCOUNT_TYPES.BUY_X_GET_Y):N.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?h(o.DISCOUNT_TYPES.FIXED_AMOUNT):N.valueType===o.DISCOUNT_VALUE_TYPES.PERCENTAGE&&h(o.DISCOUNT_TYPES.PERCENTAGE)}),[]);const B=[{value:o.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:m===o.DISCOUNT_TYPES.FIXED_AMOUNT},{value:o.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:m===o.DISCOUNT_TYPES.PERCENTAGE},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:m===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:m===o.DISCOUNT_TYPES.FREE_SHIPPING}],H=()=>{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)+(N.probability||0);return k(parseFloat(o.toFixed(4))),parseFloat(o.toFixed(4))},Q=e=>{const t=e.value;h(t),t===o.DISCOUNT_TYPES.FREE_SHIPPING?(R([]),Y([]),j(Object.assign(Object.assign({},N),{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?j(Object.assign(Object.assign({},N),{targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE})):t===o.DISCOUNT_TYPES.PERCENTAGE?(R([]),Y([]),j(Object.assign(Object.assign({},N),{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&&(R([]),Y([]),j(Object.assign(Object.assign({},N),{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(r.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,{}):F<=1?e.jsx(a.Tag,{theme:"light",tagText:`Current probability sum: ${F}`,type:"white"}):e.jsx(c.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: ${F}`,type:"negative",LeadingIcon:l.default})})})),headerRightCustomElement:S.allowStaticCoupon||_?void 0:e.jsx(i.Dropdown,{options:B,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Q(e)}}),onClose:S.onClose,footerShadow:!0,primaryButton:_?{buttonType:"primary",onClick:()=>{b(void 0)},buttonText:"Add"}:v?{buttonType:"primary",onClick:()=>{D(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:U,onClick:()=>{N.isStaticCoupon?S.onSaveClicked({quadrant:N.quadrant,couponCode:N.couponCode,description:N.description,isStaticCoupon:N.isStaticCoupon,probability:N.probability,title:N.title}):S.onSaveClicked(N),j({})}},secondaryButton:_?{buttonType:"tertiaryGray",onClick:()=>{b(void 0)},buttonText:"Back"}:v?{buttonType:"tertiaryGray",onClick:()=>{D(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!_&&!v&&e.jsxs(u.StyledDiscountDialogueContainer,{children:[S.allowStaticCoupon&&!_&&e.jsxs(u.CouponTypeContainerStyled,Object.assign({selectedDiv:N.isStaticCoupon?1:2},{children:["static"===S.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{j({isStaticCoupon:!0,couponCode:N.couponCode,description:N.description,quadrant:N.quadrant})}},{children:[e.jsx(n.TitleSmall,Object.assign({style:N.isStaticCoupon?{color:s.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"Static code"})),e.jsx(n.BodyCaption,Object.assign({style:N.isStaticCoupon?{color:s.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),"dynamic"===S.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{j(Object.assign(Object.assign({},N),{isStaticCoupon:!1}))}},{children:[e.jsx(n.TitleSmall,Object.assign({style:N.isStaticCoupon?{}:{color:s.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic code"})),e.jsx(n.BodyCaption,Object.assign({style:N.isStaticCoupon?{}:{color:s.DEFAULT_THEME.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),N.isStaticCoupon&&!_&&e.jsx(E.default,{discountData:N,setDiscountData:j,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!N.isStaticCoupon&&!_&&!v&&e.jsx(T.default,{currency:S.currency,entitledProducts:f,prerequisiteProducts:x,setEntitledProducts:Y,setPrerequisiteProducts:R,discountData:N,productPickerOpen:_,setIsProductPickerOpen:b,setDiscountData:j,selectedCouponType:m,setSelectedCouponType:h,selectedMinimumRequirement:q,setSelectedMinimumRequirement:A,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:Q,collectionPickerOpen:v,entitledCollections:w,prerequisiteCollections:L,setIsCollectionPickerOpen:D,setEntitledCollections:G,setPrerequisiteCollections:M})]}),!!_&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(d.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(y=S.products)&&void 0!==y?y:[],title:"Select Products",onClose:()=>{b(void 0)},selectedProducts:_===T.DISCOUNT_PRODUCTS.ENTITLED?f:x,setSelectedProducts:_===T.DISCOUNT_PRODUCTS.ENTITLED?Y:R,onSearchKeyChange:S.onProductSearch})})),!!v&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(d.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(O=S.collection)&&void 0!==O?O:[],title:"Select Products",onClose:()=>{D(void 0)},selectedProducts:v===T.DISCOUNT_PRODUCTS.ENTITLED?w:L,setSelectedProducts:v===T.DISCOUNT_PRODUCTS.ENTITLED?G:M,onSearchKeyChange:S.onCollectionSearch})}))]}))};
|
|
@@ -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,o,I;if(console.log(i),!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)&&!(null===(l=i.entitledCollectionIds)||void 0===l?void 0:l.length)||!i.prerequisiteQuantity||!(null===(o=i.prerequisiteProductIds)||void 0===o?void 0:o.length)&&!(null===(I=i.prerequisiteCollectionIds)||void 0===I?void 0:I.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){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;if(i.expireAt&&i.expireAt<new Date)return!0}return!1};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DISCOUNT_TYPES, ICouponData, MIN_PURCHASE_REQUIREMENT } from "../type";
|
|
3
3
|
import { SingleOption } from "../../dropdown/type";
|
|
4
|
-
import { Product } from "../../product-picker/type";
|
|
4
|
+
import { Collection, Product } from "../../product-picker/type";
|
|
5
5
|
export declare enum DISCOUNT_PRODUCTS {
|
|
6
6
|
ENTITLED = "entitled",
|
|
7
7
|
PREREQUISITE = "prerequisite"
|
|
@@ -9,7 +9,9 @@ export declare enum DISCOUNT_PRODUCTS {
|
|
|
9
9
|
interface DynamicCouponI {
|
|
10
10
|
discountData: ICouponData;
|
|
11
11
|
setIsProductPickerOpen: React.Dispatch<React.SetStateAction<DISCOUNT_PRODUCTS | undefined>>;
|
|
12
|
+
setIsCollectionPickerOpen: React.Dispatch<React.SetStateAction<DISCOUNT_PRODUCTS | undefined>>;
|
|
12
13
|
productPickerOpen: DISCOUNT_PRODUCTS | undefined;
|
|
14
|
+
collectionPickerOpen: DISCOUNT_PRODUCTS | undefined;
|
|
13
15
|
setDiscountData: React.Dispatch<React.SetStateAction<ICouponData>>;
|
|
14
16
|
selectedCouponType: DISCOUNT_TYPES | undefined;
|
|
15
17
|
setSelectedCouponType: React.Dispatch<React.SetStateAction<DISCOUNT_TYPES | undefined>>;
|
|
@@ -17,8 +19,12 @@ interface DynamicCouponI {
|
|
|
17
19
|
setSelectedMinimumRequirement: React.Dispatch<React.SetStateAction<MIN_PURCHASE_REQUIREMENT>>;
|
|
18
20
|
entitledProducts: Product[];
|
|
19
21
|
prerequisiteProducts: Product[];
|
|
22
|
+
entitledCollections: Collection[];
|
|
23
|
+
prerequisiteCollections: Collection[];
|
|
20
24
|
setEntitledProducts: React.Dispatch<React.SetStateAction<Product[]>>;
|
|
21
25
|
setPrerequisiteProducts: React.Dispatch<React.SetStateAction<Product[]>>;
|
|
26
|
+
setEntitledCollections: React.Dispatch<React.SetStateAction<Collection[]>>;
|
|
27
|
+
setPrerequisiteCollections: React.Dispatch<React.SetStateAction<Collection[]>>;
|
|
22
28
|
onChangeCouponType: (option: SingleOption) => void;
|
|
23
29
|
hideExpiration?: boolean;
|
|
24
30
|
hideProbability?: boolean;
|
|
@@ -1 +1 @@
|
|
|
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");require("../../dropdown/DropdownPopover/index.js");var i=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.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 x=[{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}],E=[{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}],D=()=>{var t,a,o,l,d;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:E,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",prefixText:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(d=j.currency)&&void 0!==d?d:"₹":void 0,type:"number",placeholder:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?"1000.00":"2"})}))]}))},b=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:x,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})}))]})),D(),!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 (0 - 1)"})})),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 (0 - 1)"})}))]})),D()]})})(),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",gap:20,flex:1}},{children:[e.jsx("div",Object.assign({style:{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("div",Object.assign({style:{flex:1}},{children: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 (0 - 1)"})}))]}))})),e.jsx(T,{}),b(exports.DISCOUNT_PRODUCTS.PREREQUISITE),e.jsx(T,{}),b(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
|
+
"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");require("../../dropdown/DropdownPopover/index.js");var i=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.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"),c=require("../../radioButton/RadioButton.js"),u=require("../../../assets/icons/cursor.svg.js"),p=require("../../../assets/icons/plus.svg.js");const j="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg";var T;function x(){return null}exports.DISCOUNT_PRODUCTS=void 0,(T=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",T.PREREQUISITE="prerequisite";exports.default=T=>{var m;const E=[{value:s.DISCOUNT_TYPES.FIXED_AMOUNT,label:"Fixed Amount",selected:T.selectedCouponType===s.DISCOUNT_TYPES.FIXED_AMOUNT},{value:s.DISCOUNT_TYPES.PERCENTAGE,label:"Percentage",selected:T.selectedCouponType===s.DISCOUNT_TYPES.PERCENTAGE},{value:s.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:T.selectedCouponType===s.DISCOUNT_TYPES.BUY_X_GET_Y},{value:s.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:T.selectedCouponType===s.DISCOUNT_TYPES.FREE_SHIPPING}],g=[{selected:T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.NA,label:"No minimum requirements",value:s.MIN_PURCHASE_REQUIREMENT.NA},{selected:T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT,label:`Minimum purchase amount (${null!==(m=T.currency)&&void 0!==m?m:"₹"})`,value:s.MIN_PURCHASE_REQUIREMENT.AMOUNT},{selected:T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.QUANTITY,label:"Minimum quantity of items",value:s.MIN_PURCHASE_REQUIREMENT.QUANTITY}],D=()=>{var t,a,o,l,d;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:g,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!==s.MIN_PURCHASE_REQUIREMENT.NA&&e.jsx(r.Input,{value:T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(a=null===(t=T.discountData.minAmount)||void 0===t?void 0:t.toString())&&void 0!==a?a:"":null!==(l=null===(o=T.discountData.minQuantity)||void 0===o?void 0:o.toString())&&void 0!==l?l:"",onChangeText:e=>{T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?T.setDiscountData(Object.assign(Object.assign({},T.discountData),{minAmount:parseInt(e)})):T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.QUANTITY&&T.setDiscountData(Object.assign(Object.assign({},T.discountData),{minQuantity:parseInt(e)}))},labelText:T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",prefixText:T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(d=T.currency)&&void 0!==d?d:"₹":void 0,type:"number",placeholder:T.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?"1000.00":"2"})}))]}))},b=s=>{var i,l,d;const c=s===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledProducts:T.prerequisiteProducts,u=null!==(i=s===exports.DISCOUNT_PRODUCTS.ENTITLED?T.entitledCollections:T.prerequisiteCollections)&&void 0!==i?i:[];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===(l=T.discountData.entitledQuantity)||void 0===l?void 0:l.toString():null===(d=T.discountData.prerequisiteQuantity)||void 0===d?void 0:d.toString(),type:"number",onChangeText:e=>{s===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.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[e.jsx(t.Button,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:p.default,onClick:()=>{T.setIsProductPickerOpen(s)}}),e.jsx(t.Button,{buttonText:"Add collection",buttonType:"tertiary",LeadingIcon:p.default,onClick:()=>{T.setIsCollectionPickerOpen(s)}})]})),!!c.length&&e.jsxs("div",Object.assign({style:{margin:"8px 0"}},{children:[e.jsx(n.TitleSmall,{children:"Products"}),c.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=j},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=c.filter((e=>e.id!==t.id));s===exports.DISCOUNT_PRODUCTS.ENTITLED?T.setEntitledProducts(e):T.setPrerequisiteProducts(e)}},{children:e.jsx(o.default,{width:14,color:a.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),t.id)))]})),!!u.length&&e.jsxs("div",Object.assign({style:{margin:"8px 0"}},{children:[e.jsx(n.TitleSmall,{children:"Collections"}),u.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=j},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=u.filter((e=>e.id!==t.id));s===exports.DISCOUNT_PRODUCTS.ENTITLED?T.setEntitledCollections(e):T.setPrerequisiteCollections(e)}},{children:e.jsx(o.default,{width:14,color:a.DEFAULT_THEME.colorsV2.content.primary})}))}))]}),t.id)))]}))]})};return e.jsxs(l.DynamicCouponContainer,{children:[T.allowStaticCoupon&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(i.Dropdown,{options:E,width:"290px",placement:"bottom-start",onSelect:e=>{T.onChangeCouponType(e)}})})),e.jsx("div",{className:"input__wrapper"})]})),(T.selectedCouponType===s.DISCOUNT_TYPES.PERCENTAGE||T.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: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(r.Input,{value:null===(i=null===(t=T.discountData)||void 0===t?void 0:t.value)||void 0===i?void 0:i.toString(),labelText:"Discount code value",type:"number",onChangeText:e=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:parseInt(e)}))},placeholder:T.selectedCouponType===s.DISCOUNT_TYPES.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:T.selectedCouponType===s.DISCOUNT_TYPES.FIXED_AMOUNT?null!==(n=T.currency)&&void 0!==n?n:"₹":void 0,suffixText:T.selectedCouponType===s.DISCOUNT_TYPES.PERCENTAGE?"%":void 0})}))]})),D(),!T.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=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 (0 - 1)"})})),e.jsx("div",{className:"input__wrapper"})]}))]})})(),T.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: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(r.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 (0 - 1)"})}))]})),D()]})})(),T.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",gap:20,flex:1}},{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(r.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("div",Object.assign({style:{flex:1}},{children:e.jsx(r.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 (0 - 1)"})}))]}))})),e.jsx(x,{}),b(exports.DISCOUNT_PRODUCTS.PREREQUISITE),e.jsx(x,{}),b(exports.DISCOUNT_PRODUCTS.ENTITLED),e.jsx(x,{}),e.jsx(n.TitleRegular,{children:"At a discount value"}),e.jsxs("div",Object.assign({style:{display:"flex",gap:18,alignItems:"center"}},{children:[e.jsx(c.RadioButton,{isActive:100!==T.discountData.value,onValueChange:()=>{T.setDiscountData(Object.assign(Object.assign({},T.discountData),{value:void 0}))}}),e.jsx(n.BodySecondary,{children:"Percentage"}),100!==T.discountData.value&&e.jsx(r.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(c.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(n.BodySecondary,{children:"Free"})]}))]})})(),T.selectedCouponType&&!T.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: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:a.DEFAULT_THEME.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:e.jsx(u.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"})]}))]})};
|
|
@@ -13,15 +13,15 @@ export interface IInstaPost {
|
|
|
13
13
|
}
|
|
14
14
|
export interface ProductPickerProps {
|
|
15
15
|
show: boolean;
|
|
16
|
-
products: Product[];
|
|
16
|
+
products: Product[] | Collection[];
|
|
17
17
|
onClose: () => void;
|
|
18
18
|
title: string;
|
|
19
|
-
onSave: (productIds: Product[]) => void;
|
|
20
|
-
onSearchKeyChange: (key: string) => Promise<Product[]>;
|
|
19
|
+
onSave: (productIds: Product[] | Collection[]) => void;
|
|
20
|
+
onSearchKeyChange: (key: string) => Promise<Product[] | Collection[]>;
|
|
21
21
|
instaPost?: IInstaPost;
|
|
22
22
|
searchPlaceholder?: string;
|
|
23
|
-
selectedProducts: Product[];
|
|
24
|
-
setSelectedProducts: React.Dispatch<React.SetStateAction<Product[]>>;
|
|
23
|
+
selectedProducts: Product[] | Collection[];
|
|
24
|
+
setSelectedProducts: React.Dispatch<React.SetStateAction<Product[] | Collection[]>>;
|
|
25
25
|
secondaryButtonProps?: ButtonProps;
|
|
26
26
|
}
|
|
27
27
|
export interface Product {
|
|
@@ -42,6 +42,16 @@ export interface Product {
|
|
|
42
42
|
name: string;
|
|
43
43
|
handle: string;
|
|
44
44
|
}
|
|
45
|
+
export interface Collection {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
image: string;
|
|
50
|
+
isHidden: boolean;
|
|
51
|
+
isPrivate: boolean;
|
|
52
|
+
handle: string;
|
|
53
|
+
isSmartCollection: boolean;
|
|
54
|
+
}
|
|
45
55
|
export interface Variant {
|
|
46
56
|
values: string[];
|
|
47
57
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("@tippyjs/react"),n=require("react"),r=require("./TooltipInternal.js"),i=require("../../constants/Theme.js");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("@tippyjs/react"),n=require("react"),r=require("./TooltipInternal.js"),i=require("../../constants/Theme.js");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var l=o(e),a=o(n);const p=`\n\t.tippy-content {\n\t\tpadding: 0px;\n\t}\n\t.tippy-arrow {\n\t\tcolor: ${t=>i.COLORS.content.primary};\n\t}\n\t.overflow-wrap-tippy {\n\t\toverflow-wrap: anywhere;\n\t}\n`;exports.Tooltip=e=>{var n;return a.default.isValidElement(e.children)?t.jsxs(t.Fragment,{children:[t.jsx("style",{children:p}),t.jsx(l.default,Object.assign({appendTo:document.body,className:"overflow-wrap-tippy",placement:e.placement||"right",maxWidth:e.width,animation:"fade",arrow:null===(n=!e.hideArrow)||void 0===n||n,interactive:!0,delay:e.delay,visible:e.alwaysVisible,content:e.tooltipContent?e.tooltipContent:t.jsx(r.default,{title:e.title,body:e.body,buttonProps:e.buttonProps}),onClickOutside:e.onClickOutside},{children:e.children}))]}):null};
|
|
@@ -36,7 +36,7 @@ export declare class MetaCustomProcessor {
|
|
|
36
36
|
value: {
|
|
37
37
|
operator: string;
|
|
38
38
|
dataType: import("../types").QueryBuilderConnectorType;
|
|
39
|
-
value?: string | number |
|
|
39
|
+
value?: string | number | string[] | number[] | Date | Date[] | undefined;
|
|
40
40
|
};
|
|
41
41
|
key: string;
|
|
42
42
|
refresh?: boolean | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ICouponData } from "./type";
|
|
3
|
-
import { Product } from "../product-picker/type";
|
|
3
|
+
import { Collection, Product } from "../product-picker/type";
|
|
4
4
|
export interface DiscountDialogueI {
|
|
5
5
|
hideOption?: 'static' | 'dynamic';
|
|
6
6
|
isOpen: boolean;
|
|
@@ -11,11 +11,13 @@ export interface DiscountDialogueI {
|
|
|
11
11
|
data?: ICouponData;
|
|
12
12
|
onSaveClicked: (discountData: ICouponData) => void;
|
|
13
13
|
onProductSearch: (key: string) => Promise<Product[]>;
|
|
14
|
+
onCollectionSearch: (key: string) => Promise<Collection[]>;
|
|
14
15
|
hideExpiration?: boolean;
|
|
15
16
|
hideProbability?: boolean;
|
|
16
17
|
probability?: number[];
|
|
17
18
|
quadrant?: number;
|
|
18
19
|
products?: Product[];
|
|
20
|
+
collection?: Collection[];
|
|
19
21
|
discountAdminUrl?: string;
|
|
20
22
|
currency?: string;
|
|
21
23
|
}
|
|
@@ -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
|
|
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 c,DISCOUNT_VALUE_TYPES as l}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as a}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.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 y}from"../modals/styledModal.js";import{ProductPickerContent as b}from"../product-picker/ProductPickerModal.js";import{Tag as v}from"../tag/Tag.js";import{Tooltip as C}from"../tooltips/Tooltip.js";import E from"../../assets/icons/triangle_error.svg.js";import{StyledDiscountDialogueContainer as T,CouponTypeContainerStyled as I}from"./DiscountModal.styled.js";import{validateDiscountData as P}from"./DiscountUtils.js";import g,{DISCOUNT_PRODUCTS as h}from"./DynamicCoupon/DynamicCoupon.js";import j from"./StaticCoupon/StaticCoupon.js";const S=S=>{var O,N,D,f,_;const[w,A]=i(),[q,x]=i(),[G,L]=i(null!==(O=S.data)&&void 0!==O?O:"string"==typeof S.hideOption?{isStaticCoupon:"dynamic"===S.hideOption}:{isStaticCoupon:!1}),[M,k]=i(!0),[F,R]=i(),[U,B]=i((null===(N=S.data)||void 0===N?void 0:N.minAmount)?r.AMOUNT:(null===(D=S.data)||void 0===D?void 0:D.minQuantity)?r.QUANTITY:r.NA),[X,Y]=i([]),[Q,H]=i([]),[V,z]=i([]),[K,$]=i([]),[Z,J]=i(0);n((()=>{let t;S.hideProbability||(t=tt()),k(P(G,U,F,S.hideProbability||!1,t,!!G.isStaticCoupon)),S.hideProbability||tt()}),[]),n((()=>{let t;S.hideProbability||(t=tt()),k(P(G,U,F,S.hideProbability||!1,t,!!G.isStaticCoupon))}),[G,Z,F,U]),n((()=>{var t,e,o,i;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))}));H(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))}));Y(t)}}if(S.collection){if(null===(o=S.data)||void 0===o?void 0:o.entitledCollectionIds){const t=S.collection.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.entitledCollectionIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));$(t)}if(null===(i=S.data)||void 0===i?void 0:i.prerequisiteCollectionIds){const t=S.collection.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.prerequisiteCollectionIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));z(t)}}}),[]),n((()=>{const t=Q.map((t=>parseInt(t.id)));L(Object.assign(Object.assign({},G),{entitledProductIds:t}))}),[Q]),n((()=>{const t=X.map((t=>parseInt(t.id)));L(Object.assign(Object.assign({},G),{prerequisiteProductIds:t}))}),[X]),n((()=>{const t=K.map((t=>parseInt(t.id)));L(Object.assign(Object.assign({},G),{entitledCollectionIds:t}))}),[K]),n((()=>{const t=V.map((t=>parseInt(t.id)));L(Object.assign(Object.assign({},G),{prerequisiteCollectionIds:t}))}),[V]),n((()=>{G.targetType===d.SHIPPING_LINE?R(s.FREE_SHIPPING):G.targetSelection===c.ENTITLED?R(s.BUY_X_GET_Y):G.valueType===l.FIXED_AMOUNT?R(s.FIXED_AMOUNT):G.valueType===l.PERCENTAGE&&R(s.PERCENTAGE)}),[]);const W=[{value:s.FIXED_AMOUNT,label:"Fixed Amount",selected:F===s.FIXED_AMOUNT},{value:s.PERCENTAGE,label:"Percentage",selected:F===s.PERCENTAGE},{value:s.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:F===s.BUY_X_GET_Y},{value:s.FREE_SHIPPING,label:"Free shipping",selected:F===s.FREE_SHIPPING}],tt=()=>{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)+(G.probability||0);return J(parseFloat(o.toFixed(4))),parseFloat(o.toFixed(4))},et=t=>{const e=t.value;R(e),e===s.FREE_SHIPPING?(Y([]),H([]),L(Object.assign(Object.assign({},G),{value:100,targetSelection:c.ALL,targetType:d.SHIPPING_LINE,valueType:l.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.BUY_X_GET_Y?L(Object.assign(Object.assign({},G),{targetSelection:c.ENTITLED,targetType:d.LINE_ITEM,valueType:l.PERCENTAGE})):e===s.PERCENTAGE?(Y([]),H([]),L(Object.assign(Object.assign({},G),{targetSelection:c.ALL,targetType:d.LINE_ITEM,valueType:l.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.FIXED_AMOUNT&&(Y([]),H([]),L(Object.assign(Object.assign({},G),{targetSelection:c.ALL,targetType:d.LINE_ITEM,valueType:l.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return t(y,Object.assign({open:S.isOpen,headingTitle:w?"Select Products":S.title,headingSubtitle:w?void 0:S.subTitle,footerLeftCustomElement:!S.quadrant||S.hideProbability?e(o,{}):Z<=1?e(v,{theme:"light",tagText:`Current probability sum: ${Z}`,type:"white"}):e(C,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(v,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Z}`,type:"negative",LeadingIcon:E})})})),headerRightCustomElement:S.allowStaticCoupon||w?void 0:e(a,{options:W,width:"200px",placement:"bottom-start",size:"small",onSelect:t=>{et(t)}}),onClose:S.onClose,footerShadow:!0,primaryButton:w?{buttonType:"primary",onClick:()=>{A(void 0)},buttonText:"Add"}:q?{buttonType:"primary",onClick:()=>{x(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:M,onClick:()=>{G.isStaticCoupon?S.onSaveClicked({quadrant:G.quadrant,couponCode:G.couponCode,description:G.description,isStaticCoupon:G.isStaticCoupon,probability:G.probability,title:G.title}):S.onSaveClicked(G),L({})}},secondaryButton:w?{buttonType:"tertiaryGray",onClick:()=>{A(void 0)},buttonText:"Back"}:q?{buttonType:"tertiaryGray",onClick:()=>{x(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!w&&!q&&t(T,{children:[S.allowStaticCoupon&&!w&&t(I,Object.assign({selectedDiv:G.isStaticCoupon?1:2},{children:["static"===S.hideOption?e(o,{}):t("div",Object.assign({className:"coupon-type__container",onClick:()=>{L({isStaticCoupon:!0,couponCode:G.couponCode,description:G.description,quadrant:G.quadrant})}},{children:[e(p,Object.assign({style:G.isStaticCoupon?{color:m.colorsV2.content.brand}:{}},{children:"Static code"})),e(u,Object.assign({style:G.isStaticCoupon?{color:m.colorsV2.content.brand}:{}},{children:"One static code for all customers"}))]})),"dynamic"===S.hideOption?e(o,{}):t("div",Object.assign({className:"coupon-type__container",onClick:()=>{L(Object.assign(Object.assign({},G),{isStaticCoupon:!1}))}},{children:[e(p,Object.assign({style:G.isStaticCoupon?{}:{color:m.colorsV2.content.brand}},{children:"Dynamic code"})),e(u,Object.assign({style:G.isStaticCoupon?{}:{color:m.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),G.isStaticCoupon&&!w&&e(j,{discountData:G,setDiscountData:L,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!G.isStaticCoupon&&!w&&!q&&e(g,{currency:S.currency,entitledProducts:Q,prerequisiteProducts:X,setEntitledProducts:H,setPrerequisiteProducts:Y,discountData:G,productPickerOpen:w,setIsProductPickerOpen:A,setDiscountData:L,selectedCouponType:F,setSelectedCouponType:R,selectedMinimumRequirement:U,setSelectedMinimumRequirement:B,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:et,collectionPickerOpen:q,entitledCollections:K,prerequisiteCollections:V,setIsCollectionPickerOpen:x,setEntitledCollections:$,setPrerequisiteCollections:z})]}),!!w&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(b,{show:!0,onSave:()=>{},products:null!==(f=S.products)&&void 0!==f?f:[],title:"Select Products",onClose:()=>{A(void 0)},selectedProducts:w===h.ENTITLED?Q:X,setSelectedProducts:w===h.ENTITLED?H:Y,onSearchKeyChange:S.onProductSearch})})),!!q&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(b,{show:!0,onSave:()=>{},products:null!==(_=S.collection)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{x(void 0)},selectedProducts:q===h.ENTITLED?K:V,setSelectedProducts:q===h.ENTITLED?$:z,onSearchKeyChange:S.onCollectionSearch})}))]}))};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,f,
|
|
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,v,a)=>{var d,T,A,E;if(console.log(u),!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(v>1)return!0}if(a){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===(d=u.entitledProductIds)||void 0===d?void 0:d.length)&&!(null===(T=u.entitledCollectionIds)||void 0===T?void 0:T.length)||!u.prerequisiteQuantity||!(null===(A=u.prerequisiteProductIds)||void 0===A?void 0:A.length)&&!(null===(E=u.prerequisiteCollectionIds)||void 0===E?void 0:E.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){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;if(u.expireAt&&u.expireAt<new Date)return!0}return!1};export{u as validateDiscountData};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DISCOUNT_TYPES, ICouponData, MIN_PURCHASE_REQUIREMENT } from "../type";
|
|
3
3
|
import { SingleOption } from "../../dropdown/type";
|
|
4
|
-
import { Product } from "../../product-picker/type";
|
|
4
|
+
import { Collection, Product } from "../../product-picker/type";
|
|
5
5
|
export declare enum DISCOUNT_PRODUCTS {
|
|
6
6
|
ENTITLED = "entitled",
|
|
7
7
|
PREREQUISITE = "prerequisite"
|
|
@@ -9,7 +9,9 @@ export declare enum DISCOUNT_PRODUCTS {
|
|
|
9
9
|
interface DynamicCouponI {
|
|
10
10
|
discountData: ICouponData;
|
|
11
11
|
setIsProductPickerOpen: React.Dispatch<React.SetStateAction<DISCOUNT_PRODUCTS | undefined>>;
|
|
12
|
+
setIsCollectionPickerOpen: React.Dispatch<React.SetStateAction<DISCOUNT_PRODUCTS | undefined>>;
|
|
12
13
|
productPickerOpen: DISCOUNT_PRODUCTS | undefined;
|
|
14
|
+
collectionPickerOpen: DISCOUNT_PRODUCTS | undefined;
|
|
13
15
|
setDiscountData: React.Dispatch<React.SetStateAction<ICouponData>>;
|
|
14
16
|
selectedCouponType: DISCOUNT_TYPES | undefined;
|
|
15
17
|
setSelectedCouponType: React.Dispatch<React.SetStateAction<DISCOUNT_TYPES | undefined>>;
|
|
@@ -17,8 +19,12 @@ interface DynamicCouponI {
|
|
|
17
19
|
setSelectedMinimumRequirement: React.Dispatch<React.SetStateAction<MIN_PURCHASE_REQUIREMENT>>;
|
|
18
20
|
entitledProducts: Product[];
|
|
19
21
|
prerequisiteProducts: Product[];
|
|
22
|
+
entitledCollections: Collection[];
|
|
23
|
+
prerequisiteCollections: Collection[];
|
|
20
24
|
setEntitledProducts: React.Dispatch<React.SetStateAction<Product[]>>;
|
|
21
25
|
setPrerequisiteProducts: React.Dispatch<React.SetStateAction<Product[]>>;
|
|
26
|
+
setEntitledCollections: React.Dispatch<React.SetStateAction<Collection[]>>;
|
|
27
|
+
setPrerequisiteCollections: React.Dispatch<React.SetStateAction<Collection[]>>;
|
|
22
28
|
onChangeCouponType: (option: SingleOption) => void;
|
|
23
29
|
hideExpiration?: boolean;
|
|
24
30
|
hideProbability?: boolean;
|
|
@@ -1 +1 @@
|
|
|
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/DropdownPopover/index.js";import{Dropdown as o}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.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,c;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",prefixText:O.selectedMinimumRequirement===a.AMOUNT?null!==(c=O.currency)&&void 0!==c?c:"₹":void 0,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 (0 - 1)"})})),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 (0 - 1)"})}))]})),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",gap:20,flex:1}},{children:[t("div",Object.assign({style:{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("div",Object.assign({style:{flex:1}},{children: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 (0 - 1)"})}))]}))})),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
|
+
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/DropdownPopover/index.js";import{Dropdown as o}from"../../dropdown/Dropdown.js";import"../../dropdown/ChipDropdown.js";import"../../zeroState/ZeroState.js";import{TitleRegular as r,BodySecondary as l,TitleMedium as c,BodyPrimary as d,TitleSmall as p}from"../../TypographyStyle.js";import{DEFAULT_THEME as u}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 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 b}from"../DiscountModal.styled.js";import{CouponExpiration as v}from"../CouponExpiration/CouponExpiration.js";import{RadioButton as y}from"../../radioButton/RadioButton.js";import h from"../../../assets/icons/cursor.svg.js";import j from"../../../assets/icons/plus.svg.js";const D="https://jkfenner.com/wp-content/uploads/2019/11/default.jpg";var O;function T(){return null}!function(e){e.ENTITLED="entitled",e.PREREQUISITE="prerequisite"}(O||(O={}));const x=x=>{var E;const C=[{value:s.FIXED_AMOUNT,label:"Fixed Amount",selected:x.selectedCouponType===s.FIXED_AMOUNT},{value:s.PERCENTAGE,label:"Percentage",selected:x.selectedCouponType===s.PERCENTAGE},{value:s.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:x.selectedCouponType===s.BUY_X_GET_Y},{value:s.FREE_SHIPPING,label:"Free shipping",selected:x.selectedCouponType===s.FREE_SHIPPING}],f=[{selected:x.selectedMinimumRequirement===a.NA,label:"No minimum requirements",value:a.NA},{selected:x.selectedMinimumRequirement===a.AMOUNT,label:`Minimum purchase amount (${null!==(E=x.currency)&&void 0!==E?E:"₹"})`,value:a.AMOUNT},{selected:x.selectedMinimumRequirement===a.QUANTITY,label:"Minimum quantity of items",value:a.QUANTITY}],_=()=>{var i,n,s,r,c;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:f,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!==a.NA&&t(m,{value:x.selectedMinimumRequirement===a.AMOUNT?null!==(n=null===(i=x.discountData.minAmount)||void 0===i?void 0:i.toString())&&void 0!==n?n:"":null!==(r=null===(s=x.discountData.minQuantity)||void 0===s?void 0:s.toString())&&void 0!==r?r:"",onChangeText:e=>{x.selectedMinimumRequirement===a.AMOUNT?x.setDiscountData(Object.assign(Object.assign({},x.discountData),{minAmount:parseInt(e)})):x.selectedMinimumRequirement===a.QUANTITY&&x.setDiscountData(Object.assign(Object.assign({},x.discountData),{minQuantity:parseInt(e)}))},labelText:x.selectedMinimumRequirement===a.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",prefixText:x.selectedMinimumRequirement===a.AMOUNT?null!==(c=x.currency)&&void 0!==c?c:"₹":void 0,type:"number",placeholder:x.selectedMinimumRequirement===a.AMOUNT?"1000.00":"2"})}))]}))},N=s=>{var a,o,l;const c=s===O.ENTITLED?x.entitledProducts:x.prerequisiteProducts,d=null!==(a=s===O.ENTITLED?x.entitledCollections:x.prerequisiteCollections)&&void 0!==a?a:[];return e(i,{children:[t(r,{children:s===O.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===O.ENTITLED?null===(o=x.discountData.entitledQuantity)||void 0===o?void 0:o.toString():null===(l=x.discountData.prerequisiteQuantity)||void 0===l?void 0:l.toString(),type:"number",onChangeText:e=>{s===O.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"})]})),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(n,{buttonText:"Add product",buttonType:"tertiary",LeadingIcon:j,onClick:()=>{x.setIsProductPickerOpen(s)}}),t(n,{buttonText:"Add collection",buttonType:"tertiary",LeadingIcon:j,onClick:()=>{x.setIsCollectionPickerOpen(s)}})]})),!!c.length&&e("div",Object.assign({style:{margin:"8px 0"}},{children:[t(p,{children:"Products"}),c.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${u.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=D},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=c.filter((e=>e.id!==i.id));s===O.ENTITLED?x.setEntitledProducts(e):x.setPrerequisiteProducts(e)}},{children:t(g,{width:14,color:u.colorsV2.content.primary})}))}))]}),i.id)))]})),!!d.length&&e("div",Object.assign({style:{margin:"8px 0"}},{children:[t(p,{children:"Collections"}),d.map((i=>e("div",Object.assign({style:{padding:"20px 0 12px 0",borderBottom:`1px solid ${u.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=D},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=d.filter((e=>e.id!==i.id));s===O.ENTITLED?x.setEntitledCollections(e):x.setPrerequisiteCollections(e)}},{children:t(g,{width:14,color:u.colorsV2.content.primary})}))}))]}),i.id)))]}))]})};return e(b,{children:[x.allowStaticCoupon&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(o,{options:C,width:"290px",placement:"bottom-start",onSelect:e=>{x.onChangeCouponType(e)}})})),t("div",{className:"input__wrapper"})]})),(x.selectedCouponType===s.PERCENTAGE||x.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: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(m,{value:null===(a=null===(n=x.discountData)||void 0===n?void 0:n.value)||void 0===a?void 0:a.toString(),labelText:"Discount code value",type:"number",onChangeText:e=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{value:parseInt(e)}))},placeholder:x.selectedCouponType===s.FIXED_AMOUNT?"0.00":"Enter a value",prefixText:x.selectedCouponType===s.FIXED_AMOUNT?null!==(o=x.currency)&&void 0!==o?o:"₹":void 0,suffixText:x.selectedCouponType===s.PERCENTAGE?"%":void 0})}))]})),_(),!x.hideProbability&&e("div",Object.assign({className:"input__rows"},{children:[t("div",Object.assign({className:"input__wrapper"},{children:t(m,{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 (0 - 1)"})})),t("div",{className:"input__wrapper"})]}))]})})(),x.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: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(m,{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 (0 - 1)"})}))]})),_()]})})(),x.selectedCouponType===s.BUY_X_GET_Y&&(()=>{var i;return e(b,{children:[t("div",Object.assign({className:"input__rows"},{children:e("div",Object.assign({style:{display:"flex",gap:20,flex:1}},{children:[t("div",Object.assign({style:{flex:1}},{children:t(m,{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("div",Object.assign({style:{flex:1}},{children:t(m,{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 (0 - 1)"})}))]}))})),t(T,{}),N(O.PREREQUISITE),t(T,{}),N(O.ENTITLED),t(T,{}),t(r,{children:"At a discount value"}),e("div",Object.assign({style:{display:"flex",gap:18,alignItems:"center"}},{children:[t(y,{isActive:100!==x.discountData.value,onValueChange:()=>{x.setDiscountData(Object.assign(Object.assign({},x.discountData),{value:void 0}))}}),t(l,{children:"Percentage"}),100!==x.discountData.value&&t(m,{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(y,{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(l,{children:"Free"})]}))]})})(),x.selectedCouponType&&!x.hideExpiration&&e(i,{children:[t("div",{style:{height:6,borderTop:`1px solid ${u.colorsV2.stroke.primary}`,marginTop:12}}),t(v,{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:u.colorsV2.background.inverse,borderRadius:"50%",display:"flex",justifyContent:"center",alignItems:"center"}},{children:t(h,{width:32,color:u.colorsV2.content.primaryInverse})})),t(c,{children:"No discount has been selected"}),t(d,{children:"Please select a discount type"})]}))]})};export{O as DISCOUNT_PRODUCTS,x as default};
|
|
@@ -13,15 +13,15 @@ export interface IInstaPost {
|
|
|
13
13
|
}
|
|
14
14
|
export interface ProductPickerProps {
|
|
15
15
|
show: boolean;
|
|
16
|
-
products: Product[];
|
|
16
|
+
products: Product[] | Collection[];
|
|
17
17
|
onClose: () => void;
|
|
18
18
|
title: string;
|
|
19
|
-
onSave: (productIds: Product[]) => void;
|
|
20
|
-
onSearchKeyChange: (key: string) => Promise<Product[]>;
|
|
19
|
+
onSave: (productIds: Product[] | Collection[]) => void;
|
|
20
|
+
onSearchKeyChange: (key: string) => Promise<Product[] | Collection[]>;
|
|
21
21
|
instaPost?: IInstaPost;
|
|
22
22
|
searchPlaceholder?: string;
|
|
23
|
-
selectedProducts: Product[];
|
|
24
|
-
setSelectedProducts: React.Dispatch<React.SetStateAction<Product[]>>;
|
|
23
|
+
selectedProducts: Product[] | Collection[];
|
|
24
|
+
setSelectedProducts: React.Dispatch<React.SetStateAction<Product[] | Collection[]>>;
|
|
25
25
|
secondaryButtonProps?: ButtonProps;
|
|
26
26
|
}
|
|
27
27
|
export interface Product {
|
|
@@ -42,6 +42,16 @@ export interface Product {
|
|
|
42
42
|
name: string;
|
|
43
43
|
handle: string;
|
|
44
44
|
}
|
|
45
|
+
export interface Collection {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
image: string;
|
|
50
|
+
isHidden: boolean;
|
|
51
|
+
isPrivate: boolean;
|
|
52
|
+
handle: string;
|
|
53
|
+
isSmartCollection: boolean;
|
|
54
|
+
}
|
|
45
55
|
export interface Variant {
|
|
46
56
|
values: string[];
|
|
47
57
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,Fragment as n,jsx as o}from"react/jsx-runtime";import e from"@tippyjs/react";import r from"react";import i from"./TooltipInternal.js";import{COLORS as
|
|
1
|
+
import{jsxs as t,Fragment as n,jsx as o}from"react/jsx-runtime";import e from"@tippyjs/react";import r from"react";import i from"./TooltipInternal.js";import{COLORS as l}from"../../constants/Theme.js";const p=`\n\t.tippy-content {\n\t\tpadding: 0px;\n\t}\n\t.tippy-arrow {\n\t\tcolor: ${t=>l.content.primary};\n\t}\n\t.overflow-wrap-tippy {\n\t\toverflow-wrap: anywhere;\n\t}\n`,a=l=>{var a;return r.isValidElement(l.children)?t(n,{children:[o("style",{children:p}),o(e,Object.assign({appendTo:document.body,className:"overflow-wrap-tippy",placement:l.placement||"right",maxWidth:l.width,animation:"fade",arrow:null===(a=!l.hideArrow)||void 0===a||a,interactive:!0,delay:l.delay,visible:l.alwaysVisible,content:l.tooltipContent?l.tooltipContent:o(i,{title:l.title,body:l.body,buttonProps:l.buttonProps}),onClickOutside:l.onClickOutside},{children:l.children}))]}):null};export{a as Tooltip};
|