@bikdotai/bik-component-library 0.0.697-0 → 0.0.697-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +16 -28
- 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/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 +18 -30
- 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
package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js
CHANGED
|
@@ -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"),l=require("../../../assets/icons/arrow_back.svg.js"),n=require("../../../assets/icons/chevronLeft.svg.js"),i=require("../../../assets/icons/chevronRight.svg.js"),s=require("../../../assets/icons/PlusIcon.js"),o=require("lodash"),r=require("react"),a=require("../../button/Button.js"),d=require("../../icon-button/IconButton.js"),u=require("../../product-picker-v2/modal.js"),c=require("../../product-picker-v2/type.js"),p=require("../Badge/index.js"),m=require("../context/templateModalContext.js"),x=require("./EditWhatsAppTemplateV2.js"),v=require("./ProductBox.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js");var h=require("../../../constants/Theme.js");require("../../curtain/CurtainHelper.js"),require("../../variable-picker-v3/model.js"),require("../../template-preview/models/TemplateMeta.js");var g=require("../../template-preview/models/WhatsAppTemplate.js");require("../../template-preview/models/Channels.js");var j=require("../../template-preview/helpers/templateMiscHelper.js"),y=require("../../TypographyStyle.js");exports.default=f=>{let{template:b,whatsappSpecificPickerMeta:C,showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}=f;var S,q,k,w,P,T,B,L;const{selectedCarouselIndex:M,setTemplate:A,pickerConf:D,isProductCarouselType:F,pod:V,cardCount:W,carouselProducts:N,setCarouselProducts:$,isError:_,cardImages:z,disableEditVariable:G,onDeleteSelectedProducts:H,setSelectedCarouselIndex:K,setVariableCallback:J,setShowVariablePicker:Q,sliderRef:U}=m.useTemplateModalContext(),[X,Y]=r.useState(j.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":F?"Product Carousel "+((null===(q=null===(S=null==b?void 0:b.mapping)||void 0===S?void 0:S.body)||void 0===q?void 0:q.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(w=null===(k=null==b?void 0:b.mapping)||void 0===k?void 0:k.body)||void 0===w?void 0:w.length)?"(Step 2/2)":"")),[Z,ee]=r.useState(!1),[te,le]=r.useState(!1),ne=M===(null!=W?W:-1)-1,ie=(null!=M?M:-1)<1;r.useEffect((()=>{var e,t,l,n;Y(j.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":F?"Product Carousel "+((null===(t=null===(e=null==b?void 0:b.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(n=null===(l=null==b?void 0:b.mapping)||void 0===l?void 0:l.body)||void 0===n?void 0:n.length)?"(Step 2/2)":""))}),[M]);const se=e=>{null==$||$([{name:"variable",productName:e.actualValue}])};return r.useEffect((()=>{-1===M&&j.isRCSChannel(null==b?void 0:b.channel)&&(null==K||K(0))}),[M,null==b?void 0:b.channel]),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!j.isRCSChannel(null==b?void 0:b.channel)&&null!=M&&M>=0&&!!(null===(T=null===(P=null==b?void 0:b.mapping)||void 0===P?void 0:P.body)||void 0===T?void 0:T.length)&&e.jsxRuntimeExports.jsx(d.IconButton,{Icon:l.default,onClick:()=>{null==K||K(-1)}}),e.jsxRuntimeExports.jsx(y.TitleMedium,Object.assign({style:{marginLeft:10}},{children:X}))]})),F&&(null!==(B=null==N?void 0:N.length)&&void 0!==B?B:0)>0&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsxRuntimeExports.jsx(v.ProductBox,{editItem:()=>{1===(null==N?void 0:N.length)&&"variable"===N[0].name?(J((()=>se)),Q(!0)):ee(!Z)},cardBody:1===(null==N?void 0:N.length)&&"variable"===N[0].name?`${N[0].productName}`:`${null==N?void 0:N.length} Products Selected`,hideIcon:1===(null==N?void 0:N.length)&&"variable"===N[0].name,deleteItem:()=>{var e;if(1===(null==N?void 0:N.length)&&"variable"===N[0].name)return void(null==$||$([]));const t=o.cloneDeep(Object.assign({},b));t&&(z&&z.length>0?null==z||z.forEach(((e,l)=>{var n;t.components[1].cards[l].components[0].example.header_handle=[null!==(n=z[l])&&void 0!==n?n:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==A||A(t)),null==$||$([]),null==H||H()}}),N&&(null==N?void 0:N.length)>0&&"variable"!=N[0].name&&e.jsxRuntimeExports.jsx(a.Button,{disabled:(null!==(L=null==N?void 0:N.length)&&void 0!==L?L:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{le(!0),ee(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!G&&F&&0===(null==N?void 0:N.length)&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsxRuntimeExports.jsx(y.TitleRegular,{children:"Product(s)"}),e.jsxRuntimeExports.jsx(y.BodySecondary,{children:`Select ${null!=W?W:1} products`})]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:_?16:12,marginRight:_?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:_?`2px dashed ${h.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsxRuntimeExports.jsx(s.default,{width:18,height:18,color:h.COLORS.content.secondary})})),onClick:e=>{ee(!0)}}),V===g.POD.CHATBOT&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsxRuntimeExports.jsx(y.BodyCaption,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsxRuntimeExports.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:_?`2px dashed ${h.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsxRuntimeExports.jsx(s.default,{width:18,height:18,color:h.COLORS.content.secondary})})),onClick:e=>{J((()=>se)),Q(!0)}})]})]})),_&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsxRuntimeExports.jsx(p.Badge,{padding:"8px",errorText:"Please add products"})}))]}),!F&&(null!=M?M:-1)>-1&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",background:h.COLORS.surface.hovered,alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(d.IconButton,{Icon:n.default,disabled:ie,width:8,height:14,svgStyle:ie?{}:{color:h.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickPrev(),(null!=M?M:-1)<1||null==K||K((e=>e-1))}}),e.jsxRuntimeExports.jsx(y.TitleRegular,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:h.COLORS.content.secondary},{children:`Card ${(null!=M?M:0)+1}/${W}`})),e.jsxRuntimeExports.jsx(d.IconButton,{Icon:i.default,width:8,height:14,disabled:ne,svgStyle:ne?{}:{color:h.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickNext(),(null!=M?M:-1)>=(null!=W?W:-1)-1||null==K||K((e=>e+1))}})]})),e.jsxRuntimeExports.jsx(x.default,{whatsappSpecificPickerMeta:C,template:b,onTemplateChange:e=>{null==A||A(e)},showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}),Z&&D&&e.jsxRuntimeExports.jsx(u.ProductPickerModal,{zIndex:200,startupScreen:te?c.ScreenName.RearrangeProducts:c.ScreenName.Collections,rearrangeEnabled:!0,storeId:D.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,n=l.productId,i=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),n in t[e].products||(t[e].products[n]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[n].variants[i]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=N?N:[]),collectionFetcher:D.fetchCollections,productFetcher:D.fetchProducts,onAdd:(e,t)=>{var l,n,i,s,r,a;le(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const o=e[t].products;if(void 0!==o&&Object.keys(o).length)for(const e of Object.keys(o)){const u=o[e].variants;if(void 0!==u&&Object.keys(u).length)for(const c of Object.keys(u)){const{name:p,image:m,quantity:x,displayOrder:v}=u[c],h={name:p,image:null!==(n=null!=m?m:null===(l=o[e])||void 0===l?void 0:l.image)&&void 0!==n?n:"",quantity:x,variantId:c,productId:e,displayOrder:v,collectionId:t,productName:null!==(s=null===(i=o[e])||void 0===i?void 0:i.name)&&void 0!==s?s:"",productImage:null!==(a=null===(r=o[e])||void 0===r?void 0:r.image)&&void 0!==a?a:""};d.push(h)}}}const u=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),c=d.map((e=>e.image)),p=o.cloneDeep(Object.assign({},b));p&&(c.forEach(((e,t)=>{var l;p.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==z?void 0:z[t])&&void 0!==l?l:""]})),null==A||A(p)),null==$||$(u),ee(!1)},searchInCollectionFetcher:D.searchInCollection,searchFetcher:D.searchProducts,visible:Z,onClose:()=>{ee(!1)},exactLimit:null!=W?W:1,appType:D.appType||t.ApplicationType.BIK})]}))};
|
|
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"),l=require("../../../assets/icons/arrow_back.svg.js"),n=require("../../../assets/icons/chevronLeft.svg.js"),i=require("../../../assets/icons/chevronRight.svg.js"),s=require("../../../assets/icons/PlusIcon.js"),o=require("lodash"),r=require("react"),a=require("../../button/Button.js"),d=require("../../icon-button/IconButton.js"),u=require("../../product-picker-v2/modal.js"),c=require("../../product-picker-v2/type.js"),p=require("../Badge/index.js"),m=require("../context/templateModalContext.js"),x=require("./EditWhatsAppTemplateV2.js"),v=require("./ProductBox.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js");var h=require("../../../constants/Theme.js");require("../../curtain/CurtainHelper.js"),require("../../variable-picker-v3/model.js"),require("../../template-preview/models/TemplateMeta.js");var g=require("../../template-preview/models/WhatsAppTemplate.js");require("../../template-preview/models/Channels.js");var j=require("../../template-preview/helpers/templateMiscHelper.js"),y=require("../../TypographyStyle.js");exports.default=f=>{let{template:b,whatsappSpecificPickerMeta:C,showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}=f;var S,k,q,w,P,T,B,L;const{selectedCarouselIndex:M,setTemplate:A,pickerConf:D,isProductCarouselType:F,pod:V,cardCount:W,carouselProducts:N,setCarouselProducts:$,isError:_,cardImages:z,disableEditVariable:G,onDeleteSelectedProducts:H,setSelectedCarouselIndex:K,setVariableCallback:J,setShowVariablePicker:Q,sliderRef:U}=m.useTemplateModalContext(),[X,Y]=r.useState(j.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":F?"Product Carousel "+((null===(k=null===(S=null==b?void 0:b.mapping)||void 0===S?void 0:S.body)||void 0===k?void 0:k.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(w=null===(q=null==b?void 0:b.mapping)||void 0===q?void 0:q.body)||void 0===w?void 0:w.length)?"(Step 2/2)":"")),[Z,ee]=r.useState(!1),[te,le]=r.useState(!1),ne=M===(null!=W?W:-1)-1,ie=(null!=M?M:-1)<1;r.useEffect((()=>{var e,t,l,n;Y(j.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":F?"Product Carousel "+((null===(t=null===(e=null==b?void 0:b.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(n=null===(l=null==b?void 0:b.mapping)||void 0===l?void 0:l.body)||void 0===n?void 0:n.length)?"(Step 2/2)":""))}),[M]);const se=e=>{null==$||$([{name:"variable",productName:e.actualValue}])};return r.useEffect((()=>{-1===M&&j.isRCSChannel(null==b?void 0:b.channel)&&(null==K||K(0))}),[M,null==b?void 0:b.channel]),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!j.isRCSChannel(null==b?void 0:b.channel)&&null!=M&&M>=0&&!!(null===(T=null===(P=null==b?void 0:b.mapping)||void 0===P?void 0:P.body)||void 0===T?void 0:T.length)&&e.jsxRuntimeExports.jsx(d.IconButton,{Icon:l.default,onClick:()=>{null==K||K(-1)}}),e.jsxRuntimeExports.jsx(y.TitleMedium,Object.assign({style:{marginLeft:10}},{children:X}))]})),F&&(null!==(B=null==N?void 0:N.length)&&void 0!==B?B:0)>0&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsxRuntimeExports.jsx(v.ProductBox,{editItem:()=>{1===(null==N?void 0:N.length)&&"variable"===N[0].name?(J((()=>se)),Q(!0)):ee(!Z)},cardBody:1===(null==N?void 0:N.length)&&"variable"===N[0].name?`${N[0].productName}`:`${null==N?void 0:N.length} Products Selected`,hideIcon:1===(null==N?void 0:N.length)&&"variable"===N[0].name,deleteItem:()=>{var e;if(1===(null==N?void 0:N.length)&&"variable"===N[0].name)return void(null==$||$([]));const t=o.cloneDeep(Object.assign({},b));t&&(z&&z.length>0?null==z||z.forEach(((e,l)=>{var n;t.components[1].cards[l].components[0].example.header_handle=[null!==(n=z[l])&&void 0!==n?n:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==A||A(t)),null==$||$([]),null==H||H()}}),N&&(null==N?void 0:N.length)>0&&"variable"!=N[0].name&&e.jsxRuntimeExports.jsx(a.Button,{disabled:(null!==(L=null==N?void 0:N.length)&&void 0!==L?L:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{le(!0),ee(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!G&&F&&0===(null==N?void 0:N.length)&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsxRuntimeExports.jsx(y.TitleRegular,{children:"Product(s)"}),e.jsxRuntimeExports.jsx(y.BodySecondary,{children:`Select ${null!=W?W:1} products`})]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:_?16:12,marginRight:_?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:_?`2px dashed ${h.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsxRuntimeExports.jsx(s.default,{width:18,height:18,color:h.COLORS.content.secondary})})),onClick:e=>{ee(!0)}}),V===g.POD.CHATBOT&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsxRuntimeExports.jsx(y.BodyCaption,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsxRuntimeExports.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:_?`2px dashed ${h.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsxRuntimeExports.jsx(s.default,{width:18,height:18,color:h.COLORS.content.secondary})})),onClick:e=>{J((()=>se)),Q(!0)}})]})]})),_&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsxRuntimeExports.jsx(p.Badge,{padding:"8px",errorText:"Please add products"})}))]}),!F&&(null!=M?M:-1)>-1&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",background:h.COLORS.surface.hovered,alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(d.IconButton,{Icon:n.default,disabled:ie,width:8,height:14,svgStyle:ie?{}:{color:h.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickPrev(),(null!=M?M:-1)<1||null==K||K((e=>e-1))}}),e.jsxRuntimeExports.jsx(y.TitleRegular,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:h.COLORS.content.secondary},{children:`Card ${(null!=M?M:0)+1}/${W}`})),e.jsxRuntimeExports.jsx(d.IconButton,{Icon:i.default,width:8,height:14,disabled:ne,svgStyle:ne?{}:{color:h.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickNext(),(null!=M?M:-1)>=(null!=W?W:-1)-1||null==K||K((e=>e+1))}})]})),e.jsxRuntimeExports.jsx(x.default,{whatsappSpecificPickerMeta:C,template:b,onTemplateChange:e=>{null==A||A(e)},showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}),Z&&D&&e.jsxRuntimeExports.jsx(u.ProductPickerModal,{zIndex:200,startupScreen:te?c.ScreenName.RearrangeProducts:c.ScreenName.Collections,rearrangeEnabled:!0,storeId:D.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,n=l.productId,i=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),n in t[e].products||(t[e].products[n]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[n].variants[i]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=N?N:[]),collectionFetcher:D.fetchCollections,productFetcher:D.fetchProducts,onAdd:(e,t)=>{var l,n,i,s,r,a;le(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const o=e[t].products;if(void 0!==o&&Object.keys(o).length)for(const e of Object.keys(o)){const u=o[e].variants;if(void 0!==u&&Object.keys(u).length)for(const c of Object.keys(u)){const{name:p,image:m,quantity:x,displayOrder:v}=u[c],h={name:p,image:null!==(n=null!=m?m:null===(l=o[e])||void 0===l?void 0:l.image)&&void 0!==n?n:"",quantity:x,variantId:c,productId:e,displayOrder:v,collectionId:t,productName:null!==(s=null===(i=o[e])||void 0===i?void 0:i.name)&&void 0!==s?s:"",productImage:null!==(a=null===(r=o[e])||void 0===r?void 0:r.image)&&void 0!==a?a:""};d.push(h)}}}const u=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),c=d.map((e=>e.image)),p=o.cloneDeep(Object.assign({},b));p&&(c.forEach(((e,t)=>{var l;p.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==z?void 0:z[t])&&void 0!==l?l:""]})),null==A||A(p)),null==$||$(u),ee(!1)},searchInCollectionFetcher:D.searchInCollection,searchFetcher:D.searchProducts,visible:Z,onClose:()=>{ee(!1)},exactLimit:null!=W?W:1,appType:D.appType||t.ApplicationType.BIK})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),s=require("@bikdotai/bik-models/growth"),t=require("../../assets/icons/cross.svg.js"),n=require("../../assets/icons/info.svg.js"),i=require("date-fns"),r=require("react"),o=require("../../constants/Theme.js"),a=require("../avatar/Avatar.js"),l=require("../avatar/AvatarHelper.js"),c=require("../button/Button.js"),d=require("../states/StateComponent.js");require("../../_virtual/_tslib.js");var u=require("../TypographyStyle.js"),p=require("./UnsatisfactoryCountIntentWiseModal.js"),x=require("./UnsatisfactoryResponseList.style.js");exports.UnsatisfactoryResponseList=j=>{const{storeId:y,appType:h,incorrectMessages:m,onIncorrectMessageBubbleClick:R,setShowIncorrectReplies:f,ChecklistType:g,IntentWiseUnsatisfactoryResponse:v,IntentHeaderTitle:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),s=require("@bikdotai/bik-models/growth/models/bik-store"),t=require("../../assets/icons/cross.svg.js"),n=require("../../assets/icons/info.svg.js"),i=require("date-fns"),r=require("react"),o=require("../../constants/Theme.js"),a=require("../avatar/Avatar.js"),l=require("../avatar/AvatarHelper.js"),c=require("../button/Button.js"),d=require("../states/StateComponent.js");require("../../_virtual/_tslib.js");var u=require("../TypographyStyle.js"),p=require("./UnsatisfactoryCountIntentWiseModal.js"),x=require("./UnsatisfactoryResponseList.style.js");exports.UnsatisfactoryResponseList=j=>{const{storeId:y,appType:h,incorrectMessages:m,onIncorrectMessageBubbleClick:R,setShowIncorrectReplies:f,ChecklistType:g,IntentWiseUnsatisfactoryResponse:v,IntentHeaderTitle:b,redirectToUnsatisfactoryResponse:E,fetchUnsatisfactoryResponseCountIntentWise:I,fetchUnsatisfactoryResponseCount:C}=j,[O,S]=r.useState(""),[T,w]=r.useState((null==m?void 0:m.length)>0),[A,U]=r.useState(!1);return r.useEffect((()=>{!T&&C&&C().then((e=>{e>0&&w(!0),0===e&&f(!1)}))}),[]),e.jsxRuntimeExports.jsx("div",Object.assign({style:{overflow:"scroll",height:"100%"}},{children:e.jsxRuntimeExports.jsxs(x.IncorrectRepliesStyle,{children:[h==s.ApplicationType.MANIFEST&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(u.TitleRegular,{children:"Unsatisfactory responses"}),e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>f(!1)},{children:e.jsxRuntimeExports.jsx(t.default,{height:16,width:16,color:o.COLORS.content.primary})}))]})),e.jsxRuntimeExports.jsx(u.BodySecondary,Object.assign({style:{color:o.COLORS.content.secondary}},{children:"Spot unsatisfactory replies, dive deeper, and enhance with relevant data for improved responses."}))]})),!(null==m?void 0:m.length)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:e.jsxRuntimeExports.jsx(d.StateComponent,{states:d.StateInterface.WARNING,heading:"No unsatisfactory responses",subline:"As of now, all responses are correct",isButtonEnabled:!1,width:0,size:l.SIZE.SMALL,icon:e.jsxRuntimeExports.jsx(a.Avatar,{type:l.AVATAR_TYPES.ICON,size:l.SIZE.MEDIUM,background:l.AVATAR_BACKGROUND.LIGHT,icon:()=>e.jsxRuntimeExports.jsx(n.default,{width:16,height:16,color:o.COLORS.content.warning})})})})),!!(null==m?void 0:m.length)&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[h==s.ApplicationType.MANIFEST&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:(null==m?void 0:m.length)?"flex-start":"center"}},{children:e.jsxRuntimeExports.jsx(c.Button,{buttonText:"Fix all unsatisfactory responses",buttonType:"tertiary",size:"small",onClick:()=>{U(!0)},disabled:!T})})),e.jsxRuntimeExports.jsx(p.UnsatisfactoryCountIntentWiseModal,{storeId:y,setShowUnsatisfactoryResponseModal:U,showUnsatisfactoryResponseModal:A,ChecklistType:g,UnsatisfactoryResponseIntentList:v,IntentHeaderTitle:b,fetchUnsatisfactoryResponseCountIntentWise:I,viewIntentWiseUnsatisfactoryResponse:E}),m&&(null==m?void 0:m.length)>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"wrapper"},{children:m.map(((s,t)=>e.jsxRuntimeExports.jsxs("div",Object.assign({className:"bubble",onClick:()=>{R(s.messageId),S(s.messageId)},style:O===s.messageId?{backgroundColor:o.COLORS.surface.hovered}:{}},{children:[e.jsxRuntimeExports.jsx(u.BodySecondary,Object.assign({style:{color:o.COLORS.content.primary}},{children:s.message})),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs(u.Caption,Object.assign({style:{color:o.COLORS.content.secondary}},{children:[i.format(new Date(null==s?void 0:s.date),"hh:mm a")," |"," ",i.format(new Date(null==s?void 0:s.date),"dd/MM/yyyy")]}))})]}),s.messageId)))}))]})]})}))};
|
|
@@ -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
|
-
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import o from"../../assets/icons/alert_triangle.svg.js";import n from"../../assets/icons/plus.svg.js";import{memo as i,useState as s,useMemo as r,useEffect as a}from"react";import{COLORS as d}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{BikShimmer as c}from"../shimmer/ShimmerComponent/BikShimmer.js";import{BodyCaption as u}from"../TypographyStyle.js";import{SourceInfoFooterStyle as h}from"./DataSourcePanel.style.js";const m=i((i=>{const{appType:m,sourceIntent:p,hideHeading:b,messageSource:j,trainingSourceCount:T={},ShowTrainingDataSource:x={},faqCount:A,ChecklistType:f,footerButtonOption:y,isFooterLoading:I,reasonForAiGeneratedResponse:R,showAiResponseReason:O}=i,F=x,[_,w]=s(!0),[N,k]=s(!0),C="/bik-ai/training",[D,E]=s({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[S,P]=s({title:"",subTitle:""}),U=r((()=>{const e=(null==T?void 0:T[p])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[T,p]),M=()=>{var e;(null==D?void 0:D.redirectUrl)?window.open(`${window.location.origin}${null==D?void 0:D.redirectUrl}`,"_self"):Object.keys(null!==(e=null==D?void 0:D.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(D):(null==y?void 0:y.navigate)&&(null==y||y.navigate("Training",m==t.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return a((()=>{var e,o,n,i;if(p){if(null===(e=null==j?void 0:j.sources)||void 0===e?void 0:e.length){const e=j.sources[0];if(F[p])p===f.ORDER_ENQUIRY&&k(!1);else{let s=null==e?void 0:e.insights,r="";switch(p){case f.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(s=`${A||"No"} FAQs added for this product`,r="Add product-specific information via FAQs to improve responses",E({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 f.ORDER_MODIFICATION:s=(null==T?void 0:T[p])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",s&&E({buttonTitle:m==t.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:m==t.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case f.ORDER_CANCELLATION:s=(null==T?void 0:T[p])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",E({buttonTitle:m==t.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:m==t.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case f.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;E({buttonTitle:m==t.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:m==t.MANIFEST?"/training/order-management":C,addFaqProps:{}});break;case f.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(i=null===(n=null===(o=null==j?void 0:j.sources)||void 0===o?void 0:o[0])||void 0===n?void 0:n.title)||void 0===i?void 0:i.toLowerCase().indexOf("collection"))){s="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}s="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}P({title:null!=s?s:"",subTitle:r})}}(F[p]||[f.PRODUCT_DETAILS,f.ORDER_MODIFICATION,f.ORDER_CANCELLATION,f.ORDER_TRACKING].includes(p))&&w(!1)}}),[null==j?void 0:j.messageId,T,p,null==j?void 0:j.sources,F,f,A,m,j]),e.jsx(h,{children:I?e.jsx(e.Fragment,{children:e.jsx(c,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsx(e.Fragment,{children:!(null==S?void 0:S.title)&&T&&p in T?e.jsxs(e.Fragment,{children:[e.jsx(g,{hideHeading:null!=b&&b}),e.jsx(v,{reason:R||"",showAiResponseReason:null!=O&&O}),e.jsxs("div",Object.assign({className:"source_info_details "+(T[p]>0?"":"no_data_source")},{children:[T[p]>0&&N?e.jsxs(e.Fragment,{children:[e.jsx(u,{children:U}),e.jsx(u,Object.assign({color:d.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):N&&e.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsx(o,{width:15,height:15,color:d.content.negative,style:{marginTop:2}}),e.jsx(u,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||_?e.jsx(e.Fragment,{}):e.jsx(l,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]}):e.jsxs(e.Fragment,{children:[e.jsx(g,{hideHeading:null!=b&&b}),e.jsx(v,{reason:R||"",showAiResponseReason:null!=O&&O}),e.jsxs("div",Object.assign({className:"source_info_details"},{children:[N&&e.jsxs(e.Fragment,{children:[e.jsx(u,{children:null==S?void 0:S.title}),e.jsx(u,Object.assign({color:d.content.secondary},{children:null==S?void 0:S.subTitle}))]}),!y||y.hideAddDataButton||_?e.jsx(e.Fragment,{}):e.jsx(l,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]})})})})),g=i((t=>t.hideHeading?null:e.jsx(u,Object.assign({color:d.content.secondary},{children:"Training insights"})))),v=i((t=>{const[o,n]=s(!1),i=t.reason&&t.reason.length>50,r=i&&!o?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsx(u,Object.assign({color:d.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxs(u,Object.assign({color:d.content.secondary,className:"clamp-text"},{children:[r||"No reason provided for this response.",i&&e.jsx(u,Object.assign({color:d.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>n(!o)},{children:o?"Show less":"Show more"}))]}))]})):e.jsx(e.Fragment,{})}));v.displayName="WhyAiGaveThisResponse",g.displayName="TrainingInsightsHeading",m.displayName="SourceInfoFooter";export{m as default};
|
|
1
|
+
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import o from"../../assets/icons/alert_triangle.svg.js";import n from"../../assets/icons/plus.svg.js";import{memo as i,useState as s,useMemo as r,useEffect as a}from"react";import{COLORS as d}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{BikShimmer as c}from"../shimmer/ShimmerComponent/BikShimmer.js";import{BodyCaption as u}from"../TypographyStyle.js";import{SourceInfoFooterStyle as h}from"./DataSourcePanel.style.js";const m=i((i=>{const{appType:m,sourceIntent:p,hideHeading:b,messageSource:j,trainingSourceCount:T={},ShowTrainingDataSource:x={},faqCount:A,ChecklistType:f,footerButtonOption:y,isFooterLoading:I,reasonForAiGeneratedResponse:R,showAiResponseReason:O}=i,F=x,[_,w]=s(!0),[N,k]=s(!0),C="/bik-ai/training",[D,E]=s({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[S,P]=s({title:"",subTitle:""}),U=r((()=>{const e=(null==T?void 0:T[p])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[T,p]),M=()=>{var e;(null==D?void 0:D.redirectUrl)?window.open(`${window.location.origin}${null==D?void 0:D.redirectUrl}`,"_self"):Object.keys(null!==(e=null==D?void 0:D.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(D):(null==y?void 0:y.navigate)&&(null==y||y.navigate("Training",m==t.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return a((()=>{var e,o,n,i;if(p){if(null===(e=null==j?void 0:j.sources)||void 0===e?void 0:e.length){const e=j.sources[0];if(F[p])p===f.ORDER_ENQUIRY&&k(!1);else{let s=null==e?void 0:e.insights,r="";switch(p){case f.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(s=`${A||"No"} FAQs added for this product`,r="Add product-specific information via FAQs to improve responses",E({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 f.ORDER_MODIFICATION:s=(null==T?void 0:T[p])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",s&&E({buttonTitle:m==t.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:m==t.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case f.ORDER_CANCELLATION:s=(null==T?void 0:T[p])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",E({buttonTitle:m==t.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:m==t.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case f.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;E({buttonTitle:m==t.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:m==t.MANIFEST?"/training/order-management":C,addFaqProps:{}});break;case f.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(i=null===(n=null===(o=null==j?void 0:j.sources)||void 0===o?void 0:o[0])||void 0===n?void 0:n.title)||void 0===i?void 0:i.toLowerCase().indexOf("collection"))){s="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}s="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}P({title:null!=s?s:"",subTitle:r})}}(F[p]||[f.PRODUCT_DETAILS,f.ORDER_MODIFICATION,f.ORDER_CANCELLATION,f.ORDER_TRACKING].includes(p))&&w(!1)}}),[null==j?void 0:j.messageId,T,p,null==j?void 0:j.sources,F,f,A,m,j]),e.jsx(h,{children:I?e.jsx(e.Fragment,{children:e.jsx(c,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsx(e.Fragment,{children:!(null==S?void 0:S.title)&&T&&p in T?e.jsxs(e.Fragment,{children:[e.jsx(g,{hideHeading:null!=b&&b}),e.jsx(v,{reason:R||"",showAiResponseReason:null!=O&&O}),e.jsxs("div",Object.assign({className:"source_info_details "+(T[p]>0?"":"no_data_source")},{children:[T[p]>0&&N?e.jsxs(e.Fragment,{children:[e.jsx(u,{children:U}),e.jsx(u,Object.assign({color:d.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):N&&e.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsx(o,{width:15,height:15,color:d.content.negative,style:{marginTop:2}}),e.jsx(u,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||_?e.jsx(e.Fragment,{}):e.jsx(l,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]}):e.jsxs(e.Fragment,{children:[e.jsx(g,{hideHeading:null!=b&&b}),e.jsx(v,{reason:R||"",showAiResponseReason:null!=O&&O}),e.jsxs("div",Object.assign({className:"source_info_details"},{children:[N&&e.jsxs(e.Fragment,{children:[e.jsx(u,{children:null==S?void 0:S.title}),e.jsx(u,Object.assign({color:d.content.secondary},{children:null==S?void 0:S.subTitle}))]}),!y||y.hideAddDataButton||_?e.jsx(e.Fragment,{}):e.jsx(l,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]})})})})),g=i((t=>t.hideHeading?null:e.jsx(u,Object.assign({color:d.content.secondary},{children:"Training insights"})))),v=i((t=>{const[o,n]=s(!1),i=t.reason&&t.reason.length>50,r=i&&!o?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsx(u,Object.assign({color:d.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxs(u,Object.assign({color:d.content.secondary,className:"clamp-text"},{children:[r||"No reason provided for this response.",i&&e.jsx(u,Object.assign({color:d.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>n(!o)},{children:o?"Show less":"Show more"}))]}))]})):e.jsx(e.Fragment,{})}));v.displayName="WhyAiGaveThisResponse",g.displayName="TrainingInsightsHeading",m.displayName="SourceInfoFooter";export{m as default};
|
|
@@ -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
|
-
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import s from"../../assets/icons/box_search.svg.js";import i from"../../assets/icons/boxV2.svg.js";import o from"../../assets/icons/chevronDownOutline.svg.js";import n from"../../assets/icons/chevronUpOutline.svg.js";import r from"../../assets/icons/cross.svg.js";import l from"../../assets/icons/edit.svg.js";import c from"../../assets/icons/filePdf.svg.js";import a from"../../assets/icons/help.svg.js";import d from"../../assets/icons/info.svg.js";import p from"../../assets/icons/openai.svg.js";import u from"../../assets/icons/plus.svg.js";import g from"../../assets/icons/redirect.svg.js";import x from"../../assets/icons/text_t9.svg.js";import h from"../../assets/icons/website.svg.js";import{useState as j,useMemo as m,useEffect as f}from"react";import{COLORS as y}from"../../constants/Theme.js";import{Button as v}from"../button/Button.js";import{IconButton as b}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as I}from"../side-modal/SideModal.js";import{Tag as O}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as w,BodySecondary as S}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as N}from"./DataSourcePanel.style.js";import{intentConfig as F}from"./IntentConfig.js";import{DescriptionModal as A}from"./Modals/DescriptionModal.js";import{CustomDataType as _}from"./model.js";const k=k=>{var D,R;const{appType:P,storeId:B,messageSource:U,setMessageSourcePanel:K,hideCloseButton:M,isSourceInfoFetched:W,allSourceInfoDetail:$,ChecklistType:H,title:q,zeroStateButton:Q,editableSources:G,preFillTrainingSourceCount:Y,redirect:z,footerButtonOption:X,fetchTrainingSourceCount:V,fetchProductFAQCount:J,productSourceData:Z,reasonForAiGeneratedResponse:ee,showAiResponseReason:te,productSearchRule:se,onEditProductSearchRule:ie}=k,{sources:oe}=U,ne=["blog","article","page","policy"],[re,le]=j(!1),[ce,ae]=j(!1),[de,pe]=j(!1),[ue,ge]=j(0),[xe,he]=j(),[je,me]=j(null!=Y?Y:{}),[fe,ye]=j(!1),[ve,be]=j(!1),Ce={};F.forEach((t=>{let{key:s,type:i,tagText:o}=t;H[s]&&(Ce[H[s]]=e.jsx(O,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ie=oe.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Oe=oe.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Te=m((()=>{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=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);f((()=>{var e,t,s,i;if(!(null==U?void 0:U.messageId))return;le(!0),ae(!0),pe(!1!==(null===(t=null===(e=U.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=U.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=U.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));J(B,n).then((e=>ge(e))).then((()=>{Y?(me(Y),setTimeout((()=>{le(!1),ae(!1)}),100)):(setTimeout((()=>le(!1)),100),V(B).then((e=>me(e))).then((()=>setTimeout((()=>{ae(!1)}),100))))}))}),[J,V,null==U?void 0:U.messageId,U.sources,Y,B]);const Ee=e=>!!(e&&0===e.length||(null==U?void 0:U.isUnsatisfactoryAnswer)),we=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=_.FILES:ne.includes(e)?e=_.FETCHED_LINKS:"url"==e?e=_.WEBSITE_LINKS:"text"===e?e=_.TEXTS:"faq"===e&&(e=_.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Se=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")):"",Le=t=>"products"==t||"product"==t?e.jsx(i,{height:16,width:16,color:y.content.secondary}):"files"==t?e.jsx(c,{height:16,width:16,color:y.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(h,{height:16,width:16,color:y.content.secondary}):"faq"==t?e.jsx(a,{height:16,width:16,color:y.content.secondary}):"texts"==t?e.jsx(x,{height:16,width:16,color:y.content.secondary}):e.jsx(p,{height:16,width:16,color:y.content.secondary}),Ne=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(re||!W)return e.jsx(N,{children:e.jsx(C,{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 Fe=s=>{const{title:i,count:r,isExpanded:l,onToggle:c,children:a}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(w,Object.assign({style:{fontWeight:"600"}},{children:i})),P===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:y.surface.subdued,color:y.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:P===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(o,{width:20,height:20,color:y.content.primary}):e.jsx(n,{width:20,height:20,color:y.content.primary})})]})),l&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(N,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!q&&e.jsx(E,{children:q}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(w,Object.assign({color:y.content.secondary},{children:"Intent"})),null!==(D=Ce[U.intent])&&void 0!==D?D:Ce.GENERIC,!M&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>K(void 0)},{children:e.jsx(r,{height:20,width:20,color:y.content.secondary})}))]})),se&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(S,Object.assign({color:y.content.primary},{children:se.rule_name})),ie&&se.rule_id&&e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsx(s,{width:14,color:y.content.secondary}),e.jsx(w,Object.assign({color:y.content.secondary},{children:"Edit search rule"})),e.jsx(b,{Icon:l,height:16,width:16,bordered:!0,iconColor:y.content.primary,onClick:()=>ie(null==se?void 0:se.rule_id)})]}))]})),se.keywords&&se.keywords.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:y.surface.subdued,borderRadius:"8px",border:`1px dashed ${y.stroke.primary}`}},{children:se.keywords.map(((t,s)=>e.jsx(O,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Ee(oe)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${y.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(d,{width:24,height:24,color:y.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(E,{children:"Insufficient data"})})),e.jsx(S,Object.assign({color:y.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"})),Q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(v,{LeadingIcon:null!==(t=Q.leadingIcon)&&void 0!==t?t:u,buttonText:null!==(s=Q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{Q.onClick()}})}))]}))})()})):!se&&e.jsx(O,{LeadingIcon:d,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:U.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 ${P===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Ee(oe)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:Ie.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(Fe,Object.assign({title:"Product Sources",count:Ie.length,isExpanded:P!==t.MANIFEST||fe,onToggle:()=>ye(!fe)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ie.map(((t,s)=>{var i,o,n,r;const c=we(t.type||t.subTitle||"OpenAI"),a=we(t.type||t.subTitle||"OpenAI",!0),d=Se(c),p=null==G?void 0:G.includes(a),u=$[null!==(i=t.productId)&&void 0!==i?i:"Products"],x=t.title,h=t.productId&&(null==Z?void 0:Z[t.productId]),j=h&&h.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ie?void 0:Ie.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(c),e.jsx(T,Object.assign({body:x,placement:"top"},{children:e.jsx(S,Object.assign({style:a==_.FETCHED_LINKS||a==_.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>a==_.FETCHED_LINKS||a==_.WEBSITE_LINKS?z(t):{}},{children:x}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:d}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==u?void 0:u.onEditClick(u.data,u.type),disabled:!u,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!u,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),h&&e.jsxs(w,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;he({title:x,description:Ne(h.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>he(void 0)})}},{children:`${null===(o=h.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${null===(n=h.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(T,Object.assign({body:j,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=h.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Oe.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(Fe,Object.assign({title:"Content Sources",count:Oe.length,isExpanded:P!==t.MANIFEST||ve,onToggle:()=>be(!ve)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Oe.map(((t,s)=>{var i,o,n,r,c,a,d,p,u,x,h,j,m,f,v,C,I;const O=we(t.type||t.subTitle||"OpenAI"),E=we(t.type||t.subTitle||"OpenAI",!0),L=Se(O),N=null==G?void 0:G.includes(E),F="Products"===t.subTitle?$[null!==(i=t.productId)&&void 0!==i?i:"Products"]:$[null!==(o=t.docId)&&void 0!==o?o:""],A=E.toLowerCase()===(null===(n=_.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:E.toLowerCase()===(null===(c=_.FILES)||void 0===c?void 0:c.toLowerCase())||E.toLowerCase()===(null===(a=_.FETCHED_LINKS)||void 0===a?void 0:a.toLowerCase())||E.toLowerCase()===(null===(d=_.TEXTS)||void 0===d?void 0:d.toLowerCase())?t.title:E.toLowerCase()===(null===(p=_.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===H.EMAIL_COLLECTION?L:t.title,k="faq"===E.toLowerCase()?null!==(h=null!==(u=null==F?void 0:F.content)&&void 0!==u?u:null===(x=null==F?void 0:F.data)||void 0===x?void 0:x.answer)&&void 0!==h?h:"":E.toLowerCase()===(null===(j=_.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||E.toLowerCase()===(null===(m=_.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||E.toLowerCase()===(null===(f=_.TEXTS)||void 0===f?void 0:f.toLowerCase())?null!==(I=null!==(v=null==F?void 0:F.content)&&void 0!==v?v:null===(C=null==F?void 0:F.data)||void 0===C?void 0:C.fileContentText)&&void 0!==I?I:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Oe?void 0:Oe.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(O),e.jsx(T,Object.assign({body:A,placement:"top"},{children:e.jsx(S,Object.assign({style:E==_.FETCHED_LINKS||E==_.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>E==_.FETCHED_LINKS||E==_.WEBSITE_LINKS?z(t):{}},{children:A}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),(null!=k?k:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.stroke.primary}`,borderRadius:"4px",backgroundColor:y.surface.subdued}},{children:e.jsx(w,Object.assign({color:y.content.primary,className:"clamp-description"},{children:Ne(null!=k?k:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),de&&!Ee(oe)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(L,{appType:P,storeId:B,messageSource:U,sourceIntent:null!==(R=U.intent)&&void 0!==R?R:H.GENERIC,faqCount:ue,trainingSourceCount:je,ShowTrainingDataSource:Te,ChecklistType:H,footerButtonOption:X,isFooterLoading:ce,reasonForAiGeneratedResponse:ee,showAiResponseReason:te})}))]})}),xe&&e.jsx(I,Object.assign({header:"Product description",onClose:()=>he(void 0),width:"30%"},{children:e.jsx(A,{title:xe.title,description:xe.description,imageUrl:xe.imageUrl,onClose:xe.onClose})}))]})};export{k as DataSourcePanel};
|
|
1
|
+
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import s from"../../assets/icons/box_search.svg.js";import i from"../../assets/icons/boxV2.svg.js";import o from"../../assets/icons/chevronDownOutline.svg.js";import n from"../../assets/icons/chevronUpOutline.svg.js";import r from"../../assets/icons/cross.svg.js";import l from"../../assets/icons/edit.svg.js";import c from"../../assets/icons/filePdf.svg.js";import d from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import p from"../../assets/icons/openai.svg.js";import u from"../../assets/icons/plus.svg.js";import g from"../../assets/icons/redirect.svg.js";import x from"../../assets/icons/text_t9.svg.js";import h from"../../assets/icons/website.svg.js";import{useState as j,useMemo as m,useEffect as f}from"react";import{COLORS as y}from"../../constants/Theme.js";import{Button as v}from"../button/Button.js";import{IconButton as b}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as I}from"../side-modal/SideModal.js";import{Tag as O}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as w,BodySecondary as S}from"../TypographyStyle.js";import L from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as N}from"./DataSourcePanel.style.js";import{intentConfig as F}from"./IntentConfig.js";import{DescriptionModal as k}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";const _=_=>{var D,R;const{appType:P,storeId:B,messageSource:U,setMessageSourcePanel:K,hideCloseButton:M,isSourceInfoFetched:W,allSourceInfoDetail:$,ChecklistType:H,title:q,zeroStateButton:Q,editableSources:G,preFillTrainingSourceCount:Y,redirect:z,footerButtonOption:X,fetchTrainingSourceCount:V,fetchProductFAQCount:J,productSourceData:Z,reasonForAiGeneratedResponse:ee,showAiResponseReason:te,productSearchRule:se,onEditProductSearchRule:ie}=_,{sources:oe}=U,ne=["blog","article","page","policy"],[re,le]=j(!1),[ce,de]=j(!1),[ae,pe]=j(!1),[ue,ge]=j(0),[xe,he]=j(),[je,me]=j(null!=Y?Y:{}),[fe,ye]=j(!1),[ve,be]=j(!1),Ce={};F.forEach((t=>{let{key:s,type:i,tagText:o}=t;H[s]&&(Ce[H[s]]=e.jsx(O,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ie=oe.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Oe=oe.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Te=m((()=>{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=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);f((()=>{var e,t,s,i;if(!(null==U?void 0:U.messageId))return;le(!0),de(!0),pe(!1!==(null===(t=null===(e=U.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=U.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=U.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));J(B,n).then((e=>ge(e))).then((()=>{Y?(me(Y),setTimeout((()=>{le(!1),de(!1)}),100)):(setTimeout((()=>le(!1)),100),V(B).then((e=>me(e))).then((()=>setTimeout((()=>{de(!1)}),100))))}))}),[J,V,null==U?void 0:U.messageId,U.sources,Y,B]);const Ee=e=>!!(e&&0===e.length||(null==U?void 0:U.isUnsatisfactoryAnswer)),we=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=A.FILES:ne.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Se=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")):"",Le=t=>"products"==t||"product"==t?e.jsx(i,{height:16,width:16,color:y.content.secondary}):"files"==t?e.jsx(c,{height:16,width:16,color:y.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(h,{height:16,width:16,color:y.content.secondary}):"faq"==t?e.jsx(d,{height:16,width:16,color:y.content.secondary}):"texts"==t?e.jsx(x,{height:16,width:16,color:y.content.secondary}):e.jsx(p,{height:16,width:16,color:y.content.secondary}),Ne=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(re||!W)return e.jsx(N,{children:e.jsx(C,{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 Fe=s=>{const{title:i,count:r,isExpanded:l,onToggle:c,children:d}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(w,Object.assign({style:{fontWeight:"600"}},{children:i})),P===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:y.surface.subdued,color:y.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:P===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(o,{width:20,height:20,color:y.content.primary}):e.jsx(n,{width:20,height:20,color:y.content.primary})})]})),l&&d]})};return e.jsxs(e.Fragment,{children:[e.jsx(N,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!q&&e.jsx(E,{children:q}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(w,Object.assign({color:y.content.secondary},{children:"Intent"})),null!==(D=Ce[U.intent])&&void 0!==D?D:Ce.GENERIC,!M&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>K(void 0)},{children:e.jsx(r,{height:20,width:20,color:y.content.secondary})}))]})),se&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsx(S,Object.assign({color:y.content.primary},{children:se.rule_name})),ie&&se.rule_id&&e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsx(s,{width:14,color:y.content.secondary}),e.jsx(w,Object.assign({color:y.content.secondary},{children:"Edit search rule"})),e.jsx(b,{Icon:l,height:16,width:16,bordered:!0,iconColor:y.content.primary,onClick:()=>ie(null==se?void 0:se.rule_id)})]}))]})),se.keywords&&se.keywords.length>0&&e.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:y.surface.subdued,borderRadius:"8px",border:`1px dashed ${y.stroke.primary}`}},{children:se.keywords.map(((t,s)=>e.jsx(O,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),Ee(oe)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${y.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a,{width:24,height:24,color:y.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(E,{children:"Insufficient data"})})),e.jsx(S,Object.assign({color:y.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"})),Q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(v,{LeadingIcon:null!==(t=Q.leadingIcon)&&void 0!==t?t:u,buttonText:null!==(s=Q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{Q.onClick()}})}))]}))})()})):!se&&e.jsx(O,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:U.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 ${P===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Ee(oe)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:Ie.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(Fe,Object.assign({title:"Product Sources",count:Ie.length,isExpanded:P!==t.MANIFEST||fe,onToggle:()=>ye(!fe)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ie.map(((t,s)=>{var i,o,n,r;const c=we(t.type||t.subTitle||"OpenAI"),d=we(t.type||t.subTitle||"OpenAI",!0),a=Se(c),p=null==G?void 0:G.includes(d),u=$[null!==(i=t.productId)&&void 0!==i?i:"Products"],x=t.title,h=t.productId&&(null==Z?void 0:Z[t.productId]),j=h&&h.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ie?void 0:Ie.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(c),e.jsx(T,Object.assign({body:x,placement:"top"},{children:e.jsx(S,Object.assign({style:d==A.FETCHED_LINKS||d==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>d==A.FETCHED_LINKS||d==A.WEBSITE_LINKS?z(t):{}},{children:x}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:a}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==u?void 0:u.onEditClick(u.data,u.type),disabled:!u,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!u,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),h&&e.jsxs(w,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;he({title:x,description:Ne(h.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>he(void 0)})}},{children:`${null===(o=h.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>h.onEditFaqClick(h.faqs)},{children:`${null===(n=h.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(T,Object.assign({body:j,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=h.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Oe.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(Fe,Object.assign({title:"Content Sources",count:Oe.length,isExpanded:P!==t.MANIFEST||ve,onToggle:()=>be(!ve)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Oe.map(((t,s)=>{var i,o,n,r,c,d,a,p,u,x,h,j,m,f,v,C,I;const O=we(t.type||t.subTitle||"OpenAI"),E=we(t.type||t.subTitle||"OpenAI",!0),L=Se(O),N=null==G?void 0:G.includes(E),F="Products"===t.subTitle?$[null!==(i=t.productId)&&void 0!==i?i:"Products"]:$[null!==(o=t.docId)&&void 0!==o?o:""],k=E.toLowerCase()===(null===(n=A.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:E.toLowerCase()===(null===(c=A.FILES)||void 0===c?void 0:c.toLowerCase())||E.toLowerCase()===(null===(d=A.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||E.toLowerCase()===(null===(a=A.TEXTS)||void 0===a?void 0:a.toLowerCase())?t.title:E.toLowerCase()===(null===(p=A.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===H.EMAIL_COLLECTION?L:t.title,_="faq"===E.toLowerCase()?null!==(h=null!==(u=null==F?void 0:F.content)&&void 0!==u?u:null===(x=null==F?void 0:F.data)||void 0===x?void 0:x.answer)&&void 0!==h?h:"":E.toLowerCase()===(null===(j=A.FETCHED_LINKS)||void 0===j?void 0:j.toLowerCase())||E.toLowerCase()===(null===(m=A.WEBSITE_LINKS)||void 0===m?void 0:m.toLowerCase())||E.toLowerCase()===(null===(f=A.TEXTS)||void 0===f?void 0:f.toLowerCase())?null!==(I=null!==(v=null==F?void 0:F.content)&&void 0!==v?v:null===(C=null==F?void 0:F.data)||void 0===C?void 0:C.fileContentText)&&void 0!==I?I:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Oe?void 0:Oe.length)?`1px solid ${y.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(O),e.jsx(T,Object.assign({body:k,placement:"top"},{children:e.jsx(S,Object.assign({style:E==A.FETCHED_LINKS||E==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:y.content.primary,className:"clamp-title",onClick:()=>E==A.FETCHED_LINKS||E==A.WEBSITE_LINKS?z(t):{}},{children:k}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(w,Object.assign({color:y.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(b,{Icon:l,height:16,width:16,iconColor:y.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(b,{Icon:g,height:16,width:16,iconColor:y.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>z(t)})}))]}))]})),(null!=_?_:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${y.stroke.primary}`,borderRadius:"4px",backgroundColor:y.surface.subdued}},{children:e.jsx(w,Object.assign({color:y.content.primary,className:"clamp-description"},{children:Ne(null!=_?_:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ae&&!Ee(oe)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(L,{appType:P,storeId:B,messageSource:U,sourceIntent:null!==(R=U.intent)&&void 0!==R?R:H.GENERIC,faqCount:ue,trainingSourceCount:je,ShowTrainingDataSource:Te,ChecklistType:H,footerButtonOption:X,isFooterLoading:ce,reasonForAiGeneratedResponse:ee,showAiResponseReason:te})}))]})}),xe&&e.jsx(I,Object.assign({header:"Product description",onClose:()=>he(void 0),width:"30%"},{children:e.jsx(k,{title:xe.title,description:xe.description,imageUrl:xe.imageUrl,onClose:xe.onClose})}))]})};export{_ as DataSourcePanel};
|
|
@@ -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
|
-
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as i}from"@bikdotai/bik-models/growth";import{useState as t,useEffect as o}from"react";import{DISCOUNT_TYPES as n,MIN_PURCHASE_REQUIREMENT as l,DISCOUNT_APPLIES_TO as r,OFFER_APPLIES_TO as d,initialStaticCouponErrorState as a,initialDynamicCouponErrorState as s,COUPON_EXPIRATION as c,DISCOUNT_TARGET_TYPES as u,DISCOUNT_TARGET_SELECTION as p,DISCOUNT_VALUE_TYPES as v}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as C}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as m,BodyCaption as b,TitleRegular as y}from"../TypographyStyle.js";import{DEFAULT_THEME as P}from"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as h}from"../modals/styledModal.js";import{ProductPickerContent as I}from"../product-picker/ProductPickerModal.js";import{Tag as f}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import E from"../../assets/icons/gift_icon.svg.js";import O from"../../assets/icons/percentage_icon.svg.js";import S from"../../assets/icons/shipping_icon.svg.js";import g from"../../assets/icons/triangle_error.svg.js";import j from"../../assets/icons/warning.svg.js";import{ProductPickerModal as x}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as V}from"../variable-picker-v3/model.js";import{VariablePicker as _}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as A,CouponTypeContainerStyled as D,VariablePickerContainer as k}from"./DiscountModal.styled.js";import{validateDiscountData as N,descriptionBuilder as F}from"./DiscountUtils.js";import w,{DISCOUNT_PRODUCTS as R}from"./DynamicCoupon/DynamicCoupon.js";import M from"./StaticCoupon/StaticCoupon.js";const q=q=>{var L,U,B,G,Y,X,Q,H,z,K,$;const Z=[{id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:q.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e.jsx(O,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:n.BUY_X_GET_Y,icon:i=>e.jsx(E,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:n.FREE_SHIPPING,icon:i=>e.jsx(S,{width:24,height:24,color:i})}],[J,W]=t(),[ee,ie]=t(),[te,oe]=t(),[ne,le]=t(null!==(L=q.data)&&void 0!==L?L:"string"==typeof q.hideOption?{isStaticCoupon:"dynamic"===q.hideOption}:{isStaticCoupon:!0}),[re,de]=t(!0),[ae,se]=t(),[ce,ue]=t((null===(U=q.data)||void 0===U?void 0:U.minAmount)?l.AMOUNT:(null===(B=q.data)||void 0===B?void 0:B.minQuantity)?l.QUANTITY:l.NA),[pe,ve]=t(r.ENTIRE_ORDER),[Ce,me]=t(d.SPECIFIC_PRODUCTS),[be,ye]=t(d.SPECIFIC_PRODUCTS),[Pe,he]=t(void 0),[Ie,fe]=t(void 0),[Te,Ee]=t(void 0),[Oe,Se]=t(void 0),[ge,je]=t(void 0),[xe,Ve]=t(void 0),[_e,Ae]=t(0),[De,ke]=t(""),[Ne,Fe]=t(Z[0]),[we,Re]=t(!1),[Me,qe]=t(a),[Le,Ue]=t(s),[Be,Ge]=t(c.DYNAMIC_EXPIRATION),Ye=[{value:n.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:ae===n.AMOUNT_OFF_ORDER},{value:n.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:ae===n.AMOUNT_OFF_PRODUCTS},{value:n.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:ae===n.BUY_X_GET_Y},{value:n.FREE_SHIPPING,label:"Free shipping",selected:ae===n.FREE_SHIPPING}];o((()=>{q.makeExpiryMandatory&&Re(!0)}),[q.makeExpiryMandatory]),o((()=>{var e,i,t,o,l,a,s,u;let p;const{tempCouponData:C,discountType:m}=Xe();se(m);const b=(e,i)=>{Fe(C.valueType===v.FIXED_AMOUNT?Z[e]:Z[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(Re(!0),(null==C?void 0:C.expireAt)&&Ge(c.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Ge(c.DYNAMIC_EXPIRATION)),m){case n.AMOUNT_OFF_ORDER:b(0,1),ve(r.ENTIRE_ORDER);break;case n.AMOUNT_OFF_PRODUCTS:b(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(r.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(r.SPECIFIC_PRODUCTS),y(null===(o=C.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,Se)):ve(r.ENTIRE_ORDER);break;case n.BUY_X_GET_Y:Fe(Z[2]),(null===(l=C.entitledCollectionIds)||void 0===l?void 0:l.length)?ye(d.SPECIFIC_COLLECTIONS):(ye(d.SPECIFIC_PRODUCTS),y(null===(a=C.productVariableConf)||void 0===a?void 0:a.entitledProductVariable,Se)),(null===(s=C.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?me(d.SPECIFIC_COLLECTIONS):(me(d.SPECIFIC_PRODUCTS),y(null===(u=C.productVariableConf)||void 0===u?void 0:u.prerequisiteProductVariable,je));break;case n.FREE_SHIPPING:Fe(Z[3])}le(Object.assign({},C)),q.hideProbability||(p=ze()),de(N(C,ce,m,q.hideProbability||!1,p,!!C.isStaticCoupon)),q.hideProbability||ze()}),[]),o((()=>{let e;q.hideProbability||(e=ze()),de(N(ne,ce,ae,q.hideProbability||!1,e,!!ne.isStaticCoupon))}),[ne,_e,ae,ce]),o((()=>{var e,i,t,o,n,l,r;if(!q.newPickerConf&&((null===(e=q.products)||void 0===e?void 0:e.length)||(null===(i=q.collection)||void 0===i?void 0:i.length))){if(q.products&&(null===(t=q.products)||void 0===t?void 0:t.length)){if(null===(o=q.data)||void 0===o?void 0:o.entitledProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}if(null===(n=q.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));he(e)}}if(q.collection&&q.collection.length){if(null===(l=q.data)||void 0===l?void 0:l.entitledCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ve(e)}if(null===(r=q.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}}}}),[q.products,q.collection]),o((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=q.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&fe(q.data.productsConf.entitledProducts),(null===(o=null===(t=q.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&he(q.data.productsConf.prerequisiteProducts),(null===(l=null===(n=q.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ve(q.data.collectionsConf.entitledCollections),(null===(d=null===(r=q.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Ee(q.data.collectionsConf.prerequisiteCollections)}),[null===(G=q.data)||void 0===G?void 0:G.productsConf,null===(Y=q.data)||void 0===Y?void 0:Y.collectionsConf]),o((()=>{if(!Ie)return;if(q.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}),[Ie]),o((()=>{if(!Pe)return;if(q.newPickerConf){const e=[];return Object.values(Pe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}const e=Pe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}),[Pe]),o((()=>{if(!xe)return;if(q.newPickerConf){(null==xe?void 0:xe.isCustom)&&delete xe.isCustom;const e=Object.keys(xe).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}const e=xe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}),[xe]),o((()=>{if(!Te)return;if(q.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}),[Te]);const Xe=()=>{var e,i;let t,o=ne;return ne.isStaticCoupon||(ne.targetType===u.SHIPPING_LINE?t=n.FREE_SHIPPING:ne.targetType===u.LINE_ITEM?t=ne.targetSelection===p.ENTITLED?(null===(e=ne.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=ne.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||ne.prerequisiteQuantity||ne.entitledQuantity?n.BUY_X_GET_Y:n.AMOUNT_OFF_PRODUCTS:n.AMOUNT_OFF_ORDER:(o=Object.assign(Object.assign({},o),{targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),t=n.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:o}},Qe=()=>{qe(a),Ue(s)},He=e=>{var i;const t={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(i=ne.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":ne.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((i=>{e[i]&&(o=t[i])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(ke(n>1?"Please add discount details":o),!0)},ze=()=>{if(!q.quadrant||!q.probability)return;const e=[...q.probability];let i=[];e.length>=q.quadrant&&e.splice(q.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(ne.probability||0);return Ae(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ke=e=>{var i,t,o,l,r,d,a,s,c,C,m,b,y,P,h,I;const f=e.value;se(f),he([]),fe([]),Ee([]),Ve([]),f===n.FREE_SHIPPING?le({value:100,targetSelection:p.ALL,targetType:u.SHIPPING_LINE,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(i=ne.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=ne.expireAfter)&&void 0!==t?t:void 0,probability:ne.probability,minQuantity:null!==(o=ne.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(l=ne.minAmount)&&void 0!==l?l:void 0}):f===n.BUY_X_GET_Y?le({value:100,targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(r=ne.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=ne.expireAfter)&&void 0!==d?d:void 0,probability:ne.probability,minQuantity:void 0,minAmount:void 0}):f===n.AMOUNT_OFF_ORDER?le({targetSelection:p.ALL,targetType:u.LINE_ITEM,valueType:null!==(a=ne.valueType)&&void 0!==a?a:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(s=ne.expireAt)&&void 0!==s?s:void 0,expireAfter:null!==(c=ne.expireAfter)&&void 0!==c?c:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(C=ne.minQuantity)&&void 0!==C?C:void 0,minAmount:null!==(m=ne.minAmount)&&void 0!==m?m:void 0}):f===n.AMOUNT_OFF_PRODUCTS&&le({targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:null!==(b=ne.valueType)&&void 0!==b?b:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(y=ne.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=ne.expireAfter)&&void 0!==P?P:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(h=ne.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=ne.minAmount)&&void 0!==I?I:void 0})},$e=i=>i&&e.jsx(f,{theme:"light",tagText:i,type:"negative",LeadingIcon:j});return e.jsxs(h,Object.assign({width:(te||J)&&q.newPickerConf?"25px":"640px",open:q.isOpen,hideCrossButton:!!ee,headingTitle:J?"Select Products":q.title,headingSubtitle:J?void 0:q.subTitle,footerLeftCustomElement:De?$e(De):q.errorMsg?$e(q.errorMsg):!q.quadrant||q.hideProbability?e.jsx(e.Fragment,{}):_e<=1?e.jsx(f,{theme:"light",tagText:`Current probability sum: ${_e}`,type:"white"}):e.jsx(T,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(f,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${_e}`,type:"negative",LeadingIcon:g})})})),headerRightCustomElement:q.allowStaticCoupon||J?void 0:e.jsx(C,{options:Ye,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ke(e)}}),onClose:q.onClose,footerContainerStyle:{borderTop:`1px solid ${P.colorsV2.stroke.primary}`},primaryButton:J?{buttonType:"primary",onClick:()=>{W(void 0)},buttonText:"Add"}:te?{buttonType:"primary",onClick:()=>{oe(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(X=q.loading)&&void 0!==X&&X,onClick:()=>{var e,i,t,o,a;if(Qe(),ne.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=ne,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!q.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(He(r))return void qe(r);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:ne.title})}else{const s={invalidCouponTitle:!ne.title,inValidProbability:!q.hideProbability&&(null!==(e=ne.probability)&&void 0!==e?e:-1)<=0||(null!==(i=ne.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=ne.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!ne.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(ae!==n.BUY_X_GET_Y&&ce!==l.NA){const{minAmount:e,minQuantity:i}=ne;s.inValidMinimumAmount=ce===l.AMOUNT&&!e,s.inValidMinimumQuantity=ce===l.QUANTITY&&!i}if(we&&(s.inValidCouponExpiry=!ne.expireAt&&!ne.expireAfter),ae!==n.AMOUNT_OFF_ORDER&&ae!==n.AMOUNT_OFF_PRODUCTS||(pe!==r.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidProductSelection=!0,s.inValidProductVariableSelection=!0),pe===r.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidCollectionSelection=!0)),ae===n.BUY_X_GET_Y&&(ne.prerequisiteQuantity||(s.inValidBuyXValue=!0),ne.entitledQuantity||(s.inValidGetYValue=!0),Ce!==d.SPECIFIC_PRODUCTS||!Pe||Object.keys(Pe).length||ge||(s.inValidBuyXProductSelection=!0,s.inValidBuyXProductVariableSelection=!0),Ce===d.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(s.inValidBuyXCollectionSelection=!0),be!==d.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidGetYProductSelection=!0,s.inValidGetYProductVariableSelection=!0),be===d.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidGetYCollectionSelection=!0)),He(s))return void Ue(s);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked(Object.assign(Object.assign({},ne),{description:F(ne,q.currency,null!==(o=q.products)&&void 0!==o?o:[],null!==(a=q.collection)&&void 0!==a?a:[]),productsConf:{entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[]},collectionsConf:{entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=Oe?Oe:{},prerequisiteProductVariable:null!=ge?ge:{}}}))}}},secondaryButton:J?{buttonType:"tertiaryGray",onClick:()=>{W(void 0)},buttonText:"Back"}:te?{buttonType:"tertiaryGray",onClick:()=>{oe(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:q.onClose,buttonText:"Cancel"}},{children:[!J&&!te&&e.jsxs(A,{children:[q.allowStaticCoupon&&!J&&e.jsxs(D,Object.assign({selectedDiv:ne.isStaticCoupon?1:2},{children:["static"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{ne.isStaticCoupon||(le({isStaticCoupon:!0,quadrant:ne.quadrant}),ke(""),Qe())}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?P.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{color:P.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;ne.isStaticCoupon&&(se(n.AMOUNT_OFF_ORDER),le({isStaticCoupon:!1,quadrant:ne.quadrant,targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),ke(""),Qe(),Fe({id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i}},{children:q.currency||""}))}),Re(null!==(i=q.makeExpiryMandatory)&&void 0!==i&&i),ue(l.NA))}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?void 0:P.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{}:{color:P.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.jsx(y,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),ne.isStaticCoupon&&!J&&e.jsx(M,{discountData:ne,setDiscountData:le,hideProbability:q.hideProbability||!1,discountAdminUrl:q.discountAdminUrl,staticDiscountValidationError:Me,currency:q.currency}),!ne.isStaticCoupon&&!J&&!te&&e.jsx(w,{currency:q.currency,entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[],setEntitledProducts:fe,setPrerequisiteProducts:he,discountData:ne,productPickerOpen:J,productVariablePickerOpen:ee,setIsProductPickerOpen:W,setIsProductVariablePickerOpen:ie,setDiscountData:le,selectedCouponType:ae,setSelectedCouponType:se,selectedMinimumRequirement:ce,setSelectedMinimumRequirement:ue,discountCouponAppliesTo:pe,offerAppliesToBuy:Ce,offerAppliesToGet:be,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:me,setOfferAppliesToGet:ye,hideProbability:q.hideProbability||!1,hideExpiration:q.hideExpiration||!1,allowStaticCoupon:q.allowStaticCoupon,onChangeCouponType:Ke,collectionPickerOpen:te,entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:oe,setEntitledCollections:Ve,setPrerequisiteCollections:Ee,useNewPicker:!!q.newPickerConf,setSelectedDiscountDetails:Fe,selectedDiscountDetails:Ne,isProductVariableSupported:q.isProductVariableSupported,entitledProductVariable:Oe,setEntitledProductVariable:Se,preRequisiteProductVariable:ge,setPreRequisiteProductVariable:je,productVariableList:q.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:Re,dynamicDiscountValidationError:Le,setDynamicDiscountValidationError:Ue,setValidationErrorMessage:ke,resetValidationErrors:Qe,discountDetailsOptions:Z,selectedExpiration:Be,setSelectedExpiration:Ge,makeExpiryMandatory:!!q.makeExpiryMandatory})]}),!!J&&e.jsxs(e.Fragment,{children:[!q.newPickerConf&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(I,{show:!0,onSave:()=>{},products:null!==(Q=q.products)&&void 0!==Q?Q:[],title:"Select Products",onClose:()=>{W(void 0)},selectedProducts:null!==(H=J===R.ENTITLED?Ie:Pe)&&void 0!==H?H:[],setSelectedProducts:J===R.ENTITLED?fe:he,onSearchKeyChange:q.onProductSearch})})),q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>W(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.fetchCollections)?q.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=q.newPickerConf)||void 0===l?void 0:l.fetchProducts)?q.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:J===R.ENTITLED?Ie:Pe,onAdd:e=>{J===R.ENTITLED?fe(e):he(e),W(void 0)},zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=q.newPickerConf)||void 0===n?void 0:n.searchInCollection)?q.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.searchProducts)?q.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!te&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxs(e.Fragment,{children:[q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>oe(void 0),collectionFetcher:q.newPickerConf.fetchCollections,productFetcher:q.newPickerConf.fetchProducts,selectedItems:te===R.ENTITLED?xe:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),te===R.ENTITLED?Ve(e):Ee(e),oe(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:q.newPickerConf.searchInCollection,searchFetcher:q.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!q.newPickerConf&&e.jsx(I,{show:!0,onSave:()=>{},products:null!==(z=q.collection)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{oe(void 0)},selectedProducts:null!==(K=te===R.ENTITLED?xe:Te)&&void 0!==K?K:[],setSelectedProducts:te===R.ENTITLED?Ve:Ee,onSearchKeyChange:q.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),ee&&e.jsx(k,{children:e.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsx(_,{type:V.EMBEDDED,data:null!==($=q.productVariableList)&&void 0!==$?$:[],showHeader:!0,onSelect:e=>{if(ee===R.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Se({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}if(ee===R.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;je({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}},onClose:()=>{ie(void 0)}})}))})]}))};export{q as DiscountModal};
|
|
1
|
+
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as i}from"@bikdotai/bik-models/growth/models/bik-store";import{useState as t,useEffect as o}from"react";import{DISCOUNT_TYPES as n,MIN_PURCHASE_REQUIREMENT as l,DISCOUNT_APPLIES_TO as r,OFFER_APPLIES_TO as d,initialStaticCouponErrorState as a,initialDynamicCouponErrorState as s,COUPON_EXPIRATION as c,DISCOUNT_TARGET_TYPES as u,DISCOUNT_TARGET_SELECTION as p,DISCOUNT_VALUE_TYPES as v}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as C}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as m,BodyCaption as b,TitleRegular as y}from"../TypographyStyle.js";import{DEFAULT_THEME as P}from"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as h}from"../modals/styledModal.js";import{ProductPickerContent as I}from"../product-picker/ProductPickerModal.js";import{Tag as f}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import E from"../../assets/icons/gift_icon.svg.js";import O from"../../assets/icons/percentage_icon.svg.js";import S from"../../assets/icons/shipping_icon.svg.js";import g from"../../assets/icons/triangle_error.svg.js";import j from"../../assets/icons/warning.svg.js";import{ProductPickerModal as x}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as V}from"../variable-picker-v3/model.js";import{VariablePicker as _}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as A,CouponTypeContainerStyled as D,VariablePickerContainer as k}from"./DiscountModal.styled.js";import{validateDiscountData as N,descriptionBuilder as F}from"./DiscountUtils.js";import w,{DISCOUNT_PRODUCTS as R}from"./DynamicCoupon/DynamicCoupon.js";import M from"./StaticCoupon/StaticCoupon.js";const q=q=>{var L,U,B,G,Y,X,Q,H,z,K,$;const Z=[{id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:q.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e.jsx(O,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:n.BUY_X_GET_Y,icon:i=>e.jsx(E,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:n.FREE_SHIPPING,icon:i=>e.jsx(S,{width:24,height:24,color:i})}],[J,W]=t(),[ee,ie]=t(),[te,oe]=t(),[ne,le]=t(null!==(L=q.data)&&void 0!==L?L:"string"==typeof q.hideOption?{isStaticCoupon:"dynamic"===q.hideOption}:{isStaticCoupon:!0}),[re,de]=t(!0),[ae,se]=t(),[ce,ue]=t((null===(U=q.data)||void 0===U?void 0:U.minAmount)?l.AMOUNT:(null===(B=q.data)||void 0===B?void 0:B.minQuantity)?l.QUANTITY:l.NA),[pe,ve]=t(r.ENTIRE_ORDER),[Ce,me]=t(d.SPECIFIC_PRODUCTS),[be,ye]=t(d.SPECIFIC_PRODUCTS),[Pe,he]=t(void 0),[Ie,fe]=t(void 0),[Te,Ee]=t(void 0),[Oe,Se]=t(void 0),[ge,je]=t(void 0),[xe,Ve]=t(void 0),[_e,Ae]=t(0),[De,ke]=t(""),[Ne,Fe]=t(Z[0]),[we,Re]=t(!1),[Me,qe]=t(a),[Le,Ue]=t(s),[Be,Ge]=t(c.DYNAMIC_EXPIRATION),Ye=[{value:n.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:ae===n.AMOUNT_OFF_ORDER},{value:n.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:ae===n.AMOUNT_OFF_PRODUCTS},{value:n.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:ae===n.BUY_X_GET_Y},{value:n.FREE_SHIPPING,label:"Free shipping",selected:ae===n.FREE_SHIPPING}];o((()=>{q.makeExpiryMandatory&&Re(!0)}),[q.makeExpiryMandatory]),o((()=>{var e,i,t,o,l,a,s,u;let p;const{tempCouponData:C,discountType:m}=Xe();se(m);const b=(e,i)=>{Fe(C.valueType===v.FIXED_AMOUNT?Z[e]:Z[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(Re(!0),(null==C?void 0:C.expireAt)&&Ge(c.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Ge(c.DYNAMIC_EXPIRATION)),m){case n.AMOUNT_OFF_ORDER:b(0,1),ve(r.ENTIRE_ORDER);break;case n.AMOUNT_OFF_PRODUCTS:b(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(r.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(r.SPECIFIC_PRODUCTS),y(null===(o=C.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,Se)):ve(r.ENTIRE_ORDER);break;case n.BUY_X_GET_Y:Fe(Z[2]),(null===(l=C.entitledCollectionIds)||void 0===l?void 0:l.length)?ye(d.SPECIFIC_COLLECTIONS):(ye(d.SPECIFIC_PRODUCTS),y(null===(a=C.productVariableConf)||void 0===a?void 0:a.entitledProductVariable,Se)),(null===(s=C.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?me(d.SPECIFIC_COLLECTIONS):(me(d.SPECIFIC_PRODUCTS),y(null===(u=C.productVariableConf)||void 0===u?void 0:u.prerequisiteProductVariable,je));break;case n.FREE_SHIPPING:Fe(Z[3])}le(Object.assign({},C)),q.hideProbability||(p=ze()),de(N(C,ce,m,q.hideProbability||!1,p,!!C.isStaticCoupon)),q.hideProbability||ze()}),[]),o((()=>{let e;q.hideProbability||(e=ze()),de(N(ne,ce,ae,q.hideProbability||!1,e,!!ne.isStaticCoupon))}),[ne,_e,ae,ce]),o((()=>{var e,i,t,o,n,l,r;if(!q.newPickerConf&&((null===(e=q.products)||void 0===e?void 0:e.length)||(null===(i=q.collection)||void 0===i?void 0:i.length))){if(q.products&&(null===(t=q.products)||void 0===t?void 0:t.length)){if(null===(o=q.data)||void 0===o?void 0:o.entitledProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}if(null===(n=q.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));he(e)}}if(q.collection&&q.collection.length){if(null===(l=q.data)||void 0===l?void 0:l.entitledCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ve(e)}if(null===(r=q.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}}}}),[q.products,q.collection]),o((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=q.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&fe(q.data.productsConf.entitledProducts),(null===(o=null===(t=q.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&he(q.data.productsConf.prerequisiteProducts),(null===(l=null===(n=q.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ve(q.data.collectionsConf.entitledCollections),(null===(d=null===(r=q.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Ee(q.data.collectionsConf.prerequisiteCollections)}),[null===(G=q.data)||void 0===G?void 0:G.productsConf,null===(Y=q.data)||void 0===Y?void 0:Y.collectionsConf]),o((()=>{if(!Ie)return;if(q.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}),[Ie]),o((()=>{if(!Pe)return;if(q.newPickerConf){const e=[];return Object.values(Pe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}const e=Pe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}),[Pe]),o((()=>{if(!xe)return;if(q.newPickerConf){(null==xe?void 0:xe.isCustom)&&delete xe.isCustom;const e=Object.keys(xe).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}const e=xe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}),[xe]),o((()=>{if(!Te)return;if(q.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}),[Te]);const Xe=()=>{var e,i;let t,o=ne;return ne.isStaticCoupon||(ne.targetType===u.SHIPPING_LINE?t=n.FREE_SHIPPING:ne.targetType===u.LINE_ITEM?t=ne.targetSelection===p.ENTITLED?(null===(e=ne.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=ne.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||ne.prerequisiteQuantity||ne.entitledQuantity?n.BUY_X_GET_Y:n.AMOUNT_OFF_PRODUCTS:n.AMOUNT_OFF_ORDER:(o=Object.assign(Object.assign({},o),{targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),t=n.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:o}},Qe=()=>{qe(a),Ue(s)},He=e=>{var i;const t={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(i=ne.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":ne.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((i=>{e[i]&&(o=t[i])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(ke(n>1?"Please add discount details":o),!0)},ze=()=>{if(!q.quadrant||!q.probability)return;const e=[...q.probability];let i=[];e.length>=q.quadrant&&e.splice(q.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(ne.probability||0);return Ae(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ke=e=>{var i,t,o,l,r,d,a,s,c,C,m,b,y,P,h,I;const f=e.value;se(f),he([]),fe([]),Ee([]),Ve([]),f===n.FREE_SHIPPING?le({value:100,targetSelection:p.ALL,targetType:u.SHIPPING_LINE,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(i=ne.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=ne.expireAfter)&&void 0!==t?t:void 0,probability:ne.probability,minQuantity:null!==(o=ne.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(l=ne.minAmount)&&void 0!==l?l:void 0}):f===n.BUY_X_GET_Y?le({value:100,targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(r=ne.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=ne.expireAfter)&&void 0!==d?d:void 0,probability:ne.probability,minQuantity:void 0,minAmount:void 0}):f===n.AMOUNT_OFF_ORDER?le({targetSelection:p.ALL,targetType:u.LINE_ITEM,valueType:null!==(a=ne.valueType)&&void 0!==a?a:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(s=ne.expireAt)&&void 0!==s?s:void 0,expireAfter:null!==(c=ne.expireAfter)&&void 0!==c?c:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(C=ne.minQuantity)&&void 0!==C?C:void 0,minAmount:null!==(m=ne.minAmount)&&void 0!==m?m:void 0}):f===n.AMOUNT_OFF_PRODUCTS&&le({targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:null!==(b=ne.valueType)&&void 0!==b?b:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(y=ne.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=ne.expireAfter)&&void 0!==P?P:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(h=ne.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=ne.minAmount)&&void 0!==I?I:void 0})},$e=i=>i&&e.jsx(f,{theme:"light",tagText:i,type:"negative",LeadingIcon:j});return e.jsxs(h,Object.assign({width:(te||J)&&q.newPickerConf?"25px":"640px",open:q.isOpen,hideCrossButton:!!ee,headingTitle:J?"Select Products":q.title,headingSubtitle:J?void 0:q.subTitle,footerLeftCustomElement:De?$e(De):q.errorMsg?$e(q.errorMsg):!q.quadrant||q.hideProbability?e.jsx(e.Fragment,{}):_e<=1?e.jsx(f,{theme:"light",tagText:`Current probability sum: ${_e}`,type:"white"}):e.jsx(T,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(f,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${_e}`,type:"negative",LeadingIcon:g})})})),headerRightCustomElement:q.allowStaticCoupon||J?void 0:e.jsx(C,{options:Ye,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ke(e)}}),onClose:q.onClose,footerContainerStyle:{borderTop:`1px solid ${P.colorsV2.stroke.primary}`},primaryButton:J?{buttonType:"primary",onClick:()=>{W(void 0)},buttonText:"Add"}:te?{buttonType:"primary",onClick:()=>{oe(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(X=q.loading)&&void 0!==X&&X,onClick:()=>{var e,i,t,o,a;if(Qe(),ne.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=ne,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!q.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(He(r))return void qe(r);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:ne.title})}else{const s={invalidCouponTitle:!ne.title,inValidProbability:!q.hideProbability&&(null!==(e=ne.probability)&&void 0!==e?e:-1)<=0||(null!==(i=ne.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=ne.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!ne.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(ae!==n.BUY_X_GET_Y&&ce!==l.NA){const{minAmount:e,minQuantity:i}=ne;s.inValidMinimumAmount=ce===l.AMOUNT&&!e,s.inValidMinimumQuantity=ce===l.QUANTITY&&!i}if(we&&(s.inValidCouponExpiry=!ne.expireAt&&!ne.expireAfter),ae!==n.AMOUNT_OFF_ORDER&&ae!==n.AMOUNT_OFF_PRODUCTS||(pe!==r.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidProductSelection=!0,s.inValidProductVariableSelection=!0),pe===r.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidCollectionSelection=!0)),ae===n.BUY_X_GET_Y&&(ne.prerequisiteQuantity||(s.inValidBuyXValue=!0),ne.entitledQuantity||(s.inValidGetYValue=!0),Ce!==d.SPECIFIC_PRODUCTS||!Pe||Object.keys(Pe).length||ge||(s.inValidBuyXProductSelection=!0,s.inValidBuyXProductVariableSelection=!0),Ce===d.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(s.inValidBuyXCollectionSelection=!0),be!==d.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidGetYProductSelection=!0,s.inValidGetYProductVariableSelection=!0),be===d.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidGetYCollectionSelection=!0)),He(s))return void Ue(s);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked(Object.assign(Object.assign({},ne),{description:F(ne,q.currency,null!==(o=q.products)&&void 0!==o?o:[],null!==(a=q.collection)&&void 0!==a?a:[]),productsConf:{entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[]},collectionsConf:{entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=Oe?Oe:{},prerequisiteProductVariable:null!=ge?ge:{}}}))}}},secondaryButton:J?{buttonType:"tertiaryGray",onClick:()=>{W(void 0)},buttonText:"Back"}:te?{buttonType:"tertiaryGray",onClick:()=>{oe(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:q.onClose,buttonText:"Cancel"}},{children:[!J&&!te&&e.jsxs(A,{children:[q.allowStaticCoupon&&!J&&e.jsxs(D,Object.assign({selectedDiv:ne.isStaticCoupon?1:2},{children:["static"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{ne.isStaticCoupon||(le({isStaticCoupon:!0,quadrant:ne.quadrant}),ke(""),Qe())}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?P.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{color:P.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;ne.isStaticCoupon&&(se(n.AMOUNT_OFF_ORDER),le({isStaticCoupon:!1,quadrant:ne.quadrant,targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),ke(""),Qe(),Fe({id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i}},{children:q.currency||""}))}),Re(null!==(i=q.makeExpiryMandatory)&&void 0!==i&&i),ue(l.NA))}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?void 0:P.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{}:{color:P.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.jsx(y,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),ne.isStaticCoupon&&!J&&e.jsx(M,{discountData:ne,setDiscountData:le,hideProbability:q.hideProbability||!1,discountAdminUrl:q.discountAdminUrl,staticDiscountValidationError:Me,currency:q.currency}),!ne.isStaticCoupon&&!J&&!te&&e.jsx(w,{currency:q.currency,entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[],setEntitledProducts:fe,setPrerequisiteProducts:he,discountData:ne,productPickerOpen:J,productVariablePickerOpen:ee,setIsProductPickerOpen:W,setIsProductVariablePickerOpen:ie,setDiscountData:le,selectedCouponType:ae,setSelectedCouponType:se,selectedMinimumRequirement:ce,setSelectedMinimumRequirement:ue,discountCouponAppliesTo:pe,offerAppliesToBuy:Ce,offerAppliesToGet:be,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:me,setOfferAppliesToGet:ye,hideProbability:q.hideProbability||!1,hideExpiration:q.hideExpiration||!1,allowStaticCoupon:q.allowStaticCoupon,onChangeCouponType:Ke,collectionPickerOpen:te,entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:oe,setEntitledCollections:Ve,setPrerequisiteCollections:Ee,useNewPicker:!!q.newPickerConf,setSelectedDiscountDetails:Fe,selectedDiscountDetails:Ne,isProductVariableSupported:q.isProductVariableSupported,entitledProductVariable:Oe,setEntitledProductVariable:Se,preRequisiteProductVariable:ge,setPreRequisiteProductVariable:je,productVariableList:q.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:Re,dynamicDiscountValidationError:Le,setDynamicDiscountValidationError:Ue,setValidationErrorMessage:ke,resetValidationErrors:Qe,discountDetailsOptions:Z,selectedExpiration:Be,setSelectedExpiration:Ge,makeExpiryMandatory:!!q.makeExpiryMandatory})]}),!!J&&e.jsxs(e.Fragment,{children:[!q.newPickerConf&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(I,{show:!0,onSave:()=>{},products:null!==(Q=q.products)&&void 0!==Q?Q:[],title:"Select Products",onClose:()=>{W(void 0)},selectedProducts:null!==(H=J===R.ENTITLED?Ie:Pe)&&void 0!==H?H:[],setSelectedProducts:J===R.ENTITLED?fe:he,onSearchKeyChange:q.onProductSearch})})),q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>W(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.fetchCollections)?q.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=q.newPickerConf)||void 0===l?void 0:l.fetchProducts)?q.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:J===R.ENTITLED?Ie:Pe,onAdd:e=>{J===R.ENTITLED?fe(e):he(e),W(void 0)},zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=q.newPickerConf)||void 0===n?void 0:n.searchInCollection)?q.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.searchProducts)?q.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!te&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxs(e.Fragment,{children:[q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>oe(void 0),collectionFetcher:q.newPickerConf.fetchCollections,productFetcher:q.newPickerConf.fetchProducts,selectedItems:te===R.ENTITLED?xe:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),te===R.ENTITLED?Ve(e):Ee(e),oe(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:q.newPickerConf.searchInCollection,searchFetcher:q.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!q.newPickerConf&&e.jsx(I,{show:!0,onSave:()=>{},products:null!==(z=q.collection)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{oe(void 0)},selectedProducts:null!==(K=te===R.ENTITLED?xe:Te)&&void 0!==K?K:[],setSelectedProducts:te===R.ENTITLED?Ve:Ee,onSearchKeyChange:q.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),ee&&e.jsx(k,{children:e.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsx(_,{type:V.EMBEDDED,data:null!==($=q.productVariableList)&&void 0!==$?$:[],showHeader:!0,onSelect:e=>{if(ee===R.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Se({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}if(ee===R.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;je({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}},onClose:()=>{ie(void 0)}})}))})]}))};export{q as DiscountModal};
|
|
@@ -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,33 +1,21 @@
|
|
|
1
|
-
import e from"styled-components";import{COLORS as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
left: 0px;
|
|
6
|
-
top: 0px;
|
|
1
|
+
import e from"styled-components";import{COLORS as i}from"../../constants/Theme.js";const t=e.div`
|
|
2
|
+
position: ${e=>e.isChildLoading?"relative":"absolute"};
|
|
3
|
+
left: 0;
|
|
4
|
+
top: 0;
|
|
7
5
|
width: 100%;
|
|
8
6
|
height: 100%;
|
|
9
|
-
z-index:
|
|
10
|
-
cursor: ${e=>(null==e?void 0:e.disabled)?"not-allowed":"pointer"};
|
|
7
|
+
z-index: 2;
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
}
|
|
9
|
+
/* Overlay can still catch clicks */
|
|
10
|
+
pointer-events: auto;
|
|
23
11
|
|
|
24
|
-
|
|
25
|
-
background-color: ${e=>e.disabled?"transparent":"rgba(0, 0, 0, 0.04)"};
|
|
26
|
-
}
|
|
12
|
+
cursor: ${e=>(null==e?void 0:e.disabled)?"not-allowed":"pointer"};
|
|
27
13
|
|
|
28
|
-
/*
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
/* Let children handle hover, but not click */
|
|
15
|
+
& > * {
|
|
16
|
+
pointer-events: none; /* child won’t intercept clicks */
|
|
17
|
+
}
|
|
18
|
+
`,r=e.div`
|
|
31
19
|
margin-top: 8px;
|
|
32
20
|
margin-bottom: 8px;
|
|
33
21
|
`;e.div`
|
|
@@ -35,10 +23,10 @@ import e from"styled-components";import{COLORS as o}from"../../constants/Theme.j
|
|
|
35
23
|
flex-direction: row;
|
|
36
24
|
align-items: center;
|
|
37
25
|
padding: 6px 8px;
|
|
38
|
-
background: ${
|
|
39
|
-
border: 1px solid ${
|
|
26
|
+
background: ${i.surface.hovered};
|
|
27
|
+
border: 1px solid ${i.stroke.primary};
|
|
40
28
|
border-radius: 4px;
|
|
41
|
-
`;const
|
|
29
|
+
`;const o=e.div`
|
|
42
30
|
width: 360px;
|
|
43
31
|
height: 100%;
|
|
44
32
|
padding: 8px;
|
|
@@ -46,11 +34,11 @@ import e from"styled-components";import{COLORS as o}from"../../constants/Theme.j
|
|
|
46
34
|
justify-content: space-between;
|
|
47
35
|
align-items: center;
|
|
48
36
|
border-radius: 4px;
|
|
49
|
-
border: ${e=>e.error?`1px solid ${
|
|
37
|
+
border: ${e=>e.error?`1px solid ${i.stroke.negative.vibrant}`:`1px solid ${i.stroke.primary}`};
|
|
50
38
|
.chips-container {
|
|
51
39
|
display: flex;
|
|
52
40
|
gap: 8px;
|
|
53
41
|
flex-wrap: wrap;
|
|
54
42
|
align-items: center;
|
|
55
43
|
}
|
|
56
|
-
`;export{
|
|
44
|
+
`;export{o as ChipInputWrapper,r as OpenDropdownContainer,t as OverLapAbs};
|
|
@@ -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
|
-
import{__rest as o}from"../../../_virtual/_tslib.js";import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t,{useState as
|
|
1
|
+
import{__rest as o}from"../../../_virtual/_tslib.js";import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t,{useState as n,useRef as i,useImperativeHandle as l,useEffect as r}from"react";import{usePopper as s}from"react-popper";import{DropShadow as d}from"../../dropShadow/DropShadow.js";import{Tooltip as a}from"../../tooltips/Tooltip.js";import{OverLapAbs as p,OpenDropdownContainer as c}from"../Common.styled.js";import{OpenedDropdown as m}from"../OpenedDropdown/components/OpennedDropdown.js";const j=t.forwardRef(((t,j)=>{var{children:v,onDropdownVisbilityChange:u,version:h="1.0",tooltipContent:w,tooltipDirection:b,showTooltipArrow:g,isChildLoading:f}=t,x=o(t,["children","onDropdownVisbilityChange","version","tooltipContent","tooltipDirection","showTooltipArrow","isChildLoading"]);const D=j,[O,y]=n(!1),[C,S]=n(null),[z,A]=n(null),L=i(null),{styles:R,attributes:T}=s(C,z,{placement:x.placement,strategy:x.strategy}),_=o=>{var e,t;"2.0"===h&&x.isMultiSelect&&o&&(null===(e=x.onSelect)||void 0===e||e.call(x,[...o])),y(!1),null===(t=null==x?void 0:x.onClose)||void 0===t||t.call(x)};l(D,(()=>({openDropdown:O})),[]),r((()=>{(null==D?void 0:D.current)&&(D.current.openDropdown=O)}),[O]),r((()=>{null==u||u(O)}),[O]);const E=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",Object.assign({style:{position:"relative"},ref:S},{children:e.jsx(p,Object.assign({ref:L,allowEvents:x.allowEvents,disabled:x.disabled,onClick:o=>{var e;null===(e=x.onDropdownOpen)||void 0===e||e.call(x),O?(y(!1),o.preventDefault()):x.disabled||y(!0)},isChildLoading:f},{children:v}))})),O&&e.jsx(c,Object.assign({ref:A,style:Object.assign(Object.assign({},R.popper),{zIndex:3})},T.popper,{"data-test":x["data-test"]},{children:e.jsx(d,Object.assign({level:"z2",position:"down",style:{borderRadius:8}},{children:e.jsx(m,Object.assign({},x,{onSelect:o=>{var e;"2.0"===h&&x.isMultiSelect||(null===(e=x.onSelect)||void 0===e||e.call(x,o),y(!1))},onClose:_,version:h,headerRef:L,zeroState:null==x?void 0:x.zeroState}))}))}))]});return e.jsx(e.Fragment,{children:O||void 0===w?E():e.jsx(a,Object.assign({body:w,placement:b,hideArrow:!g},{children:e.jsx("div",Object.assign({"data-test":x["data-test"]},{children:E()}))}))})}));j.displayName="DropdownPopover";export{j as DropdownPopover};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"../../node_modules/react/jsx-runtime.js";import{DropdownPopover as t}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"react";import"../zeroState/ZeroState.js";import"../TypographyStyle.js";import"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import{Button as
|
|
1
|
+
import{j as o}from"../../node_modules/react/jsx-runtime.js";import{DropdownPopover as t}from"../dropdown/DropdownPopover/index.js";import"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"react";import"../zeroState/ZeroState.js";import"../TypographyStyle.js";import"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import{Button as n}from"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{SpinnerColorMap as r}from"../button/themes.js";import{Spinner as e}from"../spinner/Spinner.js";import{DropdownButtonStyle as s,LoaderContainer as p}from"./DropdownButton.style.js";const d=d=>{var i,m;return o.jsxs(s,Object.assign({type:d.buttonProps.buttonType,disabled:d.buttonProps.disabled},{children:[(null===(i=d.buttonProps)||void 0===i?void 0:i.isLoading)&&o.jsx(p,{children:o.jsx(e,{className:"spinner",size:"small",color:r(d.buttonProps.buttonType||"primary",d.buttonProps.inverse)})}),o.jsx(n,Object.assign({},d.buttonProps,{isLoading:!1,style:{borderRadius:"0px",borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",borderRight:"0px"}})),o.jsx("div",{className:"divider"}),o.jsx(t,Object.assign({},d.dropdownProps,{isChildLoading:null===(m=d.buttonProps)||void 0===m?void 0:m.isLoading},{children:o.jsx(n,Object.assign({},d.buttonProps,{isLoading:!1,buttonText:"",onClick:()=>{},TrailingIcon:d.iconProps,style:{borderRadius:"0px",borderTopRightRadius:"4px",borderBottomRightRadius:"4px"}}))}))]}))};export{d as DropdownButton};
|
|
@@ -9,6 +9,8 @@ import e from"styled-components";import{BASE_COLORS as t,COLORS as i}from"../../
|
|
|
9
9
|
height: 100%;
|
|
10
10
|
}
|
|
11
11
|
`,n=e.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 @@ import e from"styled-components";import{BASE_COLORS as t,COLORS as i}from"../../
|
|
|
16
18
|
width: 100%;
|
|
17
19
|
border-radius: 4px;
|
|
18
20
|
background: ${t.brand[50]};
|
|
19
|
-
z-index:
|
|
21
|
+
z-index: 3;
|
|
20
22
|
`;export{r as DropdownButtonStyle,n as LoaderContainer};
|
|
@@ -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
|
-
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useRef as r,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import l from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as h}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as C}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as x,selectedColectionsReducer as b,CollectionIdContext as f}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as k}from"./selectedScreen.js";import{ContainerStyle as v,ScrollContainerStyle as I,StyledFooterForNonModal as F}from"./style.js";import{OUT_OF_STOCK_ACTION as P,ScreenName as O}from"./type.js";import{updateAllVariantsForSelectedProducts as T}from"./utility.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=P.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,hideSelectionCount:G,title:K,width:N,left:U,renderWithoutModal:Y,onClickSave:_,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=O.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:se,secondaryButton:re,subtitle:ie}=D,ne=D.appType||t.BIK,[le,ae]=c(y,{}),[de,ue]=s([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections),[pe,he]=s("grid"),[me,ge]=s(""),[Ce,je]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Pe]=s(!1),[Oe,Te]=s(!1),[De,Re]=c(x,{collections:{},products:{}}),[we,Ae]=c(b,Object.keys(w).length>0?w:{}),Be=r(null),[Ee,Le]=s(!1),[ze,Ve]=s();i((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),i((()=>{let e=0;J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J]),i((()=>{Ce&&(fe(!0),D.productFetcher(Ce,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:Ce,products:e}}),fe(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Pe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Pe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),i((()=>{_&&(D.onAdd(we,Se),$e())}),[_]),i((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),$e())}),[Z,we,Se]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>L&&Se>L?e.jsx(h,{tagText:`You can only select ${L} products`,type:"negative"}):z&&Se>z?e.jsx(h,{tagText:`You can only select ${z} products`,type:"negative"}):Se>0?e.jsx(a,{onClick:()=>{ue(X?O.RearrangeProducts:O.SelectedProducts)},buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(a,{disabled:!0,buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:"tertiaryGray"}),He=e=>be?"Loading...":de===O.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e.jsxs(v,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(p,{size:"small",color:n.content.primary}):e.jsx(o,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(I,Object.assign({ref:Be,screenName:de},{children:["collections"===de&&e.jsx(m,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Oe,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:ge,setSelectedCollectionId:je,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:q,scrollContainerRef:Be}),"products"===de&&me&&e.jsx(f.Provider,Object.assign({value:me},{children:e.jsx(C,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,renderWithoutModal:Y,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Be})})),"view"===de&&e.jsx(k,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===pe?"list":"grid",scrollContainerRef:Be,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(S,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:$,hideProductVariants:J,hideVariantCheckbox:H,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:je,renderWithoutModal:Y,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return e.jsx(e.Fragment,{children:Y?e.jsxs(e.Fragment,{children:[We,ce.renderFooter?e.jsxs(F,{children:[Me(),e.jsx(a,{buttonText:He(ce.primaryButtonText),disabled:!ce.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&ze?e.jsx(g,{productData:ze,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(u,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),$e()},headingTitle:K||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:N||"600px",left:U||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:e.jsx(l,{width:20,height:20,color:n.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||e.disabled,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}}))(se):{buttonText:He(),disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{D.onAdd(we,Se),$e()}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{const e=T(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:G?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[We,Ee&&ze?e.jsx(g,{productData:ze,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
|
|
1
|
+
import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth/models/bik-store";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useRef as r,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import l from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as h}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as C}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as x,selectedColectionsReducer as b,CollectionIdContext as f}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as k}from"./selectedScreen.js";import{ContainerStyle as v,ScrollContainerStyle as I,StyledFooterForNonModal as F}from"./style.js";import{OUT_OF_STOCK_ACTION as P,ScreenName as O}from"./type.js";import{updateAllVariantsForSelectedProducts as T}from"./utility.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=P.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,hideSelectionCount:G,title:K,width:N,left:U,renderWithoutModal:Y,onClickSave:_,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=O.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:se,secondaryButton:re,subtitle:ie}=D,ne=D.appType||t.BIK,[le,ae]=c(y,{}),[de,ue]=s([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections),[pe,he]=s("grid"),[me,ge]=s(""),[Ce,je]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Pe]=s(!1),[Oe,Te]=s(!1),[De,Re]=c(x,{collections:{},products:{}}),[we,Ae]=c(b,Object.keys(w).length>0?w:{}),Be=r(null),[Ee,Le]=s(!1),[ze,Ve]=s();i((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),i((()=>{let e=0;J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J]),i((()=>{Ce&&(fe(!0),D.productFetcher(Ce,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:Ce,products:e}}),fe(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Pe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Pe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),i((()=>{_&&(D.onAdd(we,Se),$e())}),[_]),i((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),$e())}),[Z,we,Se]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>L&&Se>L?e.jsx(h,{tagText:`You can only select ${L} products`,type:"negative"}):z&&Se>z?e.jsx(h,{tagText:`You can only select ${z} products`,type:"negative"}):Se>0?e.jsx(a,{onClick:()=>{ue(X?O.RearrangeProducts:O.SelectedProducts)},buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(a,{disabled:!0,buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:"tertiaryGray"}),He=e=>be?"Loading...":de===O.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e.jsxs(v,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(p,{size:"small",color:n.content.primary}):e.jsx(o,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(I,Object.assign({ref:Be,screenName:de},{children:["collections"===de&&e.jsx(m,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Oe,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:ge,setSelectedCollectionId:je,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:q,scrollContainerRef:Be}),"products"===de&&me&&e.jsx(f.Provider,Object.assign({value:me},{children:e.jsx(C,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,renderWithoutModal:Y,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Be})})),"view"===de&&e.jsx(k,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===pe?"list":"grid",scrollContainerRef:Be,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(S,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:$,hideProductVariants:J,hideVariantCheckbox:H,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:je,renderWithoutModal:Y,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return e.jsx(e.Fragment,{children:Y?e.jsxs(e.Fragment,{children:[We,ce.renderFooter?e.jsxs(F,{children:[Me(),e.jsx(a,{buttonText:He(ce.primaryButtonText),disabled:!ce.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&ze?e.jsx(g,{productData:ze,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(u,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),$e()},headingTitle:K||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:N||"600px",left:U||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:e.jsx(l,{width:20,height:20,color:n.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||e.disabled,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}}))(se):{buttonText:He(),disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{D.onAdd(we,Se),$e()}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{const e=T(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:G?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[We,Ee&&ze?e.jsx(g,{productData:ze,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
|