@bikdotai/bik-component-library 0.0.297-beta-sub → 0.0.297-beta.1

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.
Files changed (39) hide show
  1. package/dist/cjs/components/add-variableV2/AddVariableV2SideModal.js +1 -1
  2. package/dist/cjs/components/discount-modal/DiscountModal.d.ts +3 -1
  3. package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
  4. package/dist/cjs/components/discount-modal/DiscountUtils.js +1 -1
  5. package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.d.ts +7 -1
  6. package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  7. package/dist/cjs/components/plans/SubscriptionPlan.d.ts +1 -0
  8. package/dist/cjs/components/plans/SubscriptionPlan.js +1 -1
  9. package/dist/cjs/components/plans/SubscriptionPlanSelector.d.ts +2 -0
  10. package/dist/cjs/components/plans/SubscriptionPlanSelector.js +1 -1
  11. package/dist/cjs/components/product-picker/type.d.ts +15 -5
  12. package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +3 -1
  13. package/dist/cjs/components/template-context-mapper/TemplateContextMapper.js +1 -1
  14. package/dist/cjs/components/template-context-mapper/modalElements/Body.d.ts +2 -0
  15. package/dist/cjs/components/template-context-mapper/modalElements/Body.js +2 -2
  16. package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +3 -1
  17. package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.js +1 -1
  18. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorsPanel.d.ts +4 -1
  19. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorsPanel.js +24 -2
  20. package/dist/esm/components/add-variableV2/AddVariableV2SideModal.js +1 -1
  21. package/dist/esm/components/discount-modal/DiscountModal.d.ts +3 -1
  22. package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
  23. package/dist/esm/components/discount-modal/DiscountUtils.js +1 -1
  24. package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.d.ts +7 -1
  25. package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  26. package/dist/esm/components/plans/SubscriptionPlan.d.ts +1 -0
  27. package/dist/esm/components/plans/SubscriptionPlan.js +1 -1
  28. package/dist/esm/components/plans/SubscriptionPlanSelector.d.ts +2 -0
  29. package/dist/esm/components/plans/SubscriptionPlanSelector.js +1 -1
  30. package/dist/esm/components/product-picker/type.d.ts +15 -5
  31. package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +3 -1
  32. package/dist/esm/components/template-context-mapper/TemplateContextMapper.js +1 -1
  33. package/dist/esm/components/template-context-mapper/modalElements/Body.d.ts +2 -0
  34. package/dist/esm/components/template-context-mapper/modalElements/Body.js +4 -4
  35. package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +3 -1
  36. package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.js +1 -1
  37. package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorsPanel.d.ts +4 -1
  38. package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorsPanel.js +24 -2
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),r=require("../template-preview/models/Channels.js"),s=require("./context/templateModalContext.js"),i=require("./modalElements/Footer.js"),o=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:c,closeDialog:u,showVariableMapping:p,channel:m,htmlContent:h,templateVariables:g,onTemplateSelect:S,globalPlaceholders:v,showOnlyContent:b,whatsappSpecificPickerMeta:j,zIndex:M,showVariableModal:T,variableList:E,onBackPress:P}=d;var x,C;t.useEffect((()=>{q(h)}),[h]);const[L,f]=t.useState(m===r.CHANNEL_TYPE.EMAIL?"desktop":"mobile"),[w,q]=t.useState(h),[y,A]=t.useState(!1),[N,k]=t.useState(c),[V,_]=t.useState(null!=g?g:[]),[H,I]=t.useState(!1);const O=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(v)),[v]);return e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:N,setTemplate:k,device:L,setDevice:f,display_content:w,setDisplayContent:q,originalVariableList:V,setOriginalVariableList:_,isError:y,setIsError:A,channel:m,globalNormalizedPlaceholders:O,templateSelectionTriggered:H,setTemplateSelectionTriggered:I}},{children:b?e.jsx(o.default,{channel:r.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:M,centralContainerStyles:{width:m===r.CHANNEL_TYPE.EMAIL&&p?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==N?void 0:N.label,headingSubtitle:m===r.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(x=null==N?void 0:N.category)&&void 0!==x?x:"")} • ${null!==(C=null==N?void 0:N.templateCategory)&&void 0!==C?C:""}`:"",onBackPress:()=>{null==P||P()}},{children:[e.jsx(o.default,{showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:j,showVariableModal:T,variableList:E}),S?e.jsx(i.default,{onSelect:function(){const e=null==S?void 0:S(N,V,null!=w?w:"");e?A(!!e):I(!0)}}):e.jsx(e.Fragment,{})]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),s=require("../template-preview/models/Channels.js"),o=require("./context/templateModalContext.js"),i=require("./modalElements/Footer.js"),r=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:c,closeDialog:u,showVariableMapping:p,channel:m,htmlContent:h,templateVariables:g,onTemplateSelect:C,globalPlaceholders:S,showOnlyContent:v,whatsappSpecificPickerMeta:b,zIndex:j,showVariableModal:M,variableList:T,discountCode:E,setDiscountCode:P,onBackPress:x}=d;var L,f;t.useEffect((()=>{A(h)}),[h]);const[w,q]=t.useState(m===s.CHANNEL_TYPE.EMAIL?"desktop":"mobile"),[y,A]=t.useState(h),[N,k]=t.useState(!1),[D,V]=t.useState(c),[_,H]=t.useState(null!=g?g:[]),[I,O]=t.useState(!1);const B=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(S)),[S]);return e.jsx(o.TemplateModalContext.Provider,Object.assign({value:{template:D,setTemplate:V,device:w,setDevice:q,display_content:y,setDisplayContent:A,originalVariableList:_,setOriginalVariableList:H,isError:N,setIsError:k,channel:m,globalNormalizedPlaceholders:B,templateSelectionTriggered:I,setTemplateSelectionTriggered:O}},{children:v?e.jsx(r.default,{channel:s.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:j,centralContainerStyles:{width:m===s.CHANNEL_TYPE.EMAIL&&p?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==D?void 0:D.label,headingSubtitle:m===s.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(L=null==D?void 0:D.category)&&void 0!==L?L:"")} • ${null!==(f=null==D?void 0:D.templateCategory)&&void 0!==f?f:""}`:"",onBackPress:()=>{null==x||x()}},{children:[e.jsx(r.default,{showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:b,showVariableModal:M,variableList:T,discountCode:E,setDiscountCode:P}),C?e.jsx(i.default,{onSelect:function(){const e=null==C?void 0:C(D,_,null!=y?y:"");e?k(!!e):O(!0)}}):e.jsx(e.Fragment,{})]}))}))};
@@ -6,6 +6,8 @@ export interface BodyProps {
6
6
  whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
7
7
  showVariableModal?: boolean;
8
8
  variableList?: VariableListInterfaceV2[];
9
+ discountCode?: string;
10
+ setDiscountCode?: (code: string) => void;
9
11
  }
