@bikdotai/bik-component-library 0.0.290 → 0.0.291

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 (25) hide show
  1. package/dist/cjs/components/QueryBuilder/helpers/MetaCustomProcessor.d.ts +1 -1
  2. package/dist/cjs/components/alerts/Alert.styled.js +1 -0
  3. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsDropdown.d.ts +2 -0
  4. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
  5. package/dist/cjs/components/bik-layout/MockMenus.d.ts +0 -1
  6. package/dist/cjs/components/discount-modal/CouponExpiration/CouponExpiration.js +1 -1
  7. package/dist/cjs/components/discount-modal/DiscountModal.d.ts +1 -0
  8. package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
  9. package/dist/cjs/components/discount-modal/DiscountUtils.js +1 -1
  10. package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  11. package/dist/cjs/components/searchBar/searchBar.js +1 -1
  12. package/dist/cjs/components/stepper/WorkingStepper.d.ts +0 -1
  13. package/dist/esm/components/QueryBuilder/helpers/MetaCustomProcessor.d.ts +1 -1
  14. package/dist/esm/components/alerts/Alert.styled.js +1 -0
  15. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsDropdown.d.ts +2 -0
  16. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsDropdown.js +1 -1
  17. package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
  18. package/dist/esm/components/discount-modal/CouponExpiration/CouponExpiration.js +1 -1
  19. package/dist/esm/components/discount-modal/DiscountModal.d.ts +1 -0
  20. package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
  21. package/dist/esm/components/discount-modal/DiscountUtils.js +1 -1
  22. package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  23. package/dist/esm/components/searchBar/searchBar.js +1 -1
  24. package/dist/esm/components/stepper/WorkingStepper.d.ts +0 -1
  25. 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 | string[] | number[] | Date | Date[] | undefined;
39
+ value?: string | number | Date | Date[] | string[] | number[] | undefined;
40
40
  };
41
41
  key: string;
42
42
  refresh?: boolean | undefined;
