@bikdotai/bik-component-library 0.0.697-0 → 0.0.697-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.d.ts +1 -1
- package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.js +1 -1
- package/dist/cjs/components/data-source-panel/DataSourcePanel.d.ts +1 -1
- package/dist/cjs/components/data-source-panel/DataSourcePanel.js +1 -1
- package/dist/cjs/components/discount-modal/DiscountModal.d.ts +1 -1
- package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
- package/dist/cjs/components/dropdown/Common.styled.d.ts +1 -0
- package/dist/cjs/components/dropdown/Common.styled.js +8 -27
- package/dist/cjs/components/dropdown/DropdownPopover/index.d.ts +1 -0
- package/dist/cjs/components/dropdown/DropdownPopover/index.js +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.style.js +3 -1
- package/dist/cjs/components/product-picker-v2/collectionScreen.d.ts +1 -1
- package/dist/cjs/components/product-picker-v2/modal.d.ts +1 -1
- package/dist/cjs/components/product-picker-v2/modal.js +1 -1
- package/dist/cjs/components/product-picker-v2/productScreen.d.ts +1 -1
- package/dist/cjs/components/product-picker-v2/rearrangeScreen.d.ts +1 -1
- package/dist/cjs/components/product-picker-v2/searchScreen.d.ts +1 -1
- package/dist/cjs/components/product-picker-v2/selectedScreen.d.ts +1 -1
- package/dist/cjs/components/product-picker-v2/utility.d.ts +1 -1
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
- package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.d.ts +1 -1
- package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/data-source-panel/DataSourceInfoFooter.d.ts +1 -1
- package/dist/esm/components/data-source-panel/DataSourceInfoFooter.js +1 -1
- package/dist/esm/components/data-source-panel/DataSourcePanel.d.ts +1 -1
- package/dist/esm/components/data-source-panel/DataSourcePanel.js +1 -1
- package/dist/esm/components/discount-modal/DiscountModal.d.ts +1 -1
- package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
- package/dist/esm/components/dropdown/Common.styled.d.ts +1 -0
- package/dist/esm/components/dropdown/Common.styled.js +9 -28
- package/dist/esm/components/dropdown/DropdownPopover/index.d.ts +1 -0
- package/dist/esm/components/dropdown/DropdownPopover/index.js +1 -1
- package/dist/esm/components/dropdown-button/DropdownButton.js +1 -1
- package/dist/esm/components/dropdown-button/DropdownButton.style.js +3 -1
- package/dist/esm/components/product-picker-v2/collectionScreen.d.ts +1 -1
- package/dist/esm/components/product-picker-v2/modal.d.ts +1 -1
- package/dist/esm/components/product-picker-v2/modal.js +1 -1
- package/dist/esm/components/product-picker-v2/productScreen.d.ts +1 -1
- package/dist/esm/components/product-picker-v2/rearrangeScreen.d.ts +1 -1
- package/dist/esm/components/product-picker-v2/searchScreen.d.ts +1 -1
- package/dist/esm/components/product-picker-v2/selectedScreen.d.ts +1 -1
- package/dist/esm/components/product-picker-v2/utility.d.ts +1 -1
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
- package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.d.ts +1 -1
- package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
3
3
|
import { footerButtonOptionModel, MessageSource } from './model';
|
|
4
4
|
interface SourceInfoFooterProps {
|
|
5
5
|
appType: ApplicationType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),s=require("../../assets/icons/alert_triangle.svg.js"),o=require("../../assets/icons/plus.svg.js"),n=require("react"),i=require("../../constants/Theme.js"),r=require("../button/Button.js"),a=require("../shimmer/ShimmerComponent/BikShimmer.js"),d=require("../TypographyStyle.js"),l=require("./DataSourcePanel.style.js");const u=n.memo((u=>{const{appType:x,sourceIntent:m,hideHeading:j,messageSource:h,trainingSourceCount:g={},ShowTrainingDataSource:R={},faqCount:v,ChecklistType:E,footerButtonOption:y,isFooterLoading:T,reasonForAiGeneratedResponse:b,showAiResponseReason:A}=u,O=R,[C,S]=n.useState(!0),[f,I]=n.useState(!0),_="/bik-ai/training",[F,w]=n.useState({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[N,k]=n.useState({title:"",subTitle:""}),D=n.useMemo((()=>{const e=(null==g?void 0:g[m])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[g,m]),q=()=>{var e;(null==F?void 0:F.redirectUrl)?window.open(`${window.location.origin}${null==F?void 0:F.redirectUrl}`,"_self"):Object.keys(null!==(e=null==F?void 0:F.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(F):(null==y?void 0:y.navigate)&&(null==y||y.navigate("Training",x==t.ApplicationType.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return n.useEffect((()=>{var e,s,o,n;if(m){if(null===(e=null==h?void 0:h.sources)||void 0===e?void 0:e.length){const e=h.sources[0];if(O[m])m===E.ORDER_ENQUIRY&&I(!1);else{let i=null==e?void 0:e.insights,r="";switch(m){case E.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(i=`${v||"No"} FAQs added for this product`,r="Add product-specific information via FAQs to improve responses",w({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null==e?void 0:e.productId,variantId:null==e?void 0:e.variantId,name:null==e?void 0:e.title,imageUrl:null==e?void 0:e.imageUrl}]},redirectUrl:""}));break;case E.ORDER_MODIFICATION:i=(null==g?void 0:g[m])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",i&&w({buttonTitle:x==t.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":_,addFaqProps:{}});break;case E.ORDER_CANCELLATION:i=(null==g?void 0:g[m])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",w({buttonTitle:x==t.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":_,addFaqProps:{}});break;case E.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;w({buttonTitle:x==t.ApplicationType.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/training/order-management":_,addFaqProps:{}});break;case E.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(n=null===(o=null===(s=null==h?void 0:h.sources)||void 0===s?void 0:s[0])||void 0===o?void 0:o.title)||void 0===n?void 0:n.toLowerCase().indexOf("collection"))){i="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}i="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}k({title:null!=i?i:"",subTitle:r})}}(O[m]||[E.PRODUCT_DETAILS,E.ORDER_MODIFICATION,E.ORDER_CANCELLATION,E.ORDER_TRACKING].includes(m))&&S(!1)}}),[null==h?void 0:h.messageId,g,m,null==h?void 0:h.sources,O,E,v,x,h]),e.jsxRuntimeExports.jsx(l.SourceInfoFooterStyle,{children:T?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(a.BikShimmer,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:!(null==N?void 0:N.title)&&g&&m in g?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details "+(g[m]>0?"":"no_data_source")},{children:[g[m]>0&&f?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,{children:D}),e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):f&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsxRuntimeExports.jsx(s.default,{width:15,height:15,color:i.COLORS.content.negative,style:{marginTop:2}}),e.jsxRuntimeExports.jsx(d.BodyCaption,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||C?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>q(),style:{backgroundColor:"unset"}})]}))]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[f&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,{children:null==N?void 0:N.title}),e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:null==N?void 0:N.subTitle}))]}),!y||y.hideAddDataButton||C?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>q(),style:{backgroundColor:"unset"}})]}))]})})})})),c=n.memo((t=>t.hideHeading?null:e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Training insights"})))),p=n.memo((t=>{const[s,o]=n.useState(!1),r=t.reason&&t.reason.length>50,a=r&&!s?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxRuntimeExports.jsxs(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary,className:"clamp-text"},{children:[a||"No reason provided for this response.",r&&e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>o(!s)},{children:s?"Show less":"Show more"}))]}))]})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})}));p.displayName="WhyAiGaveThisResponse",c.displayName="TrainingInsightsHeading",u.displayName="SourceInfoFooter",exports.default=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),s=require("../../assets/icons/alert_triangle.svg.js"),o=require("../../assets/icons/plus.svg.js"),n=require("react"),i=require("../../constants/Theme.js"),r=require("../button/Button.js"),a=require("../shimmer/ShimmerComponent/BikShimmer.js"),d=require("../TypographyStyle.js"),l=require("./DataSourcePanel.style.js");const u=n.memo((u=>{const{appType:x,sourceIntent:m,hideHeading:j,messageSource:h,trainingSourceCount:g={},ShowTrainingDataSource:R={},faqCount:v,ChecklistType:E,footerButtonOption:y,isFooterLoading:T,reasonForAiGeneratedResponse:b,showAiResponseReason:A}=u,O=R,[C,S]=n.useState(!0),[f,I]=n.useState(!0),_="/bik-ai/training",[F,w]=n.useState({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[N,k]=n.useState({title:"",subTitle:""}),D=n.useMemo((()=>{const e=(null==g?void 0:g[m])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[g,m]),q=()=>{var e;(null==F?void 0:F.redirectUrl)?window.open(`${window.location.origin}${null==F?void 0:F.redirectUrl}`,"_self"):Object.keys(null!==(e=null==F?void 0:F.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(F):(null==y?void 0:y.navigate)&&(null==y||y.navigate("Training",x==t.ApplicationType.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return n.useEffect((()=>{var e,s,o,n;if(m){if(null===(e=null==h?void 0:h.sources)||void 0===e?void 0:e.length){const e=h.sources[0];if(O[m])m===E.ORDER_ENQUIRY&&I(!1);else{let i=null==e?void 0:e.insights,r="";switch(m){case E.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(i=`${v||"No"} FAQs added for this product`,r="Add product-specific information via FAQs to improve responses",w({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null==e?void 0:e.productId,variantId:null==e?void 0:e.variantId,name:null==e?void 0:e.title,imageUrl:null==e?void 0:e.imageUrl}]},redirectUrl:""}));break;case E.ORDER_MODIFICATION:i=(null==g?void 0:g[m])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",i&&w({buttonTitle:x==t.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":_,addFaqProps:{}});break;case E.ORDER_CANCELLATION:i=(null==g?void 0:g[m])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",w({buttonTitle:x==t.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":_,addFaqProps:{}});break;case E.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;w({buttonTitle:x==t.ApplicationType.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/training/order-management":_,addFaqProps:{}});break;case E.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(n=null===(o=null===(s=null==h?void 0:h.sources)||void 0===s?void 0:s[0])||void 0===o?void 0:o.title)||void 0===n?void 0:n.toLowerCase().indexOf("collection"))){i="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}i="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}k({title:null!=i?i:"",subTitle:r})}}(O[m]||[E.PRODUCT_DETAILS,E.ORDER_MODIFICATION,E.ORDER_CANCELLATION,E.ORDER_TRACKING].includes(m))&&S(!1)}}),[null==h?void 0:h.messageId,g,m,null==h?void 0:h.sources,O,E,v,x,h]),e.jsxRuntimeExports.jsx(l.SourceInfoFooterStyle,{children:T?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(a.BikShimmer,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:!(null==N?void 0:N.title)&&g&&m in g?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details "+(g[m]>0?"":"no_data_source")},{children:[g[m]>0&&f?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,{children:D}),e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):f&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsxRuntimeExports.jsx(s.default,{width:15,height:15,color:i.COLORS.content.negative,style:{marginTop:2}}),e.jsxRuntimeExports.jsx(d.BodyCaption,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||C?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>q(),style:{backgroundColor:"unset"}})]}))]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[f&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,{children:null==N?void 0:N.title}),e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:null==N?void 0:N.subTitle}))]}),!y||y.hideAddDataButton||C?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>q(),style:{backgroundColor:"unset"}})]}))]})})})})),c=n.memo((t=>t.hideHeading?null:e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Training insights"})))),p=n.memo((t=>{const[s,o]=n.useState(!1),r=t.reason&&t.reason.length>50,a=r&&!s?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxRuntimeExports.jsxs(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary,className:"clamp-text"},{children:[a||"No reason provided for this response.",r&&e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>o(!s)},{children:s?"Show less":"Show more"}))]}))]})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})}));p.displayName="WhyAiGaveThisResponse",c.displayName="TrainingInsightsHeading",u.displayName="SourceInfoFooter",exports.default=u;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
3
3
|
import { AllSourceInfoDetailsCustomDataModel, CustomDataType, DataSourcePanelZeroState, footerButtonOptionModel, InfoContent, MessageSource, ProductSourceData } from './model';
|
|
4
4
|
export interface ProductSearchRuleDB {
|
|
5
5
|
rule_id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),s=require("../../assets/icons/box_search.svg.js"),i=require("../../assets/icons/boxV2.svg.js"),o=require("../../assets/icons/chevronDownOutline.svg.js"),n=require("../../assets/icons/chevronUpOutline.svg.js"),r=require("../../assets/icons/cross.svg.js"),l=require("../../assets/icons/edit.svg.js"),a=require("../../assets/icons/filePdf.svg.js"),d=require("../../assets/icons/help.svg.js"),c=require("../../assets/icons/info.svg.js"),u=require("../../assets/icons/openai.svg.js"),x=require("../../assets/icons/plus.svg.js"),p=require("../../assets/icons/redirect.svg.js"),j=require("../../assets/icons/text_t9.svg.js"),m=require("../../assets/icons/website.svg.js"),g=require("react"),h=require("../../constants/Theme.js"),y=require("../button/Button.js"),E=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),R=require("../side-modal/SideModal.js"),O=require("../tag/Tag.js"),f=require("../tooltips/Tooltip.js"),v=require("../TypographyStyle.js"),S=require("./DataSourceInfoFooter.js"),T=require("./DataSourcePanel.style.js"),I=require("./IntentConfig.js"),b=require("./Modals/DescriptionModal.js"),L=require("./model.js");exports.DataSourcePanel=w=>{var D,N;const{appType:A,storeId:_,messageSource:F,setMessageSourcePanel:k,hideCloseButton:B,isSourceInfoFetched:q,allSourceInfoDetail:P,ChecklistType:M,title:U,zeroStateButton:K,editableSources:W,preFillTrainingSourceCount:$,redirect:H,footerButtonOption:Q,fetchTrainingSourceCount:G,fetchProductFAQCount:Y,productSourceData:z,reasonForAiGeneratedResponse:X,showAiResponseReason:V,productSearchRule:J,onEditProductSearchRule:Z}=w,{sources:ee}=F,te=["blog","article","page","policy"],[se,ie]=g.useState(!1),[oe,ne]=g.useState(!1),[re,le]=g.useState(!1),[ae,de]=g.useState(0),[ce,ue]=g.useState(),[xe,pe]=g.useState(null!=$?$:{}),[je,me]=g.useState(!1),[ge,he]=g.useState(!1),ye={};I.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;M[s]&&(ye[M[s]]=e.jsxRuntimeExports.jsx(O.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ee=ee.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ce=ee.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Re=g.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{M[t]&&(e[M[t]]=M[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[M]);g.useEffect((()=>{var e,t,s,i;if(!(null==F?void 0:F.messageId))return;ie(!0),ne(!0),le(!1!==(null===(t=null===(e=F.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=F.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=F.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));Y(_,n).then((e=>de(e))).then((()=>{$?(pe($),setTimeout((()=>{ie(!1),ne(!1)}),100)):(setTimeout((()=>ie(!1)),100),G(_).then((e=>pe(e))).then((()=>setTimeout((()=>{ne(!1)}),100))))}))}),[Y,G,null==F?void 0:F.messageId,F.sources,$,_]);const Oe=e=>!!(e&&0===e.length||(null==F?void 0:F.isUnsatisfactoryAnswer)),fe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=L.CustomDataType.FILES:te.includes(e)?e=L.CustomDataType.FETCHED_LINKS:"url"==e?e=L.CustomDataType.WEBSITE_LINKS:"text"===e?e=L.CustomDataType.TEXTS:"faq"===e&&(e=L.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},ve=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Se=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(i.default,{height:16,width:16,color:h.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:h.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(m.default,{height:16,width:16,color:h.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(d.default,{height:16,width:16,color:h.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:h.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(u.default,{height:16,width:16,color:h.COLORS.content.secondary}),Te=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(se||!q)return e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(C.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Ie=s=>{const{title:i,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:i})),A===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:h.COLORS.surface.subdued,color:h.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:A===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:h.COLORS.content.primary}):e.jsxRuntimeExports.jsx(n.default,{width:20,height:20,color:h.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!U&&e.jsxRuntimeExports.jsx(v.TitleSmall,{children:U}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Intent"})),null!==(D=ye[F.intent])&&void 0!==D?D:ye.GENERIC,!B&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>k(void 0)},{children:e.jsxRuntimeExports.jsx(r.default,{height:20,width:20,color:h.COLORS.content.secondary})}))]})),J&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.primary},{children:J.rule_name})),Z&&J.rule_id&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsxRuntimeExports.jsx(s.default,{width:14,color:h.COLORS.content.secondary}),e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Edit search rule"})),e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,bordered:!0,iconColor:h.COLORS.content.primary,onClick:()=>Z(null==J?void 0:J.rule_id)})]}))]})),J.keywords&&J.keywords.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:h.COLORS.surface.subdued,borderRadius:"8px",border:`1px dashed ${h.COLORS.stroke.primary}`}},{children:J.keywords.map(((t,s)=>e.jsxRuntimeExports.jsx(O.Tag,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Oe(ee)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${h.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:h.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(v.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),K&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(y.Button,{LeadingIcon:null!==(t=K.leadingIcon)&&void 0!==t?t:x.default,buttonText:null!==(s=K.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{K.onClick()}})}))]}))})()})):!J&&e.jsxRuntimeExports.jsx(O.Tag,{LeadingIcon:c.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:F.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${A===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Oe(ee)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ee.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(Ie,Object.assign({title:"Product Sources",count:Ee.length,isExpanded:A!==t.ApplicationType.MANIFEST||je,onToggle:()=>me(!je)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ee.map(((t,s)=>{var i,o,n,r;const a=fe(t.type||t.subTitle||"OpenAI"),d=fe(t.type||t.subTitle||"OpenAI",!0),c=ve(a),u=null==W?void 0:W.includes(d),x=P[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==z?void 0:z[t.productId]),g=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ee?void 0:Ee.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(a),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==x?void 0:x.onEditClick(x.data,x.type),disabled:!x,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!x,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(v.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ue({title:j,description:Te(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ue(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:g,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=m.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ce.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(Ie,Object.assign({title:"Content Sources",count:Ce.length,isExpanded:A!==t.ApplicationType.MANIFEST||ge,onToggle:()=>he(!ge)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,s)=>{var i,o,n,r,a,d,c,u,x,j,m,g,y,C,R,O,S;const T=fe(t.type||t.subTitle||"OpenAI"),I=fe(t.type||t.subTitle||"OpenAI",!0),b=ve(T),w=null==W?void 0:W.includes(I),D="Products"===t.subTitle?P[null!==(i=t.productId)&&void 0!==i?i:"Products"]:P[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=L.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=L.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=L.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=L.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=L.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===M.EMAIL_COLLECTION?b:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(x=null==D?void 0:D.content)&&void 0!==x?x:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(g=L.CustomDataType.FETCHED_LINKS)||void 0===g?void 0:g.toLowerCase())||I.toLowerCase()===(null===(y=L.CustomDataType.WEBSITE_LINKS)||void 0===y?void 0:y.toLowerCase())||I.toLowerCase()===(null===(C=L.CustomDataType.TEXTS)||void 0===C?void 0:C.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(O=null==D?void 0:D.data)||void 0===O?void 0:O.fileContentText)&&void 0!==S?S:"":t.intent===M.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ce?void 0:Ce.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(T),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:b}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${h.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:h.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.primary,className:"clamp-description"},{children:Te(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),re&&!Oe(ee)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(S.default,{appType:A,storeId:_,messageSource:F,sourceIntent:null!==(N=F.intent)&&void 0!==N?N:M.GENERIC,faqCount:ae,trainingSourceCount:xe,ShowTrainingDataSource:Re,ChecklistType:M,footerButtonOption:Q,isFooterLoading:oe,reasonForAiGeneratedResponse:X,showAiResponseReason:V})}))]})}),ce&&e.jsxRuntimeExports.jsx(R.SideModal,Object.assign({header:"Product description",onClose:()=>ue(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(b.DescriptionModal,{title:ce.title,description:ce.description,imageUrl:ce.imageUrl,onClose:ce.onClose})}))]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),s=require("../../assets/icons/box_search.svg.js"),i=require("../../assets/icons/boxV2.svg.js"),o=require("../../assets/icons/chevronDownOutline.svg.js"),n=require("../../assets/icons/chevronUpOutline.svg.js"),r=require("../../assets/icons/cross.svg.js"),l=require("../../assets/icons/edit.svg.js"),a=require("../../assets/icons/filePdf.svg.js"),d=require("../../assets/icons/help.svg.js"),c=require("../../assets/icons/info.svg.js"),u=require("../../assets/icons/openai.svg.js"),x=require("../../assets/icons/plus.svg.js"),p=require("../../assets/icons/redirect.svg.js"),j=require("../../assets/icons/text_t9.svg.js"),m=require("../../assets/icons/website.svg.js"),g=require("react"),h=require("../../constants/Theme.js"),y=require("../button/Button.js"),E=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),R=require("../side-modal/SideModal.js"),O=require("../tag/Tag.js"),f=require("../tooltips/Tooltip.js"),v=require("../TypographyStyle.js"),S=require("./DataSourceInfoFooter.js"),T=require("./DataSourcePanel.style.js"),I=require("./IntentConfig.js"),b=require("./Modals/DescriptionModal.js"),L=require("./model.js");exports.DataSourcePanel=w=>{var D,N;const{appType:A,storeId:_,messageSource:k,setMessageSourcePanel:F,hideCloseButton:B,isSourceInfoFetched:q,allSourceInfoDetail:P,ChecklistType:M,title:U,zeroStateButton:K,editableSources:W,preFillTrainingSourceCount:$,redirect:H,footerButtonOption:Q,fetchTrainingSourceCount:G,fetchProductFAQCount:Y,productSourceData:z,reasonForAiGeneratedResponse:X,showAiResponseReason:V,productSearchRule:J,onEditProductSearchRule:Z}=w,{sources:ee}=k,te=["blog","article","page","policy"],[se,ie]=g.useState(!1),[oe,ne]=g.useState(!1),[re,le]=g.useState(!1),[ae,de]=g.useState(0),[ce,ue]=g.useState(),[xe,pe]=g.useState(null!=$?$:{}),[je,me]=g.useState(!1),[ge,he]=g.useState(!1),ye={};I.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;M[s]&&(ye[M[s]]=e.jsxRuntimeExports.jsx(O.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ee=ee.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ce=ee.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Re=g.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{M[t]&&(e[M[t]]=M[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[M]);g.useEffect((()=>{var e,t,s,i;if(!(null==k?void 0:k.messageId))return;ie(!0),ne(!0),le(!1!==(null===(t=null===(e=k.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=k.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=k.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));Y(_,n).then((e=>de(e))).then((()=>{$?(pe($),setTimeout((()=>{ie(!1),ne(!1)}),100)):(setTimeout((()=>ie(!1)),100),G(_).then((e=>pe(e))).then((()=>setTimeout((()=>{ne(!1)}),100))))}))}),[Y,G,null==k?void 0:k.messageId,k.sources,$,_]);const Oe=e=>!!(e&&0===e.length||(null==k?void 0:k.isUnsatisfactoryAnswer)),fe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=L.CustomDataType.FILES:te.includes(e)?e=L.CustomDataType.FETCHED_LINKS:"url"==e?e=L.CustomDataType.WEBSITE_LINKS:"text"===e?e=L.CustomDataType.TEXTS:"faq"===e&&(e=L.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},ve=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Se=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(i.default,{height:16,width:16,color:h.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:h.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(m.default,{height:16,width:16,color:h.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(d.default,{height:16,width:16,color:h.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:h.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(u.default,{height:16,width:16,color:h.COLORS.content.secondary}),Te=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(se||!q)return e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(C.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const Ie=s=>{const{title:i,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:i})),A===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:h.COLORS.surface.subdued,color:h.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:A===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:h.COLORS.content.primary}):e.jsxRuntimeExports.jsx(n.default,{width:20,height:20,color:h.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!U&&e.jsxRuntimeExports.jsx(v.TitleSmall,{children:U}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Intent"})),null!==(D=ye[k.intent])&&void 0!==D?D:ye.GENERIC,!B&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>F(void 0)},{children:e.jsxRuntimeExports.jsx(r.default,{height:20,width:20,color:h.COLORS.content.secondary})}))]})),J&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.primary},{children:J.rule_name})),Z&&J.rule_id&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsxRuntimeExports.jsx(s.default,{width:14,color:h.COLORS.content.secondary}),e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Edit search rule"})),e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,bordered:!0,iconColor:h.COLORS.content.primary,onClick:()=>Z(null==J?void 0:J.rule_id)})]}))]})),J.keywords&&J.keywords.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:h.COLORS.surface.subdued,borderRadius:"8px",border:`1px dashed ${h.COLORS.stroke.primary}`}},{children:J.keywords.map(((t,s)=>e.jsxRuntimeExports.jsx(O.Tag,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Oe(ee)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${h.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:h.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(v.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),K&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(y.Button,{LeadingIcon:null!==(t=K.leadingIcon)&&void 0!==t?t:x.default,buttonText:null!==(s=K.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{K.onClick()}})}))]}))})()})):!J&&e.jsxRuntimeExports.jsx(O.Tag,{LeadingIcon:c.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:k.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${A===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Oe(ee)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ee.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(Ie,Object.assign({title:"Product Sources",count:Ee.length,isExpanded:A!==t.ApplicationType.MANIFEST||je,onToggle:()=>me(!je)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ee.map(((t,s)=>{var i,o,n,r;const a=fe(t.type||t.subTitle||"OpenAI"),d=fe(t.type||t.subTitle||"OpenAI",!0),c=ve(a),u=null==W?void 0:W.includes(d),x=P[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==z?void 0:z[t.productId]),g=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ee?void 0:Ee.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(a),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==x?void 0:x.onEditClick(x.data,x.type),disabled:!x,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!x,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(v.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ue({title:j,description:Te(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ue(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:g,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=m.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ce.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(Ie,Object.assign({title:"Content Sources",count:Ce.length,isExpanded:A!==t.ApplicationType.MANIFEST||ge,onToggle:()=>he(!ge)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,s)=>{var i,o,n,r,a,d,c,u,x,j,m,g,y,C,R,O,S;const T=fe(t.type||t.subTitle||"OpenAI"),I=fe(t.type||t.subTitle||"OpenAI",!0),b=ve(T),w=null==W?void 0:W.includes(I),D="Products"===t.subTitle?P[null!==(i=t.productId)&&void 0!==i?i:"Products"]:P[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=L.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=L.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=L.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=L.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=L.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===M.EMAIL_COLLECTION?b:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(x=null==D?void 0:D.content)&&void 0!==x?x:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(g=L.CustomDataType.FETCHED_LINKS)||void 0===g?void 0:g.toLowerCase())||I.toLowerCase()===(null===(y=L.CustomDataType.WEBSITE_LINKS)||void 0===y?void 0:y.toLowerCase())||I.toLowerCase()===(null===(C=L.CustomDataType.TEXTS)||void 0===C?void 0:C.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(O=null==D?void 0:D.data)||void 0===O?void 0:O.fileContentText)&&void 0!==S?S:"":t.intent===M.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ce?void 0:Ce.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Se(T),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:b}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${h.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:h.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.primary,className:"clamp-description"},{children:Te(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),re&&!Oe(ee)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(S.default,{appType:A,storeId:_,messageSource:k,sourceIntent:null!==(N=k.intent)&&void 0!==N?N:M.GENERIC,faqCount:ae,trainingSourceCount:xe,ShowTrainingDataSource:Re,ChecklistType:M,footerButtonOption:Q,isFooterLoading:oe,reasonForAiGeneratedResponse:X,showAiResponseReason:V})}))]})}),ce&&e.jsxRuntimeExports.jsx(R.SideModal,Object.assign({header:"Product description",onClose:()=>ue(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(b.DescriptionModal,{title:ce.title,description:ce.description,imageUrl:ce.imageUrl,onClose:ce.onClose})}))]})};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ICouponData } from "./type";
|
|
4
4
|
import { Collection, Product } from "../product-picker/type";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),i=require("react"),o=require("./type.js");require("../dropdown/DropdownPopover/index.js");var n=require("../dropdown/Dropdown.js");require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var l=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("../icon-button/IconButton.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var s=require("../modals/styledModal.js"),a=require("../product-picker/ProductPickerModal.js"),d=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/gift_icon.svg.js"),p=require("../../assets/icons/percentage_icon.svg.js"),C=require("../../assets/icons/shipping_icon.svg.js"),E=require("../../assets/icons/triangle_error.svg.js"),T=require("../../assets/icons/warning.svg.js"),S=require("../product-picker-v2/modal.js");require("../product-picker-v2/type.js");var P=require("../variable-picker-v3/model.js"),I=require("../variable-picker-v3/VariablePicker.js"),O=require("./DiscountModal.styled.js"),v=require("./DiscountUtils.js"),_=require("./DynamicCoupon/DynamicCoupon.js"),b=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=y=>{var m,x,D,N,h,j,R,f,U,A,g;const V=[{id:"0",label:"Amount",value:"amount",icon:t=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:t,lineHeight:.9}},{children:y.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:t=>e.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:t})},{id:"2",label:"Buy X get Y",value:o.DISCOUNT_TYPES.BUY_X_GET_Y,icon:t=>e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:t})},{id:"3",label:"Free Shipping",value:o.DISCOUNT_TYPES.FREE_SHIPPING,icon:t=>e.jsxRuntimeExports.jsx(C.default,{width:24,height:24,color:t})}],[F,k]=i.useState(),[q,L]=i.useState(),[M,Y]=i.useState(),[w,G]=i.useState(null!==(m=y.data)&&void 0!==m?m:"string"==typeof y.hideOption?{isStaticCoupon:"dynamic"===y.hideOption}:{isStaticCoupon:!0}),[B,X]=i.useState(!0),[Q,H]=i.useState(),[z,K]=i.useState((null===(x=y.data)||void 0===x?void 0:x.minAmount)?o.MIN_PURCHASE_REQUIREMENT.AMOUNT:(null===(D=y.data)||void 0===D?void 0:D.minQuantity)?o.MIN_PURCHASE_REQUIREMENT.QUANTITY:o.MIN_PURCHASE_REQUIREMENT.NA),[$,Z]=i.useState(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),[J,W]=i.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ee,te]=i.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ie,oe]=i.useState(void 0),[ne,le]=i.useState(void 0),[re,se]=i.useState(void 0),[ae,de]=i.useState(void 0),[ue,ce]=i.useState(void 0),[pe,Ce]=i.useState(void 0),[Ee,Te]=i.useState(0),[Se,Pe]=i.useState(""),[Ie,Oe]=i.useState(V[0]),[ve,_e]=i.useState(!1),[be,ye]=i.useState(o.initialStaticCouponErrorState),[me,xe]=i.useState(o.initialDynamicCouponErrorState),[De,Ne]=i.useState(o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION),he=[{value:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER},{value:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:Q===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:Q===o.DISCOUNT_TYPES.FREE_SHIPPING}];i.useEffect((()=>{y.makeExpiryMandatory&&_e(!0)}),[y.makeExpiryMandatory]),i.useEffect((()=>{var e,t,i,n,l,r,s,a;let d;const{tempCouponData:u,discountType:c}=je();H(c);const p=(e,t)=>{Oe(u.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?V[e]:V[t])},C=(e,t)=>{Object.keys(e||{}).length&&t(e)};switch(((null==u?void 0:u.expireAfter)||(null==u?void 0:u.expireAt))&&(_e(!0),(null==u?void 0:u.expireAt)&&Ne(o.COUPON_EXPIRATION.FIXED_EXPIRATION),(null==u?void 0:u.expireAfter)&&Ne(o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)),c){case o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:p(0,1),Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:p(0,1),(null===(e=u.entitledCollectionIds)||void 0===e?void 0:e.length)?Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS):(null===(t=u.entitledProductIds)||void 0===t?void 0:t.length)||(null===(i=u.productVariableConf)||void 0===i?void 0:i.entitledProductVariable)?(Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(n=u.productVariableConf)||void 0===n?void 0:n.entitledProductVariable,de)):Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.BUY_X_GET_Y:Oe(V[2]),(null===(l=u.entitledCollectionIds)||void 0===l?void 0:l.length)?te(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(te(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(r=u.productVariableConf)||void 0===r?void 0:r.entitledProductVariable,de)),(null===(s=u.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?W(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(W(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(a=u.productVariableConf)||void 0===a?void 0:a.prerequisiteProductVariable,ce));break;case o.DISCOUNT_TYPES.FREE_SHIPPING:Oe(V[3])}G(Object.assign({},u)),y.hideProbability||(d=Ue()),X(v.validateDiscountData(u,z,c,y.hideProbability||!1,d,!!u.isStaticCoupon)),y.hideProbability||Ue()}),[]),i.useEffect((()=>{let e;y.hideProbability||(e=Ue()),X(v.validateDiscountData(w,z,Q,y.hideProbability||!1,e,!!w.isStaticCoupon))}),[w,Ee,Q,z]),i.useEffect((()=>{var e,t,i,o,n,l,r;if(!y.newPickerConf&&((null===(e=y.products)||void 0===e?void 0:e.length)||(null===(t=y.collection)||void 0===t?void 0:t.length))){if(y.products&&(null===(i=y.products)||void 0===i?void 0:i.length)){if(null===(o=y.data)||void 0===o?void 0:o.entitledProductIds){const e=y.products.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.entitledProductIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));le(e)}if(null===(n=y.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=y.products.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.prerequisiteProductIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));oe(e)}}if(y.collection&&y.collection.length){if(null===(l=y.data)||void 0===l?void 0:l.entitledCollectionIds){const e=y.collection.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.entitledCollectionIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));Ce(e)}if(null===(r=y.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=y.collection.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.prerequisiteCollectionIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));se(e)}}}}),[y.products,y.collection]),i.useEffect((()=>{var e,t,i,o,n,l,r,s;(null===(t=null===(e=y.data)||void 0===e?void 0:e.productsConf)||void 0===t?void 0:t.entitledProducts)&&le(y.data.productsConf.entitledProducts),(null===(o=null===(i=y.data)||void 0===i?void 0:i.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&oe(y.data.productsConf.prerequisiteProducts),(null===(l=null===(n=y.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ce(y.data.collectionsConf.entitledCollections),(null===(s=null===(r=y.data)||void 0===r?void 0:r.collectionsConf)||void 0===s?void 0:s.prerequisiteCollections)&&se(y.data.collectionsConf.prerequisiteCollections)}),[null===(N=y.data)||void 0===N?void 0:N.productsConf,null===(h=y.data)||void 0===h?void 0:h.collectionsConf]),i.useEffect((()=>{if(!ne)return;if(y.newPickerConf){const e=[];return Object.values(ne).forEach((t=>{t.products&&Object.keys(t.products).forEach((t=>{e.push(parseInt(t))}))})),void G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}const e=ne.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}),[ne]),i.useEffect((()=>{if(!ie)return;if(y.newPickerConf){const e=[];return Object.values(ie).forEach((t=>{t.products&&Object.keys(t.products).forEach((t=>{e.push(parseInt(t))}))})),void G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}const e=ie.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}),[ie]),i.useEffect((()=>{if(!pe)return;if(y.newPickerConf){(null==pe?void 0:pe.isCustom)&&delete pe.isCustom;const e=Object.keys(pe).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}const e=pe.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}),[pe]),i.useEffect((()=>{if(!re)return;if(y.newPickerConf){(null==re?void 0:re.isCustom)&&delete re.isCustom;const e=Object.keys(re).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}const e=re.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}),[re]);const je=()=>{var e,t;let i,n=w;return w.isStaticCoupon||(w.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?i=o.DISCOUNT_TYPES.FREE_SHIPPING:w.targetType===o.DISCOUNT_TARGET_TYPES.LINE_ITEM?i=w.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(e=w.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(t=w.prerequisiteCollectionIds)||void 0===t?void 0:t.length)||w.prerequisiteQuantity||w.entitledQuantity?o.DISCOUNT_TYPES.BUY_X_GET_Y:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:(n=Object.assign(Object.assign({},n),{targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),i=o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER)),{discountType:i,tempCouponData:n}},Re=()=>{ye(o.initialStaticCouponErrorState),xe(o.initialDynamicCouponErrorState)},fe=e=>{var t;const i={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(t=w.probability)&&void 0!==t?t:-1)>1?"Probability should not exceed 1":w.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((t=>{e[t]&&(o=i[t])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(Pe(n>1?"Please add discount details":o),!0)},Ue=()=>{if(!y.quadrant||!y.probability)return;const e=[...y.probability];let t=[];e.length>=y.quadrant&&e.splice(y.quadrant-1,1),t=e;const i=t.reduce(((e,t)=>e+t),0)+(w.probability||0);return Te(parseFloat(i.toFixed(4))),parseFloat(i.toFixed(4))},Ae=e=>{var t,i,n,l,r,s,a,d,u,c,p,C,E,T,S,P;const I=e.value;H(I),oe([]),le([]),se([]),Ce([]),I===o.DISCOUNT_TYPES.FREE_SHIPPING?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(t=w.expireAt)&&void 0!==t?t:void 0,expireAfter:null!==(i=w.expireAfter)&&void 0!==i?i:void 0,probability:w.probability,minQuantity:null!==(n=w.minQuantity)&&void 0!==n?n:void 0,minAmount:null!==(l=w.minAmount)&&void 0!==l?l:void 0}):I===o.DISCOUNT_TYPES.BUY_X_GET_Y?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(r=w.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(s=w.expireAfter)&&void 0!==s?s:void 0,probability:w.probability,minQuantity:void 0,minAmount:void 0}):I===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER?G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(a=w.valueType)&&void 0!==a?a:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(d=w.expireAt)&&void 0!==d?d:void 0,expireAfter:null!==(u=w.expireAfter)&&void 0!==u?u:void 0,probability:w.probability,value:w.value,minQuantity:null!==(c=w.minQuantity)&&void 0!==c?c:void 0,minAmount:null!==(p=w.minAmount)&&void 0!==p?p:void 0}):I===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS&&G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(C=w.valueType)&&void 0!==C?C:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(E=w.expireAt)&&void 0!==E?E:void 0,expireAfter:null!==(T=w.expireAfter)&&void 0!==T?T:void 0,probability:w.probability,value:w.value,minQuantity:null!==(S=w.minQuantity)&&void 0!==S?S:void 0,minAmount:null!==(P=w.minAmount)&&void 0!==P?P:void 0})},ge=t=>t&&e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:t,type:"negative",LeadingIcon:T.default});return e.jsxRuntimeExports.jsxs(s.StyledModal,Object.assign({width:(M||F)&&y.newPickerConf?"25px":"640px",open:y.isOpen,hideCrossButton:!!q,headingTitle:F?"Select Products":y.title,headingSubtitle:F?void 0:y.subTitle,footerLeftCustomElement:Se?ge(Se):y.errorMsg?ge(y.errorMsg):!y.quadrant||y.hideProbability?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Ee<=1?e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:`Current probability sum: ${Ee}`,type:"white"}):e.jsxRuntimeExports.jsx(u.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(d.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Ee}`,type:"negative",LeadingIcon:E.default})})})),headerRightCustomElement:y.allowStaticCoupon||F?void 0:e.jsxRuntimeExports.jsx(n.Dropdown,{options:he,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ae(e)}}),onClose:y.onClose,footerContainerStyle:{borderTop:`1px solid ${r.DEFAULT_THEME.colorsV2.stroke.primary}`},primaryButton:F?{buttonType:"primary",onClick:()=>{k(void 0)},buttonText:"Add"}:M?{buttonType:"primary",onClick:()=>{Y(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(j=y.loading)&&void 0!==j&&j,onClick:()=>{var e,t,i,n,l;if(Re(),w.isStaticCoupon){const{isStaticCoupon:e,couponCode:t,title:i,description:o,quadrant:n,probability:l}=w,r={invalidDiscountCode:!t,invalidCouponTitle:!i,invalidCouponDescription:!o,inValidProbability:!y.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(fe(r))return void ye(r);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked({quadrant:n,couponCode:t,description:o,isStaticCoupon:e,probability:l,title:w.title})}else{const r={invalidCouponTitle:!w.title,inValidProbability:!y.hideProbability&&(null!==(e=w.probability)&&void 0!==e?e:-1)<=0||(null!==(t=w.probability)&&void 0!==t?t:-1)>1||Number.isNaN(null!==(i=w.probability)&&void 0!==i?i:-1),inValidDiscountAmount:!w.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(Q!==o.DISCOUNT_TYPES.BUY_X_GET_Y&&z!==o.MIN_PURCHASE_REQUIREMENT.NA){const{minAmount:e,minQuantity:t}=w;r.inValidMinimumAmount=z===o.MIN_PURCHASE_REQUIREMENT.AMOUNT&&!e,r.inValidMinimumQuantity=z===o.MIN_PURCHASE_REQUIREMENT.QUANTITY&&!t}if(ve&&(r.inValidCouponExpiry=!w.expireAt&&!w.expireAfter),Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||($!==o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidProductSelection=!0,r.inValidProductVariableSelection=!0),$===o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(r.inValidCollectionSelection=!0)),Q===o.DISCOUNT_TYPES.BUY_X_GET_Y&&(w.prerequisiteQuantity||(r.inValidBuyXValue=!0),w.entitledQuantity||(r.inValidGetYValue=!0),J!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ie||Object.keys(ie).length||ue||(r.inValidBuyXProductSelection=!0,r.inValidBuyXProductVariableSelection=!0),J===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&re&&!Object.keys(re).length&&(r.inValidBuyXCollectionSelection=!0),ee!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidGetYProductSelection=!0,r.inValidGetYProductVariableSelection=!0),ee===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(r.inValidGetYCollectionSelection=!0)),fe(r))return void xe(r);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked(Object.assign(Object.assign({},w),{description:v.descriptionBuilder(w,y.currency,null!==(n=y.products)&&void 0!==n?n:[],null!==(l=y.collection)&&void 0!==l?l:[]),productsConf:{entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=ie?ie:[]},collectionsConf:{entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[]},productVariableConf:{entitledProductVariable:null!=ae?ae:{},prerequisiteProductVariable:null!=ue?ue:{}}}))}}},secondaryButton:F?{buttonType:"tertiaryGray",onClick:()=>{k(void 0)},buttonText:"Back"}:M?{buttonType:"tertiaryGray",onClick:()=>{Y(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:y.onClose,buttonText:"Cancel"}},{children:[!F&&!M&&e.jsxRuntimeExports.jsxs(O.StyledDiscountDialogueContainer,{children:[y.allowStaticCoupon&&!F&&e.jsxRuntimeExports.jsxs(O.CouponTypeContainerStyled,Object.assign({selectedDiv:w.isStaticCoupon?1:2},{children:["static"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{w.isStaticCoupon||(G({isStaticCoupon:!0,quadrant:w.quadrant}),Pe(""),Re())}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?r.DEFAULT_THEME.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var t;w.isStaticCoupon&&(H(o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER),G({isStaticCoupon:!1,quadrant:w.quadrant,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),Pe(""),Re(),Oe({id:"0",label:"Amount",value:"amount",icon:t=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:t}},{children:y.currency||""}))}),_e(null!==(t=y.makeExpiryMandatory)&&void 0!==t&&t),K(o.MIN_PURCHASE_REQUIREMENT.NA))}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?void 0:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),e.jsxRuntimeExports.jsx(l.TitleRegular,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),w.isStaticCoupon&&!F&&e.jsxRuntimeExports.jsx(b.default,{discountData:w,setDiscountData:G,hideProbability:y.hideProbability||!1,discountAdminUrl:y.discountAdminUrl,staticDiscountValidationError:be,currency:y.currency}),!w.isStaticCoupon&&!F&&!M&&e.jsxRuntimeExports.jsx(_.default,{currency:y.currency,entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=ie?ie:[],setEntitledProducts:le,setPrerequisiteProducts:oe,discountData:w,productPickerOpen:F,productVariablePickerOpen:q,setIsProductPickerOpen:k,setIsProductVariablePickerOpen:L,setDiscountData:G,selectedCouponType:Q,setSelectedCouponType:H,selectedMinimumRequirement:z,setSelectedMinimumRequirement:K,discountCouponAppliesTo:$,offerAppliesToBuy:J,offerAppliesToGet:ee,setDiscountCouponAppliesTo:Z,setOfferAppliesToBuy:W,setOfferAppliesToGet:te,hideProbability:y.hideProbability||!1,hideExpiration:y.hideExpiration||!1,allowStaticCoupon:y.allowStaticCoupon,onChangeCouponType:Ae,collectionPickerOpen:M,entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[],setIsCollectionPickerOpen:Y,setEntitledCollections:Ce,setPrerequisiteCollections:se,useNewPicker:!!y.newPickerConf,setSelectedDiscountDetails:Oe,selectedDiscountDetails:Ie,isProductVariableSupported:y.isProductVariableSupported,entitledProductVariable:ae,setEntitledProductVariable:de,preRequisiteProductVariable:ue,setPreRequisiteProductVariable:ce,productVariableList:y.productVariableList,isAddExpirationChecked:ve,setIsAddExpirationChecked:_e,dynamicDiscountValidationError:me,setDynamicDiscountValidationError:xe,setValidationErrorMessage:Pe,resetValidationErrors:Re,discountDetailsOptions:V,selectedExpiration:De,setSelectedExpiration:Ne,makeExpiryMandatory:!!y.makeExpiryMandatory})]}),!!F&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!y.newPickerConf&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsx(a.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(R=y.products)&&void 0!==R?R:[],title:"Select Products",onClose:()=>{k(void 0)},selectedProducts:null!==(f=F===_.DISCOUNT_PRODUCTS.ENTITLED?ne:ie)&&void 0!==f?f:[],setSelectedProducts:F===_.DISCOUNT_PRODUCTS.ENTITLED?le:oe,onSearchKeyChange:y.onProductSearch})})),y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>k(void 0),collectionFetcher:(e,t,i)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.fetchCollections)?y.newPickerConf.fetchCollections(e,t,!1,i):null},productFetcher:(e,t,i,o,n)=>{var l;return(null===(l=y.newPickerConf)||void 0===l?void 0:l.fetchProducts)?y.newPickerConf.fetchProducts(e,t,o,n,!1,i):null},selectedItems:F===_.DISCOUNT_PRODUCTS.ENTITLED?ne:ie,onAdd:e=>{F===_.DISCOUNT_PRODUCTS.ENTITLED?le(e):oe(e),k(void 0)},zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||t.ApplicationType.BIK,searchInCollectionFetcher:(e,t,i,o)=>{var n;return(null===(n=y.newPickerConf)||void 0===n?void 0:n.searchInCollection)?y.newPickerConf.searchInCollection(e,t,i,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,t,i)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.searchProducts)?y.newPickerConf.searchProducts(e,t,!1,i):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!M&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>Y(void 0),collectionFetcher:y.newPickerConf.fetchCollections,productFetcher:y.newPickerConf.fetchProducts,selectedItems:M===_.DISCOUNT_PRODUCTS.ENTITLED?pe:re,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),M===_.DISCOUNT_PRODUCTS.ENTITLED?Ce(e):se(e),Y(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||t.ApplicationType.BIK,searchInCollectionFetcher:y.newPickerConf.searchInCollection,searchFetcher:y.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!y.newPickerConf&&e.jsxRuntimeExports.jsx(a.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(U=y.collection)&&void 0!==U?U:[],title:"Select Products",onClose:()=>{Y(void 0)},selectedProducts:null!==(A=M===_.DISCOUNT_PRODUCTS.ENTITLED?pe:re)&&void 0!==A?A:[],setSelectedProducts:M===_.DISCOUNT_PRODUCTS.ENTITLED?Ce:se,onSearchKeyChange:y.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),q&&e.jsxRuntimeExports.jsx(O.VariablePickerContainer,{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsxRuntimeExports.jsx(I.VariablePicker,{type:P.PickerType.EMBEDDED,data:null!==(g=y.productVariableList)&&void 0!==g?g:[],showHeader:!0,onSelect:e=>{if(q===_.DISCOUNT_PRODUCTS.ENTITLED){const{displayName:t,actualValue:i,isAvailable:o}=e;de({displayName:t,actualValue:i,isAvailable:o}),L(void 0)}if(q===_.DISCOUNT_PRODUCTS.PREREQUISITE){const{displayName:t,actualValue:i,isAvailable:o}=e;ce({displayName:t,actualValue:i,isAvailable:o}),L(void 0)}},onClose:()=>{L(void 0)}})}))})]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),i=require("react"),o=require("./type.js");require("../dropdown/DropdownPopover/index.js");var n=require("../dropdown/Dropdown.js");require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var l=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("../icon-button/IconButton.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var s=require("../modals/styledModal.js"),a=require("../product-picker/ProductPickerModal.js"),d=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/gift_icon.svg.js"),p=require("../../assets/icons/percentage_icon.svg.js"),C=require("../../assets/icons/shipping_icon.svg.js"),E=require("../../assets/icons/triangle_error.svg.js"),T=require("../../assets/icons/warning.svg.js"),S=require("../product-picker-v2/modal.js");require("../product-picker-v2/type.js");var P=require("../variable-picker-v3/model.js"),I=require("../variable-picker-v3/VariablePicker.js"),O=require("./DiscountModal.styled.js"),v=require("./DiscountUtils.js"),_=require("./DynamicCoupon/DynamicCoupon.js"),b=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=y=>{var m,x,D,N,h,j,R,f,U,A,g;const V=[{id:"0",label:"Amount",value:"amount",icon:t=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:t,lineHeight:.9}},{children:y.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:t=>e.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:t})},{id:"2",label:"Buy X get Y",value:o.DISCOUNT_TYPES.BUY_X_GET_Y,icon:t=>e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:t})},{id:"3",label:"Free Shipping",value:o.DISCOUNT_TYPES.FREE_SHIPPING,icon:t=>e.jsxRuntimeExports.jsx(C.default,{width:24,height:24,color:t})}],[F,k]=i.useState(),[q,L]=i.useState(),[M,Y]=i.useState(),[w,G]=i.useState(null!==(m=y.data)&&void 0!==m?m:"string"==typeof y.hideOption?{isStaticCoupon:"dynamic"===y.hideOption}:{isStaticCoupon:!0}),[B,X]=i.useState(!0),[Q,H]=i.useState(),[z,K]=i.useState((null===(x=y.data)||void 0===x?void 0:x.minAmount)?o.MIN_PURCHASE_REQUIREMENT.AMOUNT:(null===(D=y.data)||void 0===D?void 0:D.minQuantity)?o.MIN_PURCHASE_REQUIREMENT.QUANTITY:o.MIN_PURCHASE_REQUIREMENT.NA),[$,Z]=i.useState(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),[J,W]=i.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ee,te]=i.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ie,oe]=i.useState(void 0),[ne,le]=i.useState(void 0),[re,se]=i.useState(void 0),[ae,de]=i.useState(void 0),[ue,ce]=i.useState(void 0),[pe,Ce]=i.useState(void 0),[Ee,Te]=i.useState(0),[Se,Pe]=i.useState(""),[Ie,Oe]=i.useState(V[0]),[ve,_e]=i.useState(!1),[be,ye]=i.useState(o.initialStaticCouponErrorState),[me,xe]=i.useState(o.initialDynamicCouponErrorState),[De,Ne]=i.useState(o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION),he=[{value:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER},{value:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:Q===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:Q===o.DISCOUNT_TYPES.FREE_SHIPPING}];i.useEffect((()=>{y.makeExpiryMandatory&&_e(!0)}),[y.makeExpiryMandatory]),i.useEffect((()=>{var e,t,i,n,l,r,s,a;let d;const{tempCouponData:u,discountType:c}=je();H(c);const p=(e,t)=>{Oe(u.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?V[e]:V[t])},C=(e,t)=>{Object.keys(e||{}).length&&t(e)};switch(((null==u?void 0:u.expireAfter)||(null==u?void 0:u.expireAt))&&(_e(!0),(null==u?void 0:u.expireAt)&&Ne(o.COUPON_EXPIRATION.FIXED_EXPIRATION),(null==u?void 0:u.expireAfter)&&Ne(o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)),c){case o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:p(0,1),Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:p(0,1),(null===(e=u.entitledCollectionIds)||void 0===e?void 0:e.length)?Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS):(null===(t=u.entitledProductIds)||void 0===t?void 0:t.length)||(null===(i=u.productVariableConf)||void 0===i?void 0:i.entitledProductVariable)?(Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(n=u.productVariableConf)||void 0===n?void 0:n.entitledProductVariable,de)):Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.BUY_X_GET_Y:Oe(V[2]),(null===(l=u.entitledCollectionIds)||void 0===l?void 0:l.length)?te(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(te(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(r=u.productVariableConf)||void 0===r?void 0:r.entitledProductVariable,de)),(null===(s=u.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?W(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(W(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(a=u.productVariableConf)||void 0===a?void 0:a.prerequisiteProductVariable,ce));break;case o.DISCOUNT_TYPES.FREE_SHIPPING:Oe(V[3])}G(Object.assign({},u)),y.hideProbability||(d=Ue()),X(v.validateDiscountData(u,z,c,y.hideProbability||!1,d,!!u.isStaticCoupon)),y.hideProbability||Ue()}),[]),i.useEffect((()=>{let e;y.hideProbability||(e=Ue()),X(v.validateDiscountData(w,z,Q,y.hideProbability||!1,e,!!w.isStaticCoupon))}),[w,Ee,Q,z]),i.useEffect((()=>{var e,t,i,o,n,l,r;if(!y.newPickerConf&&((null===(e=y.products)||void 0===e?void 0:e.length)||(null===(t=y.collection)||void 0===t?void 0:t.length))){if(y.products&&(null===(i=y.products)||void 0===i?void 0:i.length)){if(null===(o=y.data)||void 0===o?void 0:o.entitledProductIds){const e=y.products.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.entitledProductIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));le(e)}if(null===(n=y.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=y.products.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.prerequisiteProductIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));oe(e)}}if(y.collection&&y.collection.length){if(null===(l=y.data)||void 0===l?void 0:l.entitledCollectionIds){const e=y.collection.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.entitledCollectionIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));Ce(e)}if(null===(r=y.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=y.collection.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.prerequisiteCollectionIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));se(e)}}}}),[y.products,y.collection]),i.useEffect((()=>{var e,t,i,o,n,l,r,s;(null===(t=null===(e=y.data)||void 0===e?void 0:e.productsConf)||void 0===t?void 0:t.entitledProducts)&&le(y.data.productsConf.entitledProducts),(null===(o=null===(i=y.data)||void 0===i?void 0:i.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&oe(y.data.productsConf.prerequisiteProducts),(null===(l=null===(n=y.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ce(y.data.collectionsConf.entitledCollections),(null===(s=null===(r=y.data)||void 0===r?void 0:r.collectionsConf)||void 0===s?void 0:s.prerequisiteCollections)&&se(y.data.collectionsConf.prerequisiteCollections)}),[null===(N=y.data)||void 0===N?void 0:N.productsConf,null===(h=y.data)||void 0===h?void 0:h.collectionsConf]),i.useEffect((()=>{if(!ne)return;if(y.newPickerConf){const e=[];return Object.values(ne).forEach((t=>{t.products&&Object.keys(t.products).forEach((t=>{e.push(parseInt(t))}))})),void G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}const e=ne.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}),[ne]),i.useEffect((()=>{if(!ie)return;if(y.newPickerConf){const e=[];return Object.values(ie).forEach((t=>{t.products&&Object.keys(t.products).forEach((t=>{e.push(parseInt(t))}))})),void G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}const e=ie.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}),[ie]),i.useEffect((()=>{if(!pe)return;if(y.newPickerConf){(null==pe?void 0:pe.isCustom)&&delete pe.isCustom;const e=Object.keys(pe).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}const e=pe.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}),[pe]),i.useEffect((()=>{if(!re)return;if(y.newPickerConf){(null==re?void 0:re.isCustom)&&delete re.isCustom;const e=Object.keys(re).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}const e=re.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}),[re]);const je=()=>{var e,t;let i,n=w;return w.isStaticCoupon||(w.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?i=o.DISCOUNT_TYPES.FREE_SHIPPING:w.targetType===o.DISCOUNT_TARGET_TYPES.LINE_ITEM?i=w.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(e=w.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(t=w.prerequisiteCollectionIds)||void 0===t?void 0:t.length)||w.prerequisiteQuantity||w.entitledQuantity?o.DISCOUNT_TYPES.BUY_X_GET_Y:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:(n=Object.assign(Object.assign({},n),{targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),i=o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER)),{discountType:i,tempCouponData:n}},Re=()=>{ye(o.initialStaticCouponErrorState),xe(o.initialDynamicCouponErrorState)},fe=e=>{var t;const i={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(t=w.probability)&&void 0!==t?t:-1)>1?"Probability should not exceed 1":w.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((t=>{e[t]&&(o=i[t])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(Pe(n>1?"Please add discount details":o),!0)},Ue=()=>{if(!y.quadrant||!y.probability)return;const e=[...y.probability];let t=[];e.length>=y.quadrant&&e.splice(y.quadrant-1,1),t=e;const i=t.reduce(((e,t)=>e+t),0)+(w.probability||0);return Te(parseFloat(i.toFixed(4))),parseFloat(i.toFixed(4))},Ae=e=>{var t,i,n,l,r,s,a,d,u,c,p,C,E,T,S,P;const I=e.value;H(I),oe([]),le([]),se([]),Ce([]),I===o.DISCOUNT_TYPES.FREE_SHIPPING?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(t=w.expireAt)&&void 0!==t?t:void 0,expireAfter:null!==(i=w.expireAfter)&&void 0!==i?i:void 0,probability:w.probability,minQuantity:null!==(n=w.minQuantity)&&void 0!==n?n:void 0,minAmount:null!==(l=w.minAmount)&&void 0!==l?l:void 0}):I===o.DISCOUNT_TYPES.BUY_X_GET_Y?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(r=w.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(s=w.expireAfter)&&void 0!==s?s:void 0,probability:w.probability,minQuantity:void 0,minAmount:void 0}):I===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER?G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(a=w.valueType)&&void 0!==a?a:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(d=w.expireAt)&&void 0!==d?d:void 0,expireAfter:null!==(u=w.expireAfter)&&void 0!==u?u:void 0,probability:w.probability,value:w.value,minQuantity:null!==(c=w.minQuantity)&&void 0!==c?c:void 0,minAmount:null!==(p=w.minAmount)&&void 0!==p?p:void 0}):I===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS&&G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(C=w.valueType)&&void 0!==C?C:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(E=w.expireAt)&&void 0!==E?E:void 0,expireAfter:null!==(T=w.expireAfter)&&void 0!==T?T:void 0,probability:w.probability,value:w.value,minQuantity:null!==(S=w.minQuantity)&&void 0!==S?S:void 0,minAmount:null!==(P=w.minAmount)&&void 0!==P?P:void 0})},ge=t=>t&&e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:t,type:"negative",LeadingIcon:T.default});return e.jsxRuntimeExports.jsxs(s.StyledModal,Object.assign({width:(M||F)&&y.newPickerConf?"25px":"640px",open:y.isOpen,hideCrossButton:!!q,headingTitle:F?"Select Products":y.title,headingSubtitle:F?void 0:y.subTitle,footerLeftCustomElement:Se?ge(Se):y.errorMsg?ge(y.errorMsg):!y.quadrant||y.hideProbability?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Ee<=1?e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:`Current probability sum: ${Ee}`,type:"white"}):e.jsxRuntimeExports.jsx(u.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(d.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Ee}`,type:"negative",LeadingIcon:E.default})})})),headerRightCustomElement:y.allowStaticCoupon||F?void 0:e.jsxRuntimeExports.jsx(n.Dropdown,{options:he,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ae(e)}}),onClose:y.onClose,footerContainerStyle:{borderTop:`1px solid ${r.DEFAULT_THEME.colorsV2.stroke.primary}`},primaryButton:F?{buttonType:"primary",onClick:()=>{k(void 0)},buttonText:"Add"}:M?{buttonType:"primary",onClick:()=>{Y(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(j=y.loading)&&void 0!==j&&j,onClick:()=>{var e,t,i,n,l;if(Re(),w.isStaticCoupon){const{isStaticCoupon:e,couponCode:t,title:i,description:o,quadrant:n,probability:l}=w,r={invalidDiscountCode:!t,invalidCouponTitle:!i,invalidCouponDescription:!o,inValidProbability:!y.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(fe(r))return void ye(r);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked({quadrant:n,couponCode:t,description:o,isStaticCoupon:e,probability:l,title:w.title})}else{const r={invalidCouponTitle:!w.title,inValidProbability:!y.hideProbability&&(null!==(e=w.probability)&&void 0!==e?e:-1)<=0||(null!==(t=w.probability)&&void 0!==t?t:-1)>1||Number.isNaN(null!==(i=w.probability)&&void 0!==i?i:-1),inValidDiscountAmount:!w.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(Q!==o.DISCOUNT_TYPES.BUY_X_GET_Y&&z!==o.MIN_PURCHASE_REQUIREMENT.NA){const{minAmount:e,minQuantity:t}=w;r.inValidMinimumAmount=z===o.MIN_PURCHASE_REQUIREMENT.AMOUNT&&!e,r.inValidMinimumQuantity=z===o.MIN_PURCHASE_REQUIREMENT.QUANTITY&&!t}if(ve&&(r.inValidCouponExpiry=!w.expireAt&&!w.expireAfter),Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||($!==o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidProductSelection=!0,r.inValidProductVariableSelection=!0),$===o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(r.inValidCollectionSelection=!0)),Q===o.DISCOUNT_TYPES.BUY_X_GET_Y&&(w.prerequisiteQuantity||(r.inValidBuyXValue=!0),w.entitledQuantity||(r.inValidGetYValue=!0),J!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ie||Object.keys(ie).length||ue||(r.inValidBuyXProductSelection=!0,r.inValidBuyXProductVariableSelection=!0),J===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&re&&!Object.keys(re).length&&(r.inValidBuyXCollectionSelection=!0),ee!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidGetYProductSelection=!0,r.inValidGetYProductVariableSelection=!0),ee===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(r.inValidGetYCollectionSelection=!0)),fe(r))return void xe(r);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked(Object.assign(Object.assign({},w),{description:v.descriptionBuilder(w,y.currency,null!==(n=y.products)&&void 0!==n?n:[],null!==(l=y.collection)&&void 0!==l?l:[]),productsConf:{entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=ie?ie:[]},collectionsConf:{entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[]},productVariableConf:{entitledProductVariable:null!=ae?ae:{},prerequisiteProductVariable:null!=ue?ue:{}}}))}}},secondaryButton:F?{buttonType:"tertiaryGray",onClick:()=>{k(void 0)},buttonText:"Back"}:M?{buttonType:"tertiaryGray",onClick:()=>{Y(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:y.onClose,buttonText:"Cancel"}},{children:[!F&&!M&&e.jsxRuntimeExports.jsxs(O.StyledDiscountDialogueContainer,{children:[y.allowStaticCoupon&&!F&&e.jsxRuntimeExports.jsxs(O.CouponTypeContainerStyled,Object.assign({selectedDiv:w.isStaticCoupon?1:2},{children:["static"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{w.isStaticCoupon||(G({isStaticCoupon:!0,quadrant:w.quadrant}),Pe(""),Re())}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?r.DEFAULT_THEME.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var t;w.isStaticCoupon&&(H(o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER),G({isStaticCoupon:!1,quadrant:w.quadrant,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),Pe(""),Re(),Oe({id:"0",label:"Amount",value:"amount",icon:t=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:t}},{children:y.currency||""}))}),_e(null!==(t=y.makeExpiryMandatory)&&void 0!==t&&t),K(o.MIN_PURCHASE_REQUIREMENT.NA))}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?void 0:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),e.jsxRuntimeExports.jsx(l.TitleRegular,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),w.isStaticCoupon&&!F&&e.jsxRuntimeExports.jsx(b.default,{discountData:w,setDiscountData:G,hideProbability:y.hideProbability||!1,discountAdminUrl:y.discountAdminUrl,staticDiscountValidationError:be,currency:y.currency}),!w.isStaticCoupon&&!F&&!M&&e.jsxRuntimeExports.jsx(_.default,{currency:y.currency,entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=ie?ie:[],setEntitledProducts:le,setPrerequisiteProducts:oe,discountData:w,productPickerOpen:F,productVariablePickerOpen:q,setIsProductPickerOpen:k,setIsProductVariablePickerOpen:L,setDiscountData:G,selectedCouponType:Q,setSelectedCouponType:H,selectedMinimumRequirement:z,setSelectedMinimumRequirement:K,discountCouponAppliesTo:$,offerAppliesToBuy:J,offerAppliesToGet:ee,setDiscountCouponAppliesTo:Z,setOfferAppliesToBuy:W,setOfferAppliesToGet:te,hideProbability:y.hideProbability||!1,hideExpiration:y.hideExpiration||!1,allowStaticCoupon:y.allowStaticCoupon,onChangeCouponType:Ae,collectionPickerOpen:M,entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[],setIsCollectionPickerOpen:Y,setEntitledCollections:Ce,setPrerequisiteCollections:se,useNewPicker:!!y.newPickerConf,setSelectedDiscountDetails:Oe,selectedDiscountDetails:Ie,isProductVariableSupported:y.isProductVariableSupported,entitledProductVariable:ae,setEntitledProductVariable:de,preRequisiteProductVariable:ue,setPreRequisiteProductVariable:ce,productVariableList:y.productVariableList,isAddExpirationChecked:ve,setIsAddExpirationChecked:_e,dynamicDiscountValidationError:me,setDynamicDiscountValidationError:xe,setValidationErrorMessage:Pe,resetValidationErrors:Re,discountDetailsOptions:V,selectedExpiration:De,setSelectedExpiration:Ne,makeExpiryMandatory:!!y.makeExpiryMandatory})]}),!!F&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!y.newPickerConf&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsx(a.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(R=y.products)&&void 0!==R?R:[],title:"Select Products",onClose:()=>{k(void 0)},selectedProducts:null!==(f=F===_.DISCOUNT_PRODUCTS.ENTITLED?ne:ie)&&void 0!==f?f:[],setSelectedProducts:F===_.DISCOUNT_PRODUCTS.ENTITLED?le:oe,onSearchKeyChange:y.onProductSearch})})),y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>k(void 0),collectionFetcher:(e,t,i)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.fetchCollections)?y.newPickerConf.fetchCollections(e,t,!1,i):null},productFetcher:(e,t,i,o,n)=>{var l;return(null===(l=y.newPickerConf)||void 0===l?void 0:l.fetchProducts)?y.newPickerConf.fetchProducts(e,t,o,n,!1,i):null},selectedItems:F===_.DISCOUNT_PRODUCTS.ENTITLED?ne:ie,onAdd:e=>{F===_.DISCOUNT_PRODUCTS.ENTITLED?le(e):oe(e),k(void 0)},zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||t.ApplicationType.BIK,searchInCollectionFetcher:(e,t,i,o)=>{var n;return(null===(n=y.newPickerConf)||void 0===n?void 0:n.searchInCollection)?y.newPickerConf.searchInCollection(e,t,i,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,t,i)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.searchProducts)?y.newPickerConf.searchProducts(e,t,!1,i):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!M&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>Y(void 0),collectionFetcher:y.newPickerConf.fetchCollections,productFetcher:y.newPickerConf.fetchProducts,selectedItems:M===_.DISCOUNT_PRODUCTS.ENTITLED?pe:re,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),M===_.DISCOUNT_PRODUCTS.ENTITLED?Ce(e):se(e),Y(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||t.ApplicationType.BIK,searchInCollectionFetcher:y.newPickerConf.searchInCollection,searchFetcher:y.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!y.newPickerConf&&e.jsxRuntimeExports.jsx(a.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(U=y.collection)&&void 0!==U?U:[],title:"Select Products",onClose:()=>{Y(void 0)},selectedProducts:null!==(A=M===_.DISCOUNT_PRODUCTS.ENTITLED?pe:re)&&void 0!==A?A:[],setSelectedProducts:M===_.DISCOUNT_PRODUCTS.ENTITLED?Ce:se,onSearchKeyChange:y.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),q&&e.jsxRuntimeExports.jsx(O.VariablePickerContainer,{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsxRuntimeExports.jsx(I.VariablePicker,{type:P.PickerType.EMBEDDED,data:null!==(g=y.productVariableList)&&void 0!==g?g:[],showHeader:!0,onSelect:e=>{if(q===_.DISCOUNT_PRODUCTS.ENTITLED){const{displayName:t,actualValue:i,isAvailable:o}=e;de({displayName:t,actualValue:i,isAvailable:o}),L(void 0)}if(q===_.DISCOUNT_PRODUCTS.PREREQUISITE){const{displayName:t,actualValue:i,isAvailable:o}=e;ce({displayName:t,actualValue:i,isAvailable:o}),L(void 0)}},onClose:()=>{L(void 0)}})}))})]}))};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const OverLapAbs: import("styled-components").StyledComponent<"div", any, {
|
|
2
2
|
disabled?: boolean | undefined;
|
|
3
3
|
allowEvents?: boolean | undefined;
|
|
4
|
+
isChildLoading?: boolean | undefined;
|
|
4
5
|
}, never>;
|
|
5
6
|
export declare const OpenDropdownContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
7
|
export declare const LoadingContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=i(e);const o=r.default.div`
|
|
2
|
+
position:
|
|
2
3
|
// if allowEvents is true, then position is relative, else position is absolute
|
|
3
|
-
|
|
4
|
-
position: ${e=>(null==e?void 0:e.allowEvents)?"relative":"absolute"};
|
|
4
|
+
${e=>(null==e?void 0:e.allowEvents)||(null==e?void 0:e.isChildLoading)?"relative":"absolute"};
|
|
5
5
|
left: 0px;
|
|
6
6
|
top: 0px;
|
|
7
7
|
width: 100%;
|
|
8
8
|
height: 100%;
|
|
9
|
-
z-index:
|
|
9
|
+
z-index: 2;
|
|
10
10
|
cursor: ${e=>(null==e?void 0:e.disabled)?"not-allowed":"pointer"};
|
|
11
|
-
|
|
12
|
-
&::before {
|
|
13
|
-
content: '';
|
|
14
|
-
position: absolute;
|
|
15
|
-
inset: 0;
|
|
16
|
-
width: 100%;
|
|
17
|
-
height: 100%;
|
|
18
|
-
background-color: transparent;
|
|
19
|
-
transition: background-color 0.2s ease;
|
|
20
|
-
pointer-events: none;
|
|
21
|
-
z-index: -1;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&:hover::before {
|
|
25
|
-
background-color: ${e=>e.disabled?"transparent":"rgba(0, 0, 0, 0.04)"};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* When allowEvents is true, make this layer non-interactive */
|
|
29
|
-
pointer-events: ${e=>e.allowEvents?"none":"auto"};
|
|
30
|
-
`,n=o.default.div`
|
|
11
|
+
`,n=r.default.div`
|
|
31
12
|
margin-top: 8px;
|
|
32
13
|
margin-bottom: 8px;
|
|
33
|
-
`;
|
|
14
|
+
`;r.default.div`
|
|
34
15
|
display: flex;
|
|
35
16
|
flex-direction: row;
|
|
36
17
|
align-items: center;
|
|
@@ -38,7 +19,7 @@
|
|
|
38
19
|
background: ${t.COLORS.surface.hovered};
|
|
39
20
|
border: 1px solid ${t.COLORS.stroke.primary};
|
|
40
21
|
border-radius: 4px;
|
|
41
|
-
`;const
|
|
22
|
+
`;const s=r.default.div`
|
|
42
23
|
width: 360px;
|
|
43
24
|
height: 100%;
|
|
44
25
|
padding: 8px;
|
|
@@ -53,4 +34,4 @@
|
|
|
53
34
|
flex-wrap: wrap;
|
|
54
35
|
align-items: center;
|
|
55
36
|
}
|
|
56
|
-
`;exports.ChipInputWrapper=
|
|
37
|
+
`;exports.ChipInputWrapper=s,exports.OpenDropdownContainer=n,exports.OverLapAbs=o;
|
|
@@ -12,6 +12,7 @@ export declare const DropdownPopover: React.ForwardRefExoticComponent<OpenDropdo
|
|
|
12
12
|
showTooltipArrow?: boolean | undefined;
|
|
13
13
|
allowEvents?: boolean | undefined;
|
|
14
14
|
'data-test'?: string | undefined;
|
|
15
|
+
isChildLoading?: boolean | undefined;
|
|
15
16
|
} & React.RefAttributes<{
|
|
16
17
|
openDropdown: boolean;
|
|
17
18
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("../../../node_modules/react/jsx-runtime.js"),o=require("react"),n=require("react-popper"),s=require("../../dropShadow/DropShadow.js"),r=require("../../tooltips/Tooltip.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("../../../node_modules/react/jsx-runtime.js"),o=require("react"),n=require("react-popper"),s=require("../../dropShadow/DropShadow.js"),r=require("../../tooltips/Tooltip.js"),i=require("../Common.styled.js"),l=require("../OpenedDropdown/components/OpennedDropdown.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const d=a(o).default.forwardRef(((a,d)=>{var{children:p,onDropdownVisbilityChange:u,version:c="1.0",tooltipContent:j,tooltipDirection:x,showTooltipArrow:v,isChildLoading:w}=a,m=e.__rest(a,["children","onDropdownVisbilityChange","version","tooltipContent","tooltipDirection","showTooltipArrow","isChildLoading"]);const h=d,[b,f]=o.useState(!1),[g,E]=o.useState(null),[D,O]=o.useState(null),R=o.useRef(null),{styles:y,attributes:S}=n.usePopper(g,D,{placement:m.placement,strategy:m.strategy}),C=e=>{var t,o;"2.0"===c&&m.isMultiSelect&&e&&(null===(t=m.onSelect)||void 0===t||t.call(m,[...e])),f(!1),null===(o=null==m?void 0:m.onClose)||void 0===o||o.call(m)};o.useImperativeHandle(h,(()=>({openDropdown:b})),[]),o.useEffect((()=>{(null==h?void 0:h.current)&&(h.current.openDropdown=b)}),[b]),o.useEffect((()=>{null==u||u(b)}),[b]);const q=()=>t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",Object.assign({style:{position:"relative"},ref:E},{children:[t.jsxRuntimeExports.jsx(i.OverLapAbs,Object.assign({ref:R,allowEvents:m.allowEvents,disabled:m.disabled,onClick:e=>{var t;null===(t=m.onDropdownOpen)||void 0===t||t.call(m),b?(f(!1),e.preventDefault()):m.disabled||f(!0)},isChildLoading:w},{children:m.allowEvents?p:null})),m.allowEvents?null:p]})),b&&t.jsxRuntimeExports.jsx(i.OpenDropdownContainer,Object.assign({ref:O,style:Object.assign(Object.assign({},y.popper),{zIndex:3})},S.popper,{"data-test":m["data-test"]},{children:t.jsxRuntimeExports.jsx(s.DropShadow,Object.assign({level:"z2",position:"down",style:{borderRadius:8}},{children:t.jsxRuntimeExports.jsx(l.OpenedDropdown,Object.assign({},m,{onSelect:e=>{var t;"2.0"===c&&m.isMultiSelect||(null===(t=m.onSelect)||void 0===t||t.call(m,e),f(!1))},onClose:C,version:c,headerRef:R,zeroState:null==m?void 0:m.zeroState}))}))}))]});return t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:b||void 0===j?q():t.jsxRuntimeExports.jsx(r.Tooltip,Object.assign({body:j,placement:x,hideArrow:!v},{children:t.jsxRuntimeExports.jsx("div",Object.assign({"data-test":m["data-test"]},{children:q()}))}))})}));d.displayName="DropdownPopover",exports.DropdownPopover=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),o=require("../../node_modules/react/jsx-runtime.js"),r=require("../dropdown/DropdownPopover/index.js");require("../dropdown/Dropdown.js"),require("../dropdown/ChipDropdown.js"),require("react"),require("../zeroState/ZeroState.js"),require("../TypographyStyle.js"),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");var t=require("../button/Button.js");require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../icon-button/IconButton.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var n=require("../button/themes.js"),s=require("../spinner/Spinner.js"),i=require("./DropdownButton.style.js");exports.DropdownButton=d=>{var p,u;const j=d.buttonProps,a=e.__rest(j,["onClick"]);return o.jsxRuntimeExports.jsxs(i.DropdownButtonStyle,Object.assign({type:d.buttonProps.buttonType,disabled:d.buttonProps.disabled},{children:[(null===(p=d.buttonProps)||void 0===p?void 0:p.isLoading)&&o.jsxRuntimeExports.jsx(i.LoaderContainer,{children:o.jsxRuntimeExports.jsx(s.Spinner,{className:"spinner",size:"small",color:n.SpinnerColorMap(d.buttonProps.buttonType||"primary",d.buttonProps.inverse)})}),o.jsxRuntimeExports.jsx(t.Button,Object.assign({},d.buttonProps,{isLoading:!1,style:{borderRadius:"0px",borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",borderRight:"0px"}})),o.jsxRuntimeExports.jsx("div",{className:"divider"}),o.jsxRuntimeExports.jsx(r.DropdownPopover,Object.assign({},d.dropdownProps,{isChildLoading:null===(u=d.buttonProps)||void 0===u?void 0:u.isLoading},{children:o.jsxRuntimeExports.jsx(t.Button,Object.assign({},a,{isLoading:!1,buttonText:"",TrailingIcon:d.iconProps,style:{borderRadius:"0px",borderTopRightRadius:"4px",borderBottomRightRadius:"4px"}}))}))]}))};
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
height: 100%;
|
|
10
10
|
}
|
|
11
11
|
`,o=i.default.div`
|
|
12
|
+
position: absolute;
|
|
13
|
+
inset: 0;
|
|
12
14
|
display: flex;
|
|
13
15
|
flex-direction: row;
|
|
14
16
|
align-items: center;
|
|
@@ -16,5 +18,5 @@
|
|
|
16
18
|
width: 100%;
|
|
17
19
|
border-radius: 4px;
|
|
18
20
|
background: ${t.BASE_COLORS.brand[50]};
|
|
19
|
-
z-index:
|
|
21
|
+
z-index: 3;
|
|
20
22
|
`;exports.DropdownButtonStyle=n,exports.LoaderContainer=o;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Collection, CollectionFetcherReturn, SelectedItems } from '.';
|
|
4
4
|
import { CollectionsActions, SelectedCollectionsActions } from './reducers';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
3
3
|
import { ButtonProps } from '../button/model';
|
|
4
4
|
import { FooterForNonModalI, OUT_OF_STOCK_ACTION, ScreenName } from './type';
|
|
5
5
|
export interface ProductVariant {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),o=require("../../assets/icons/search.svg.js"),s=require("react"),r=require("../../constants/Theme.js"),c=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),p=require("./productInfoOverlay.js"),x=require("./productScreen.js"),h=require("./rearrangeScreen.js"),j=require("./reducers.js"),m=require("./searchScreen.js"),S=require("./selectedScreen.js"),C=require("./style.js"),g=require("./type.js"),y=require("./utility.js");exports.ProductPickerModal=R=>{const{storeId:b,selectedItems:f,onClose:E,visible:v,zIndex:k,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:P,outOfStockAction:T=g.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:A,width:B,left:w,renderWithoutModal:L,onClickSave:M,pickerType:V,hideProductVariants:z=!1,startupScreen:$=g.ScreenName.Collections,rearrangeEnabled:_,selectSingleItem:H=!1,showProductDetails:K,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=R,X=R.appType||t.ApplicationType.BIK,[Z,ee]=s.useReducer(j.collectionsReducer,{}),[te,oe]=s.useState([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections),[se,re]=s.useState("grid"),[ce,ne]=s.useState(""),[ie,le]=s.useState(""),[ae,de]=s.useState(0),[ue,pe]=s.useState(!1),[xe,he]=s.useState(0),[je,me]=s.useState(""),[Se,Ce]=s.useState(!1),[ge,ye]=s.useState(!1),[Re,be]=s.useReducer(j.searchReducer,{collections:{},products:{}}),[fe,Ee]=s.useReducer(j.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=s.useRef(null),[ke,Ie]=s.useState(!1),[Oe,Fe]=s.useState();s.useEffect((()=>{pe(!0),ye(!0),R.collectionFetcher(ae,b,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),pe(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),s.useEffect((()=>{let e=0;z?Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s;"-1"!==t&&fe[-1]&&(null===(s=fe[-1].products)||void 0===s?void 0:s[o])||(e+=1)}))})):Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s,r;Object.keys((null===(r=null===(s=fe[t].products)||void 0===s?void 0:s[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Z,fe,z]),s.useEffect((()=>{ie&&(pe(!0),R.productFetcher(ie,b,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),pe(!1)})).catch())}),[ie]),s.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(je.length||"collections"!==te)&&(je.length?(Ce(!0),R.searchFetcher(b,je,X).then((e=>{"collections"in e&&"products"in e?(be({type:"set",data:e}),ee({type:"searched",data:e.collections}),ee({type:"searched",data:e.products})):(be({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),pe(!1),Ce(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[je]),s.useEffect((()=>{M&&(R.onAdd(fe,xe),Pe())}),[M]),s.useEffect((()=>{H&&Object.keys(fe||{}).length&&xe&&(R.onAdd(fe,xe),Pe())}),[H,fe,xe]);const Pe=()=>{Ee({type:"reset",data:{}})},Te=()=>I&&xe>I?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):O&&xe>O?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):xe>0?e.jsxRuntimeExports.jsx(n.Button,{onClick:()=>{oe(_?g.ScreenName.RearrangeProducts:g.ScreenName.SelectedProducts)},buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsxRuntimeExports.jsx(n.Button,{disabled:!0,buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:"tertiaryGray"}),De=e=>ue?"Loading...":te===g.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",qe=e.jsxRuntimeExports.jsxs(C.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[R.postHeader&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:L?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsxRuntimeExports.jsx(i.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?e.jsxRuntimeExports.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:je,onChangeText:e=>{e.length&&e.trim().length?me(e):me("")}})}))}),e.jsxRuntimeExports.jsxs(C.ScrollContainerStyle,Object.assign({ref:ve,screenName:te},{children:["collections"===te&&e.jsxRuntimeExports.jsx(u.CollectionsScreen,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:ge,collections:Z,selectedCollectionsDispatch:Ee,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:fe,collectionFetcher:R.collectionFetcher,storeId:b,appType:X,collectionsDispatch:ee,setSaveDisabled:pe,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:F,renderWithoutModal:L,pickerType:V,scrollContainerRef:ve}),"products"===te&&ce&&e.jsxRuntimeExports.jsx(j.CollectionIdContext.Provider,Object.assign({value:ce},{children:e.jsxRuntimeExports.jsx(x.ProductsScreen,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:oe,storeId:b,appType:X,data:Z[ce],collectionsDispatch:ee,selectedCollectionsDispatch:Ee,selectedData:fe,setSaveDisabled:pe,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:P,outOfStockAction:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:L,pickerType:V,hideProductVariants:z,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Fe(e)},showProductDetailInfoIcon:K,scrollContainerRef:ve})})),"view"===te&&e.jsxRuntimeExports.jsx(S.SelectedScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,hideProductVariants:z,outOfStockAction:T,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===te&&e.jsxRuntimeExports.jsx(h.RearrangeScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,outOfStockAction:T,rearrangeViewType:"grid"===se?"list":"grid",scrollContainerRef:ve,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===te&&e.jsxRuntimeExports.jsx(m.SearchScreen,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:fe||{},searchedCollections:Re||{},searchedCollectionsDispatch:be,selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,onBackPress:()=>{me(""),be({type:"set",data:{collections:{},products:{}}})},pickerType:V,hideProductCheckbox:P,hideProductVariants:z,hideVariantCheckbox:D,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:L,hideCollectionCheckbox:F,outOfStockAction:T})]}))]}));return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:L?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[qe,U.renderFooter?e.jsxRuntimeExports.jsxs(C.StyledFooterForNonModal,{children:[Te(),e.jsxRuntimeExports.jsx(n.Button,{buttonText:De(U.primaryButtonText),disabled:!U.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections)}})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,outOfStockAction:T,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}):e.jsxRuntimeExports.jsxs(l.StyledModal,Object.assign({zIndex:k,open:v,onClose:()=>{null==E||E(),Pe()},headingTitle:A||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:B||"600px",left:w||"auto"},headerRightCustomElement:G?e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:e.jsxRuntimeExports.jsx(c.default,{width:20,height:20,color:r.COLORS.content.secondary})})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||e.disabled,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections)}}))(Y):{buttonText:De(),disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{R.onAdd(fe,xe),Pe()}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{const e=y.updateAllVariantsForSelectedProducts(fe,Z,Re);R.onAdd(e,xe,!0)}}))(J):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Te(),hideCrossButton:ke||G},{children:[qe,ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}))})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),o=require("../../assets/icons/search.svg.js"),s=require("react"),r=require("../../constants/Theme.js"),c=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),p=require("./productInfoOverlay.js"),x=require("./productScreen.js"),h=require("./rearrangeScreen.js"),j=require("./reducers.js"),m=require("./searchScreen.js"),S=require("./selectedScreen.js"),C=require("./style.js"),g=require("./type.js"),y=require("./utility.js");exports.ProductPickerModal=R=>{const{storeId:b,selectedItems:f,onClose:E,visible:k,zIndex:v,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:P,outOfStockAction:T=g.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:A,width:B,left:w,renderWithoutModal:L,onClickSave:M,pickerType:V,hideProductVariants:z=!1,startupScreen:$=g.ScreenName.Collections,rearrangeEnabled:_,selectSingleItem:H=!1,showProductDetails:K,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=R,X=R.appType||t.ApplicationType.BIK,[Z,ee]=s.useReducer(j.collectionsReducer,{}),[te,oe]=s.useState([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections),[se,re]=s.useState("grid"),[ce,ne]=s.useState(""),[ie,le]=s.useState(""),[ae,de]=s.useState(0),[ue,pe]=s.useState(!1),[xe,he]=s.useState(0),[je,me]=s.useState(""),[Se,Ce]=s.useState(!1),[ge,ye]=s.useState(!1),[Re,be]=s.useReducer(j.searchReducer,{collections:{},products:{}}),[fe,Ee]=s.useReducer(j.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ke=s.useRef(null),[ve,Ie]=s.useState(!1),[Oe,Fe]=s.useState();s.useEffect((()=>{pe(!0),ye(!0),R.collectionFetcher(ae,b,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),pe(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),s.useEffect((()=>{let e=0;z?Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s;"-1"!==t&&fe[-1]&&(null===(s=fe[-1].products)||void 0===s?void 0:s[o])||(e+=1)}))})):Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s,r;Object.keys((null===(r=null===(s=fe[t].products)||void 0===s?void 0:s[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Z,fe,z]),s.useEffect((()=>{ie&&(pe(!0),R.productFetcher(ie,b,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),pe(!1)})).catch())}),[ie]),s.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(je.length||"collections"!==te)&&(je.length?(Ce(!0),R.searchFetcher(b,je,X).then((e=>{"collections"in e&&"products"in e?(be({type:"set",data:e}),ee({type:"searched",data:e.collections}),ee({type:"searched",data:e.products})):(be({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),pe(!1),Ce(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[je]),s.useEffect((()=>{M&&(R.onAdd(fe,xe),Pe())}),[M]),s.useEffect((()=>{H&&Object.keys(fe||{}).length&&xe&&(R.onAdd(fe,xe),Pe())}),[H,fe,xe]);const Pe=()=>{Ee({type:"reset",data:{}})},Te=()=>I&&xe>I?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):O&&xe>O?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):xe>0?e.jsxRuntimeExports.jsx(n.Button,{onClick:()=>{oe(_?g.ScreenName.RearrangeProducts:g.ScreenName.SelectedProducts)},buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsxRuntimeExports.jsx(n.Button,{disabled:!0,buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:"tertiaryGray"}),De=e=>ue?"Loading...":te===g.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",qe=e.jsxRuntimeExports.jsxs(C.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[R.postHeader&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:L?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsxRuntimeExports.jsx(i.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?e.jsxRuntimeExports.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:je,onChangeText:e=>{e.length&&e.trim().length?me(e):me("")}})}))}),e.jsxRuntimeExports.jsxs(C.ScrollContainerStyle,Object.assign({ref:ke,screenName:te},{children:["collections"===te&&e.jsxRuntimeExports.jsx(u.CollectionsScreen,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:ge,collections:Z,selectedCollectionsDispatch:Ee,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:fe,collectionFetcher:R.collectionFetcher,storeId:b,appType:X,collectionsDispatch:ee,setSaveDisabled:pe,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:F,renderWithoutModal:L,pickerType:V,scrollContainerRef:ke}),"products"===te&&ce&&e.jsxRuntimeExports.jsx(j.CollectionIdContext.Provider,Object.assign({value:ce},{children:e.jsxRuntimeExports.jsx(x.ProductsScreen,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:oe,storeId:b,appType:X,data:Z[ce],collectionsDispatch:ee,selectedCollectionsDispatch:Ee,selectedData:fe,setSaveDisabled:pe,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:P,outOfStockAction:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:L,pickerType:V,hideProductVariants:z,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Fe(e)},showProductDetailInfoIcon:K,scrollContainerRef:ke})})),"view"===te&&e.jsxRuntimeExports.jsx(S.SelectedScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,hideProductVariants:z,outOfStockAction:T,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===te&&e.jsxRuntimeExports.jsx(h.RearrangeScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,outOfStockAction:T,rearrangeViewType:"grid"===se?"list":"grid",scrollContainerRef:ke,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===te&&e.jsxRuntimeExports.jsx(m.SearchScreen,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:fe||{},searchedCollections:Re||{},searchedCollectionsDispatch:be,selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,onBackPress:()=>{me(""),be({type:"set",data:{collections:{},products:{}}})},pickerType:V,hideProductCheckbox:P,hideProductVariants:z,hideVariantCheckbox:D,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:L,hideCollectionCheckbox:F,outOfStockAction:T})]}))]}));return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:L?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[qe,U.renderFooter?e.jsxRuntimeExports.jsxs(C.StyledFooterForNonModal,{children:[Te(),e.jsxRuntimeExports.jsx(n.Button,{buttonText:De(U.primaryButtonText),disabled:!U.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections)}})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),ve&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,outOfStockAction:T,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}):e.jsxRuntimeExports.jsxs(l.StyledModal,Object.assign({zIndex:v,open:k,onClose:()=>{null==E||E(),Pe()},headingTitle:A||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:B||"600px",left:w||"auto"},headerRightCustomElement:G?e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:e.jsxRuntimeExports.jsx(c.default,{width:20,height:20,color:r.COLORS.content.secondary})})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||e.disabled,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections)}}))(Y):{buttonText:De(),disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{R.onAdd(fe,xe),Pe()}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{const e=y.updateAllVariantsForSelectedProducts(fe,Z,Re);R.onAdd(e,xe,!0)}}))(J):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Te(),hideCrossButton:ve||G},{children:[qe,ve&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}))})};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Collection, FbStatusFetcherReturn, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
|
|
4
4
|
import { CollectionsActions, SelectedCollectionsActions } from './reducers';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { FbStatusFetcherReturn, SelectedItems } from '.';
|
|
4
4
|
import { SelectedCollectionsActions } from './reducers';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
3
3
|
import { Collection, FbStatusFetcherReturn, SearchedItems, SelectedItems } from '.';
|
|
4
4
|
import { SearchReducerActions, SelectedCollectionsActions } from './reducers';
|
|
5
5
|
import { OUT_OF_STOCK_ACTION } from './type';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
3
3
|
import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
|
|
4
4
|
import { SelectedCollectionsActions } from './reducers';
|
|
5
5
|
import { OUT_OF_STOCK_ACTION } from './type';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
2
2
|
import { Collection, FbStatusFetcherReturn, Product, ProductVariant, SearchedItems, SelectedItems } from './modal';
|
|
3
3
|
import { CollectionsActions } from './reducers';
|
|
4
4
|
export declare const liftTheStateUp: (payload: any, data: any) => any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth/models/bik-store';
|
|
2
2
|
import { VariableListInterfaceV2 } from "../add-variableV2/AddVariableV2";
|
|
3
3
|
import { CarouselProduct } from "./modalElements/EditWhatsAppCarouselTemplateV2";
|
|
4
4
|
import { WhatsAppCarouselTemplateVariables } from "../template-preview/models/WhatsappCarouselTemplate";
|