10
12
  declare const Body: (props: BodyProps) => import("react/jsx-runtime").JSX.Element;
11
13
  export default Body;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("styled-components"),n=require("../../template-preview/models/Channels.js"),o=require("../../../constants/Theme.js"),i=require("../context/templateModalContext.js"),a=require("../utils/getVariableNameEmail.js"),r=require("../utils/highlightFor.js"),s=require("./DesktopPreview.js"),d=require("./EditWhatsAppTemplateV2.js"),u=require("./MobilePreview.js"),p=require("./VariableConnectorsPanel.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=c(l);const m=h.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("styled-components"),n=require("../../template-preview/models/Channels.js"),o=require("../../../constants/Theme.js"),i=require("../context/templateModalContext.js"),a=require("../utils/getVariableNameEmail.js"),r=require("../utils/highlightFor.js"),s=require("./DesktopPreview.js"),d=require("./EditWhatsAppTemplateV2.js"),u=require("./MobilePreview.js"),c=require("./VariableConnectorsPanel.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=p(l);const m=h.default.div`
2
2
  display: flex;
3
3
  // height: 100%;
4
4
  `,f=h.default.div`
@@ -15,4 +15,4 @@
15
15
  flex: 1;
16
16
  height: 475px;
17
17
  overflow-y: auto;
18
- `;exports.default=l=>{const{showVariableMapping:c,showOnlyContent:h,whatsappSpecificPickerMeta:g,showVariableModal:v,variableList:b}=l,j=t.useRef(),w=t.useRef(),{device:E,display_content:y,channel:C,template:P,setTemplate:T}=i.useTemplateModalContext();const L=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(m,{children:[e.jsx(x,Object.assign({showOnlyContent:h,showVariableMapping:c},{children:"mobile"===E?e.jsx(u.default,{ref:w,display_content:null!=y?y:"",channel:C,template:P}):C!==n.CHANNEL_TYPE.MESSAGE?e.jsx(s.default,{ref:j,channel:C,display_content:null!=y?y:""}):e.jsx(e.Fragment,{})})),c&&e.jsx(f,Object.assign({channel:C},{children:C!==n.CHANNEL_TYPE.WHATSAPP?e.jsx(p.default,{onFocus:C===n.CHANNEL_TYPE.EMAIL?function(e){var t,l,i;const s=null===document||void 0===document?void 0:document.getElementById("mobile"===E?"template_html_mobile":"template_html_desktop"),d=a.getVariableNameForEmailByIndex(e+1),u=C===n.CHANNEL_TYPE.EMAIL?null===(t=null==s?void 0:s.contentWindow)||void 0===t?void 0:t.document.getElementById(d):document.getElementById(d),p=L(u),c=null==u?void 0:u.offsetLeft;"desktop"===E?p&&j.current&&(null===(l=null==s?void 0:s.contentWindow)||void 0===l||l.scrollTo(null!=c?c:0,p),r.highlightFor(d,o.COLORS.background.warning.light,2,C,E)):p&&w.current&&(null===(i=null==s?void 0:s.contentWindow)||void 0===i||i.scrollTo(null!=c?c:0,p),r.highlightFor(d,o.COLORS.background.warning.light,2,C,E))}:void 0,showVariableModal:v,variableList:b}):e.jsx(d.default,{whatsappSpecificPickerMeta:g,template:P,onTemplateChange:e=>{null==T||T(e)},showVariableModal:v,variableList:b})}))]})};
18
+ `;exports.default=l=>{const{showVariableMapping:p,showOnlyContent:h,whatsappSpecificPickerMeta:g,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w}=l,C=t.useRef(),E=t.useRef(),{device:y,display_content:P,channel:T,template:L,setTemplate:M}=i.useTemplateModalContext();const _=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(m,{children:[e.jsx(x,Object.assign({showOnlyContent:h,showVariableMapping:p},{children:"mobile"===y?e.jsx(u.default,{ref:E,display_content:null!=P?P:"",channel:T,template:L}):T!==n.CHANNEL_TYPE.MESSAGE?e.jsx(s.default,{ref:C,channel:T,display_content:null!=P?P:""}):e.jsx(e.Fragment,{})})),p&&e.jsx(f,Object.assign({channel:T},{children:T!==n.CHANNEL_TYPE.WHATSAPP?e.jsx(c.default,{onFocus:T===n.CHANNEL_TYPE.EMAIL?function(e){var t,l,i;const s=null===document||void 0===document?void 0:document.getElementById("mobile"===y?"template_html_mobile":"template_html_desktop"),d=a.getVariableNameForEmailByIndex(e+1),u=T===n.CHANNEL_TYPE.EMAIL?null===(t=null==s?void 0:s.contentWindow)||void 0===t?void 0:t.document.getElementById(d):document.getElementById(d),c=_(u),p=null==u?void 0:u.offsetLeft;"desktop"===y?c&&C.current&&(null===(l=null==s?void 0:s.contentWindow)||void 0===l||l.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,y)):c&&E.current&&(null===(i=null==s?void 0:s.contentWindow)||void 0===i||i.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,y))}:void 0,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w}):e.jsx(d.default,{whatsappSpecificPickerMeta:g,template:L,onTemplateChange:e=>{null==M||M(e)},showVariableModal:v,variableList:b})}))]})};
@@ -9,6 +9,8 @@ export interface TemplateSelectModalContentProps {
9
9
  whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
10
10
  showVariableModal?: boolean;
11
11
  variableList?: VariableListInterfaceV2[];
12
+ discountCode?: string;
13
+ setDiscountCode?: (code: string) => void;
12
14
  }
13
- declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
15
+ declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
14
16
  export default TemplateSelectModalContent;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../template-preview/models/Channels.js"),t=require("./Body.js"),i=require("./Header.js");exports.default=r=>{let{channel:s,showVariableMapping:l,showOnlyContent:n,whatsappSpecificPickerMeta:o,showVariableModal:d,variableList:p}=r;return e.jsx("div",Object.assign({style:{paddingBottom:0}},{children:e.jsxs("div",{children:[s===a.CHANNEL_TYPE.EMAIL&&e.jsx(i.default,{showOnlyContent:n}),e.jsx(t.default,{whatsappSpecificPickerMeta:o,showVariableMapping:!!l,showOnlyContent:n,showVariableModal:d,variableList:p})]})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../template-preview/models/Channels.js"),s=require("./Body.js"),a=require("./Header.js");exports.default=i=>{let{channel:r,showVariableMapping:o,showOnlyContent:n,whatsappSpecificPickerMeta:l,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u}=i;return e.jsx("div",Object.assign({style:{paddingBottom:0}},{children:e.jsxs("div",{children:[r===t.CHANNEL_TYPE.EMAIL&&e.jsx(a.default,{showOnlyContent:n}),e.jsx(s.default,{whatsappSpecificPickerMeta:l,showVariableMapping:!!o,showOnlyContent:n,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u})]})}))};
@@ -4,6 +4,9 @@ export interface VariableConnectorsProps {
4
4
  onFocus?: (variableIndex: number) => void;
5
5
  showVariableModal?: boolean;
6
6
  variableList?: VariableListInterfaceV2[];
7
+ discountCode?: string;
8
+ setDiscountCode?: (code: string) => void;
7
9
  }
8
- declare const VariableConnectors: ({ onFocus, showVariableModal, variableList, }: VariableConnectorsProps) => import("react/jsx-runtime").JSX.Element;
10
+ declare const VariableConnectors: ({ onFocus, showVariableModal, variableList, discountCode, setDiscountCode, }: VariableConnectorsProps) => import("react/jsx-runtime").JSX.Element;
9
11
  export default VariableConnectors;
12
+ export declare const AddVariableStyled: import("styled-components").StyledComponent<"button", any, {}, never>;
@@ -1,6 +1,28 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/info.svg.js"),i=require("styled-components"),s=require("../../input/Input.js"),a=require("../../template-preview/models/Channels.js"),l=require("../../tooltips/Tooltip.js"),r=require("../../TypographyStyle.js"),n=require("../../../constants/Theme.js"),o=require("../context/templateModalContext.js"),d=require("./VariableConnector.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const u=c(i).default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../../assets/icons/info.svg.js"),i=require("react"),t=require("styled-components"),s=require("../../add-variableV2/AddVariableV2SideModal.js"),r=require("../../../assets/icons/plus.svg.js");require("../../add-variableV2/AddVariableV2.styled.js"),require("../../button/Button.js"),require("../../icon-button/IconButton.js");var l=require("../../input/Input.js"),n=require("../../tooltips/Tooltip.js"),o=require("../../../constants/Theme.js"),d=require("../../TypographyStyle.js"),c=require("../../checkBox/CheckBox.js"),u=require("../../template-preview/models/Channels.js"),h=require("../context/templateModalContext.js"),x=require("./VariableConnector.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=b(t);const p=j.default.div`
2
2
  overflow-y: auto;
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  height: 100%;
6
- `;exports.Container=u,exports.default=i=>{let{onFocus:c,showVariableModal:p,variableList:h}=i;const{originalVariableList:j,channel:x}=o.useTemplateModalContext();return e.jsxs(u,{children:[e.jsxs("div",Object.assign({style:{padding:8}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:8}},{children:[e.jsx(r.TitleRegular,Object.assign({style:{color:n.COLORS.content.primary}},{children:"Edit variables and links"})),e.jsx(l.Tooltip,Object.assign({body:"Variables are placeholder texts which can either be filled by data, eg: customer name or can have any custom text within them"},{children:e.jsx("div",{children:e.jsx(t.default,{width:20,height:20,color:n.COLORS.content.placeholder})})}))]})),e.jsx(r.BodySecondary,Object.assign({style:{color:n.COLORS.content.secondary}},{children:"You can view variables and links on the left underlined in purple colour."}))]})),null==j?void 0:j.map(((t,i)=>x!==a.CHANNEL_TYPE.EMAIL||t.isEditableVariable?e.jsx("div",Object.assign({style:{marginTop:16}},{children:e.jsx(d.default,{index:i,variable:t,onFocus:()=>null==c?void 0:c(i),showVariableModal:p,variableList:h})}),i):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(r.BodySecondary,Object.assign({style:{color:n.COLORS.content.primary}},{children:["Locked variable ",i+1]})),e.jsx(s.Input,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),i)))]})};
6
+ `,g=j.default.button`
7
+ padding: 2px 8px;
8
+ cursor: pointer;
9
+ color: white;
10
+ background-color: black;
11
+ width: fit-content;
12
+ float: right;
13
+ margin-top: 0px;
14
+ font-family: Inter;
15
+ font-style: normal;
16
+ font-weight: 600;
17
+ font-size: 14px;
18
+ line-height: 20px;
19
+ align-self: flex-end;
20
+ border-radius: 4px;
21
+ border: 1px solid #ccc;
22
+ margin-right: 1px;
23
+
24
+ .add {
25
+ display: flex;
26
+ align-items: center;
27
+ }
28
+ `;exports.AddVariableStyled=g,exports.Container=p,exports.default=t=>{let{onFocus:b,showVariableModal:j,variableList:f,discountCode:v,setDiscountCode:y}=t;const{originalVariableList:m,channel:O}=h.useTemplateModalContext(),[V,C]=i.useState(!1),[q,w]=i.useState(!1),[S,T]=i.useState(!1),[L,k]=i.useState(""),A=i.useRef(),B=i.useRef();return i.useEffect((()=>{y&&y(v+L)}),[L]),e.jsxs(p,{children:[e.jsxs("div",Object.assign({style:{padding:8}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",gap:8}},{children:[e.jsx(d.TitleRegular,Object.assign({style:{color:o.COLORS.content.primary}},{children:"Edit variables and links"})),e.jsx(n.Tooltip,Object.assign({body:"Variables are placeholder texts which can either be filled by data, eg: customer name or can have any custom text within them"},{children:e.jsx("div",{children:e.jsx(a.default,{width:20,height:20,color:o.COLORS.content.placeholder})})}))]})),e.jsx(d.BodySecondary,Object.assign({style:{color:o.COLORS.content.secondary}},{children:"You can view variables and links on the left underlined in purple colour."}))]})),null==m?void 0:m.map(((a,i)=>O!==u.CHANNEL_TYPE.EMAIL||a.isEditableVariable?e.jsx("div",Object.assign({style:{marginTop:16}},{children:e.jsx(x.default,{index:i,variable:a,onFocus:()=>null==b?void 0:b(i),showVariableModal:j,variableList:f})}),i):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:o.COLORS.content.primary}},{children:["Locked variable ",i+1]})),e.jsx(l.Input,{state:"disabled",placeholder:a.variableName,onChangeText:()=>{}})]}),i))),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",marginLeft:10,marginTop:8}},{children:[e.jsx(c.CheckBox,{isChecked:!1,onValueChange:()=>{C(!V)}}),e.jsx(d.TitleSmall,Object.assign({style:{marginLeft:8}},{children:"Add discount codes"}))]})),V&&e.jsxs("div",Object.assign({ref:A,style:{margin:10}},{children:[e.jsx(l.Input,{placeholder:"Enter your discount code",onChangeText:e=>{y&&y(e)},value:v,onFocus:()=>{w(!0)},onBlur:e=>{var a;"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)?(A.current&&A.current.focus(),w(!0)):(w(!1),T(!1))}}),q&&e.jsx(g,Object.assign({ref:B,id:"addVar",onClick:e=>{e.stopPropagation(),T(!0)}},{children:e.jsxs("div",Object.assign({className:"add"},{children:[e.jsx(r.default,{width:20,height:20,color:"white"}),e.jsx("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),S&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=f?f:[],showVariable:S,setShowVariable:T,variableValue:L,setVariableValue:k,placeholder:"Add a variable"})]})};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import a from"react-dom";import{AddVariableV2 as r}from"./AddVariableV2.js";import{SideModalStyle as o,SideModalContainer as t}from"../side-modal/SideModal.style.js";const d=d=>a.createPortal(e(o,Object.assign({zIndex:d.zIndex},{children:e(t,{children:e(r,{data:d.data,showVariable:d.showVariable,setShowVariable:d.setShowVariable,placeholder:"Add a variable",customTrigger:d.customTrigger,isModalState:!0})})})),document.body);export{d as AddVariableV2SideModal};
1
+ import{jsx as a}from"react/jsx-runtime";import e from"react-dom";import{AddVariableV2 as r}from"./AddVariableV2.js";import{SideModalStyle as o,SideModalContainer as t}from"../side-modal/SideModal.style.js";const i=i=>e.createPortal(a(o,Object.assign({zIndex:i.zIndex},{children:a(t,{children:a(r,{data:i.data,showVariable:i.showVariable,setShowVariable:i.setShowVariable,variableValue:i.variableValue,setVariableValue:i.setVariableValue,placeholder:"Add a variable",customTrigger:i.customTrigger,isModalState:!0})})})),document.body);export{i as AddVariableV2SideModal};
@@ -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 a,DISCOUNT_VALUE_TYPES as c}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as p}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as l,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 E}from"../tag/Tag.js";import{Tooltip as v}from"../tooltips/Tooltip.js";import T from"../../assets/icons/triangle_error.svg.js";import{StyledDiscountDialogueContainer as C,CouponTypeContainerStyled as P}from"./DiscountModal.styled.js";import{validateDiscountData as g}from"./DiscountUtils.js";import I,{DISCOUNT_PRODUCTS as h}from"./DynamicCoupon/DynamicCoupon.js";import j from"./StaticCoupon/StaticCoupon.js";const S=S=>{var O,N,D,_;const[w,f]=i(),[A,q]=i(null!==(O=S.data)&&void 0!==O?O:"string"==typeof S.hideOption?{isStaticCoupon:"dynamic"===S.hideOption}:{isStaticCoupon:!1}),[G,M]=i(!0),[x,F]=i(),[L,R]=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),[k,U]=i([]),[B,X]=i([]),[Y,Q]=i(0);n((()=>{let t;S.hideProbability||(t=V()),M(g(A,L,x,S.hideProbability||!1,t,!!A.isStaticCoupon)),S.hideProbability||V()}),[]),n((()=>{let t;S.hideProbability||(t=V()),M(g(A,L,x,S.hideProbability||!1,t,!!A.isStaticCoupon))}),[A,Y,x,L]),n((()=>{var t,e;if(S.products){if(null===(t=S.data)||void 0===t?void 0:t.entitledProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));X(t)}if(null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds){const t=S.products.filter((t=>{var e,o;return null===(o=null===(e=S.data)||void 0===e?void 0:e.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));U(t)}}}),[]),n((()=>{const t=B.map((t=>parseInt(t.id)));q(Object.assign(Object.assign({},A),{entitledProductIds:t}))}),[B]),n((()=>{const t=k.map((t=>parseInt(t.id)));q(Object.assign(Object.assign({},A),{prerequisiteProductIds:t}))}),[k]),n((()=>{A.targetType===d.SHIPPING_LINE?F(s.FREE_SHIPPING):A.targetSelection===a.ENTITLED?F(s.BUY_X_GET_Y):A.valueType===c.FIXED_AMOUNT?F(s.FIXED_AMOUNT):A.valueType===c.PERCENTAGE&&F(s.PERCENTAGE)}),[]);const H=[{value:s.FIXED_AMOUNT,label:"Fixed Amount",selected:x===s.FIXED_AMOUNT},{value:s.PERCENTAGE,label:"Percentage",selected:x===s.PERCENTAGE},{value:s.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:x===s.BUY_X_GET_Y},{value:s.FREE_SHIPPING,label:"Free shipping",selected:x===s.FREE_SHIPPING}],V=()=>{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)+(A.probability||0);return Q(parseFloat(o.toFixed(4))),parseFloat(o.toFixed(4))},z=t=>{const e=t.value;F(e),e===s.FREE_SHIPPING?(U([]),X([]),q(Object.assign(Object.assign({},A),{value:100,targetSelection:a.ALL,targetType:d.SHIPPING_LINE,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.BUY_X_GET_Y?q(Object.assign(Object.assign({},A),{targetSelection:a.ENTITLED,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE})):e===s.PERCENTAGE?(U([]),X([]),q(Object.assign(Object.assign({},A),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.PERCENTAGE,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0}))):e===s.FIXED_AMOUNT&&(U([]),X([]),q(Object.assign(Object.assign({},A),{targetSelection:a.ALL,targetType:d.LINE_ITEM,valueType:c.FIXED_AMOUNT,entitledQuantity:void 0,prerequisiteQuantity:void 0,entitledProductIds:void 0,prerequisiteProductIds:void 0})))};return t(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,{}):Y<=1?e(E,{theme:"light",tagText:`Current probability sum: ${Y}`,type:"white"}):e(v,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(E,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Y}`,type:"negative",LeadingIcon:T})})})),headerRightCustomElement:S.allowStaticCoupon||w?void 0:e(p,{options:H,width:"200px",placement:"bottom-start",size:"small",onSelect:t=>{z(t)}}),onClose:S.onClose,footerShadow:!0,primaryButton:w?{buttonType:"primary",onClick:()=>{f(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:G,onClick:()=>{A.isStaticCoupon?S.onSaveClicked({quadrant:A.quadrant,couponCode:A.couponCode,description:A.description,isStaticCoupon:A.isStaticCoupon,probability:A.probability,title:A.title}):S.onSaveClicked(A),q({})}},secondaryButton:w?{buttonType:"tertiaryGray",onClick:()=>{f(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:S.onClose,buttonText:"Close"}},{children:[!w&&t(C,{children:[S.allowStaticCoupon&&!w&&t(P,Object.assign({selectedDiv:A.isStaticCoupon?1:2},{children:["static"===S.hideOption?e(o,{}):t("div",Object.assign({className:"coupon-type__container",onClick:()=>{q({isStaticCoupon:!0,couponCode:A.couponCode,description:A.description,quadrant:A.quadrant})}},{children:[e(l,Object.assign({style:A.isStaticCoupon?{color:m.colorsV2.content.brand}:{}},{children:"Static code"})),e(u,Object.assign({style:A.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:()=>{q(Object.assign(Object.assign({},A),{isStaticCoupon:!1}))}},{children:[e(l,Object.assign({style:A.isStaticCoupon?{}:{color:m.colorsV2.content.brand}},{children:"Dynamic code"})),e(u,Object.assign({style:A.isStaticCoupon?{}:{color:m.colorsV2.content.brand}},{children:"New code generated for everyone"}))]}))]})),A.isStaticCoupon&&!w&&e(j,{discountData:A,setDiscountData:q,hideProbability:S.hideProbability||!1,discountAdminUrl:S.discountAdminUrl}),!A.isStaticCoupon&&!w&&e(I,{currency:S.currency,entitledProducts:B,prerequisiteProducts:k,setEntitledProducts:X,setPrerequisiteProducts:U,discountData:A,productPickerOpen:w,setIsProductPickerOpen:f,setDiscountData:q,selectedCouponType:x,setSelectedCouponType:F,selectedMinimumRequirement:L,setSelectedMinimumRequirement:R,hideProbability:S.hideProbability||!1,hideExpiration:S.hideExpiration||!1,allowStaticCoupon:S.allowStaticCoupon,onChangeCouponType:z})]}),!!w&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(b,{show:!0,onSave:()=>{},products:null!==(_=S.products)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{f(void 0)},selectedProducts:w===h.ENTITLED?B:k,setSelectedProducts:w===h.ENTITLED?X:U,onSearchKeyChange:S.onProductSearch})}))]}))};export{S as DiscountModal};
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 S from"./StaticCoupon/StaticCoupon.js";const j=j=>{var O,N,D,f,_;const[w,A]=i(),[q,x]=i(),[G,L]=i(null!==(O=j.data)&&void 0!==O?O:"string"==typeof j.hideOption?{isStaticCoupon:"dynamic"===j.hideOption}:{isStaticCoupon:!1}),[M,k]=i(!0),[F,R]=i(),[U,B]=i((null===(N=j.data)||void 0===N?void 0:N.minAmount)?r.AMOUNT:(null===(D=j.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;j.hideProbability||(t=tt()),k(P(G,U,F,j.hideProbability||!1,t,!!G.isStaticCoupon)),j.hideProbability||tt()}),[]),n((()=>{let t;j.hideProbability||(t=tt()),k(P(G,U,F,j.hideProbability||!1,t,!!G.isStaticCoupon))}),[G,Z,F,U]),n((()=>{var t,e,o,i,n;if(j.products&&(null===(t=j.products)||void 0===t?void 0:t.length)){if(null===(e=j.data)||void 0===e?void 0:e.entitledProductIds){const t=j.products.filter((t=>{var e,o;return null===(o=null===(e=j.data)||void 0===e?void 0:e.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));H(t)}if(null===(o=j.data)||void 0===o?void 0:o.prerequisiteProductIds){const t=j.products.filter((t=>{var e,o;return null===(o=null===(e=j.data)||void 0===e?void 0:e.prerequisiteProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));Y(t)}}if(j.collection&&j.collection.length){if(null===(i=j.data)||void 0===i?void 0:i.entitledCollectionIds){const t=j.collection.filter((t=>{var e,o;return null===(o=null===(e=j.data)||void 0===e?void 0:e.entitledCollectionIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));$(t)}if(null===(n=j.data)||void 0===n?void 0:n.prerequisiteCollectionIds){const t=j.collection.filter((t=>{var e,o;return null===(o=null===(e=j.data)||void 0===e?void 0:e.prerequisiteCollectionIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));z(t)}}}),[j.products,j.collection]),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(!j.quadrant||!j.probability)return;const t=[...j.probability];let e=[];t.length>=j.quadrant&&t.splice(j.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:j.isOpen,headingTitle:w?"Select Products":j.title,headingSubtitle:w?void 0:j.subTitle,footerLeftCustomElement:!j.quadrant||j.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:j.allowStaticCoupon||w?void 0:e(a,{options:W,width:"200px",placement:"bottom-start",size:"small",onSelect:t=>{et(t)}}),onClose:j.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?j.onSaveClicked({quadrant:G.quadrant,couponCode:G.couponCode,description:G.description,isStaticCoupon:G.isStaticCoupon,probability:G.probability,title:G.title}):j.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:j.onClose,buttonText:"Close"}},{children:[!w&&!q&&t(T,{children:[j.allowStaticCoupon&&!w&&t(I,Object.assign({selectedDiv:G.isStaticCoupon?1:2},{children:["static"===j.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"===j.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(S,{discountData:G,setDiscountData:L,hideProbability:j.hideProbability||!1,discountAdminUrl:j.discountAdminUrl}),!G.isStaticCoupon&&!w&&!q&&e(g,{currency:j.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:j.hideProbability||!1,hideExpiration:j.hideExpiration||!1,allowStaticCoupon:j.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=j.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:j.onProductSearch})})),!!q&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(b,{show:!0,onSave:()=>{},products:null!==(_=j.collection)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{x(void 0)},selectedProducts:q===h.ENTITLED?K:V,setSelectedProducts:q===h.ENTITLED?$:z,onSearchKeyChange:j.onCollectionSearch,searchPlaceholder:"Search collections..."})}))]}))};export{j 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,o,a,v)=>{var T,d;if(!u.title)return!0;if(!o){if(isNaN(u.probability))return!0;if((u.probability||0)>1)return!0;if((u.probability||0)<0)return!0;if(a>1)return!0}if(v){if(!(null==u?void 0:u.couponCode))return!0;if(!u.description)return!0}else{if(f&&f===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(f&&f===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(f&&f===e.BUY_X_GET_Y){if(!(u.entitledQuantity&&(null===(T=u.entitledProductIds)||void 0===T?void 0:T.length)&&u.prerequisiteQuantity&&(null===(d=u.prerequisiteProductIds)||void 0===d?void 0:d.length)))return!0;if(u.valueType!==i.PERCENTAGE)return!0;if(!u.value)return!0;if(u.value<=0||u.value>100)return!0;if(u.targetSelection!==n.ENTITLED)return!0;if(u.targetType!==r.LINE_ITEM)return!0}else if(f&&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
+ 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};
@@ -24,6 +24,7 @@ export interface SubscriptionPlanProps {
24
24
  freeTrialMessages?: string;
25
25
  extraBlockMessage?: string;
26
26
  isLoading?: boolean;
27
+ showMonthlyOptions?: boolean;
27
28
  }
28
29
  type Props = SubscriptionPlanProps;
29
30
  export declare const SubscriptionPlan: FunctionComponent<Props>;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as s}from"react/jsx-runtime";import i from"../../assets/icons/check.svg.js";import{Button as a}from"../button/Button.js";import{SubscriptionPlanStyled as n}from"./SubscriptionPlanStyled.js";import{Caption as c,TitleRegular as l,TitleMedium as r,BodyPrimary as o,BodyCaption as d}from"../TypographyStyle.js";import{COLORS as m}from"../../constants/Theme.js";const b=b=>{const h=b.showMonthly?b.monthlyPlan:b.yearlyPlan,p=!b.isDisabled&&b.isMostPopular;return e(n,Object.assign({isManifestPlan:!0,isSelected:b.isSelected||!1,style:{marginTop:p?0:24}},{children:[p&&t("div",Object.assign({className:"most-popular"},{children:t(c,Object.assign({className:"text"},{children:"Most popular ⭐️"}))})),e("div",Object.assign({className:`box ${b.isSelected?"selected":""} ${b.isDisabled?"disabled":""} ${p?"":"rounded-corners"}\n\t\t\t\t`},{children:[e("div",{children:[t(l,Object.assign({style:{color:m.content.secondary,marginBottom:4}},{children:b.planName})),e("div",Object.assign({className:"price-block"},{children:[e(r,Object.assign({style:{color:m.content.primary}},{children:["$ ",h.price]})),e(o,Object.assign({style:{color:m.content.secondary,marginLeft:4}},{children:["/ ",b.showMonthly?"month":"year"]}))]})),e("div",Object.assign({className:"per-message-price"},{children:[t(d,Object.assign({style:{color:m.content.secondary}},{children:b.planDescription})),t(d,Object.assign({style:{color:m.background.positive.vibrant,marginLeft:4}},{children:b.planDescriptionDiscount}))]})),b.showTrialOptions&&e(c,Object.assign({className:"trial "+(b.isSelected?"selected":"")},{children:["7 day free trial with ",b.freeTrialMessages," messages"]})),b.extraBlockMessage&&t(c,Object.assign({className:"trial "+(b.isSelected?"selected":"")},{children:b.extraBlockMessage})),t("div",Object.assign({className:"features"},{children:b.features.map(((s,a)=>e("div",Object.assign({className:"feature"},{children:[t("div",{children:t(i,{height:12,width:12,color:m.content.primary})}),t(d,Object.assign({className:"feature-text"},{children:s.detail}),a)]}),s.detail)))}))]}),t("div",Object.assign({className:"button-box"},{children:b.isLoading?t(a,{isLoading:!0,buttonType:"primary",buttonText:"Selected Plan",size:"medium",matchParentWidth:!0}):e(s,{children:[b.isSelected&&t(a,{LeadingIcon:i,buttonType:"tertiary",size:"medium",matchParentWidth:!0,buttonText:"Selected Plan",disabled:!1}),b.isDisabled&&t(a,{disabled:!0,buttonType:"primary",size:"medium",matchParentWidth:!0,buttonText:"Choose plan"}),!b.isSelected&&!b.isDisabled&&t(a,{buttonType:"primary",size:"medium",onClick:()=>b.onPlanSelect(b.code),matchParentWidth:!0,buttonText:"Choose plan"})]})}))]})),b.bottomDescription&&t("div",Object.assign({className:`plan-bottom-information\n\t\t\t\t\t${b.isDisabled?"disabled":""}\n\t\t\t\t\t${b.isSelected?"selected":""}\n\t\t\t\t`},{children:t(c,Object.assign({className:"text",style:{color:m.background.inverse}},{children:b.bottomDescription}))}))]}))};export{b as SubscriptionPlan};
1
+ import{jsxs as e,jsx as t,Fragment as s}from"react/jsx-runtime";import i from"../../assets/icons/check.svg.js";import{Button as a}from"../button/Button.js";import{SubscriptionPlanStyled as n}from"./SubscriptionPlanStyled.js";import{Caption as c,TitleRegular as l,TitleMedium as r,BodyPrimary as o,BodyCaption as d}from"../TypographyStyle.js";import{COLORS as m}from"../../constants/Theme.js";const b=b=>{const h=b.showMonthlyOptions?b.monthlyPlan:b.yearlyPlan,p=!b.isDisabled&&b.isMostPopular;return e(n,Object.assign({isManifestPlan:!0,isSelected:b.isSelected||!1,style:{marginTop:p?0:24}},{children:[p&&t("div",Object.assign({className:"most-popular"},{children:t(c,Object.assign({className:"text"},{children:"Most popular ⭐️"}))})),e("div",Object.assign({className:`box ${b.isSelected?"selected":""} ${b.isDisabled?"disabled":""} ${p?"":"rounded-corners"}\n\t\t\t\t`},{children:[e("div",{children:[t(l,Object.assign({style:{color:m.content.secondary,marginBottom:4}},{children:b.planName})),e("div",Object.assign({className:"price-block"},{children:[e(r,Object.assign({style:{color:m.content.primary}},{children:["$ ",h.price]})),e(o,Object.assign({style:{color:m.content.secondary,marginLeft:4}},{children:["/ ",b.showMonthlyOptions?"month":"year"]}))]})),e("div",Object.assign({className:"per-message-price"},{children:[t(d,Object.assign({style:{color:m.content.secondary}},{children:b.planDescription})),t(d,Object.assign({style:{color:m.background.positive.vibrant,marginLeft:4}},{children:b.planDescriptionDiscount}))]})),b.showTrialOptions&&e(c,Object.assign({className:"trial "+(b.isSelected?"selected":"")},{children:["7 day free trial with ",b.freeTrialMessages," messages"]})),b.extraBlockMessage&&t(c,Object.assign({className:"trial "+(b.isSelected?"selected":"")},{children:b.extraBlockMessage})),t("div",Object.assign({className:"features"},{children:b.features.map(((s,a)=>e("div",Object.assign({className:"feature"},{children:[t("div",{children:t(i,{height:12,width:12,color:m.content.primary})}),t(d,Object.assign({className:"feature-text"},{children:s.detail}),a)]}),s.detail)))}))]}),t("div",Object.assign({className:"button-box"},{children:b.isLoading?t(a,{isLoading:!0,buttonType:"primary",buttonText:"Selected Plan",size:"medium",matchParentWidth:!0}):e(s,{children:[b.isSelected&&t(a,{LeadingIcon:i,buttonType:"tertiary",size:"medium",matchParentWidth:!0,buttonText:"Selected Plan",disabled:!1}),b.isDisabled&&t(a,{disabled:!0,buttonType:"primary",size:"medium",matchParentWidth:!0,buttonText:"Choose plan"}),!b.isSelected&&!b.isDisabled&&t(a,{buttonType:"primary",size:"medium",onClick:()=>b.onPlanSelect(b.code),matchParentWidth:!0,buttonText:"Choose plan"})]})}))]})),b.bottomDescription&&t("div",Object.assign({className:`plan-bottom-information\n\t\t\t\t\t${b.isDisabled?"disabled":""}\n\t\t\t\t\t${b.isSelected?"selected":""}\n\t\t\t\t`},{children:t(c,Object.assign({className:"text",style:{color:m.background.inverse}},{children:b.bottomDescription}))}))]}))};export{b as SubscriptionPlan};
@@ -18,8 +18,10 @@ type Props = {
18
18
  errorMessage?: string;
19
19
  successText?: string;
20
20
  defaultValue?: string;
21
+ showRemoveCoupon?: boolean;
21
22
  onChangeText: (text: string) => void;
22
23
  removeCoupon?: () => void;
24
+ onCouponApply?: () => void;
23
25
  };
24
26
  showBookAdemo?: boolean;
25
27
  demoLink?: string;