@@ -1,5 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("./AlertHelper.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=t(e).default.div`
2
2
  display: flex;
3
+ align-items: center;
3
4
  justify-content: center;
4
5
  padding: 8px 16px;
5
6
  background-color: ${e=>r.COLOR_CONFIG_MAP[e.type].backgroundColor};
@@ -1,5 +1,6 @@
1
1
  import 'bootstrap/dist/css/bootstrap.min.css';
2
2
  import React from 'react';
3
+ import { DropDirection } from 'react-bootstrap/esm/DropdownContext';
3
4
  export interface DropdownOptions {
4
5
  label: string;
5
6
  value: string;
@@ -29,6 +30,7 @@ export interface AnalyticsDropdownInterface {
29
30
  offsetDistance?: number;
30
31
  };
31
32
  variant?: 'small' | 'default';
33
+ datePickerPlacement?: DropDirection;
32
34
  }
33
35
  export declare const AnalyticsDropdown: React.FC<AnalyticsDropdownInterface>;
34
36
  export declare const EachItem: React.FC<{
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react"),t=require("react-bootstrap"),n=require("../../constants/Theme.js"),s=require("../datePicker/DatePicker.js"),i=require("../TypographyStyle.js"),l=require("./CommonStyles.js");const a=o=>{let{eachOption:t,selectedOption:s,selectedDate:a,onClickingEachItem:c,rangeSelection:r}=o;return e.jsxs(l.ItemMenuContainer,Object.assign({onClick:()=>c(t),isSelected:t.isCustom?t.key==(null==s?void 0:s.key)&&!!a:t.key==(null==s?void 0:s.key)},{children:[e.jsx(i.BodySecondary,Object.assign({color:t.key==(null==s?void 0:s.key)?n.BASE_COLORS.positive[900]:n.BASE_COLORS.grayscale[900]},{children:t.label})),a&&(null==s?void 0:s.isCustom)&&t.key==(null==s?void 0:s.key)&&e.jsx(i.BodyCaption,{children:r?`${d(a[0])} to ${d(a[1])}`:`${d(a[0])}`})]}),t.key)},d=e=>e.toLocaleString("default",{day:"numeric",month:"short",year:"numeric"});exports.AnalyticsDropdown=c=>{let{options:r,placeholder:u="Select an option",selected:g,onOptionSelected:p,resetDropdown:v,maxHeight:O,backgroundColor:m,calendarPopperConfig:j,variant:D="default"}=c;var y,S,b;const[h,x]=o.useState(!1),[f,k]=o.useState(g),[w,C]=o.useState(),[R,E]=o.useState(!1),T=()=>{!h&&E(!R)},[A,M]=o.useState(g),q="small"===D?i.Caption:i.BodySecondary;return o.useEffect((()=>{v&&k(void 0)}),[v]),o.useEffect((()=>{var e;(null==g?void 0:g.isCustom)&&(null===(e=g.dateRangeSelectionOptions)||void 0===e?void 0:e.selectedDates)?C(g.dateRangeSelectionOptions.selectedDates):g&&k(g)}),[g]),e.jsx(e.Fragment,{children:e.jsxs(l.MainDropdown,Object.assign({drop:"down",show:R,onToggle:T,backgroundColor:m},{children:[e.jsx(t.Dropdown.Toggle,Object.assign({id:"dropdown-autoclose-outside",className:"main--dropdown",style:"small"===D?{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",backgroundColor:"#FAFAFA",borderRadius:4,border:`1px solid ${n.DEFAULT_THEME.colorsV2.stroke.primary}`}:void 0},{children:e.jsx(q,Object.assign({style:"small"===D?{color:n.DEFAULT_THEME.colorsV2.content.secondary}:void 0},{children:(null==f?void 0:f.isCustom)?w?d(w[0])===d(w[1])?`${d(w[0])}`:`${d(w[0])} to ${d(w[1])}`:null==A?void 0:A.label:f?null==f?void 0:f.label:u}))})),e.jsx(t.Dropdown.Menu,Object.assign({className:"main--dropdown"},{children:e.jsxs(l.MainDropdown,Object.assign({drop:"end",id:"sub--dropdown",show:h,onToggle:e=>{!e&&E(!1),x(!h)}},{children:[e.jsx("div",Object.assign({style:{maxHeight:O||"auto",overflowY:"scroll"}},{children:r.map((o=>{var n;return e.jsx("div",{children:(null==o?void 0:o.isCustom)?e.jsx(t.Dropdown.Toggle,Object.assign({className:"sub--dropdown"},{children:e.jsx(a,{eachOption:o,selectedOption:f,selectedDate:w,onClickingEachItem:e=>{k(e),x(!0)},rangeSelection:!!(null===(n=null==o?void 0:o.dateRangeSelectionOptions)||void 0===n?void 0:n.selectRange)})})):e.jsx(a,{eachOption:o,selectedOption:f,selectedDate:w,onClickingEachItem:e=>{if(k(e),M(e),T(),!e.noOfDays)return void p(e);const o=new Date,t=new Date;t.setDate(o.getDate()-e.noOfDays),p(Object.assign(Object.assign({},e),{selectedRange:[t,o]}))}})},null==o?void 0:o.key)}))})),e.jsx(t.Dropdown.Menu,Object.assign({className:"sub--dropdown",popperConfig:{modifiers:[{name:"offset",options:{offset:[(null==j?void 0:j.offsetSkid)||0,(null==j?void 0:j.offsetDistance)||0]}}]}},{children:e.jsx(s.DatePicker,{selectRange:(null===(y=null==f?void 0:f.dateRangeSelectionOptions)||void 0===y?void 0:y.selectRange)||!1,maxDate:null===(S=null==f?void 0:f.dateRangeSelectionOptions)||void 0===S?void 0:S.maxDate,minDate:null===(b=null==f?void 0:f.dateRangeSelectionOptions)||void 0===b?void 0:b.minDate,selectedDates:w,onSelectRange:(e,o)=>{const t=[e,o];(null==f?void 0:f.dateRangeSelectionOptions)&&(f.dateRangeSelectionOptions.selectedDates=t,p(Object.assign(Object.assign({},f),{selectedRange:[e,o]}))),M(f),x(!1),C(t),E(!R)},onSelectDate:e=>{(null==f?void 0:f.dateRangeSelectionOptions)&&(f.dateRangeSelectionOptions.selectedDates=[e,e],p(Object.assign(Object.assign({},f),{selectedRange:[e,e]}))),M(f),x(!1),C([e,e]),E(!R)}})}))]}))}))]}))})},exports.EachItem=a,exports.formatDate=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react"),t=require("react-bootstrap"),n=require("../../constants/Theme.js"),s=require("../datePicker/DatePicker.js"),i=require("../TypographyStyle.js"),l=require("./CommonStyles.js");const a=o=>{let{eachOption:t,selectedOption:s,selectedDate:a,onClickingEachItem:c,rangeSelection:r}=o;return e.jsxs(l.ItemMenuContainer,Object.assign({onClick:()=>c(t),isSelected:t.isCustom?t.key==(null==s?void 0:s.key)&&!!a:t.key==(null==s?void 0:s.key)},{children:[e.jsx(i.BodySecondary,Object.assign({color:t.key==(null==s?void 0:s.key)?n.BASE_COLORS.positive[900]:n.BASE_COLORS.grayscale[900]},{children:t.label})),a&&(null==s?void 0:s.isCustom)&&t.key==(null==s?void 0:s.key)&&e.jsx(i.BodyCaption,{children:r?`${d(a[0])} to ${d(a[1])}`:`${d(a[0])}`})]}),t.key)},d=e=>e.toLocaleString("default",{day:"numeric",month:"short",year:"numeric"});exports.AnalyticsDropdown=c=>{let{options:r,placeholder:u="Select an option",selected:g,onOptionSelected:p,resetDropdown:v,maxHeight:m,backgroundColor:O,calendarPopperConfig:j,variant:D="default",datePickerPlacement:y}=c;var S,b,h;const[x,f]=o.useState(!1),[k,w]=o.useState(g),[C,R]=o.useState(),[E,T]=o.useState(!1),A=()=>{!x&&T(!E)},[M,q]=o.useState(g),P="small"===D?i.Caption:i.BodySecondary;return o.useEffect((()=>{v&&w(void 0)}),[v]),o.useEffect((()=>{var e;(null==g?void 0:g.isCustom)&&(null===(e=g.dateRangeSelectionOptions)||void 0===e?void 0:e.selectedDates)?R(g.dateRangeSelectionOptions.selectedDates):g&&w(g)}),[g]),e.jsx(e.Fragment,{children:e.jsxs(l.MainDropdown,Object.assign({drop:"down",show:E,onToggle:A,backgroundColor:O},{children:[e.jsx(t.Dropdown.Toggle,Object.assign({id:"dropdown-autoclose-outside",className:"main--dropdown",style:"small"===D?{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",backgroundColor:"#FAFAFA",borderRadius:4,border:`1px solid ${n.DEFAULT_THEME.colorsV2.stroke.primary}`}:void 0},{children:e.jsx(P,Object.assign({style:"small"===D?{color:n.DEFAULT_THEME.colorsV2.content.secondary}:void 0},{children:(null==k?void 0:k.isCustom)?C?d(C[0])===d(C[1])?`${d(C[0])}`:`${d(C[0])} to ${d(C[1])}`:null==M?void 0:M.label:k?null==k?void 0:k.label:u}))})),e.jsx(t.Dropdown.Menu,Object.assign({className:"main--dropdown"},{children:e.jsxs(l.MainDropdown,Object.assign({drop:null!=y?y:"end",id:"sub--dropdown",show:x,onToggle:e=>{!e&&T(!1),f(!x)}},{children:[e.jsx("div",Object.assign({style:{maxHeight:m||"auto",overflowY:"scroll"}},{children:r.map((o=>{var n;return e.jsx("div",{children:(null==o?void 0:o.isCustom)?e.jsx(t.Dropdown.Toggle,Object.assign({className:"sub--dropdown"},{children:e.jsx(a,{eachOption:o,selectedOption:k,selectedDate:C,onClickingEachItem:e=>{w(e),f(!0)},rangeSelection:!!(null===(n=null==o?void 0:o.dateRangeSelectionOptions)||void 0===n?void 0:n.selectRange)})})):e.jsx(a,{eachOption:o,selectedOption:k,selectedDate:C,onClickingEachItem:e=>{if(w(e),q(e),A(),!e.noOfDays)return void p(e);const o=new Date,t=new Date;t.setDate(o.getDate()-e.noOfDays),p(Object.assign(Object.assign({},e),{selectedRange:[t,o]}))}})},null==o?void 0:o.key)}))})),e.jsx(t.Dropdown.Menu,Object.assign({className:"sub--dropdown",popperConfig:{modifiers:[{name:"offset",options:{offset:[(null==j?void 0:j.offsetSkid)||0,(null==j?void 0:j.offsetDistance)||0]}}]}},{children:e.jsx(s.DatePicker,{selectRange:(null===(S=null==k?void 0:k.dateRangeSelectionOptions)||void 0===S?void 0:S.selectRange)||!1,maxDate:null===(b=null==k?void 0:k.dateRangeSelectionOptions)||void 0===b?void 0:b.maxDate,minDate:null===(h=null==k?void 0:k.dateRangeSelectionOptions)||void 0===h?void 0:h.minDate,selectedDates:C,onSelectRange:(e,o)=>{const t=[e,o];(null==k?void 0:k.dateRangeSelectionOptions)&&(k.dateRangeSelectionOptions.selectedDates=t,p(Object.assign(Object.assign({},k),{selectedRange:[e,o]}))),q(k),f(!1),R(t),T(!E)},onSelectDate:e=>{(null==k?void 0:k.dateRangeSelectionOptions)&&(k.dateRangeSelectionOptions.selectedDates=[e,e],p(Object.assign(Object.assign({},k),{selectedRange:[e,e]}))),q(k),f(!1),R([e,e]),T(!E)}})}))]}))}))]}))})},exports.EachItem=a,exports.formatDate=d;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),i=require("date-fns"),s=require("react"),a=require("../../custom-date-time/CustomDateTime.js"),r=require("../../input/Input.js"),o=require("../../radioButton/RadioButton.js"),n=require("../../TypographyStyle.js"),I=require("../../../constants/Theme.js");exports.COUPON_EXPIRATION=void 0,(e=exports.COUPON_EXPIRATION||(exports.COUPON_EXPIRATION={})).FIXED_EXPIRATION="fixedExpiration",e.DYNAMIC_EXPIRATION="dynamicExpiration";exports.CouponExpiration=e=>{var d;const[O,c]=s.useState(e.discountData.expireAt?exports.COUPON_EXPIRATION.FIXED_EXPIRATION:e.discountData.expireAfter?exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION:void 0),[x,p]=s.useState(),[u,A]=s.useState(),N=(new Date).setDate((new Date).getDate()+1);s.useEffect((()=>{(null==O||x||u)&&e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAfter:void 0,expireAt:void 0})),O&&(x||u)&&(O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION?A(void 0):p(void 0))}),[O,x,u]);return t.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13}},{children:[t.jsx(n.TitleRegular,{children:"Coupon expiration (optional)"}),t.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[t.jsx(o.RadioButton,{isActive:O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION,onValueChange:()=>{A(void 0),c(O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION?void 0:exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)}}),t.jsx(n.BodySecondary,{children:"Validity days from coupon claim"})]})),O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION&&t.jsx(r.Input,{value:null===(d=e.discountData.expireAfter)||void 0===d?void 0:d.toString(),placeholder:"Enter the number of days",width:"400px",type:"number",onChangeText:t=>{(t=>{A(void 0);const i=Number.parseInt(t);i>0?e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAfter:i,expireAt:void 0})):A("Please enter days more than 0")})(t)}}),u&&t.jsx(n.BodySecondary,Object.assign({style:{color:I.DEFAULT_THEME.colorsV2.stroke.negative.vibrant}},{children:u})),t.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[t.jsx(o.RadioButton,{isActive:O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION,onValueChange:()=>{c(O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION?void 0:exports.COUPON_EXPIRATION.FIXED_EXPIRATION)}}),t.jsx(n.BodySecondary,{children:"Fixed expiry date"})]})),O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION&&t.jsxs(t.Fragment,{children:[t.jsx(n.BodySecondary,{children:"Ending on"}),t.jsx(a.CustomDateTime,{placement:"bottom-start",time:e.discountData.expireAt?i.format(new Date(e.discountData.expireAt),"hh:mm a"):i.format(new Date,"hh:mm a"),date:e.discountData.expireAt?new Date(e.discountData.expireAt):new Date,error:x,setError:p,onChange:t=>{e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAt:t,expireAfter:void 0}))},minDate:new Date(N)})]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),i=require("date-fns"),s=require("react"),a=require("../../custom-date-time/CustomDateTime.js"),r=require("../../input/Input.js"),o=require("../../radioButton/RadioButton.js"),n=require("../../TypographyStyle.js"),I=require("../../../constants/Theme.js");exports.COUPON_EXPIRATION=void 0,(e=exports.COUPON_EXPIRATION||(exports.COUPON_EXPIRATION={})).FIXED_EXPIRATION="fixedExpiration",e.DYNAMIC_EXPIRATION="dynamicExpiration";exports.CouponExpiration=e=>{var d;const[O,c]=s.useState(e.discountData.expireAt?exports.COUPON_EXPIRATION.FIXED_EXPIRATION:e.discountData.expireAfter?exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION:void 0),[p,x]=s.useState(),[u,A]=s.useState(),N=(new Date).setDate((new Date).getDate()+1);s.useEffect((()=>{(null==O||p||u)&&e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAfter:void 0,expireAt:void 0})),O&&(p||u)&&(O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION?A(void 0):x(void 0))}),[O,p,u]);return t.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13}},{children:[t.jsx(n.TitleRegular,{children:"Coupon expiration (optional)"}),t.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[t.jsx(o.RadioButton,{isActive:O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION,onValueChange:()=>{A(void 0),c(O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION?void 0:exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)}}),t.jsx(n.BodySecondary,{children:"Validity days from coupon claim"})]})),O===exports.COUPON_EXPIRATION.DYNAMIC_EXPIRATION&&t.jsx(r.Input,{value:null===(d=e.discountData.expireAfter)||void 0===d?void 0:d.toString(),placeholder:"Enter the number of days",width:"400px",type:"number",onChangeText:t=>{(t=>{A(void 0);const i=Number.parseInt(t);i>0?e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAfter:i,expireAt:void 0})):A("Please enter valid input")})(t)}}),u&&t.jsx(n.BodySecondary,Object.assign({style:{color:I.DEFAULT_THEME.colorsV2.stroke.negative.vibrant}},{children:u})),t.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[t.jsx(o.RadioButton,{isActive:O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION,onValueChange:()=>{c(O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION?void 0:exports.COUPON_EXPIRATION.FIXED_EXPIRATION)}}),t.jsx(n.BodySecondary,{children:"Fixed expiry date"})]})),O===exports.COUPON_EXPIRATION.FIXED_EXPIRATION&&t.jsxs(t.Fragment,{children:[t.jsx(n.BodySecondary,{children:"Ending on"}),t.jsx(a.CustomDateTime,{placement:"bottom-start",time:e.discountData.expireAt?i.format(new Date(e.discountData.expireAt),"hh:mm a"):i.format(new Date,"hh:mm a"),date:e.discountData.expireAt?new Date(e.discountData.expireAt):new Date,error:p,setError:x,onChange:t=>{e.setDiscountData(Object.assign(Object.assign({},e.discountData),{expireAt:t,expireAfter:void 0}))},minDate:new Date(N)})]})]}))};
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { ICouponData } from "./type";
3
3
  import { Product } from "../product-picker/type";
4
4
  export interface DiscountDialogueI {
5
+ hideOption?: 'static' | 'dynamic';
5
6
  isOpen: boolean;
6
7
  title: string;
7
8
  subTitle?: string;
@@ -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"),T=require("./DiscountUtils.js"),p=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:{isStaticCoupon:!1}),[N,j]=t.useState(!0),[v,U]=t.useState(),[g,m]=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),[q,A]=t.useState([]),[h,x]=t.useState([]),[R,Y]=t.useState(0);t.useEffect((()=>{let e;S.hideProbability||(e=M()),j(T.validateDiscountData(b,g,v,S.hideProbability||!1,e,!!b.isStaticCoupon)),S.hideProbability||M()}),[]),t.useEffect((()=>{let e;S.hideProbability||(e=M()),j(T.validateDiscountData(b,g,v,S.hideProbability||!1,e,!!b.isStaticCoupon))}),[b,R,v,g]),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))}));A(e)}}}),[]),t.useEffect((()=>{const e=h.map((e=>parseInt(e.id)));D(Object.assign(Object.assign({},b),{entitledProductIds:e}))}),[h]),t.useEffect((()=>{const e=q.map((e=>parseInt(e.id)));D(Object.assign(Object.assign({},b),{prerequisiteProductIds:e}))}),[q]),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?(A([]),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?(A([]),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&&(A([]),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:[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"}))]})),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(p.default,{currency:S.currency,entitledProducts:h,prerequisiteProducts:q,setEntitledProducts:x,setPrerequisiteProducts:A,discountData:b,productPickerOpen:y,setIsProductPickerOpen:O,setDiscountData:D,selectedCouponType:v,setSelectedCouponType:U,selectedMinimumRequirement:g,setSelectedMinimumRequirement:m,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===p.DISCOUNT_PRODUCTS.ENTITLED?h:q,setSelectedProducts:y===p.DISCOUNT_PRODUCTS.ENTITLED?x:A,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"),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 +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(!i.title)return!0;if(!n){if(isNaN(i.probability))return!0;if((i.probability||0)>1)return!0;if((i.probability||0)<0)return!0;if(u>1)return!0}if(T){if(!(null==i?void 0:i.couponCode))return!0;if(!i.description)return!0}else{if(r&&r===e.DISCOUNT_TYPES.FIXED_AMOUNT){if(i.valueType!==e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT)return!0;if(!(null==i?void 0:i.value)||(null==i?void 0:i.value)<=0)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.PERCENTAGE){if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!(null==i?void 0:i.value)||(null==i?void 0:i.value)<=0||(null==i?void 0:i.value)>100)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.BUY_X_GET_Y){if(!(i.entitledQuantity&&(null===(E=i.entitledProductIds)||void 0===E?void 0:E.length)&&i.prerequisiteQuantity&&(null===(l=i.prerequisiteProductIds)||void 0===l?void 0:l.length)))return!0;if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!i.value)return!0;if(i.value<=0||i.value>100)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else{if(!r||!e.DISCOUNT_TYPES.FREE_SHIPPING)return!0;if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE)return!0;if(100!==i.value)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0}if(null!==i.expireAfter&&void 0!==i.expireAfter&&i.expireAfter<=0)return!0}return!1};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./type.js");exports.validateDiscountData=(i,t,r,n,u,T)=>{var E,l;if(!i.title)return!0;if(!n){if(isNaN(i.probability))return!0;if((i.probability||0)>1)return!0;if((i.probability||0)<0)return!0;if(u>1)return!0}if(T){if(!(null==i?void 0:i.couponCode))return!0;if(!i.description)return!0}else{if(r&&r===e.DISCOUNT_TYPES.FIXED_AMOUNT){if(i.valueType!==e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT)return!0;if(!(null==i?void 0:i.value)||(null==i?void 0:i.value)<=0)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.PERCENTAGE){if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!(null==i?void 0:i.value)||(null==i?void 0:i.value)<=0||(null==i?void 0:i.value)>100)return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!i.minAmount||(null==i?void 0:i.minAmount)<=0))return!0;if(t===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==i?void 0:i.minQuantity)||(null==i?void 0:i.minQuantity)<=0))return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.BUY_X_GET_Y){if(!(i.entitledQuantity&&(null===(E=i.entitledProductIds)||void 0===E?void 0:E.length)&&i.prerequisiteQuantity&&(null===(l=i.prerequisiteProductIds)||void 0===l?void 0:l.length)))return!0;if(i.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!i.value)return!0;if(i.value<=0||i.value>100)return!0;if(i.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(i.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else if(r&&e.DISCOUNT_TYPES.FREE_SHIPPING){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 +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"),c=require("../../radioButton/RadioButton.js"),u=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}],D=[{selected:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.NA,label:"No minimum requirements",value:s.MIN_PURCHASE_REQUIREMENT.NA},{selected:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT,label:`Minimum purchase amount (${null!==(m=j.currency)&&void 0!==m?m:"₹"})`,value:s.MIN_PURCHASE_REQUIREMENT.AMOUNT},{selected:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.QUANTITY,label:"Minimum quantity of items",value:s.MIN_PURCHASE_REQUIREMENT.QUANTITY}],E=()=>{var t,a,o,l;return e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsxs("div",Object.assign({className:"input__wrapper"},{children:[e.jsx(n.BodySecondary,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),e.jsx(i.Dropdown,{options:D,placement:"bottom-start",onSelect:e=>{const t=e.value;j.setSelectedMinimumRequirement(t),j.setDiscountData(Object.assign(Object.assign({},j.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),e.jsx("div",Object.assign({className:"input__wrapper"},{children:j.selectedMinimumRequirement!==s.MIN_PURCHASE_REQUIREMENT.NA&&e.jsx(r.Input,{value:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?null!==(a=null===(t=j.discountData.minAmount)||void 0===t?void 0:t.toString())&&void 0!==a?a:"":null!==(l=null===(o=j.discountData.minQuantity)||void 0===o?void 0:o.toString())&&void 0!==l?l:"",onChangeText:e=>{j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?j.setDiscountData(Object.assign(Object.assign({},j.discountData),{minAmount:parseInt(e)})):j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.QUANTITY&&j.setDiscountData(Object.assign(Object.assign({},j.discountData),{minQuantity:parseInt(e)}))},labelText:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",type:"number",placeholder:j.selectedMinimumRequirement===s.MIN_PURCHASE_REQUIREMENT.AMOUNT?"1000.00":"2"})}))]}))},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})}))]})),E(),!j.hideProbability&&e.jsxs("div",Object.assign({className:"input__rows"},{children:[e.jsx("div",Object.assign({className:"input__wrapper"},{children:e.jsx(r.Input,{type:"number",value:null===(a=j.discountData.probability)||void 0===a?void 0:a.toString(),onChangeText:e=>{j.setDiscountData(Object.assign(Object.assign({},j.discountData),{probability:e.startsWith(".")?parseFloat(`0${e}`):parseFloat(e)}))},labelText:"Probability",placeholder:"Enter probability in decimals (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)"})}))]})),E()]})})(),j.selectedCouponType===s.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var t;return e.jsxs(l.DynamicCouponContainer,{children:[e.jsx("div",Object.assign({className:"input__rows"},{children:e.jsxs("div",Object.assign({style:{display:"flex",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(c.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(c.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(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"})]}))]})};
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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/searchIcon.js"),s=require("react"),a=require("../../assets/icons/cross.svg.js"),n=require("../input/Input.js");exports.SearchBar=r=>{const{isEnabled:c,onEnter:o,placeholder:i,width:l,variant:u,validate:d,isActive:h}=r,[v,f]=s.useState("search"),[p,g]=s.useState("default"),[C,j]=s.useState(h?"active":c?"none":"disabled"),[k,I]=s.useState(r.initialValue||"");s.useEffect((()=>{j(h?"active":c?"none":"disabled")}),[c,h]),s.useEffect((()=>{r.reset&&b()}),[null==r?void 0:r.reset]);const S=e=>{c&&o(e)},b=()=>{f("search"),g("default"),I(""),r.onChange(""),j("none"),o("")};return e.jsx(n.Input,{validate:d,onFocus:()=>{k.length&&f("cross"),"default"===p&&c&&(g("clicked"),j("active"))},width:l,state:C,leftIcon:"search"===v&&"default"===p?{icon:t.SearchIcon}:void 0,rightIcon:"cross"===v?{icon:a.default,callback:()=>{b(),r.onClickCross&&r.onClickCross()}}:void 0,onChangeText:(e,t)=>{r.onChange(e),I(e),"keydown"!==(null==t?void 0:t.type)||13!==t.which&&13!==t.keyCode?e.trim().length?f("cross"):f("search"):S(e)},placeholder:i,variant:u,value:k,onBlur:()=>{k.length||g("default"),j("none")}})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../assets/icons/searchIcon.js"),s=require("react"),a=require("../../assets/icons/cross.svg.js"),n=require("../input/Input.js");exports.SearchBar=r=>{const{isEnabled:c,onEnter:i,placeholder:o,width:l,variant:u,validate:d,isActive:h}=r,[v,f]=s.useState("search"),[p,C]=s.useState("default"),[g,j]=s.useState(h?"active":c?"none":"disabled"),[k,I]=s.useState(r.initialValue||"");s.useEffect((()=>{j(h?"active":c?"none":"disabled")}),[c,h]),s.useEffect((()=>{r.reset&&b()}),[null==r?void 0:r.reset]);const S=e=>{c&&i(e)},b=()=>{f("search"),C("default"),I(""),r.onChange(""),j("none"),i("")};return e.jsx(n.Input,{validate:d,onFocus:()=>{"default"===p&&c&&(C("clicked"),j("active"))},width:l,state:g,leftIcon:"search"===v&&"default"===p?{icon:t.SearchIcon}:void 0,rightIcon:"cross"===v?{icon:a.default,callback:()=>{b(),r.onClickCross&&r.onClickCross()}}:void 0,onChangeText:(e,t)=>{r.onChange(e),I(e),"keydown"!==(null==t?void 0:t.type)||13!==t.which&&13!==t.keyCode?e.trim().length?f("cross"):f("search"):S(e)},placeholder:o,variant:u,value:k,onBlur:()=>{k.length||C("default"),j("none")}})};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const WorkingStepper: () => JSX.Element;
3
2
  export declare enum STEPENUM {
4
3
  STEP1 = "STEP1",
@@ -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 | string[] | number[] | Date | Date[] | undefined;
39
+ value?: string | number | Date | Date[] | string[] | number[] | undefined;
40
40
  };
41
41
  key: string;
42
42
  refresh?: boolean | undefined;
@@ -1,5 +1,6 @@
1
1
  import o from"styled-components";import{COLOR_CONFIG_MAP as r}from"./AlertHelper.js";const e=o.div`
2
2
  display: flex;
3
+ align-items: center;
3
4
  justify-content: center;
4
5
  padding: 8px 16px;
5
6
  background-color: ${o=>r[o.type].backgroundColor};
@@ -1,5 +1,6 @@
1
1
  import 'bootstrap/dist/css/bootstrap.min.css';
2
2
  import React from 'react';
3
+ import { DropDirection } from 'react-bootstrap/esm/DropdownContext';
3
4
  export interface DropdownOptions {
4
5
  label: string;
5
6
  value: string;
@@ -29,6 +30,7 @@ export interface AnalyticsDropdownInterface {
29
30
  offsetDistance?: number;
30
31
  };
31
32
  variant?: 'small' | 'default';
33
+ datePickerPlacement?: DropDirection;
32
34
  }
33
35
  export declare const AnalyticsDropdown: React.FC<AnalyticsDropdownInterface>;
34
36
  export declare const EachItem: React.FC<{
@@ -1 +1 @@
1
- import{jsx as e,Fragment as o,jsxs as n}from"react/jsx-runtime";import{useState as t,useEffect as l}from"react";import{Dropdown as i}from"react-bootstrap";import{DEFAULT_THEME as s,BASE_COLORS as a}from"../../constants/Theme.js";import{DatePicker as d}from"../datePicker/DatePicker.js";import{BodySecondary as c,BodyCaption as r,Caption as g}from"../TypographyStyle.js";import{MainDropdown as p,ItemMenuContainer as u}from"./CommonStyles.js";const m=a=>{let{options:r,placeholder:u="Select an option",selected:m,onOptionSelected:b,resetDropdown:h,maxHeight:f,backgroundColor:y,calendarPopperConfig:D,variant:j="default"}=a;var k,S,R;const[C,w]=t(!1),[x,$]=t(m),[T,I]=t(),[N,A]=t(!1),E=()=>{!C&&A(!N)},[F,P]=t(m),H="small"===j?g:c;return l((()=>{h&&$(void 0)}),[h]),l((()=>{var e;(null==m?void 0:m.isCustom)&&(null===(e=m.dateRangeSelectionOptions)||void 0===e?void 0:e.selectedDates)?I(m.dateRangeSelectionOptions.selectedDates):m&&$(m)}),[m]),e(o,{children:n(p,Object.assign({drop:"down",show:N,onToggle:E,backgroundColor:y},{children:[e(i.Toggle,Object.assign({id:"dropdown-autoclose-outside",className:"main--dropdown",style:"small"===j?{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",backgroundColor:"#FAFAFA",borderRadius:4,border:`1px solid ${s.colorsV2.stroke.primary}`}:void 0},{children:e(H,Object.assign({style:"small"===j?{color:s.colorsV2.content.secondary}:void 0},{children:(null==x?void 0:x.isCustom)?T?O(T[0])===O(T[1])?`${O(T[0])}`:`${O(T[0])} to ${O(T[1])}`:null==F?void 0:F.label:x?null==x?void 0:x.label:u}))})),e(i.Menu,Object.assign({className:"main--dropdown"},{children:n(p,Object.assign({drop:"end",id:"sub--dropdown",show:C,onToggle:e=>{!e&&A(!1),w(!C)}},{children:[e("div",Object.assign({style:{maxHeight:f||"auto",overflowY:"scroll"}},{children:r.map((o=>{var n;return e("div",{children:(null==o?void 0:o.isCustom)?e(i.Toggle,Object.assign({className:"sub--dropdown"},{children:e(v,{eachOption:o,selectedOption:x,selectedDate:T,onClickingEachItem:e=>{$(e),w(!0)},rangeSelection:!!(null===(n=null==o?void 0:o.dateRangeSelectionOptions)||void 0===n?void 0:n.selectRange)})})):e(v,{eachOption:o,selectedOption:x,selectedDate:T,onClickingEachItem:e=>{if($(e),P(e),E(),!e.noOfDays)return void b(e);const o=new Date,n=new Date;n.setDate(o.getDate()-e.noOfDays),b(Object.assign(Object.assign({},e),{selectedRange:[n,o]}))}})},null==o?void 0:o.key)}))})),e(i.Menu,Object.assign({className:"sub--dropdown",popperConfig:{modifiers:[{name:"offset",options:{offset:[(null==D?void 0:D.offsetSkid)||0,(null==D?void 0:D.offsetDistance)||0]}}]}},{children:e(d,{selectRange:(null===(k=null==x?void 0:x.dateRangeSelectionOptions)||void 0===k?void 0:k.selectRange)||!1,maxDate:null===(S=null==x?void 0:x.dateRangeSelectionOptions)||void 0===S?void 0:S.maxDate,minDate:null===(R=null==x?void 0:x.dateRangeSelectionOptions)||void 0===R?void 0:R.minDate,selectedDates:T,onSelectRange:(e,o)=>{const n=[e,o];(null==x?void 0:x.dateRangeSelectionOptions)&&(x.dateRangeSelectionOptions.selectedDates=n,b(Object.assign(Object.assign({},x),{selectedRange:[e,o]}))),P(x),w(!1),I(n),A(!N)},onSelectDate:e=>{(null==x?void 0:x.dateRangeSelectionOptions)&&(x.dateRangeSelectionOptions.selectedDates=[e,e],b(Object.assign(Object.assign({},x),{selectedRange:[e,e]}))),P(x),w(!1),I([e,e]),A(!N)}})}))]}))}))]}))})},v=o=>{let{eachOption:t,selectedOption:l,selectedDate:i,onClickingEachItem:s,rangeSelection:d}=o;return n(u,Object.assign({onClick:()=>s(t),isSelected:t.isCustom?t.key==(null==l?void 0:l.key)&&!!i:t.key==(null==l?void 0:l.key)},{children:[e(c,Object.assign({color:t.key==(null==l?void 0:l.key)?a.positive[900]:a.grayscale[900]},{children:t.label})),i&&(null==l?void 0:l.isCustom)&&t.key==(null==l?void 0:l.key)&&e(r,{children:d?`${O(i[0])} to ${O(i[1])}`:`${O(i[0])}`})]}),t.key)},O=e=>e.toLocaleString("default",{day:"numeric",month:"short",year:"numeric"});export{m as AnalyticsDropdown,v as EachItem,O as formatDate};
1
+ import{jsx as e,Fragment as o,jsxs as n}from"react/jsx-runtime";import{useState as t,useEffect as l}from"react";import{Dropdown as i}from"react-bootstrap";import{DEFAULT_THEME as s,BASE_COLORS as a}from"../../constants/Theme.js";import{DatePicker as d}from"../datePicker/DatePicker.js";import{BodySecondary as c,BodyCaption as r,Caption as g}from"../TypographyStyle.js";import{MainDropdown as p,ItemMenuContainer as u}from"./CommonStyles.js";const m=a=>{let{options:r,placeholder:u="Select an option",selected:m,onOptionSelected:b,resetDropdown:h,maxHeight:f,backgroundColor:y,calendarPopperConfig:k,variant:D="default",datePickerPlacement:j}=a;var S,R,C;const[w,x]=t(!1),[$,T]=t(m),[P,I]=t(),[N,A]=t(!1),E=()=>{!w&&A(!N)},[F,H]=t(m),M="small"===D?g:c;return l((()=>{h&&T(void 0)}),[h]),l((()=>{var e;(null==m?void 0:m.isCustom)&&(null===(e=m.dateRangeSelectionOptions)||void 0===e?void 0:e.selectedDates)?I(m.dateRangeSelectionOptions.selectedDates):m&&T(m)}),[m]),e(o,{children:n(p,Object.assign({drop:"down",show:N,onToggle:E,backgroundColor:y},{children:[e(i.Toggle,Object.assign({id:"dropdown-autoclose-outside",className:"main--dropdown",style:"small"===D?{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",backgroundColor:"#FAFAFA",borderRadius:4,border:`1px solid ${s.colorsV2.stroke.primary}`}:void 0},{children:e(M,Object.assign({style:"small"===D?{color:s.colorsV2.content.secondary}:void 0},{children:(null==$?void 0:$.isCustom)?P?O(P[0])===O(P[1])?`${O(P[0])}`:`${O(P[0])} to ${O(P[1])}`:null==F?void 0:F.label:$?null==$?void 0:$.label:u}))})),e(i.Menu,Object.assign({className:"main--dropdown"},{children:n(p,Object.assign({drop:null!=j?j:"end",id:"sub--dropdown",show:w,onToggle:e=>{!e&&A(!1),x(!w)}},{children:[e("div",Object.assign({style:{maxHeight:f||"auto",overflowY:"scroll"}},{children:r.map((o=>{var n;return e("div",{children:(null==o?void 0:o.isCustom)?e(i.Toggle,Object.assign({className:"sub--dropdown"},{children:e(v,{eachOption:o,selectedOption:$,selectedDate:P,onClickingEachItem:e=>{T(e),x(!0)},rangeSelection:!!(null===(n=null==o?void 0:o.dateRangeSelectionOptions)||void 0===n?void 0:n.selectRange)})})):e(v,{eachOption:o,selectedOption:$,selectedDate:P,onClickingEachItem:e=>{if(T(e),H(e),E(),!e.noOfDays)return void b(e);const o=new Date,n=new Date;n.setDate(o.getDate()-e.noOfDays),b(Object.assign(Object.assign({},e),{selectedRange:[n,o]}))}})},null==o?void 0:o.key)}))})),e(i.Menu,Object.assign({className:"sub--dropdown",popperConfig:{modifiers:[{name:"offset",options:{offset:[(null==k?void 0:k.offsetSkid)||0,(null==k?void 0:k.offsetDistance)||0]}}]}},{children:e(d,{selectRange:(null===(S=null==$?void 0:$.dateRangeSelectionOptions)||void 0===S?void 0:S.selectRange)||!1,maxDate:null===(R=null==$?void 0:$.dateRangeSelectionOptions)||void 0===R?void 0:R.maxDate,minDate:null===(C=null==$?void 0:$.dateRangeSelectionOptions)||void 0===C?void 0:C.minDate,selectedDates:P,onSelectRange:(e,o)=>{const n=[e,o];(null==$?void 0:$.dateRangeSelectionOptions)&&($.dateRangeSelectionOptions.selectedDates=n,b(Object.assign(Object.assign({},$),{selectedRange:[e,o]}))),H($),x(!1),I(n),A(!N)},onSelectDate:e=>{(null==$?void 0:$.dateRangeSelectionOptions)&&($.dateRangeSelectionOptions.selectedDates=[e,e],b(Object.assign(Object.assign({},$),{selectedRange:[e,e]}))),H($),x(!1),I([e,e]),A(!N)}})}))]}))}))]}))})},v=o=>{let{eachOption:t,selectedOption:l,selectedDate:i,onClickingEachItem:s,rangeSelection:d}=o;return n(u,Object.assign({onClick:()=>s(t),isSelected:t.isCustom?t.key==(null==l?void 0:l.key)&&!!i:t.key==(null==l?void 0:l.key)},{children:[e(c,Object.assign({color:t.key==(null==l?void 0:l.key)?a.positive[900]:a.grayscale[900]},{children:t.label})),i&&(null==l?void 0:l.isCustom)&&t.key==(null==l?void 0:l.key)&&e(r,{children:d?`${O(i[0])} to ${O(i[1])}`:`${O(i[0])}`})]}),t.key)},O=e=>e.toLocaleString("default",{day:"numeric",month:"short",year:"numeric"});export{m as AnalyticsDropdown,v as EachItem,O as formatDate};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{format as a}from"date-fns";import{useState as n,useEffect as o}from"react";import{CustomDateTime as r}from"../../custom-date-time/CustomDateTime.js";import{Input as s}from"../../input/Input.js";import{RadioButton as d}from"../../radioButton/RadioButton.js";import{TitleRegular as c,BodySecondary as p}from"../../TypographyStyle.js";import{DEFAULT_THEME as D}from"../../../constants/Theme.js";var I;!function(e){e.FIXED_EXPIRATION="fixedExpiration",e.DYNAMIC_EXPIRATION="dynamicExpiration"}(I||(I={}));const l=l=>{var m;const[A,u]=n(l.discountData.expireAt?I.FIXED_EXPIRATION:l.discountData.expireAfter?I.DYNAMIC_EXPIRATION:void 0),[x,E]=n(),[h,v]=n(),O=(new Date).setDate((new Date).getDate()+1);o((()=>{(null==A||x||h)&&l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:void 0,expireAt:void 0})),A&&(x||h)&&(A===I.FIXED_EXPIRATION?v(void 0):E(void 0))}),[A,x,h]);return e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13}},{children:[t(c,{children:"Coupon expiration (optional)"}),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(d,{isActive:A===I.DYNAMIC_EXPIRATION,onValueChange:()=>{v(void 0),u(A===I.DYNAMIC_EXPIRATION?void 0:I.DYNAMIC_EXPIRATION)}}),t(p,{children:"Validity days from coupon claim"})]})),A===I.DYNAMIC_EXPIRATION&&t(s,{value:null===(m=l.discountData.expireAfter)||void 0===m?void 0:m.toString(),placeholder:"Enter the number of days",width:"400px",type:"number",onChangeText:e=>{(e=>{v(void 0);const t=Number.parseInt(e);t>0?l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:t,expireAt:void 0})):v("Please enter days more than 0")})(e)}}),h&&t(p,Object.assign({style:{color:D.colorsV2.stroke.negative.vibrant}},{children:h})),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(d,{isActive:A===I.FIXED_EXPIRATION,onValueChange:()=>{u(A===I.FIXED_EXPIRATION?void 0:I.FIXED_EXPIRATION)}}),t(p,{children:"Fixed expiry date"})]})),A===I.FIXED_EXPIRATION&&e(i,{children:[t(p,{children:"Ending on"}),t(r,{placement:"bottom-start",time:l.discountData.expireAt?a(new Date(l.discountData.expireAt),"hh:mm a"):a(new Date,"hh:mm a"),date:l.discountData.expireAt?new Date(l.discountData.expireAt):new Date,error:x,setError:E,onChange:e=>{l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAt:e,expireAfter:void 0}))},minDate:new Date(O)})]})]}))};export{I as COUPON_EXPIRATION,l as CouponExpiration};
1
+ import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import{format as a}from"date-fns";import{useState as n,useEffect as o}from"react";import{CustomDateTime as r}from"../../custom-date-time/CustomDateTime.js";import{Input as s}from"../../input/Input.js";import{RadioButton as d}from"../../radioButton/RadioButton.js";import{TitleRegular as c,BodySecondary as p}from"../../TypographyStyle.js";import{DEFAULT_THEME as D}from"../../../constants/Theme.js";var I;!function(e){e.FIXED_EXPIRATION="fixedExpiration",e.DYNAMIC_EXPIRATION="dynamicExpiration"}(I||(I={}));const l=l=>{var m;const[u,A]=n(l.discountData.expireAt?I.FIXED_EXPIRATION:l.discountData.expireAfter?I.DYNAMIC_EXPIRATION:void 0),[x,E]=n(),[v,O]=n(),f=(new Date).setDate((new Date).getDate()+1);o((()=>{(null==u||x||v)&&l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:void 0,expireAt:void 0})),u&&(x||v)&&(u===I.FIXED_EXPIRATION?O(void 0):E(void 0))}),[u,x,v]);return e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13}},{children:[t(c,{children:"Coupon expiration (optional)"}),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(d,{isActive:u===I.DYNAMIC_EXPIRATION,onValueChange:()=>{O(void 0),A(u===I.DYNAMIC_EXPIRATION?void 0:I.DYNAMIC_EXPIRATION)}}),t(p,{children:"Validity days from coupon claim"})]})),u===I.DYNAMIC_EXPIRATION&&t(s,{value:null===(m=l.discountData.expireAfter)||void 0===m?void 0:m.toString(),placeholder:"Enter the number of days",width:"400px",type:"number",onChangeText:e=>{(e=>{O(void 0);const t=Number.parseInt(e);t>0?l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAfter:t,expireAt:void 0})):O("Please enter valid input")})(e)}}),v&&t(p,Object.assign({style:{color:D.colorsV2.stroke.negative.vibrant}},{children:v})),e("div",Object.assign({style:{display:"flex",gap:18}},{children:[t(d,{isActive:u===I.FIXED_EXPIRATION,onValueChange:()=>{A(u===I.FIXED_EXPIRATION?void 0:I.FIXED_EXPIRATION)}}),t(p,{children:"Fixed expiry date"})]})),u===I.FIXED_EXPIRATION&&e(i,{children:[t(p,{children:"Ending on"}),t(r,{placement:"bottom-start",time:l.discountData.expireAt?a(new Date(l.discountData.expireAt),"hh:mm a"):a(new Date,"hh:mm a"),date:l.discountData.expireAt?new Date(l.discountData.expireAt):new Date,error:x,setError:E,onChange:e=>{l.setDiscountData(Object.assign(Object.assign({},l.discountData),{expireAt:e,expireAfter:void 0}))},minDate:new Date(f)})]})]}))};export{I as COUPON_EXPIRATION,l as CouponExpiration};
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { ICouponData } from "./type";
3
3
  import { Product } from "../product-picker/type";
4
4
  export interface DiscountDialogueI {
5
+ hideOption?: 'static' | 'dynamic';
5
6
  isOpen: boolean;
6
7
  title: string;
7
8
  subTitle?: string;
@@ -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 l}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 b}from"../modals/styledModal.js";import{ProductPickerContent as y}from"../product-picker/ProductPickerModal.js";import{Tag as E}from"../tag/Tag.js";import{Tooltip as v}from"../tooltips/Tooltip.js";import T from"../../assets/icons/triangle_error.svg.js";import{StyledDiscountDialogueContainer as P,CouponTypeContainerStyled as C}from"./DiscountModal.styled.js";import{validateDiscountData as g}from"./DiscountUtils.js";import I,{DISCOUNT_PRODUCTS as j}from"./DynamicCoupon/DynamicCoupon.js";import S from"./StaticCoupon/StaticCoupon.js";const h=h=>{var O,N,D,_;const[w,f]=i(),[A,q]=i(null!==(O=h.data)&&void 0!==O?O:{isStaticCoupon:!1}),[G,M]=i(!0),[x,F]=i(),[L,R]=i((null===(N=h.data)||void 0===N?void 0:N.minAmount)?r.AMOUNT:(null===(D=h.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;h.hideProbability||(t=V()),M(g(A,L,x,h.hideProbability||!1,t,!!A.isStaticCoupon)),h.hideProbability||V()}),[]),n((()=>{let t;h.hideProbability||(t=V()),M(g(A,L,x,h.hideProbability||!1,t,!!A.isStaticCoupon))}),[A,Y,x,L]),n((()=>{var t,e;if(h.products){if(null===(t=h.data)||void 0===t?void 0:t.entitledProductIds){const t=h.products.filter((t=>{var e,o;return null===(o=null===(e=h.data)||void 0===e?void 0:e.entitledProductIds)||void 0===o?void 0:o.includes(parseInt(t.id))}));X(t)}if(null===(e=h.data)||void 0===e?void 0:e.prerequisiteProductIds){const t=h.products.filter((t=>{var e,o;return null===(o=null===(e=h.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(!h.quadrant||!h.probability)return;const t=[...h.probability];let e=[];t.length>=h.quadrant&&t.splice(h.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(b,Object.assign({open:h.isOpen,headingTitle:w?"Select Products":h.title,headingSubtitle:w?void 0:h.subTitle,footerLeftCustomElement:!h.quadrant||h.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:h.allowStaticCoupon||w?void 0:e(l,{options:H,width:"200px",placement:"bottom-start",size:"small",onSelect:t=>{z(t)}}),onClose:h.onClose,footerShadow:!0,primaryButton:w?{buttonType:"primary",onClick:()=>{f(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Add code",disabled:G,onClick:()=>{A.isStaticCoupon?h.onSaveClicked({quadrant:A.quadrant,couponCode:A.couponCode,description:A.description,isStaticCoupon:A.isStaticCoupon,probability:A.probability,title:A.title}):h.onSaveClicked(A),q({})}},secondaryButton:w?{buttonType:"tertiaryGray",onClick:()=>{f(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:h.onClose,buttonText:"Close"}},{children:[!w&&t(P,{children:[h.allowStaticCoupon&&!w&&t(C,Object.assign({selectedDiv:A.isStaticCoupon?1:2},{children:[t("div",Object.assign({className:"coupon-type__container",onClick:()=>{q({isStaticCoupon:!0,couponCode:A.couponCode,description:A.description,quadrant:A.quadrant})}},{children:[e(p,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"}))]})),t("div",Object.assign({className:"coupon-type__container",onClick:()=>{q(Object.assign(Object.assign({},A),{isStaticCoupon:!1}))}},{children:[e(p,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(S,{discountData:A,setDiscountData:q,hideProbability:h.hideProbability||!1,discountAdminUrl:h.discountAdminUrl}),!A.isStaticCoupon&&!w&&e(I,{currency:h.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:h.hideProbability||!1,hideExpiration:h.hideExpiration||!1,allowStaticCoupon:h.allowStaticCoupon,onChangeCouponType:z})]}),!!w&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(y,{show:!0,onSave:()=>{},products:null!==(_=h.products)&&void 0!==_?_:[],title:"Select Products",onClose:()=>{f(void 0)},selectedProducts:w===j.ENTITLED?B:k,setSelectedProducts:w===j.ENTITLED?X:U,onSearchKeyChange:h.onProductSearch})}))]}))};export{h 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 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 +1 @@
1
- import{DISCOUNT_TYPES as e,DISCOUNT_VALUE_TYPES as i,MIN_PURCHASE_REQUIREMENT as t,DISCOUNT_TARGET_TYPES as r,DISCOUNT_TARGET_SELECTION as n}from"./type.js";const u=(u,l,o,f,a,v)=>{var T,d;if(!u.title)return!0;if(!f){if(isNaN(u.probability))return!0;if((u.probability||0)>1)return!0;if((u.probability||0)<0)return!0;if(a>1)return!0}if(v){if(!(null==u?void 0:u.couponCode))return!0;if(!u.description)return!0}else{if(o&&o===e.FIXED_AMOUNT){if(u.valueType!==i.FIXED_AMOUNT)return!0;if(!(null==u?void 0:u.value)||(null==u?void 0:u.value)<=0)return!0;if(l===t.AMOUNT&&(!u.minAmount||(null==u?void 0:u.minAmount)<=0))return!0;if(l===t.QUANTITY&&(!(null==u?void 0:u.minQuantity)||(null==u?void 0:u.minQuantity)<=0))return!0;if(u.targetType!==r.LINE_ITEM)return!0;if(u.targetSelection!==n.ALL)return!0}else if(o&&o===e.PERCENTAGE){if(u.valueType!==i.PERCENTAGE)return!0;if(!(null==u?void 0:u.value)||(null==u?void 0:u.value)<=0||(null==u?void 0:u.value)>100)return!0;if(l===t.AMOUNT&&(!u.minAmount||(null==u?void 0:u.minAmount)<=0))return!0;if(l===t.QUANTITY&&(!(null==u?void 0:u.minQuantity)||(null==u?void 0:u.minQuantity)<=0))return!0;if(u.targetType!==r.LINE_ITEM)return!0;if(u.targetSelection!==n.ALL)return!0}else if(o&&o===e.BUY_X_GET_Y){if(!(u.entitledQuantity&&(null===(T=u.entitledProductIds)||void 0===T?void 0:T.length)&&u.prerequisiteQuantity&&(null===(d=u.prerequisiteProductIds)||void 0===d?void 0:d.length)))return!0;if(u.valueType!==i.PERCENTAGE)return!0;if(!u.value)return!0;if(u.value<=0||u.value>100)return!0;if(u.targetSelection!==n.ENTITLED)return!0;if(u.targetType!==r.LINE_ITEM)return!0}else{if(!o||!e.FREE_SHIPPING)return!0;if(u.valueType!==i.PERCENTAGE)return!0;if(u.targetType!==r.SHIPPING_LINE)return!0;if(100!==u.value)return!0;if(u.targetSelection!==n.ALL)return!0;if(l===t.AMOUNT&&(!u.minAmount||(null==u?void 0:u.minAmount)<=0))return!0;if(l===t.QUANTITY&&(!(null==u?void 0:u.minQuantity)||(null==u?void 0:u.minQuantity)<=0))return!0}if(null!==u.expireAfter&&void 0!==u.expireAfter&&u.expireAfter<=0)return!0}return!1};export{u as validateDiscountData};
1
+ 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 +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}],C=()=>{var i,n,s,r;return e("div",Object.assign({className:"input__rows"},{children:[e("div",Object.assign({className:"input__wrapper"},{children:[t(l,Object.assign({style:{marginBottom:10}},{children:"Min purchase requirements"})),t(o,{options:_,placement:"bottom-start",onSelect:e=>{const t=e.value;O.setSelectedMinimumRequirement(t),O.setDiscountData(Object.assign(Object.assign({},O.discountData),{minQuantity:void 0,minAmount:void 0}))}})]})),t("div",Object.assign({className:"input__wrapper"},{children:O.selectedMinimumRequirement!==a.NA&&t(m,{value:O.selectedMinimumRequirement===a.AMOUNT?null!==(n=null===(i=O.discountData.minAmount)||void 0===i?void 0:i.toString())&&void 0!==n?n:"":null!==(r=null===(s=O.discountData.minQuantity)||void 0===s?void 0:s.toString())&&void 0!==r?r:"",onChangeText:e=>{O.selectedMinimumRequirement===a.AMOUNT?O.setDiscountData(Object.assign(Object.assign({},O.discountData),{minAmount:parseInt(e)})):O.selectedMinimumRequirement===a.QUANTITY&&O.setDiscountData(Object.assign(Object.assign({},O.discountData),{minQuantity:parseInt(e)}))},labelText:O.selectedMinimumRequirement===a.AMOUNT?"Minimum purchase amount":"Minimum purchase quantity",type:"number",placeholder:O.selectedMinimumRequirement===a.AMOUNT?"1000.00":"2"})}))]}))},N=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})}))]})),C(),!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)"})}))]})),C()]})})(),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,{}),N(D.PREREQUISITE),t(T,{}),N(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 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 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{SearchIcon as o}from"../../assets/icons/searchIcon.js";import{useState as t,useEffect as n}from"react";import s from"../../assets/icons/cross.svg.js";import{Input as a}from"../input/Input.js";const i=i=>{const{isEnabled:r,onEnter:c,placeholder:l,width:d,variant:h,validate:u,isActive:v}=i,[m,f]=t("search"),[p,g]=t("default"),[C,k]=t(v?"active":r?"none":"disabled"),[b,j]=t(i.initialValue||"");n((()=>{k(v?"active":r?"none":"disabled")}),[r,v]),n((()=>{i.reset&&I()}),[null==i?void 0:i.reset]);const w=e=>{r&&c(e)},I=()=>{f("search"),g("default"),j(""),i.onChange(""),k("none"),c("")};return e(a,{validate:u,onFocus:()=>{b.length&&f("cross"),"default"===p&&r&&(g("clicked"),k("active"))},width:d,state:C,leftIcon:"search"===m&&"default"===p?{icon:o}:void 0,rightIcon:"cross"===m?{icon:s,callback:()=>{I(),i.onClickCross&&i.onClickCross()}}:void 0,onChangeText:(e,o)=>{i.onChange(e),j(e),"keydown"!==(null==o?void 0:o.type)||13!==o.which&&13!==o.keyCode?e.trim().length?f("cross"):f("search"):w(e)},placeholder:l,variant:h,value:b,onBlur:()=>{b.length||g("default"),k("none")}})};export{i as SearchBar};
1
+ import{jsx as e}from"react/jsx-runtime";import{SearchIcon as o}from"../../assets/icons/searchIcon.js";import{useState as t,useEffect as n}from"react";import a from"../../assets/icons/cross.svg.js";import{Input as s}from"../input/Input.js";const i=i=>{const{isEnabled:r,onEnter:c,placeholder:l,width:d,variant:h,validate:u,isActive:v}=i,[m,f]=t("search"),[p,C]=t("default"),[g,k]=t(v?"active":r?"none":"disabled"),[b,j]=t(i.initialValue||"");n((()=>{k(v?"active":r?"none":"disabled")}),[r,v]),n((()=>{i.reset&&I()}),[null==i?void 0:i.reset]);const w=e=>{r&&c(e)},I=()=>{f("search"),C("default"),j(""),i.onChange(""),k("none"),c("")};return e(s,{validate:u,onFocus:()=>{"default"===p&&r&&(C("clicked"),k("active"))},width:d,state:g,leftIcon:"search"===m&&"default"===p?{icon:o}:void 0,rightIcon:"cross"===m?{icon:a,callback:()=>{I(),i.onClickCross&&i.onClickCross()}}:void 0,onChangeText:(e,o)=>{i.onChange(e),j(e),"keydown"!==(null==o?void 0:o.type)||13!==o.which&&13!==o.keyCode?e.trim().length?f("cross"):f("search"):w(e)},placeholder:l,variant:h,value:b,onBlur:()=>{b.length||C("default"),k("none")}})};export{i as SearchBar};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const WorkingStepper: () => JSX.Element;
3
2
  export declare enum STEPENUM {
4
3
  STEP1 = "STEP1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.290",
3
+ "version": "0.0.291",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",