@bikdotai/bik-component-library 0.0.690 → 0.0.692
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/_virtual/billing.js +1 -0
- package/dist/cjs/_virtual/index.js +1 -0
- package/dist/cjs/_virtual/store.js +1 -0
- package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.d.ts +1 -1
- package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.js +1 -1
- package/dist/cjs/components/data-source-panel/DataSourcePanel.d.ts +1 -1
- package/dist/cjs/components/data-source-panel/DataSourcePanel.js +1 -1
- package/dist/cjs/components/discount-modal/DiscountModal.d.ts +1 -1
- package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
- package/dist/cjs/components/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/context/templateModalContext.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/cjs/node_modules/@bikdotai/bik-models/growth/index.js +1 -0
- package/dist/cjs/node_modules/@bikdotai/bik-models/growth/models/billing.js +1 -0
- package/dist/cjs/node_modules/@bikdotai/bik-models/growth/models/store.js +1 -0
- package/dist/esm/_virtual/billing.js +1 -0
- package/dist/esm/_virtual/index.js +1 -0
- package/dist/esm/_virtual/store.js +1 -0
- package/dist/esm/components/data-source-panel/DataSourceInfoFooter.d.ts +1 -1
- package/dist/esm/components/data-source-panel/DataSourceInfoFooter.js +1 -1
- package/dist/esm/components/data-source-panel/DataSourcePanel.d.ts +1 -1
- package/dist/esm/components/data-source-panel/DataSourcePanel.js +1 -1
- package/dist/esm/components/discount-modal/DiscountModal.d.ts +1 -1
- package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
- package/dist/esm/components/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/context/templateModalContext.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/dist/esm/node_modules/@bikdotai/bik-models/growth/index.js +1 -0
- package/dist/esm/node_modules/@bikdotai/bik-models/growth/models/billing.js +1 -0
- package/dist/esm/node_modules/@bikdotai/bik-models/growth/models/store.js +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as o,jsxs as t}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/
|
|
1
|
+
import{jsx as e,Fragment as o,jsxs as t}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import i from"../../assets/icons/alert_triangle.svg.js";import n from"../../assets/icons/plus.svg.js";import{memo as r,useState as a,useMemo as s,useEffect as d}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as c}from"../button/Button.js";import{BikShimmer as u}from"../shimmer/ShimmerComponent/BikShimmer.js";import{BodyCaption as p}from"../TypographyStyle.js";import{SourceInfoFooterStyle as h}from"./DataSourcePanel.style.js";import{__exports as m}from"../../_virtual/index.js";const v=r((r=>{const{appType:v,sourceIntent:b,hideHeading:A,messageSource:y,trainingSourceCount:f={},ShowTrainingDataSource:_={},faqCount:I,ChecklistType:R,footerButtonOption:O,isFooterLoading:w,reasonForAiGeneratedResponse:N,showAiResponseReason:k}=r,C=_,[F,j]=a(!0),[D,E]=a(!0),S="/bik-ai/training",[x,P]=a({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[U,M]=a({title:"",subTitle:""}),q=s((()=>{const e=(null==f?void 0:f[b])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[f,b]),L=()=>{var e;(null==x?void 0:x.redirectUrl)?window.open(`${window.location.origin}${null==x?void 0:x.redirectUrl}`,"_self"):Object.keys(null!==(e=null==x?void 0:x.addFaqProps)&&void 0!==e?e:{}).length>0?null==O||O.onClick(x):(null==O?void 0:O.navigate)&&(null==O||O.navigate("Training",v==m.ApplicationType.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return d((()=>{var e,o,t,i;if(b){if(null===(e=null==y?void 0:y.sources)||void 0===e?void 0:e.length){const e=y.sources[0];if(C[b])b===R.ORDER_ENQUIRY&&E(!1);else{let n=null==e?void 0:e.insights,r="";switch(b){case R.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(n=`${I||"No"} FAQs added for this product`,r="Add product-specific information via FAQs to improve responses",P({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 R.ORDER_MODIFICATION:n=(null==f?void 0:f[b])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",n&&P({buttonTitle:v==m.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:v==m.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":S,addFaqProps:{}});break;case R.ORDER_CANCELLATION:n=(null==f?void 0:f[b])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",P({buttonTitle:v==m.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:v==m.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":S,addFaqProps:{}});break;case R.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;P({buttonTitle:v==m.ApplicationType.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:v==m.ApplicationType.MANIFEST?"/training/order-management":S,addFaqProps:{}});break;case R.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(i=null===(t=null===(o=null==y?void 0:y.sources)||void 0===o?void 0:o[0])||void 0===t?void 0:t.title)||void 0===i?void 0:i.toLowerCase().indexOf("collection"))){n="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}n="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}M({title:null!=n?n:"",subTitle:r})}}(C[b]||[R.PRODUCT_DETAILS,R.ORDER_MODIFICATION,R.ORDER_CANCELLATION,R.ORDER_TRACKING].includes(b))&&j(!1)}}),[null==y?void 0:y.messageId,f,b,null==y?void 0:y.sources,C,R,I,v,y]),e(h,{children:e(o,w?{children:e(u,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}:{children:!(null==U?void 0:U.title)&&f&&b in f?t(o,{children:[e(g,{hideHeading:null!=A&&A}),e(T,{reason:N||"",showAiResponseReason:null!=k&&k}),t("div",Object.assign({className:"source_info_details "+(f[b]>0?"":"no_data_source")},{children:[f[b]>0&&D?t(o,{children:[e(p,{children:q}),e(p,Object.assign({color:l.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):D&&t("div",Object.assign({className:"no_data_source_title"},{children:[e(i,{width:15,height:15,color:l.content.negative,style:{marginTop:2}}),e(p,{children:"No data sources added to the identified link"})]})),!O||O.hideAddDataButton||F?e(o,{}):e(c,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==x?void 0:x.buttonTitle.length)>0?null==x?void 0:x.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>L(),style:{backgroundColor:"unset"}})]}))]}):t(o,{children:[e(g,{hideHeading:null!=A&&A}),e(T,{reason:N||"",showAiResponseReason:null!=k&&k}),t("div",Object.assign({className:"source_info_details"},{children:[D&&t(o,{children:[e(p,{children:null==U?void 0:U.title}),e(p,Object.assign({color:l.content.secondary},{children:null==U?void 0:U.subTitle}))]}),!O||O.hideAddDataButton||F?e(o,{}):e(c,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==x?void 0:x.buttonTitle.length)>0?null==x?void 0:x.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>L(),style:{backgroundColor:"unset"}})]}))]})})})})),g=r((o=>o.hideHeading?null:e(p,Object.assign({color:l.content.secondary},{children:"Training insights"})))),T=r((i=>{const[n,r]=a(!1),s=i.reason&&i.reason.length>50,d=s&&!n?i.reason.substring(0,50)+"...":i.reason;return i.showAiResponseReason?t("div",Object.assign({className:"source_info_details"},{children:[e(p,Object.assign({color:l.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),t(p,Object.assign({color:l.content.secondary,className:"clamp-text"},{children:[d||"No reason provided for this response.",s&&e(p,Object.assign({color:l.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>r(!n)},{children:n?"Show less":"Show more"}))]}))]})):e(o,{})}));T.displayName="WhyAiGaveThisResponse",g.displayName="TrainingInsightsHeading",v.displayName="SourceInfoFooter";export{v 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';
|
|
3
3
|
import { AllSourceInfoDetailsCustomDataModel, CustomDataType, DataSourcePanelZeroState, footerButtonOptionModel, InfoContent, MessageSource, ProductSourceData } from './model';
|
|
4
4
|
export interface CollapsibleSectionProps {
|
|
5
5
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/models/bik-store.js";import o from"../../assets/icons/boxV2.svg.js";import n from"../../assets/icons/chevronDownOutline.svg.js";import s from"../../assets/icons/chevronUpOutline.svg.js";import l from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/edit.svg.js";import a from"../../assets/icons/filePdf.svg.js";import c 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 h from"../../assets/icons/text_t9.svg.js";import m from"../../assets/icons/website.svg.js";import{useState as f,useMemo as v,useEffect as y}from"react";import{COLORS as x}from"../../constants/Theme.js";import{Button as C}from"../button/Button.js";import{IconButton as I}from"../icon-button/IconButton.js";import{BikShimmer as b}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as T}from"../side-modal/SideModal.js";import{Tag as j}from"../tag/Tag.js";import{Tooltip as O}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as S,BodySecondary as L}from"../TypographyStyle.js";import w from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as N}from"./DataSourcePanel.style.js";import{intentConfig as A}from"./IntentConfig.js";import{DescriptionModal as _}from"./Modals/DescriptionModal.js";import{CustomDataType as D}from"./model.js";import{__exports as k}from"../../_virtual/bik-store.js";const F=F=>{var R,B;const{appType:P,storeId:U,messageSource:K,setMessageSourcePanel:M,hideCloseButton:W,isSourceInfoFetched:H,allSourceInfoDetail:$,ChecklistType:q,title:Q,zeroStateButton:G,editableSources:Y,preFillTrainingSourceCount:z,redirect:X,footerButtonOption:V,fetchTrainingSourceCount:J,fetchProductFAQCount:Z,productSourceData:ee,reasonForAiGeneratedResponse:te,showAiResponseReason:ie}=F,{sources:oe}=K,ne=["blog","article","page","policy"],[se,le]=f(!1),[re,ae]=f(!1),[ce,de]=f(!1),[pe,ue]=f(0),[ge,he]=f(),[me,fe]=f(null!=z?z:{}),[ve,ye]=f(!1),[xe,Ce]=f(!1),Ie={};A.forEach((t=>{let{key:i,type:o,tagText:n}=t;q[i]&&(Ie[q[i]]=e(j,{theme:"light",type:o,tagText:n,cursor:"pointer"}))}));const be=oe.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Te=oe.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),je=v((()=>{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=>{q[t]&&(e[q[t]]=q[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[q]);y((()=>{var e,t,i,o;if(!(null==K?void 0:K.messageId))return;le(!0),ae(!0),de(!1!==(null===(t=null===(e=K.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=K.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights));const n=K.sources.filter((e=>!!e.productId)).map((e=>e.productId)),s=Array.from(new Set(n)).filter((e=>!!e));Z(U,s).then((e=>ue(e))).then((()=>{z?(fe(z),setTimeout((()=>{le(!1),ae(!1)}),100)):(setTimeout((()=>le(!1)),100),J(U).then((e=>fe(e))).then((()=>setTimeout((()=>{ae(!1)}),100))))}))}),[Z,J,null==K?void 0:K.messageId,K.sources,z,U]);const Oe=e=>!!(e&&0===e.length||(null==K?void 0:K.isUnsatisfactoryAnswer)),Ee=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=D.FILES:ne.includes(e)?e=D.FETCHED_LINKS:"url"==e?e=D.WEBSITE_LINKS:"text"===e?e=D.TEXTS:"faq"===e&&(e=D.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.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=>e("products"==t||"product"==t?o:"files"==t?a:"website links"==t||"fetched links"==t?m:"faq"==t?c:"texts"==t?h:p,{height:16,width:16,color:x.content.secondary}),we=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),i=document.createElement("textarea");return i.innerHTML=t,i.value};if(se||!H)return e(N,{children:e(b,{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 Ne=o=>{const{title:l,count:r,isExpanded:a,onToggle:c,children:d}=o;return t("div",{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e(S,Object.assign({style:{fontWeight:"600"}},{children:l})),P===k.ApplicationType.MANIFEST?e("div",Object.assign({style:{backgroundColor:x.surface.subdued,color:x.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e(i,{})]})),e(i,{children:P===k.ApplicationType.BIK?e(i,{}):e(a?n:s,{width:20,height:20,color:x.content.primary})})]})),a&&d]})};return t(i,{children:[e(N,{children:t(i,{children:[t("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!Q&&e(E,{children:Q}),t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(S,Object.assign({color:x.content.secondary},{children:"Intent"})),null!==(R=Ie[K.intent])&&void 0!==R?R:Ie.GENERIC,!W&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>M(void 0)},{children:e(l,{height:20,width:20,color:x.content.secondary})}))]})),Oe(oe)?e("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var i,o;return t("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${x.background.negative.light}`,borderRadius:"100px"}},{children:e(d,{width:24,height:24,color:x.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(E,{children:"Insufficient data"})})),e(L,Object.assign({color:x.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"})),G&&e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(C,{LeadingIcon:null!==(i=G.leadingIcon)&&void 0!==i?i:u,buttonText:null!==(o=G.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{G.onClick()}})}))]}))})()})):e(j,{LeadingIcon:d,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:K.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${P===k.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Oe(oe)&&t("div",Object.assign({className:"info-container"},{children:[e(i,{children:be.length>0&&e("div",Object.assign({className:"info-product-source"},{children:e(Ne,Object.assign({title:"Product Sources",count:be.length,isExpanded:P!==k.ApplicationType.MANIFEST||ve,onToggle:()=>ye(!ve)},{children:e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:be.map(((o,n)=>{var s,l,a,c;const d=Ee(o.type||o.subTitle||"OpenAI"),p=Ee(o.type||o.subTitle||"OpenAI",!0),u=Se(d),h=null==Y?void 0:Y.includes(p),m=$[null!==(s=o.productId)&&void 0!==s?s:"Products"],f=o.title,v=o.productId&&(null==ee?void 0:ee[o.productId]),y=v&&v.metafield.join(", ");return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<(null==be?void 0:be.length)?`1px solid ${x.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(d),e(O,Object.assign({body:f,placement:"top"},{children:e(L,Object.assign({style:p==D.FETCHED_LINKS||p==D.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:x.content.primary,className:"clamp-title",onClick:()=>p==D.FETCHED_LINKS||p==D.WEBSITE_LINKS?X(o):{}},{children:f}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==q.EMAIL_COLLECTION&&e(i,{children:e(S,Object.assign({color:x.content.secondary},{children:u}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(I,h?{Icon:r,height:16,width:16,iconColor:x.content.secondary,onClick:()=>null==m?void 0:m.onEditClick(m.data,m.type),disabled:!m,disabledTooltip:"This source is deleted"}:{Icon:g,height:16,width:16,iconColor:x.content.secondary,disabled:"custom"===o.type&&!m,disabledTooltip:"This source is deleted",onClick:()=>X(o)})}))]}))]})),v&&t(S,{children:[e("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;he({title:f,description:we(v.description),imageUrl:null!==(e=o.imageUrl)&&void 0!==e?e:"",onClose:()=>he(void 0)})}},{children:`${null===(l=v.description)||void 0===l?void 0:l.length} characters description,`})),e("span",Object.assign({className:"product-data-text1",onClick:()=>v.onEditFaqClick(v.faqs)},{children:`${null===(a=v.faqs)||void 0===a?void 0:a.length} FAQs, `})),e("span",Object.assign({className:"product-data-text2"},{children:"and"})),e(O,Object.assign({body:y,placement:"top"},{children:e("span",Object.assign({className:"product-data-text1"},{children:`${null===(c=v.metafield)||void 0===c?void 0:c.length} metafields`}))}))]})]}),`info-${n}`)}))}))}))}))}),e(i,{children:Te.length>0&&e("div",Object.assign({className:"info-content-source"},{children:e(Ne,Object.assign({title:"Content Sources",count:Te.length,isExpanded:P!==k.ApplicationType.MANIFEST||xe,onToggle:()=>Ce(!xe)},{children:e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Te.map(((o,n)=>{var s,l,a,c,d,p,u,h,m,f,v,y,C,b,T,j,E;const w=Ee(o.type||o.subTitle||"OpenAI"),N=Ee(o.type||o.subTitle||"OpenAI",!0),A=Se(w),_=null==Y?void 0:Y.includes(N),k="Products"===o.subTitle?$[null!==(s=o.productId)&&void 0!==s?s:"Products"]:$[null!==(l=o.docId)&&void 0!==l?l:""],F=N.toLowerCase()===(null===(a=D.FAQ)||void 0===a?void 0:a.toLowerCase())?"faq"===(null===(c=o.title)||void 0===c?void 0:c.toLowerCase())?o.subTitle:o.title:N.toLowerCase()===(null===(d=D.FILES)||void 0===d?void 0:d.toLowerCase())||N.toLowerCase()===(null===(p=D.FETCHED_LINKS)||void 0===p?void 0:p.toLowerCase())||N.toLowerCase()===(null===(u=D.TEXTS)||void 0===u?void 0:u.toLowerCase())?o.title:N.toLowerCase()===(null===(h=D.WEBSITE_LINKS)||void 0===h?void 0:h.toLowerCase())?o.title.split("/")[o.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):o.intent===q.EMAIL_COLLECTION?A:o.title,R="faq"===N.toLowerCase()?null!==(v=null!==(m=null==k?void 0:k.content)&&void 0!==m?m:null===(f=null==k?void 0:k.data)||void 0===f?void 0:f.answer)&&void 0!==v?v:"":N.toLowerCase()===(null===(y=D.FETCHED_LINKS)||void 0===y?void 0:y.toLowerCase())||N.toLowerCase()===(null===(C=D.WEBSITE_LINKS)||void 0===C?void 0:C.toLowerCase())||N.toLowerCase()===(null===(b=D.TEXTS)||void 0===b?void 0:b.toLowerCase())?null!==(E=null!==(T=null==k?void 0:k.content)&&void 0!==T?T:null===(j=null==k?void 0:k.data)||void 0===j?void 0:j.fileContentText)&&void 0!==E?E:"":o.intent===q.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<(null==Te?void 0:Te.length)?`1px solid ${x.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(w),e(O,Object.assign({body:F,placement:"top"},{children:e(L,Object.assign({style:N==D.FETCHED_LINKS||N==D.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:x.content.primary,className:"clamp-title",onClick:()=>N==D.FETCHED_LINKS||N==D.WEBSITE_LINKS?X(o):{}},{children:F}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==q.EMAIL_COLLECTION&&e(i,{children:e(S,Object.assign({color:x.content.secondary},{children:A}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(I,_?{Icon:r,height:16,width:16,iconColor:x.content.secondary,onClick:()=>null==k?void 0:k.onEditClick(k.data,k.type),disabled:!k,disabledTooltip:"This source is deleted"}:{Icon:g,height:16,width:16,iconColor:x.content.secondary,disabled:"custom"===o.type&&!k,disabledTooltip:"This source is deleted",onClick:()=>X(o)})}))]}))]})),(null!=R?R:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${x.stroke.primary}`,borderRadius:"4px",backgroundColor:x.surface.subdued}},{children:e(S,Object.assign({color:x.content.primary,className:"clamp-description"},{children:we(null!=R?R:"").trim()}))}))]}),`info-${n}`)}))}))}))}))})]})),ce&&!Oe(oe)&&e("div",Object.assign({className:"footer"},{children:e(w,{appType:P,storeId:U,messageSource:K,sourceIntent:null!==(B=K.intent)&&void 0!==B?B:q.GENERIC,faqCount:pe,trainingSourceCount:me,ShowTrainingDataSource:je,ChecklistType:q,footerButtonOption:V,isFooterLoading:re,reasonForAiGeneratedResponse:te,showAiResponseReason:ie})}))]})}),ge&&e(T,Object.assign({header:"Product description",onClose:()=>he(void 0),width:"30%"},{children:e(_,{title:ge.title,description:ge.description,imageUrl:ge.imageUrl,onClose:ge.onClose})}))]})};export{F as DataSourcePanel};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import o from"../../assets/icons/boxV2.svg.js";import n from"../../assets/icons/chevronDownOutline.svg.js";import s from"../../assets/icons/chevronUpOutline.svg.js";import l from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/edit.svg.js";import a from"../../assets/icons/filePdf.svg.js";import c 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 h from"../../assets/icons/text_t9.svg.js";import m from"../../assets/icons/website.svg.js";import{useState as f,useMemo as v,useEffect as y}from"react";import{COLORS as x}from"../../constants/Theme.js";import{Button as C}from"../button/Button.js";import{IconButton as I}from"../icon-button/IconButton.js";import{BikShimmer as b}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as T}from"../side-modal/SideModal.js";import{Tag as j}from"../tag/Tag.js";import{Tooltip as O}from"../tooltips/Tooltip.js";import{TitleSmall as E,BodyCaption as S,BodySecondary as L}from"../TypographyStyle.js";import w from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as N}from"./DataSourcePanel.style.js";import{intentConfig as A}from"./IntentConfig.js";import{DescriptionModal as _}from"./Modals/DescriptionModal.js";import{CustomDataType as D}from"./model.js";import{__exports as k}from"../../_virtual/index.js";const F=F=>{var R,B;const{appType:P,storeId:U,messageSource:K,setMessageSourcePanel:M,hideCloseButton:W,isSourceInfoFetched:H,allSourceInfoDetail:$,ChecklistType:q,title:Q,zeroStateButton:G,editableSources:Y,preFillTrainingSourceCount:z,redirect:X,footerButtonOption:V,fetchTrainingSourceCount:J,fetchProductFAQCount:Z,productSourceData:ee,reasonForAiGeneratedResponse:te,showAiResponseReason:ie}=F,{sources:oe}=K,ne=["blog","article","page","policy"],[se,le]=f(!1),[re,ae]=f(!1),[ce,de]=f(!1),[pe,ue]=f(0),[ge,he]=f(),[me,fe]=f(null!=z?z:{}),[ve,ye]=f(!1),[xe,Ce]=f(!1),Ie={};A.forEach((t=>{let{key:i,type:o,tagText:n}=t;q[i]&&(Ie[q[i]]=e(j,{theme:"light",type:o,tagText:n,cursor:"pointer"}))}));const be=oe.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Te=oe.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),je=v((()=>{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=>{q[t]&&(e[q[t]]=q[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[q]);y((()=>{var e,t,i,o;if(!(null==K?void 0:K.messageId))return;le(!0),ae(!0),de(!1!==(null===(t=null===(e=K.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(o=null===(i=K.sources)||void 0===i?void 0:i[0])||void 0===o?void 0:o.insights));const n=K.sources.filter((e=>!!e.productId)).map((e=>e.productId)),s=Array.from(new Set(n)).filter((e=>!!e));Z(U,s).then((e=>ue(e))).then((()=>{z?(fe(z),setTimeout((()=>{le(!1),ae(!1)}),100)):(setTimeout((()=>le(!1)),100),J(U).then((e=>fe(e))).then((()=>setTimeout((()=>{ae(!1)}),100))))}))}),[Z,J,null==K?void 0:K.messageId,K.sources,z,U]);const Oe=e=>!!(e&&0===e.length||(null==K?void 0:K.isUnsatisfactoryAnswer)),Ee=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=D.FILES:ne.includes(e)?e=D.FETCHED_LINKS:"url"==e?e=D.WEBSITE_LINKS:"text"===e?e=D.TEXTS:"faq"===e&&(e=D.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.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=>e("products"==t||"product"==t?o:"files"==t?a:"website links"==t||"fetched links"==t?m:"faq"==t?c:"texts"==t?h:p,{height:16,width:16,color:x.content.secondary}),we=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),i=document.createElement("textarea");return i.innerHTML=t,i.value};if(se||!H)return e(N,{children:e(b,{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 Ne=o=>{const{title:l,count:r,isExpanded:a,onToggle:c,children:d}=o;return t("div",{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[t("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e(S,Object.assign({style:{fontWeight:"600"}},{children:l})),P===k.ApplicationType.MANIFEST?e("div",Object.assign({style:{backgroundColor:x.surface.subdued,color:x.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e(i,{})]})),e(i,{children:P===k.ApplicationType.BIK?e(i,{}):e(a?n:s,{width:20,height:20,color:x.content.primary})})]})),a&&d]})};return t(i,{children:[e(N,{children:t(i,{children:[t("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!Q&&e(E,{children:Q}),t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e(S,Object.assign({color:x.content.secondary},{children:"Intent"})),null!==(R=Ie[K.intent])&&void 0!==R?R:Ie.GENERIC,!W&&e("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>M(void 0)},{children:e(l,{height:20,width:20,color:x.content.secondary})}))]})),Oe(oe)?e("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var i,o;return t("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${x.background.negative.light}`,borderRadius:"100px"}},{children:e(d,{width:24,height:24,color:x.stroke.negative.vibrant})})),e("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e(E,{children:"Insufficient data"})})),e(L,Object.assign({color:x.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"})),G&&e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(C,{LeadingIcon:null!==(i=G.leadingIcon)&&void 0!==i?i:u,buttonText:null!==(o=G.title)&&void 0!==o?o:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{G.onClick()}})}))]}))})()})):e(j,{LeadingIcon:d,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:K.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${P===k.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Oe(oe)&&t("div",Object.assign({className:"info-container"},{children:[e(i,{children:be.length>0&&e("div",Object.assign({className:"info-product-source"},{children:e(Ne,Object.assign({title:"Product Sources",count:be.length,isExpanded:P!==k.ApplicationType.MANIFEST||ve,onToggle:()=>ye(!ve)},{children:e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:be.map(((o,n)=>{var s,l,a,c;const d=Ee(o.type||o.subTitle||"OpenAI"),p=Ee(o.type||o.subTitle||"OpenAI",!0),u=Se(d),h=null==Y?void 0:Y.includes(p),m=$[null!==(s=o.productId)&&void 0!==s?s:"Products"],f=o.title,v=o.productId&&(null==ee?void 0:ee[o.productId]),y=v&&v.metafield.join(", ");return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<(null==be?void 0:be.length)?`1px solid ${x.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(d),e(O,Object.assign({body:f,placement:"top"},{children:e(L,Object.assign({style:p==D.FETCHED_LINKS||p==D.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:x.content.primary,className:"clamp-title",onClick:()=>p==D.FETCHED_LINKS||p==D.WEBSITE_LINKS?X(o):{}},{children:f}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==q.EMAIL_COLLECTION&&e(i,{children:e(S,Object.assign({color:x.content.secondary},{children:u}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(I,h?{Icon:r,height:16,width:16,iconColor:x.content.secondary,onClick:()=>null==m?void 0:m.onEditClick(m.data,m.type),disabled:!m,disabledTooltip:"This source is deleted"}:{Icon:g,height:16,width:16,iconColor:x.content.secondary,disabled:"custom"===o.type&&!m,disabledTooltip:"This source is deleted",onClick:()=>X(o)})}))]}))]})),v&&t(S,{children:[e("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;he({title:f,description:we(v.description),imageUrl:null!==(e=o.imageUrl)&&void 0!==e?e:"",onClose:()=>he(void 0)})}},{children:`${null===(l=v.description)||void 0===l?void 0:l.length} characters description,`})),e("span",Object.assign({className:"product-data-text1",onClick:()=>v.onEditFaqClick(v.faqs)},{children:`${null===(a=v.faqs)||void 0===a?void 0:a.length} FAQs, `})),e("span",Object.assign({className:"product-data-text2"},{children:"and"})),e(O,Object.assign({body:y,placement:"top"},{children:e("span",Object.assign({className:"product-data-text1"},{children:`${null===(c=v.metafield)||void 0===c?void 0:c.length} metafields`}))}))]})]}),`info-${n}`)}))}))}))}))}),e(i,{children:Te.length>0&&e("div",Object.assign({className:"info-content-source"},{children:e(Ne,Object.assign({title:"Content Sources",count:Te.length,isExpanded:P!==k.ApplicationType.MANIFEST||xe,onToggle:()=>Ce(!xe)},{children:e("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Te.map(((o,n)=>{var s,l,a,c,d,p,u,h,m,f,v,y,C,b,T,j,E;const w=Ee(o.type||o.subTitle||"OpenAI"),N=Ee(o.type||o.subTitle||"OpenAI",!0),A=Se(w),_=null==Y?void 0:Y.includes(N),k="Products"===o.subTitle?$[null!==(s=o.productId)&&void 0!==s?s:"Products"]:$[null!==(l=o.docId)&&void 0!==l?l:""],F=N.toLowerCase()===(null===(a=D.FAQ)||void 0===a?void 0:a.toLowerCase())?"faq"===(null===(c=o.title)||void 0===c?void 0:c.toLowerCase())?o.subTitle:o.title:N.toLowerCase()===(null===(d=D.FILES)||void 0===d?void 0:d.toLowerCase())||N.toLowerCase()===(null===(p=D.FETCHED_LINKS)||void 0===p?void 0:p.toLowerCase())||N.toLowerCase()===(null===(u=D.TEXTS)||void 0===u?void 0:u.toLowerCase())?o.title:N.toLowerCase()===(null===(h=D.WEBSITE_LINKS)||void 0===h?void 0:h.toLowerCase())?o.title.split("/")[o.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):o.intent===q.EMAIL_COLLECTION?A:o.title,R="faq"===N.toLowerCase()?null!==(v=null!==(m=null==k?void 0:k.content)&&void 0!==m?m:null===(f=null==k?void 0:k.data)||void 0===f?void 0:f.answer)&&void 0!==v?v:"":N.toLowerCase()===(null===(y=D.FETCHED_LINKS)||void 0===y?void 0:y.toLowerCase())||N.toLowerCase()===(null===(C=D.WEBSITE_LINKS)||void 0===C?void 0:C.toLowerCase())||N.toLowerCase()===(null===(b=D.TEXTS)||void 0===b?void 0:b.toLowerCase())?null!==(E=null!==(T=null==k?void 0:k.content)&&void 0!==T?T:null===(j=null==k?void 0:k.data)||void 0===j?void 0:j.fileContentText)&&void 0!==E?E:"":o.intent===q.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:n+1<(null==Te?void 0:Te.length)?`1px solid ${x.stroke.primary}`:"none"}},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[t("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Le(w),e(O,Object.assign({body:F,placement:"top"},{children:e(L,Object.assign({style:N==D.FETCHED_LINKS||N==D.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:x.content.primary,className:"clamp-title",onClick:()=>N==D.FETCHED_LINKS||N==D.WEBSITE_LINKS?X(o):{}},{children:F}))}))]})),t("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[o.intent!==q.EMAIL_COLLECTION&&e(i,{children:e(S,Object.assign({color:x.content.secondary},{children:A}))}),(o.link||o.docId)&&e("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:e(I,_?{Icon:r,height:16,width:16,iconColor:x.content.secondary,onClick:()=>null==k?void 0:k.onEditClick(k.data,k.type),disabled:!k,disabledTooltip:"This source is deleted"}:{Icon:g,height:16,width:16,iconColor:x.content.secondary,disabled:"custom"===o.type&&!k,disabledTooltip:"This source is deleted",onClick:()=>X(o)})}))]}))]})),(null!=R?R:"").trim()&&e("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${x.stroke.primary}`,borderRadius:"4px",backgroundColor:x.surface.subdued}},{children:e(S,Object.assign({color:x.content.primary,className:"clamp-description"},{children:we(null!=R?R:"").trim()}))}))]}),`info-${n}`)}))}))}))}))})]})),ce&&!Oe(oe)&&e("div",Object.assign({className:"footer"},{children:e(w,{appType:P,storeId:U,messageSource:K,sourceIntent:null!==(B=K.intent)&&void 0!==B?B:q.GENERIC,faqCount:pe,trainingSourceCount:me,ShowTrainingDataSource:je,ChecklistType:q,footerButtonOption:V,isFooterLoading:re,reasonForAiGeneratedResponse:te,showAiResponseReason:ie})}))]})}),ge&&e(T,Object.assign({header:"Product description",onClose:()=>he(void 0),width:"30%"},{children:e(_,{title:ge.title,description:ge.description,imageUrl:ge.imageUrl,onClose:ge.onClose})}))]})};export{F as DataSourcePanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
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{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/models/bik-store.js";import{useState as o,useEffect as n}from"react";import{DISCOUNT_TYPES as l,MIN_PURCHASE_REQUIREMENT as r,DISCOUNT_APPLIES_TO as d,OFFER_APPLIES_TO as a,initialStaticCouponErrorState as c,initialDynamicCouponErrorState as s,COUPON_EXPIRATION as u,DISCOUNT_TARGET_TYPES as p,DISCOUNT_TARGET_SELECTION as v,DISCOUNT_VALUE_TYPES as C}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as b}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as m,BodyCaption as y,TitleRegular as P}from"../TypographyStyle.js";import{DEFAULT_THEME as h}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 I}from"../modals/styledModal.js";import{ProductPickerContent as f}from"../product-picker/ProductPickerModal.js";import{Tag as T}from"../tag/Tag.js";import{Tooltip as E}from"../tooltips/Tooltip.js";import O from"../../assets/icons/gift_icon.svg.js";import S from"../../assets/icons/percentage_icon.svg.js";import g from"../../assets/icons/shipping_icon.svg.js";import _ from"../../assets/icons/triangle_error.svg.js";import V from"../../assets/icons/warning.svg.js";import{ProductPickerModal as A}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as D}from"../variable-picker-v3/model.js";import{VariablePicker as j}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as k,CouponTypeContainerStyled as N,VariablePickerContainer as x}from"./DiscountModal.styled.js";import{validateDiscountData as F,descriptionBuilder as w}from"./DiscountUtils.js";import R,{DISCOUNT_PRODUCTS as M}from"./DynamicCoupon/DynamicCoupon.js";import q from"./StaticCoupon/StaticCoupon.js";import{__exports as L}from"../../_virtual/bik-store.js";const U=U=>{var B,G,Y,X,Q,H,z,K,$,Z,J;const W=[{id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:U.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e(S,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:l.BUY_X_GET_Y,icon:i=>e(O,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:l.FREE_SHIPPING,icon:i=>e(g,{width:24,height:24,color:i})}],[ee,ie]=o(),[te,oe]=o(),[ne,le]=o(),[re,de]=o(null!==(B=U.data)&&void 0!==B?B:"string"==typeof U.hideOption?{isStaticCoupon:"dynamic"===U.hideOption}:{isStaticCoupon:!0}),[ae,ce]=o(!0),[se,ue]=o(),[pe,ve]=o((null===(G=U.data)||void 0===G?void 0:G.minAmount)?r.AMOUNT:(null===(Y=U.data)||void 0===Y?void 0:Y.minQuantity)?r.QUANTITY:r.NA),[Ce,be]=o(d.ENTIRE_ORDER),[me,ye]=o(a.SPECIFIC_PRODUCTS),[Pe,he]=o(a.SPECIFIC_PRODUCTS),[Ie,fe]=o(void 0),[Te,Ee]=o(void 0),[Oe,Se]=o(void 0),[ge,_e]=o(void 0),[Ve,Ae]=o(void 0),[De,je]=o(void 0),[ke,Ne]=o(0),[xe,Fe]=o(""),[we,Re]=o(W[0]),[Me,qe]=o(!1),[Le,Ue]=o(c),[Be,Ge]=o(s),[Ye,Xe]=o(u.DYNAMIC_EXPIRATION),Qe=[{value:l.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:se===l.AMOUNT_OFF_ORDER},{value:l.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:se===l.AMOUNT_OFF_PRODUCTS},{value:l.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:se===l.BUY_X_GET_Y},{value:l.FREE_SHIPPING,label:"Free shipping",selected:se===l.FREE_SHIPPING}];n((()=>{U.makeExpiryMandatory&&qe(!0)}),[U.makeExpiryMandatory]),n((()=>{var e,i,t,o,n,r,c,s;let p;const{tempCouponData:v,discountType:b}=He();ue(b);const m=(e,i)=>{Re(v.valueType===C.FIXED_AMOUNT?W[e]:W[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==v?void 0:v.expireAfter)||(null==v?void 0:v.expireAt))&&(qe(!0),(null==v?void 0:v.expireAt)&&Xe(u.FIXED_EXPIRATION),(null==v?void 0:v.expireAfter)&&Xe(u.DYNAMIC_EXPIRATION)),b){case l.AMOUNT_OFF_ORDER:m(0,1),be(d.ENTIRE_ORDER);break;case l.AMOUNT_OFF_PRODUCTS:m(0,1),(null===(e=v.entitledCollectionIds)||void 0===e?void 0:e.length)?be(d.SPECIFIC_COLLECTIONS):(null===(i=v.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=v.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(be(d.SPECIFIC_PRODUCTS),y(null===(o=v.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,_e)):be(d.ENTIRE_ORDER);break;case l.BUY_X_GET_Y:Re(W[2]),(null===(n=v.entitledCollectionIds)||void 0===n?void 0:n.length)?he(a.SPECIFIC_COLLECTIONS):(he(a.SPECIFIC_PRODUCTS),y(null===(r=v.productVariableConf)||void 0===r?void 0:r.entitledProductVariable,_e)),(null===(c=v.prerequisiteCollectionIds)||void 0===c?void 0:c.length)?ye(a.SPECIFIC_COLLECTIONS):(ye(a.SPECIFIC_PRODUCTS),y(null===(s=v.productVariableConf)||void 0===s?void 0:s.prerequisiteProductVariable,Ae));break;case l.FREE_SHIPPING:Re(W[3])}de(Object.assign({},v)),U.hideProbability||(p=$e()),ce(F(v,pe,b,U.hideProbability||!1,p,!!v.isStaticCoupon)),U.hideProbability||$e()}),[]),n((()=>{let e;U.hideProbability||(e=$e()),ce(F(re,pe,se,U.hideProbability||!1,e,!!re.isStaticCoupon))}),[re,ke,se,pe]),n((()=>{var e,i,t,o,n,l,r;if(!U.newPickerConf&&((null===(e=U.products)||void 0===e?void 0:e.length)||(null===(i=U.collection)||void 0===i?void 0:i.length))){if(U.products&&(null===(t=U.products)||void 0===t?void 0:t.length)){if(null===(o=U.data)||void 0===o?void 0:o.entitledProductIds){const e=U.products.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}if(null===(n=U.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=U.products.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}}if(U.collection&&U.collection.length){if(null===(l=U.data)||void 0===l?void 0:l.entitledCollectionIds){const e=U.collection.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));je(e)}if(null===(r=U.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=U.collection.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Se(e)}}}}),[U.products,U.collection]),n((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=U.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&Ee(U.data.productsConf.entitledProducts),(null===(o=null===(t=U.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&fe(U.data.productsConf.prerequisiteProducts),(null===(l=null===(n=U.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&je(U.data.collectionsConf.entitledCollections),(null===(d=null===(r=U.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Se(U.data.collectionsConf.prerequisiteCollections)}),[null===(X=U.data)||void 0===X?void 0:X.productsConf,null===(Q=U.data)||void 0===Q?void 0:Q.collectionsConf]),n((()=>{if(!Te)return;if(U.newPickerConf){const e=[];return Object.values(Te).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}const e=Te.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}),[Te]),n((()=>{if(!Ie)return;if(U.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}),[Ie]),n((()=>{if(!De)return;if(U.newPickerConf){(null==De?void 0:De.isCustom)&&delete De.isCustom;const e=Object.keys(De).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}const e=De.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}),[De]),n((()=>{if(!Oe)return;if(U.newPickerConf){(null==Oe?void 0:Oe.isCustom)&&delete Oe.isCustom;const e=Object.keys(Oe).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}const e=Oe.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}),[Oe]);const He=()=>{var e,i;let t,o=re;return re.isStaticCoupon||(re.targetType===p.SHIPPING_LINE?t=l.FREE_SHIPPING:re.targetType===p.LINE_ITEM?t=re.targetSelection===v.ENTITLED?(null===(e=re.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=re.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||re.prerequisiteQuantity||re.entitledQuantity?l.BUY_X_GET_Y:l.AMOUNT_OFF_PRODUCTS:l.AMOUNT_OFF_ORDER:(o=Object.assign(Object.assign({},o),{targetType:p.LINE_ITEM,targetSelection:v.ALL,valueType:C.FIXED_AMOUNT}),t=l.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:o}},ze=()=>{Ue(c),Ge(s)},Ke=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=re.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":re.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&&(Fe(n>1?"Please add discount details":o),!0)},$e=()=>{if(!U.quadrant||!U.probability)return;const e=[...U.probability];let i=[];e.length>=U.quadrant&&e.splice(U.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(re.probability||0);return Ne(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ze=e=>{var i,t,o,n,r,d,a,c,s,u,b,m,y,P,h,I;const f=e.value;ue(f),fe([]),Ee([]),Se([]),je([]),f===l.FREE_SHIPPING?de({value:100,targetSelection:v.ALL,targetType:p.SHIPPING_LINE,valueType:C.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(i=re.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=re.expireAfter)&&void 0!==t?t:void 0,probability:re.probability,minQuantity:null!==(o=re.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(n=re.minAmount)&&void 0!==n?n:void 0}):f===l.BUY_X_GET_Y?de({value:100,targetSelection:v.ENTITLED,targetType:p.LINE_ITEM,valueType:C.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(r=re.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=re.expireAfter)&&void 0!==d?d:void 0,probability:re.probability,minQuantity:void 0,minAmount:void 0}):f===l.AMOUNT_OFF_ORDER?de({targetSelection:v.ALL,targetType:p.LINE_ITEM,valueType:null!==(a=re.valueType)&&void 0!==a?a:C.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(c=re.expireAt)&&void 0!==c?c:void 0,expireAfter:null!==(s=re.expireAfter)&&void 0!==s?s:void 0,probability:re.probability,value:re.value,minQuantity:null!==(u=re.minQuantity)&&void 0!==u?u:void 0,minAmount:null!==(b=re.minAmount)&&void 0!==b?b:void 0}):f===l.AMOUNT_OFF_PRODUCTS&&de({targetSelection:v.ENTITLED,targetType:p.LINE_ITEM,valueType:null!==(m=re.valueType)&&void 0!==m?m:C.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(y=re.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=re.expireAfter)&&void 0!==P?P:void 0,probability:re.probability,value:re.value,minQuantity:null!==(h=re.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=re.minAmount)&&void 0!==I?I:void 0})},Je=i=>i&&e(T,{theme:"light",tagText:i,type:"negative",LeadingIcon:V});return i(I,Object.assign({width:(ne||ee)&&U.newPickerConf?"25px":"640px",open:U.isOpen,hideCrossButton:!!te,headingTitle:ee?"Select Products":U.title,headingSubtitle:ee?void 0:U.subTitle,footerLeftCustomElement:xe?Je(xe):U.errorMsg?Je(U.errorMsg):!U.quadrant||U.hideProbability?e(t,{}):ke<=1?e(T,{theme:"light",tagText:`Current probability sum: ${ke}`,type:"white"}):e(E,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(T,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${ke}`,type:"negative",LeadingIcon:_})})})),headerRightCustomElement:U.allowStaticCoupon||ee?void 0:e(b,{options:Qe,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ze(e)}}),onClose:U.onClose,footerContainerStyle:{borderTop:`1px solid ${h.colorsV2.stroke.primary}`},primaryButton:ee?{buttonType:"primary",onClick:()=>{ie(void 0)},buttonText:"Add"}:ne?{buttonType:"primary",onClick:()=>{le(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(H=U.loading)&&void 0!==H&&H,onClick:()=>{var e,i,t,o,n;if(ze(),re.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=re,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!U.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(Ke(r))return void Ue(r);if(ae||ke>1)return void Fe(!U.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");U.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:re.title})}else{const c={invalidCouponTitle:!re.title,inValidProbability:!U.hideProbability&&(null!==(e=re.probability)&&void 0!==e?e:-1)<=0||(null!==(i=re.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=re.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!re.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(se!==l.BUY_X_GET_Y&&pe!==r.NA){const{minAmount:e,minQuantity:i}=re;c.inValidMinimumAmount=pe===r.AMOUNT&&!e,c.inValidMinimumQuantity=pe===r.QUANTITY&&!i}if(Me&&(c.inValidCouponExpiry=!re.expireAt&&!re.expireAfter),se!==l.AMOUNT_OFF_ORDER&&se!==l.AMOUNT_OFF_PRODUCTS||(Ce!==d.SPECIFIC_PRODUCTS||!Te||Object.keys(Te).length||ge||(c.inValidProductSelection=!0,c.inValidProductVariableSelection=!0),Ce===d.SPECIFIC_COLLECTIONS&&De&&!Object.keys(De).length&&(c.inValidCollectionSelection=!0)),se===l.BUY_X_GET_Y&&(re.prerequisiteQuantity||(c.inValidBuyXValue=!0),re.entitledQuantity||(c.inValidGetYValue=!0),me!==a.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Ve||(c.inValidBuyXProductSelection=!0,c.inValidBuyXProductVariableSelection=!0),me===a.SPECIFIC_COLLECTIONS&&Oe&&!Object.keys(Oe).length&&(c.inValidBuyXCollectionSelection=!0),Pe!==a.SPECIFIC_PRODUCTS||!Te||Object.keys(Te).length||ge||(c.inValidGetYProductSelection=!0,c.inValidGetYProductVariableSelection=!0),Pe===a.SPECIFIC_COLLECTIONS&&De&&!Object.keys(De).length&&(c.inValidGetYCollectionSelection=!0)),Ke(c))return void Ge(c);if(ae||ke>1)return void Fe(!U.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");U.onSaveClicked(Object.assign(Object.assign({},re),{description:w(re,U.currency,null!==(o=U.products)&&void 0!==o?o:[],null!==(n=U.collection)&&void 0!==n?n:[]),productsConf:{entitledProducts:null!=Te?Te:[],prerequisiteProducts:null!=Ie?Ie:[]},collectionsConf:{entitledCollections:null!=De?De:[],prerequisiteCollections:null!=Oe?Oe:[]},productVariableConf:{entitledProductVariable:null!=ge?ge:{},prerequisiteProductVariable:null!=Ve?Ve:{}}}))}}},secondaryButton:ee?{buttonType:"tertiaryGray",onClick:()=>{ie(void 0)},buttonText:"Back"}:ne?{buttonType:"tertiaryGray",onClick:()=>{le(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:U.onClose,buttonText:"Cancel"}},{children:[!ee&&!ne&&i(k,{children:[U.allowStaticCoupon&&!ee&&i(N,Object.assign({selectedDiv:re.isStaticCoupon?1:2},{children:["static"===U.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{re.isStaticCoupon||(de({isStaticCoupon:!0,quadrant:re.quadrant}),Fe(""),ze())}},{children:[e(m,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?h.colorsV2.content.brand:void 0}},{children:"Static Code"})),e(y,Object.assign({style:re.isStaticCoupon?{color:h.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===U.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;re.isStaticCoupon&&(ue(l.AMOUNT_OFF_ORDER),de({isStaticCoupon:!1,quadrant:re.quadrant,targetType:p.LINE_ITEM,targetSelection:v.ALL,valueType:C.FIXED_AMOUNT}),Fe(""),ze(),Re({id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i}},{children:U.currency||""}))}),qe(null!==(i=U.makeExpiryMandatory)&&void 0!==i&&i),ve(r.NA))}},{children:[e(m,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?void 0:h.colorsV2.content.brand}},{children:"Dynamic Code"})),e(y,Object.assign({style:re.isStaticCoupon?{}:{color:h.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(P,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),re.isStaticCoupon&&!ee&&e(q,{discountData:re,setDiscountData:de,hideProbability:U.hideProbability||!1,discountAdminUrl:U.discountAdminUrl,staticDiscountValidationError:Le,currency:U.currency}),!re.isStaticCoupon&&!ee&&!ne&&e(R,{currency:U.currency,entitledProducts:null!=Te?Te:[],prerequisiteProducts:null!=Ie?Ie:[],setEntitledProducts:Ee,setPrerequisiteProducts:fe,discountData:re,productPickerOpen:ee,productVariablePickerOpen:te,setIsProductPickerOpen:ie,setIsProductVariablePickerOpen:oe,setDiscountData:de,selectedCouponType:se,setSelectedCouponType:ue,selectedMinimumRequirement:pe,setSelectedMinimumRequirement:ve,discountCouponAppliesTo:Ce,offerAppliesToBuy:me,offerAppliesToGet:Pe,setDiscountCouponAppliesTo:be,setOfferAppliesToBuy:ye,setOfferAppliesToGet:he,hideProbability:U.hideProbability||!1,hideExpiration:U.hideExpiration||!1,allowStaticCoupon:U.allowStaticCoupon,onChangeCouponType:Ze,collectionPickerOpen:ne,entitledCollections:null!=De?De:[],prerequisiteCollections:null!=Oe?Oe:[],setIsCollectionPickerOpen:le,setEntitledCollections:je,setPrerequisiteCollections:Se,useNewPicker:!!U.newPickerConf,setSelectedDiscountDetails:Re,selectedDiscountDetails:we,isProductVariableSupported:U.isProductVariableSupported,entitledProductVariable:ge,setEntitledProductVariable:_e,preRequisiteProductVariable:Ve,setPreRequisiteProductVariable:Ae,productVariableList:U.productVariableList,isAddExpirationChecked:Me,setIsAddExpirationChecked:qe,dynamicDiscountValidationError:Be,setDynamicDiscountValidationError:Ge,setValidationErrorMessage:Fe,resetValidationErrors:ze,discountDetailsOptions:W,selectedExpiration:Ye,setSelectedExpiration:Xe,makeExpiryMandatory:!!U.makeExpiryMandatory})]}),!!ee&&i(t,{children:[!U.newPickerConf&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(f,{show:!0,onSave:()=>{},products:null!==(z=U.products)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{ie(void 0)},selectedProducts:null!==(K=ee===M.ENTITLED?Te:Ie)&&void 0!==K?K:[],setSelectedProducts:ee===M.ENTITLED?Ee:fe,onSearchKeyChange:U.onProductSearch})})),U.newPickerConf&&e(A,{visible:!0,onClose:()=>ie(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=U.newPickerConf)||void 0===o?void 0:o.fetchCollections)?U.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=U.newPickerConf)||void 0===l?void 0:l.fetchProducts)?U.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:ee===M.ENTITLED?Te:Ie,onAdd:e=>{ee===M.ENTITLED?Ee(e):fe(e),ie(void 0)},zIndex:200,storeId:U.newPickerConf.storeId,appType:U.newPickerConf.appType||L.ApplicationType.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=U.newPickerConf)||void 0===n?void 0:n.searchInCollection)?U.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=U.newPickerConf)||void 0===o?void 0:o.searchProducts)?U.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!ne&&e("div",Object.assign({style:{padding:"12px 0"}},{children:i(t,{children:[U.newPickerConf&&e(A,{visible:!0,onClose:()=>le(void 0),collectionFetcher:U.newPickerConf.fetchCollections,productFetcher:U.newPickerConf.fetchProducts,selectedItems:ne===M.ENTITLED?De:Oe,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),ne===M.ENTITLED?je(e):Se(e),le(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:U.newPickerConf.storeId,appType:U.newPickerConf.appType||L.ApplicationType.BIK,searchInCollectionFetcher:U.newPickerConf.searchInCollection,searchFetcher:U.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!U.newPickerConf&&e(f,{show:!0,onSave:()=>{},products:null!==($=U.collection)&&void 0!==$?$:[],title:"Select Products",onClose:()=>{le(void 0)},selectedProducts:null!==(Z=ne===M.ENTITLED?De:Oe)&&void 0!==Z?Z:[],setSelectedProducts:ne===M.ENTITLED?je:Se,onSearchKeyChange:U.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),te&&e(x,{children:e("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e(j,{type:D.EMBEDDED,data:null!==(J=U.productVariableList)&&void 0!==J?J:[],showHeader:!0,onSelect:e=>{if(te===M.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;_e({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}if(te===M.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;Ae({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}},onClose:()=>{oe(void 0)}})}))})]}))};export{U as DiscountModal};
|
|
1
|
+
import{jsx as e,jsxs as i,Fragment as t}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import{useState as o,useEffect as n}from"react";import{DISCOUNT_TYPES as l,MIN_PURCHASE_REQUIREMENT as r,DISCOUNT_APPLIES_TO as d,OFFER_APPLIES_TO as a,initialStaticCouponErrorState as c,initialDynamicCouponErrorState as s,COUPON_EXPIRATION as u,DISCOUNT_TARGET_TYPES as p,DISCOUNT_TARGET_SELECTION as v,DISCOUNT_VALUE_TYPES as C}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as b}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as m,BodyCaption as y,TitleRegular as P}from"../TypographyStyle.js";import{DEFAULT_THEME as h}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 I}from"../modals/styledModal.js";import{ProductPickerContent as f}from"../product-picker/ProductPickerModal.js";import{Tag as T}from"../tag/Tag.js";import{Tooltip as E}from"../tooltips/Tooltip.js";import O from"../../assets/icons/gift_icon.svg.js";import S from"../../assets/icons/percentage_icon.svg.js";import g from"../../assets/icons/shipping_icon.svg.js";import _ from"../../assets/icons/triangle_error.svg.js";import V from"../../assets/icons/warning.svg.js";import{ProductPickerModal as A}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as D}from"../variable-picker-v3/model.js";import{VariablePicker as j}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as k,CouponTypeContainerStyled as N,VariablePickerContainer as x}from"./DiscountModal.styled.js";import{validateDiscountData as F,descriptionBuilder as w}from"./DiscountUtils.js";import R,{DISCOUNT_PRODUCTS as M}from"./DynamicCoupon/DynamicCoupon.js";import q from"./StaticCoupon/StaticCoupon.js";import{__exports as L}from"../../_virtual/index.js";const U=U=>{var B,G,Y,X,Q,H,z,K,$,Z,J;const W=[{id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:U.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e(S,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:l.BUY_X_GET_Y,icon:i=>e(O,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:l.FREE_SHIPPING,icon:i=>e(g,{width:24,height:24,color:i})}],[ee,ie]=o(),[te,oe]=o(),[ne,le]=o(),[re,de]=o(null!==(B=U.data)&&void 0!==B?B:"string"==typeof U.hideOption?{isStaticCoupon:"dynamic"===U.hideOption}:{isStaticCoupon:!0}),[ae,ce]=o(!0),[se,ue]=o(),[pe,ve]=o((null===(G=U.data)||void 0===G?void 0:G.minAmount)?r.AMOUNT:(null===(Y=U.data)||void 0===Y?void 0:Y.minQuantity)?r.QUANTITY:r.NA),[Ce,be]=o(d.ENTIRE_ORDER),[me,ye]=o(a.SPECIFIC_PRODUCTS),[Pe,he]=o(a.SPECIFIC_PRODUCTS),[Ie,fe]=o(void 0),[Te,Ee]=o(void 0),[Oe,Se]=o(void 0),[ge,_e]=o(void 0),[Ve,Ae]=o(void 0),[De,je]=o(void 0),[ke,Ne]=o(0),[xe,Fe]=o(""),[we,Re]=o(W[0]),[Me,qe]=o(!1),[Le,Ue]=o(c),[Be,Ge]=o(s),[Ye,Xe]=o(u.DYNAMIC_EXPIRATION),Qe=[{value:l.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:se===l.AMOUNT_OFF_ORDER},{value:l.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:se===l.AMOUNT_OFF_PRODUCTS},{value:l.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:se===l.BUY_X_GET_Y},{value:l.FREE_SHIPPING,label:"Free shipping",selected:se===l.FREE_SHIPPING}];n((()=>{U.makeExpiryMandatory&&qe(!0)}),[U.makeExpiryMandatory]),n((()=>{var e,i,t,o,n,r,c,s;let p;const{tempCouponData:v,discountType:b}=He();ue(b);const m=(e,i)=>{Re(v.valueType===C.FIXED_AMOUNT?W[e]:W[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==v?void 0:v.expireAfter)||(null==v?void 0:v.expireAt))&&(qe(!0),(null==v?void 0:v.expireAt)&&Xe(u.FIXED_EXPIRATION),(null==v?void 0:v.expireAfter)&&Xe(u.DYNAMIC_EXPIRATION)),b){case l.AMOUNT_OFF_ORDER:m(0,1),be(d.ENTIRE_ORDER);break;case l.AMOUNT_OFF_PRODUCTS:m(0,1),(null===(e=v.entitledCollectionIds)||void 0===e?void 0:e.length)?be(d.SPECIFIC_COLLECTIONS):(null===(i=v.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=v.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(be(d.SPECIFIC_PRODUCTS),y(null===(o=v.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,_e)):be(d.ENTIRE_ORDER);break;case l.BUY_X_GET_Y:Re(W[2]),(null===(n=v.entitledCollectionIds)||void 0===n?void 0:n.length)?he(a.SPECIFIC_COLLECTIONS):(he(a.SPECIFIC_PRODUCTS),y(null===(r=v.productVariableConf)||void 0===r?void 0:r.entitledProductVariable,_e)),(null===(c=v.prerequisiteCollectionIds)||void 0===c?void 0:c.length)?ye(a.SPECIFIC_COLLECTIONS):(ye(a.SPECIFIC_PRODUCTS),y(null===(s=v.productVariableConf)||void 0===s?void 0:s.prerequisiteProductVariable,Ae));break;case l.FREE_SHIPPING:Re(W[3])}de(Object.assign({},v)),U.hideProbability||(p=$e()),ce(F(v,pe,b,U.hideProbability||!1,p,!!v.isStaticCoupon)),U.hideProbability||$e()}),[]),n((()=>{let e;U.hideProbability||(e=$e()),ce(F(re,pe,se,U.hideProbability||!1,e,!!re.isStaticCoupon))}),[re,ke,se,pe]),n((()=>{var e,i,t,o,n,l,r;if(!U.newPickerConf&&((null===(e=U.products)||void 0===e?void 0:e.length)||(null===(i=U.collection)||void 0===i?void 0:i.length))){if(U.products&&(null===(t=U.products)||void 0===t?void 0:t.length)){if(null===(o=U.data)||void 0===o?void 0:o.entitledProductIds){const e=U.products.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}if(null===(n=U.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=U.products.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}}if(U.collection&&U.collection.length){if(null===(l=U.data)||void 0===l?void 0:l.entitledCollectionIds){const e=U.collection.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));je(e)}if(null===(r=U.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=U.collection.filter((e=>{var i,t;return null===(t=null===(i=U.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Se(e)}}}}),[U.products,U.collection]),n((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=U.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&Ee(U.data.productsConf.entitledProducts),(null===(o=null===(t=U.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&fe(U.data.productsConf.prerequisiteProducts),(null===(l=null===(n=U.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&je(U.data.collectionsConf.entitledCollections),(null===(d=null===(r=U.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Se(U.data.collectionsConf.prerequisiteCollections)}),[null===(X=U.data)||void 0===X?void 0:X.productsConf,null===(Q=U.data)||void 0===Q?void 0:Q.collectionsConf]),n((()=>{if(!Te)return;if(U.newPickerConf){const e=[];return Object.values(Te).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}const e=Te.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledProductIds:e}))}),[Te]),n((()=>{if(!Ie)return;if(U.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteProductIds:e}))}),[Ie]),n((()=>{if(!De)return;if(U.newPickerConf){(null==De?void 0:De.isCustom)&&delete De.isCustom;const e=Object.keys(De).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}const e=De.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{entitledCollectionIds:e}))}),[De]),n((()=>{if(!Oe)return;if(U.newPickerConf){(null==Oe?void 0:Oe.isCustom)&&delete Oe.isCustom;const e=Object.keys(Oe).map((e=>parseInt(e)));return void de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}const e=Oe.map((e=>parseInt(e.id)));de(Object.assign(Object.assign({},re),{prerequisiteCollectionIds:e}))}),[Oe]);const He=()=>{var e,i;let t,o=re;return re.isStaticCoupon||(re.targetType===p.SHIPPING_LINE?t=l.FREE_SHIPPING:re.targetType===p.LINE_ITEM?t=re.targetSelection===v.ENTITLED?(null===(e=re.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=re.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||re.prerequisiteQuantity||re.entitledQuantity?l.BUY_X_GET_Y:l.AMOUNT_OFF_PRODUCTS:l.AMOUNT_OFF_ORDER:(o=Object.assign(Object.assign({},o),{targetType:p.LINE_ITEM,targetSelection:v.ALL,valueType:C.FIXED_AMOUNT}),t=l.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:o}},ze=()=>{Ue(c),Ge(s)},Ke=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=re.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":re.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&&(Fe(n>1?"Please add discount details":o),!0)},$e=()=>{if(!U.quadrant||!U.probability)return;const e=[...U.probability];let i=[];e.length>=U.quadrant&&e.splice(U.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(re.probability||0);return Ne(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ze=e=>{var i,t,o,n,r,d,a,c,s,u,b,m,y,P,h,I;const f=e.value;ue(f),fe([]),Ee([]),Se([]),je([]),f===l.FREE_SHIPPING?de({value:100,targetSelection:v.ALL,targetType:p.SHIPPING_LINE,valueType:C.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(i=re.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=re.expireAfter)&&void 0!==t?t:void 0,probability:re.probability,minQuantity:null!==(o=re.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(n=re.minAmount)&&void 0!==n?n:void 0}):f===l.BUY_X_GET_Y?de({value:100,targetSelection:v.ENTITLED,targetType:p.LINE_ITEM,valueType:C.PERCENTAGE,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(r=re.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=re.expireAfter)&&void 0!==d?d:void 0,probability:re.probability,minQuantity:void 0,minAmount:void 0}):f===l.AMOUNT_OFF_ORDER?de({targetSelection:v.ALL,targetType:p.LINE_ITEM,valueType:null!==(a=re.valueType)&&void 0!==a?a:C.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(c=re.expireAt)&&void 0!==c?c:void 0,expireAfter:null!==(s=re.expireAfter)&&void 0!==s?s:void 0,probability:re.probability,value:re.value,minQuantity:null!==(u=re.minQuantity)&&void 0!==u?u:void 0,minAmount:null!==(b=re.minAmount)&&void 0!==b?b:void 0}):f===l.AMOUNT_OFF_PRODUCTS&&de({targetSelection:v.ENTITLED,targetType:p.LINE_ITEM,valueType:null!==(m=re.valueType)&&void 0!==m?m:C.FIXED_AMOUNT,quadrant:re.quadrant,isStaticCoupon:!1,title:re.title,expireAt:null!==(y=re.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=re.expireAfter)&&void 0!==P?P:void 0,probability:re.probability,value:re.value,minQuantity:null!==(h=re.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=re.minAmount)&&void 0!==I?I:void 0})},Je=i=>i&&e(T,{theme:"light",tagText:i,type:"negative",LeadingIcon:V});return i(I,Object.assign({width:(ne||ee)&&U.newPickerConf?"25px":"640px",open:U.isOpen,hideCrossButton:!!te,headingTitle:ee?"Select Products":U.title,headingSubtitle:ee?void 0:U.subTitle,footerLeftCustomElement:xe?Je(xe):U.errorMsg?Je(U.errorMsg):!U.quadrant||U.hideProbability?e(t,{}):ke<=1?e(T,{theme:"light",tagText:`Current probability sum: ${ke}`,type:"white"}):e(E,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e("div",{children:e(T,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${ke}`,type:"negative",LeadingIcon:_})})})),headerRightCustomElement:U.allowStaticCoupon||ee?void 0:e(b,{options:Qe,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ze(e)}}),onClose:U.onClose,footerContainerStyle:{borderTop:`1px solid ${h.colorsV2.stroke.primary}`},primaryButton:ee?{buttonType:"primary",onClick:()=>{ie(void 0)},buttonText:"Add"}:ne?{buttonType:"primary",onClick:()=>{le(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(H=U.loading)&&void 0!==H&&H,onClick:()=>{var e,i,t,o,n;if(ze(),re.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=re,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!U.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(Ke(r))return void Ue(r);if(ae||ke>1)return void Fe(!U.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");U.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:re.title})}else{const c={invalidCouponTitle:!re.title,inValidProbability:!U.hideProbability&&(null!==(e=re.probability)&&void 0!==e?e:-1)<=0||(null!==(i=re.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=re.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!re.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(se!==l.BUY_X_GET_Y&&pe!==r.NA){const{minAmount:e,minQuantity:i}=re;c.inValidMinimumAmount=pe===r.AMOUNT&&!e,c.inValidMinimumQuantity=pe===r.QUANTITY&&!i}if(Me&&(c.inValidCouponExpiry=!re.expireAt&&!re.expireAfter),se!==l.AMOUNT_OFF_ORDER&&se!==l.AMOUNT_OFF_PRODUCTS||(Ce!==d.SPECIFIC_PRODUCTS||!Te||Object.keys(Te).length||ge||(c.inValidProductSelection=!0,c.inValidProductVariableSelection=!0),Ce===d.SPECIFIC_COLLECTIONS&&De&&!Object.keys(De).length&&(c.inValidCollectionSelection=!0)),se===l.BUY_X_GET_Y&&(re.prerequisiteQuantity||(c.inValidBuyXValue=!0),re.entitledQuantity||(c.inValidGetYValue=!0),me!==a.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Ve||(c.inValidBuyXProductSelection=!0,c.inValidBuyXProductVariableSelection=!0),me===a.SPECIFIC_COLLECTIONS&&Oe&&!Object.keys(Oe).length&&(c.inValidBuyXCollectionSelection=!0),Pe!==a.SPECIFIC_PRODUCTS||!Te||Object.keys(Te).length||ge||(c.inValidGetYProductSelection=!0,c.inValidGetYProductVariableSelection=!0),Pe===a.SPECIFIC_COLLECTIONS&&De&&!Object.keys(De).length&&(c.inValidGetYCollectionSelection=!0)),Ke(c))return void Ge(c);if(ae||ke>1)return void Fe(!U.hideProbability&&ke>1?"Probability sum should not exceed 1":"Invalid coupon details");U.onSaveClicked(Object.assign(Object.assign({},re),{description:w(re,U.currency,null!==(o=U.products)&&void 0!==o?o:[],null!==(n=U.collection)&&void 0!==n?n:[]),productsConf:{entitledProducts:null!=Te?Te:[],prerequisiteProducts:null!=Ie?Ie:[]},collectionsConf:{entitledCollections:null!=De?De:[],prerequisiteCollections:null!=Oe?Oe:[]},productVariableConf:{entitledProductVariable:null!=ge?ge:{},prerequisiteProductVariable:null!=Ve?Ve:{}}}))}}},secondaryButton:ee?{buttonType:"tertiaryGray",onClick:()=>{ie(void 0)},buttonText:"Back"}:ne?{buttonType:"tertiaryGray",onClick:()=>{le(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:U.onClose,buttonText:"Cancel"}},{children:[!ee&&!ne&&i(k,{children:[U.allowStaticCoupon&&!ee&&i(N,Object.assign({selectedDiv:re.isStaticCoupon?1:2},{children:["static"===U.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{re.isStaticCoupon||(de({isStaticCoupon:!0,quadrant:re.quadrant}),Fe(""),ze())}},{children:[e(m,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?h.colorsV2.content.brand:void 0}},{children:"Static Code"})),e(y,Object.assign({style:re.isStaticCoupon?{color:h.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===U.hideOption?e(t,{}):i("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;re.isStaticCoupon&&(ue(l.AMOUNT_OFF_ORDER),de({isStaticCoupon:!1,quadrant:re.quadrant,targetType:p.LINE_ITEM,targetSelection:v.ALL,valueType:C.FIXED_AMOUNT}),Fe(""),ze(),Re({id:"0",label:"Amount",value:"amount",icon:i=>e("span",Object.assign({style:{fontSize:20,color:i}},{children:U.currency||""}))}),qe(null!==(i=U.makeExpiryMandatory)&&void 0!==i&&i),ve(r.NA))}},{children:[e(m,Object.assign({style:{marginBottom:"4px",color:re.isStaticCoupon?void 0:h.colorsV2.content.brand}},{children:"Dynamic Code"})),e(y,Object.assign({style:re.isStaticCoupon?{}:{color:h.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(P,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),re.isStaticCoupon&&!ee&&e(q,{discountData:re,setDiscountData:de,hideProbability:U.hideProbability||!1,discountAdminUrl:U.discountAdminUrl,staticDiscountValidationError:Le,currency:U.currency}),!re.isStaticCoupon&&!ee&&!ne&&e(R,{currency:U.currency,entitledProducts:null!=Te?Te:[],prerequisiteProducts:null!=Ie?Ie:[],setEntitledProducts:Ee,setPrerequisiteProducts:fe,discountData:re,productPickerOpen:ee,productVariablePickerOpen:te,setIsProductPickerOpen:ie,setIsProductVariablePickerOpen:oe,setDiscountData:de,selectedCouponType:se,setSelectedCouponType:ue,selectedMinimumRequirement:pe,setSelectedMinimumRequirement:ve,discountCouponAppliesTo:Ce,offerAppliesToBuy:me,offerAppliesToGet:Pe,setDiscountCouponAppliesTo:be,setOfferAppliesToBuy:ye,setOfferAppliesToGet:he,hideProbability:U.hideProbability||!1,hideExpiration:U.hideExpiration||!1,allowStaticCoupon:U.allowStaticCoupon,onChangeCouponType:Ze,collectionPickerOpen:ne,entitledCollections:null!=De?De:[],prerequisiteCollections:null!=Oe?Oe:[],setIsCollectionPickerOpen:le,setEntitledCollections:je,setPrerequisiteCollections:Se,useNewPicker:!!U.newPickerConf,setSelectedDiscountDetails:Re,selectedDiscountDetails:we,isProductVariableSupported:U.isProductVariableSupported,entitledProductVariable:ge,setEntitledProductVariable:_e,preRequisiteProductVariable:Ve,setPreRequisiteProductVariable:Ae,productVariableList:U.productVariableList,isAddExpirationChecked:Me,setIsAddExpirationChecked:qe,dynamicDiscountValidationError:Be,setDynamicDiscountValidationError:Ge,setValidationErrorMessage:Fe,resetValidationErrors:ze,discountDetailsOptions:W,selectedExpiration:Ye,setSelectedExpiration:Xe,makeExpiryMandatory:!!U.makeExpiryMandatory})]}),!!ee&&i(t,{children:[!U.newPickerConf&&e("div",Object.assign({style:{padding:"12px 0"}},{children:e(f,{show:!0,onSave:()=>{},products:null!==(z=U.products)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{ie(void 0)},selectedProducts:null!==(K=ee===M.ENTITLED?Te:Ie)&&void 0!==K?K:[],setSelectedProducts:ee===M.ENTITLED?Ee:fe,onSearchKeyChange:U.onProductSearch})})),U.newPickerConf&&e(A,{visible:!0,onClose:()=>ie(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=U.newPickerConf)||void 0===o?void 0:o.fetchCollections)?U.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=U.newPickerConf)||void 0===l?void 0:l.fetchProducts)?U.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:ee===M.ENTITLED?Te:Ie,onAdd:e=>{ee===M.ENTITLED?Ee(e):fe(e),ie(void 0)},zIndex:200,storeId:U.newPickerConf.storeId,appType:U.newPickerConf.appType||L.ApplicationType.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=U.newPickerConf)||void 0===n?void 0:n.searchInCollection)?U.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=U.newPickerConf)||void 0===o?void 0:o.searchProducts)?U.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!ne&&e("div",Object.assign({style:{padding:"12px 0"}},{children:i(t,{children:[U.newPickerConf&&e(A,{visible:!0,onClose:()=>le(void 0),collectionFetcher:U.newPickerConf.fetchCollections,productFetcher:U.newPickerConf.fetchProducts,selectedItems:ne===M.ENTITLED?De:Oe,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),ne===M.ENTITLED?je(e):Se(e),le(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:U.newPickerConf.storeId,appType:U.newPickerConf.appType||L.ApplicationType.BIK,searchInCollectionFetcher:U.newPickerConf.searchInCollection,searchFetcher:U.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!U.newPickerConf&&e(f,{show:!0,onSave:()=>{},products:null!==($=U.collection)&&void 0!==$?$:[],title:"Select Products",onClose:()=>{le(void 0)},selectedProducts:null!==(Z=ne===M.ENTITLED?De:Oe)&&void 0!==Z?Z:[],setSelectedProducts:ne===M.ENTITLED?je:Se,onSearchKeyChange:U.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),te&&e(x,{children:e("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e(j,{type:D.EMBEDDED,data:null!==(J=U.productVariableList)&&void 0!==J?J:[],showHeader:!0,onSelect:e=>{if(te===M.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;_e({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}if(te===M.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;Ae({displayName:i,actualValue:t,isAvailable:o}),oe(void 0)}},onClose:()=>{oe(void 0)}})}))})]}))};export{U as DiscountModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
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';
|
|
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{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import a from"../../assets/icons/cross.svg.js";import{Button as d}from"../button/Button.js";import{Input as u}from"../input/Input.js";import{StyledModal as p}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as m}from"../tag/Tag.js";import{CollectionsScreen as C}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as y}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as S,selectedColectionsReducer as k,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as j}from"./searchScreen.js";import{SelectedScreen as I}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as P,StyledFooterForNonModal as O}from"./style.js";import{OUT_OF_STOCK_ACTION as T,ScreenName as D}from"./type.js";import{updateAllVariantsForSelectedProducts as F}from"./utility.js";import{__exports as R}from"../../_virtual/index.js";const w=w=>{const{storeId:A,selectedItems:B,onClose:E,visible:L,zIndex:z,exactLimit:V,limit:$,hideCollectionCheckbox:M,hideProductCheckbox:H,outOfStockAction:W=T.BLUR,hideVariantCheckbox:_,selectProductsFromCustomCollection:G,hideSelectionCount:K,title:N,width:U,left:Y,renderWithoutModal:q,onClickSave:J,pickerType:Q,hideProductVariants:X=!1,startupScreen:Z=D.Collections,rearrangeEnabled:ee,selectSingleItem:te=!1,showProductDetails:oe,containerStyle:ce,crossButtonInsideHeader:re=!1,footerForNonModal:se={},primaryButton:ie,secondaryButton:ne,subtitle:le}=w,ae=w.appType||R.ApplicationType.BIK,[de,ue]=r(f,{}),[pe,he]=s([D.Collections,D.RearrangeProducts].includes(Z)?Z:D.Collections),[me,Ce]=s("grid"),[ge,ye]=s(""),[be,fe]=s(""),[Se,ke]=s(0),[ve,je]=s(!1),[Ie,xe]=s(0),[Pe,Oe]=s(""),[Te,De]=s(!1),[Fe,Re]=s(!1),[we,Ae]=r(S,{collections:{},products:{}}),[Be,Ee]=r(k,Object.keys(B).length>0?B:{}),Le=i(null),[ze,Ve]=s(!1),[$e,Me]=s();n((()=>{je(!0),Re(!0),w.collectionFetcher(Se,A,ae).then((e=>{ue({type:"fetched",data:(null==e?void 0:e.collections)||{}}),je(!1),ke((e=>e+1)),Re(!1)})).catch()}),[]),n((()=>{let e=0;X?Object.keys(Be||[]).forEach((t=>{var o;Object.keys((null===(o=Be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&Be[-1]&&(null===(c=Be[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(Be||[]).forEach((t=>{var o;Object.keys((null===(o=Be[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=Be[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),xe(e)}),[de,Be,X]),n((()=>{be&&(je(!0),w.productFetcher(be,A,ae).then((e=>{Object.keys(e).length&&ue({type:"productsFetched",data:{collectionId:be,products:e}}),je(!1)})).catch())}),[be]),n((()=>{const e=setTimeout((()=>{"rearrange"!==pe&&(Pe.length||"collections"!==pe)&&(Pe.length?(De(!0),w.searchFetcher(A,Pe,ae).then((e=>{"collections"in e&&"products"in e?(Ae({type:"set",data:e}),ue({type:"searched",data:e.collections}),ue({type:"searched",data:e.products})):(Ae({type:"set",data:{collections:{},products:e}}),ue({type:"searched",data:e})),he("searchProducts"),je(!1),De(!1)}))):he("collections"))}),800);return()=>clearTimeout(e)}),[Pe]),n((()=>{J&&(w.onAdd(Be,Ie),He())}),[J]),n((()=>{te&&Object.keys(Be||{}).length&&Ie&&(w.onAdd(Be,Ie),He())}),[te,Be,Ie]);const He=()=>{Ee({type:"reset",data:{}})},We=()=>V&&Ie>V?t(m,{tagText:`You can only select ${V} products`,type:"negative"}):$&&Ie>$?t(m,{tagText:`You can only select ${$} products`,type:"negative"}):t(d,Ie>0?{onClick:()=>{he(ee?D.RearrangeProducts:D.SelectedProducts)},buttonText:V?`${Ie}/${V} products selected`:`${Ie} products selected`,buttonType:["rearrange","view"].includes(pe)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(pe)}:{disabled:!0,buttonText:V?`${Ie}/${V} products selected`:`${Ie} products selected`,buttonType:"tertiaryGray"}),_e=e=>ve?"Loading...":pe===D.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",Ge=e(x,Object.assign({style:null!=ce?ce:{}},{children:[w.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:w.postHeader})),!w.hideGlobalSearch&&t(o,{children:("collections"===pe||"searchProducts"===pe)&&t("div",Object.assign({style:{padding:q?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(u,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Te?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:Pe,onChangeText:e=>{e.length&&e.trim().length?Oe(e):Oe("")}})}))}),e(P,Object.assign({ref:Le,screenName:pe},{children:["collections"===pe&&t(C,{customCollectionRestriction:w.customCollectionRestriction,dataLoading:Fe,collections:de,selectedCollectionsDispatch:Ee,setCollectionId:ye,setSelectedCollectionId:fe,setScreen:he,selectedCollections:Be,collectionFetcher:w.collectionFetcher,storeId:A,appType:ae,collectionsDispatch:ue,setSaveDisabled:je,pagingControls:{curPage:Se,setCurPage:ke},hideCollectionCheckbox:M,renderWithoutModal:q,pickerType:Q,scrollContainerRef:Le}),"products"===pe&&ge&&t(v.Provider,Object.assign({value:ge},{children:t(y,{hideInCollectionSearch:w.hideInCollectionSearch,customCollectionRestriction:w.customCollectionRestriction,productFetcher:w.productFetcher,setScreen:he,storeId:A,appType:ae,data:de[ge],collectionsDispatch:ue,selectedCollectionsDispatch:Ee,selectedData:Be,setSaveDisabled:je,searchInCollectionFetcher:w.searchInCollectionFetcher,hideProductCheckbox:H,outOfStockAction:W,hideVariantCheckbox:_,selectProductsFromCustomCollection:G,renderWithoutModal:q,pickerType:Q,hideProductVariants:X,fbStatusFetcher:w.fbStatusFetcher,onProductDetailClick:e=>{Ve(!0),Me(e)},showProductDetailInfoIcon:oe,scrollContainerRef:Le})})),"view"===pe&&t(I,{selectedCollections:Be||{},selectedCollectionsDispatch:Ee,setScreen:he,collections:de,hideProductVariants:X,outOfStockAction:W,storeId:A,appType:ae,fbStatusFetcher:w.fbStatusFetcher}),"rearrange"===pe&&t(b,{selectedCollections:Be||{},selectedCollectionsDispatch:Ee,setScreen:he,outOfStockAction:W,rearrangeViewType:"grid"===me?"list":"grid",scrollContainerRef:Le,storeId:A,appType:ae,fbStatusFetcher:w.fbStatusFetcher}),"searchProducts"===pe&&t(j,{customCollectionRestriction:w.customCollectionRestriction,selectedCollections:Be||{},searchedCollections:we||{},searchedCollectionsDispatch:Ae,selectedCollectionsDispatch:Ee,setScreen:he,collections:de,onBackPress:()=>{Oe(""),Ae({type:"set",data:{collections:{},products:{}}})},pickerType:Q,hideProductCheckbox:H,hideProductVariants:X,hideVariantCheckbox:_,storeId:A,appType:ae,fbStatusFetcher:w.fbStatusFetcher,setCollectionId:ye,setSelectedCollectionId:fe,renderWithoutModal:q,hideCollectionCheckbox:M,outOfStockAction:W})]}))]}));return t(o,{children:q?e(o,{children:[Ge,se.renderFooter?e(O,{children:[We(),t(d,{buttonText:_e(se.primaryButtonText),disabled:!se.isLoading&&(ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$)||se.primaryButtonDisabled,isLoading:se.isLoading,onClick:()=>{w.onAdd(Be,Ie),He(),he([D.Collections,D.RearrangeProducts].includes(Z)?Z:D.Collections)}})]}):t(o,{}),ze&&$e?t(g,{productData:$e,outOfStockAction:W,useDynamicInfoImageSize:w.useDynamicInfoImageSize,onClose:()=>{Ve(!1)}}):t(o,{})]}):e(p,Object.assign({zIndex:z,open:L,onClose:()=>{null==E||E(),He()},headingTitle:N||("collections"===pe||"products"===pe?"Select Products":"view"===pe?"Selected Products":"searchProducts"===pe?"Searched Results":"rearrange"===pe?"Rearrange Products":void 0),headingSubtitle:le,footerShadow:!0,centralContainerStyles:{width:U||"600px",left:Y||"auto"},headerRightCustomElement:re?t("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:t(a,{width:20,height:20,color:l.content.secondary})})):t(o,{}),footerContainerStyle:w.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:ie?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$)||e.disabled,onClick:()=>{w.onAdd(Be,Ie),He(),he([D.Collections,D.RearrangeProducts].includes(Z)?Z:D.Collections)}}))(ie):{buttonText:_e(),disabled:ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$||!1,onClick:()=>{w.onAdd(Be,Ie),He()}},secondaryButton:ne?(e=>Object.assign(Object.assign({},e),{disabled:ve||Ie<1||V&&Ie<V||!V&&$&&Ie>$||!1,onClick:()=>{const e=F(Be,de,we);w.onAdd(e,Ie,!0)}}))(ne):void 0,wrapperStyle:w.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:K?t(o,{}):We(),hideCrossButton:ze||re},{children:[Ge,ze&&$e?t(g,{productData:$e,useDynamicInfoImageSize:w.useDynamicInfoImageSize,outOfStockAction:W,onClose:()=>{Ve(!1)}}):t(o,{})]}))})};export{w as ProductPickerModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Collection, FbStatusFetcherReturn, Product, ProductFetcherReturn, ProductVariant, SelectedItems } from '.';
|
|
4
4
|
import { CollectionsActions, SelectedCollectionsActions } from './reducers';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { FbStatusFetcherReturn, SelectedItems } from '.';
|
|
4
4
|
import { SelectedCollectionsActions } from './reducers';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
2
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
3
3
|
import { Collection, FbStatusFetcherReturn, SearchedItems, SelectedItems } from '.';
|
|
4
4
|
import { SearchReducerActions, SelectedCollectionsActions } from './reducers';
|
|
5
5
|
import { OUT_OF_STOCK_ACTION } from './type';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
2
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
3
3
|
import { Collection, FbStatusFetcherReturn, SelectedItems } from '.';
|
|
4
4
|
import { SelectedCollectionsActions } from './reducers';
|
|
5
5
|
import { OUT_OF_STOCK_ACTION } from './type';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
2
|
import { Collection, FbStatusFetcherReturn, Product, ProductVariant, SearchedItems, SelectedItems } from './modal';
|
|
3
3
|
import { CollectionsActions } from './reducers';
|
|
4
4
|
export declare const liftTheStateUp: (payload: any, data: any) => any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
2
|
import { VariableListInterfaceV2 } from "../add-variableV2/AddVariableV2";
|
|
3
3
|
import { CarouselProduct } from "./modalElements/EditWhatsAppCarouselTemplateV2";
|
|
4
4
|
import { WhatsAppCarouselTemplateVariables } from "../template-preview/models/WhatsappCarouselTemplate";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplicationType } from '@bikdotai/bik-models/growth
|
|
1
|
+
import { ApplicationType } from '@bikdotai/bik-models/growth';
|
|
2
2
|
import { VariableV3 } from "../../../helpers";
|
|
3
3
|
import React, { LegacyRef } from 'react';
|
|
4
4
|
import Slider from 'react-slick';
|
package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import"../../../node_modules/@bikdotai/bik-models/growth/
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import"../../../node_modules/@bikdotai/bik-models/growth/index.js";import o from"../../../assets/icons/arrow_back.svg.js";import i from"../../../assets/icons/chevronLeft.svg.js";import n from"../../../assets/icons/chevronRight.svg.js";import r from"../../../assets/icons/PlusIcon.js";import{cloneDeep as a}from"lodash";import{useState as d,useEffect as s}from"react";import{Button as c}from"../../button/Button.js";import{IconButton as p}from"../../icon-button/IconButton.js";import{ProductPickerModal as u}from"../../product-picker-v2/modal.js";import{ScreenName as m}from"../../product-picker-v2/type.js";import{Badge as v}from"../Badge/index.js";import{useTemplateModalContext as h}from"../context/templateModalContext.js";import g from"./EditWhatsAppTemplateV2.js";import{ProductBox as f}from"./ProductBox.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import{COLORS as y}from"../../../constants/Theme.js";import"../../curtain/CurtainHelper.js";import"../../variable-picker-v3/model.js";import"../../template-preview/models/TemplateMeta.js";import{POD as b}from"../../template-preview/models/WhatsAppTemplate.js";import"../../template-preview/models/Channels.js";import{isRCSChannel as j}from"../../template-preview/helpers/templateMiscHelper.js";import{TitleMedium as x,TitleRegular as C,BodySecondary as I,BodyCaption as w}from"../../TypographyStyle.js";import{__exports as k}from"../../../_virtual/index.js";const O=O=>{let{template:P,whatsappSpecificPickerMeta:T,showVariableModal:S,variableListForImage:L,discountCode:B,setDiscountCode:E}=O;var A,M,V,D,F,R,W,_;const{selectedCarouselIndex:$,setTemplate:q,pickerConf:N,isProductCarouselType:z,pod:G,cardCount:H,carouselProducts:K,setCarouselProducts:J,isError:Q,cardImages:U,disableEditVariable:X,onDeleteSelectedProducts:Y,setSelectedCarouselIndex:Z,setVariableCallback:ee,setShowVariablePicker:te,sliderRef:le}=h(),[oe,ie]=d(j(null==P?void 0:P.channel)?"Carousel Cards":-1==$?"First Message (Step 1/2)":z?"Product Carousel "+((null===(M=null===(A=null==P?void 0:P.mapping)||void 0===A?void 0:A.body)||void 0===M?void 0:M.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(D=null===(V=null==P?void 0:P.mapping)||void 0===V?void 0:V.body)||void 0===D?void 0:D.length)?"(Step 2/2)":"")),[ne,re]=d(!1),[ae,de]=d(!1),se=$===(null!=H?H:-1)-1,ce=(null!=$?$:-1)<1;s((()=>{var e,t,l,o;ie(j(null==P?void 0:P.channel)?"Carousel Cards":-1==$?"First Message (Step 1/2)":z?"Product Carousel "+((null===(t=null===(e=null==P?void 0:P.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(o=null===(l=null==P?void 0:P.mapping)||void 0===l?void 0:l.body)||void 0===o?void 0:o.length)?"(Step 2/2)":""))}),[$]);const pe=e=>{null==J||J([{name:"variable",productName:e.actualValue}])};return s((()=>{-1===$&&j(null==P?void 0:P.channel)&&(null==Z||Z(0))}),[$,null==P?void 0:P.channel]),e("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!j(null==P?void 0:P.channel)&&null!=$&&$>=0&&!!(null===(R=null===(F=null==P?void 0:P.mapping)||void 0===F?void 0:F.body)||void 0===R?void 0:R.length)&&t(p,{Icon:o,onClick:()=>{null==Z||Z(-1)}}),t(x,Object.assign({style:{marginLeft:10}},{children:oe}))]})),z&&(null!==(W=null==K?void 0:K.length)&&void 0!==W?W:0)>0&&null!=$&&$>=0&&e("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[t(f,{editItem:()=>{1===(null==K?void 0:K.length)&&"variable"===K[0].name?(ee((()=>pe)),te(!0)):re(!ne)},cardBody:1===(null==K?void 0:K.length)&&"variable"===K[0].name?`${K[0].productName}`:`${null==K?void 0:K.length} Products Selected`,hideIcon:1===(null==K?void 0:K.length)&&"variable"===K[0].name,deleteItem:()=>{var e;if(1===(null==K?void 0:K.length)&&"variable"===K[0].name)return void(null==J||J([]));const t=a(Object.assign({},P));t&&(U&&U.length>0?null==U||U.forEach(((e,l)=>{var o;t.components[1].cards[l].components[0].example.header_handle=[null!==(o=U[l])&&void 0!==o?o:"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==q||q(t)),null==J||J([]),null==Y||Y()}}),K&&(null==K?void 0:K.length)>0&&"variable"!=K[0].name&&t(c,{disabled:(null!==(_=null==K?void 0:K.length)&&void 0!==_?_:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{de(!0),re(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!X&&z&&0===(null==K?void 0:K.length)&&null!=$&&$>=0&&e(l,{children:[e("div",Object.assign({style:{marginLeft:12}},{children:[t(C,{children:"Product(s)"}),t(I,{children:`Select ${null!=H?H:1} products`})]})),e("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:Q?16:12,marginRight:Q?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[t(c,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:Q?`2px dashed ${y.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:Q?"tertiaryGray":"dashBold",LeadingIcon:()=>t("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:t(r,{width:18,height:18,color:y.content.secondary})})),onClick:e=>{re(!0)}}),G===b.CHATBOT&&e(l,{children:[e("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),t(w,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),t("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),t(c,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:Q?`2px dashed ${y.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:Q?"tertiaryGray":"dashBold",LeadingIcon:()=>t("div",Object.assign({style:{display:"flex"}},{children:t(r,{width:18,height:18,color:y.content.secondary})})),onClick:e=>{ee((()=>pe)),te(!0)}})]})]})),Q&&t("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:t(v,{padding:"8px",errorText:"Please add products"})}))]}),!z&&(null!=$?$:-1)>-1&&e("div",Object.assign({style:{display:"flex",background:y.surface.hovered,alignItems:"center"}},{children:[t(p,{Icon:i,disabled:ce,width:8,height:14,svgStyle:ce?{}:{color:y.content.secondary},onClick:()=>{var e;null===(e=null==le?void 0:le.current)||void 0===e||e.slickPrev(),(null!=$?$:-1)<1||null==Z||Z((e=>e-1))}}),t(C,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:y.content.secondary},{children:`Card ${(null!=$?$:0)+1}/${H}`})),t(p,{Icon:n,width:8,height:14,disabled:se,svgStyle:se?{}:{color:y.content.secondary},onClick:()=>{var e;null===(e=null==le?void 0:le.current)||void 0===e||e.slickNext(),(null!=$?$:-1)>=(null!=H?H:-1)-1||null==Z||Z((e=>e+1))}})]})),t(g,{whatsappSpecificPickerMeta:T,template:P,onTemplateChange:e=>{null==q||q(e)},showVariableModal:S,variableListForImage:L,discountCode:B,setDiscountCode:E}),ne&&N&&t(u,{zIndex:200,startupScreen:ae?m.RearrangeProducts:m.Collections,rearrangeEnabled:!0,storeId:N.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,o=l.productId,i=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),o in t[e].products||(t[e].products[o]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[o].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!=K?K:[]),collectionFetcher:N.fetchCollections,productFetcher:N.fetchProducts,onAdd:(e,t)=>{var l,o,i,n,r,d;de(!1);const s=[];delete e.isCustom;for(const t of Object.keys(e)){const a=e[t].products;if(void 0!==a&&Object.keys(a).length)for(const e of Object.keys(a)){const c=a[e].variants;if(void 0!==c&&Object.keys(c).length)for(const p of Object.keys(c)){const{name:u,image:m,quantity:v,displayOrder:h}=c[p],g={name:u,image:null!==(o=null!=m?m:null===(l=a[e])||void 0===l?void 0:l.image)&&void 0!==o?o:"",quantity:v,variantId:p,productId:e,displayOrder:h,collectionId:t,productName:null!==(n=null===(i=a[e])||void 0===i?void 0:i.name)&&void 0!==n?n:"",productImage:null!==(d=null===(r=a[e])||void 0===r?void 0:r.image)&&void 0!==d?d:""};s.push(g)}}}const c=s.sort(((e,t)=>e.displayOrder-t.displayOrder)),p=s.map((e=>e.image)),u=a(Object.assign({},P));u&&(p.forEach(((e,t)=>{var l;u.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==U?void 0:U[t])&&void 0!==l?l:""]})),null==q||q(u)),null==J||J(c),re(!1)},searchInCollectionFetcher:N.searchInCollection,searchFetcher:N.searchProducts,visible:ne,onClose:()=>{re(!1)},exactLimit:null!=H?H:1,appType:N.appType||k.ApplicationType.BIK})]}))};export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as s}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as s}from"react/jsx-runtime";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import n from"../../assets/icons/cross.svg.js";import o from"../../assets/icons/info.svg.js";import{format as i}from"date-fns";import{useState as r,useEffect as a}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Avatar as c}from"../avatar/Avatar.js";import{SIZE as d,AVATAR_TYPES as p,AVATAR_BACKGROUND as m}from"../avatar/AvatarHelper.js";import{Button as y}from"../button/Button.js";import{StateComponent as h,StateInterface as f}from"../states/StateComponent.js";import"../../_virtual/_tslib.js";import{TitleRegular as g,BodySecondary as u,Caption as v}from"../TypographyStyle.js";import{UnsatisfactoryCountIntentWiseModal as b}from"./UnsatisfactoryCountIntentWiseModal.js";import{IncorrectRepliesStyle as j}from"./UnsatisfactoryResponseList.style.js";import{__exports as I}from"../../_virtual/index.js";const w=w=>{const{storeId:C,appType:T,incorrectMessages:x,onIncorrectMessageBubbleClick:U,setShowIncorrectReplies:M,ChecklistType:O,IntentWiseUnsatisfactoryResponse:R,IntentHeaderTitle:k,redirectToUnsatisfactoryResponse:A,fetchUnsatisfactoryResponseCountIntentWise:N,fetchUnsatisfactoryResponseCount:S}=w,[W,_]=r(""),[L,D]=r((null==x?void 0:x.length)>0),[E,H]=r(!1);return a((()=>{!L&&S&&S().then((e=>{e>0&&D(!0),0===e&&M(!1)}))}),[]),e("div",Object.assign({style:{overflow:"scroll",height:"100%"}},{children:t(j,{children:[T==I.ApplicationType.MANIFEST&&t("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px"}},{children:[t("div",Object.assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},{children:[e(g,{children:"Unsatisfactory responses"}),e("div",Object.assign({style:{cursor:"pointer"},onClick:()=>M(!1)},{children:e(n,{height:16,width:16,color:l.content.primary})}))]})),e(u,Object.assign({style:{color:l.content.secondary}},{children:"Spot unsatisfactory replies, dive deeper, and enhance with relevant data for improved responses."}))]})),!(null==x?void 0:x.length)&&e("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:e(h,{states:f.WARNING,heading:"No unsatisfactory responses",subline:"As of now, all responses are correct",isButtonEnabled:!1,width:0,size:d.SMALL,icon:e(c,{type:p.ICON,size:d.MEDIUM,background:m.LIGHT,icon:()=>e(o,{width:16,height:16,color:l.content.warning})})})})),!!(null==x?void 0:x.length)&&t(s,{children:[T==I.ApplicationType.MANIFEST&&e("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:(null==x?void 0:x.length)?"flex-start":"center"}},{children:e(y,{buttonText:"Fix all unsatisfactory responses",buttonType:"tertiary",size:"small",onClick:()=>{H(!0)},disabled:!L})})),e(b,{storeId:C,setShowUnsatisfactoryResponseModal:H,showUnsatisfactoryResponseModal:E,ChecklistType:O,UnsatisfactoryResponseIntentList:R,IntentHeaderTitle:k,fetchUnsatisfactoryResponseCountIntentWise:N,viewIntentWiseUnsatisfactoryResponse:A}),x&&(null==x?void 0:x.length)>0&&e("div",Object.assign({className:"wrapper"},{children:x.map(((s,n)=>t("div",Object.assign({className:"bubble",onClick:()=>{U(s.messageId),_(s.messageId)},style:W===s.messageId?{backgroundColor:l.surface.hovered}:{}},{children:[e(u,Object.assign({style:{color:l.content.primary}},{children:s.message})),e("div",{children:t(v,Object.assign({style:{color:l.content.secondary}},{children:[i(new Date(null==s?void 0:s.date),"hh:mm a")," |"," ",i(new Date(null==s?void 0:s.date),"dd/MM/yyyy")]}))})]}),s.messageId)))}))]})]})}))};export{w as UnsatisfactoryResponseList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{commonjsGlobal as r}from"../../../../_virtual/_commonjsHelpers.js";import{__exports as e}from"../../../../_virtual/index.js";import"./models/store.js";import"./models/billing.js";import"./models/bik-store.js";import{__exports as t}from"../../../../_virtual/store.js";import{__exports as o}from"../../../../_virtual/billing.js";import{__exports as i}from"../../../../_virtual/bik-store.js";var s,n,a;s=e,n=r&&r.__createBinding||(Object.create?function(r,e,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(e,t);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,o,i)}:function(r,e,t,o){void 0===o&&(o=t),r[o]=e[t]}),a=r&&r.__exportStar||function(r,e){for(var t in r)"default"===t||Object.prototype.hasOwnProperty.call(e,t)||n(e,r,t)},Object.defineProperty(s,"__esModule",{value:!0}),a(t,s),a(o,s),a(i,s);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__exports as e}from"../../../../../_virtual/billing.js";!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ExchangeRateMap=e.PACKAGES=e.TIER=e.PACKAGENAMES=e.MANIFEST_PACKAGENAMES=void 0;const _=14;var a,r,i;(a=e.MANIFEST_PACKAGENAMES||(e.MANIFEST_PACKAGENAMES={})).FREE="FREE",a.GLOBAL_STARTER_1_MONTH="GLOBAL_STARTER_1_MONTH",a.GLOBAL_BOOST_1_MONTH="GLOBAL_BOOST_1_MONTH",a.GLOBAL_GROWTH_1_MONTH="GLOBAL_GROWTH_1_MONTH",a.GLOBAL_SCALE_1_MONTH="GLOBAL_SCALE_1_MONTH",a.GLOBAL_STARTER_12_MONTH="GLOBAL_STARTER_12_MONTH",a.GLOBAL_BOOST_12_MONTH="GLOBAL_BOOST_12_MONTH",a.GLOBAL_GROWTH_12_MONTH="GLOBAL_GROWTH_12_MONTH",a.GLOBAL_SCALE_12_MONTH="GLOBAL_SCALE_12_MONTH",a.GLOBAL_BASIC_1_MONTH="GLOBAL_BASIC_1_MONTH",a.GLOBAL_PREMIUM_1_MONTH="GLOBAL_PREMIUM_1_MONTH",a.GLOBAL_VIP_1_MONTH="GLOBAL_VIP_1_MONTH",a.GLOBAL_ENTERPRISE_1_MONTH="GLOBAL_ENTERPRISE_1_MONTH",a.GLOBAL_BASIC_12_MONTH="GLOBAL_BASIC_12_MONTH",a.GLOBAL_PREMIUM_12_MONTH="GLOBAL_PREMIUM_12_MONTH",a.GLOBAL_VIP_12_MONTH="GLOBAL_VIP_12_MONTH",a.GLOBAL_ENTERPRISE_12_MONTH="GLOBAL_ENTERPRISE_12_MONTH",function(e){e.BIK_INSTAGRAM_PLAN="BIK_INSTAGRAM_PLAN",e.BIK_GROWTH_PLAN="BIK_GROWTH_PLAN",e.BIK_BUSINESS_PLAN="BIK_BUSINESS_PLAN",e.BIK_CUSTOM_PLAN="BIK_CUSTOM_PLAN",e.BIK_FREE_PLAN="BIK_FREE_PLAN",e.BIK_PLG_GROWTH_PLAN="BIK_PLG_GROWTH_PLAN",e.BIK_PLG_BUSINESS_PLAN="BIK_PLG_BUSINESS_PLAN",e.BIK_PLG_STARTER_PLAN="BIK_PLG_STARTER_PLAN",e.BIK_SALES_STARTER_PLAN="BIK_SALES_STARTER_PLAN",e.BIK_SALES_GROWTH_PLAN="BIK_SALES_GROWTH_PLAN",e.BIK_SALES_BUSINESS_PLAN="BIK_SALES_BUSINESS_PLAN"}(r=e.PACKAGENAMES||(e.PACKAGENAMES={})),function(e){e.TIER_0="TIER_0",e.TIER_1="TIER_1",e.TIER_2="TIER_2",e.TIER_3="TIER_3",e.TIER_4="TIER_4",e.TIER_5="TIER_5",e.TIER_6="TIER_6"}(i=e.TIER||(e.TIER={})),e.PACKAGES={FREE:{packageName:"FREE",quota:100,duration:30,description:"Free plan",price:0,freeTrialDays:0,overagePrice:0,overageAllowed:0},GLOBAL_STARTER_1_MONTH:{packageName:"GLOBAL_STARTER_1_MONTH",quota:1e3,duration:30,description:"Bik Starter Monthly Package",price:39,freeTrialDays:_,overagePrice:.04,overageAllowed:4975},GLOBAL_BOOST_1_MONTH:{packageName:"GLOBAL_BOOST_1_MONTH",quota:3e3,duration:30,description:"Bik Boost Monthly Package",price:99,freeTrialDays:_,overagePrice:.04,overageAllowed:4975},GLOBAL_GROWTH_1_MONTH:{packageName:"GLOBAL_GROWTH_1_MONTH",quota:7500,duration:30,description:"Bik Growth Monthly Package",price:249,freeTrialDays:_,overagePrice:.035,overageAllowed:14229},GLOBAL_SCALE_1_MONTH:{packageName:"GLOBAL_SCALE_1_MONTH",quota:3e4,duration:30,description:"Bik Scale Monthly Package",price:799,freeTrialDays:_,overagePrice:.025,overageAllowed:63920},GLOBAL_STARTER_12_MONTH:{packageName:"GLOBAL_STARTER_12_MONTH",quota:12e3,duration:365,description:"Bik Starter Annual Package",price:399,freeTrialDays:_},GLOBAL_BOOST_12_MONTH:{packageName:"GLOBAL_BOOST_12_MONTH",quota:36e3,duration:365,description:"Bik Boost Annual Package",price:999,freeTrialDays:_},GLOBAL_GROWTH_12_MONTH:{packageName:"GLOBAL_GROWTH_12_MONTH",quota:9e4,duration:365,description:"Bik Growth Annual Package",price:2499,freeTrialDays:_},GLOBAL_SCALE_12_MONTH:{packageName:"GLOBAL_SCALE_12_MONTH",quota:36e4,duration:365,description:"Bik Scale Annual Package",price:7999,freeTrialDays:_},GLOBAL_BASIC_1_MONTH:{packageName:"GLOBAL_BASIC_1_MONTH",quota:600,duration:30,description:"Bik Basic Monthly Package",price:99,freeTrialDays:7,overagePrice:.2,overageAllowed:1500},GLOBAL_PREMIUM_1_MONTH:{packageName:"GLOBAL_PREMIUM_1_MONTH",quota:2500,duration:30,description:"Bik Premium Monthly Package",price:249,freeTrialDays:7,overagePrice:.15,overageAllowed:5e3},GLOBAL_VIP_1_MONTH:{packageName:"GLOBAL_VIP_1_MONTH",quota:7e3,duration:30,description:"Bik VIP Monthly Package",price:499,freeTrialDays:7,overagePrice:.1,overageAllowed:15e3},GLOBAL_ENTERPRISE_1_MONTH:{packageName:"GLOBAL_ENTERPRISE_1_MONTH",quota:7e3,duration:30,description:"Manifest Enterprise Monthly Package",price:499,overagePrice:.1,overageAllowed:15e3,freeTrialDays:7},GLOBAL_BASIC_12_MONTH:{packageName:"GLOBAL_BASIC_12_MONTH",quota:7200,duration:365,description:"Bik Basic Annual Package",price:999,freeTrialDays:7},GLOBAL_PREMIUM_12_MONTH:{packageName:"GLOBAL_PREMIUM_12_MONTH",quota:3e4,duration:365,description:"Bik Premium Annual Package",price:2499,freeTrialDays:7},GLOBAL_VIP_12_MONTH:{packageName:"GLOBAL_VIP_12_MONTH",quota:84e3,duration:365,description:"Bik VIP Annual Package",price:4999,freeTrialDays:7},GLOBAL_ENTERPRISE_12_MONTH:{packageName:"GLOBAL_ENTERPRISE_12_MONTH",quota:84e3,duration:365,description:"Manifest Enterprise Annual Package",price:4999,freeTrialDays:7},[r.BIK_INSTAGRAM_PLAN]:{packageName:r.BIK_INSTAGRAM_PLAN,quota:2990,duration:30,description:"Instagram Plan",price:299,freeTrialDays:14,overageAllowed:598,waFreeCredits:1.1,emailFreeCredits:5.95,freeContacts:1e4,emailUnitCost:37e-5},[r.BIK_GROWTH_PLAN]:{packageName:r.BIK_GROWTH_PLAN,quota:5990,duration:30,description:"Growth Plan",price:599,freeTrialDays:14,overageAllowed:1198,waFreeCredits:4.95,emailFreeCredits:35.71,freeContacts:1e5,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_BUSINESS_PLAN]:{packageName:r.BIK_BUSINESS_PLAN,quota:7990,duration:30,description:"Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:49.5,emailFreeCredits:35.71,emailUnitCost:37e-5,freeContacts:2e6,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}},[r.BIK_CUSTOM_PLAN]:{packageName:r.BIK_CUSTOM_PLAN,quota:5e3,duration:30,description:"Custom Plan",price:0,freeTrialDays:0,overageAllowed:79900,waFreeCredits:12.5,emailFreeCredits:12.5,emailUnitCost:37e-5},[r.BIK_FREE_PLAN]:{packageName:r.BIK_FREE_PLAN,quota:10,duration:30,description:"Free Plan",price:0,freeTrialDays:0,overageAllowed:10,waFreeCredits:.55,emailFreeCredits:.6,freeContacts:500,emailUnitCost:37e-5},[r.BIK_PLG_STARTER_PLAN]:{packageName:r.BIK_PLG_STARTER_PLAN,quota:990,duration:30,description:"BIK Starter Plan",price:99,freeTrialDays:14,overageAllowed:198,waFreeCredits:1.1,emailFreeCredits:5.95,freeContacts:1e4,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:99},[i.TIER_2]:{price:169},[i.TIER_3]:{price:179},[i.TIER_4]:{price:329},[i.TIER_5]:{price:529}}},[r.BIK_PLG_GROWTH_PLAN]:{packageName:r.BIK_PLG_GROWTH_PLAN,quota:3990,duration:30,description:"BIK Growth Plan",price:399,freeTrialDays:14,overageAllowed:798,waFreeCredits:4.95,emailFreeCredits:35.71,freeContacts:1e5,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_PLG_BUSINESS_PLAN]:{packageName:r.BIK_PLG_BUSINESS_PLAN,quota:7990,duration:30,description:"BIK Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:49.5,emailFreeCredits:35.71,freeContacts:2e6,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}},[r.BIK_SALES_STARTER_PLAN]:{packageName:r.BIK_SALES_STARTER_PLAN,quota:990,duration:30,description:"BIK Sales Starter Plan",price:99,freeTrialDays:14,overageAllowed:198,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:99},[i.TIER_2]:{price:169},[i.TIER_3]:{price:179},[i.TIER_4]:{price:329},[i.TIER_5]:{price:529}}},[r.BIK_SALES_GROWTH_PLAN]:{packageName:r.BIK_SALES_GROWTH_PLAN,quota:3990,duration:30,description:"BIK Sales Growth Plan",price:399,freeTrialDays:14,overageAllowed:798,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_SALES_BUSINESS_PLAN]:{packageName:r.BIK_SALES_BUSINESS_PLAN,quota:7990,duration:30,description:"BIK Sales Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}}},e.ExchangeRateMap={"USD-INR":83.235758,"INR-USD":.0120141,"GBP-INR":101.020305081,"INR-GBP":.00990747,"AUD-INR":52.606042,"INR-AUD":.0190078,"JPY-INR":.55805653,"INR-JPY":1.79193,"INR-PKR":3.41966,"PKR-INR":.2924269,"CAD-INR":60.719681,"INR-CAD":.0164691,"INR-RUB":1.19476,"RUB-INR":.83698689,"INR-AED":.0441093,"AED-INR":22.670942,"INR-EUR":.011435464,"EUR-INR":87.447258,"INR-BRL":.061935861,"BRL-INR":16.1457,"USD-GBP":.811721,"USD-EUR":.940639,"USD-CAD":1.36082,"USD-SGD":1.36185,"USD-USD":1,"USD-SAR":3.75,"SAR-USD":.26666667,"KWD-USD":3.23494,"USD-KWD":.309125,"QAR-USD":.27472527,"USD-QAR":3.64,"AED-USD":.27229408,"USD-AED":3.6725,"ZAR-USD":.053130272,"USD-ZAR":18.8202,"PKR-USD":.0035818064,"USD-PKR":279.189,"LKR-USD":.0030839229,"USD-LKR":324.262,"TRY-USD":.03604935,"USD-TRY":27.7395,"CNY-USD":.13756281,"USD-CNY":7.26941,"CNH-USD":.13701883,"USD-CNH":7.29853,"BRL-USD":.19798628,"USD-BRL":5.05086,"KRW-USD":.0007471076,"USD-KRW":1338.5,"AUD-USD":.6409892,"USD-AUD":1.56009,"JPY-USD":.0067046544,"USD-JPY":149.15,"CAD-USD":.7348507,"GBP-USD":1.2319473,"EUR-USD":1.0631068,"SGD-USD":.73429505}}(e);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__exports as T}from"../../../../../_virtual/store.js";var S,e,A,_,P,O;S=T,Object.defineProperty(S,"__esModule",{value:!0}),S.ATTRIBUTION_TYPE=S.Statuses=S.PartnerSyncStatusType=S.AppType=S.BillingType=void 0,(e=S.BillingType||(S.BillingType={})).COMPLETELY_ON_SHOPIFY="COMPLETELY_ON_SHOPIFY",e.PARTIALLY_ON_SHOPIFY="PARTIALLY_ON_SHOPIFY",e.OUTSIDE_SHOPIFY="OUTSIDE_SHOPIFY",(A=S.AppType||(S.AppType={})).GLOBAL="GLOBAL",A.WHATSAPP="WHATSAPP",A.BSP="BSP",A.WHATSAPP_CUSTOM="WHATSAPP_CUSTOM",A.WHATSAPP_LISTING="WHATSAPP_LISTING",A.GLOBAL_LISTING="GLOBAL_LISTING",A.GLOBAL_CUSTOM="GLOBAL_CUSTOM",(_=S.PartnerSyncStatusType||(S.PartnerSyncStatusType={})).NOT_STARTED="NOT_STARTED",_.IN_PROGRESS="IN_PROGRESS",_.COMPLETED="COMPLETED",_.FAILED="FAILED",(P=S.Statuses||(S.Statuses={})).Active="Active",P.Inactive="Inactive",P.Blocked="Blocked",P.Closed="Closed",P.Churned_deleted="Churned_deleted",(O=S.ATTRIBUTION_TYPE||(S.ATTRIBUTION_TYPE={})).CLICK_BASED="CLICK_BASED",O.OPEN_BASED="OPEN_BASED",O.DELIVERY_BASED="DELIVERY_BASED";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bikdotai/bik-component-library",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.692",
|
|
4
4
|
"description": "Bik Component Library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@amplitude/analytics-browser": "^2.9.3",
|
|
50
50
|
"@babel/runtime": "^7.20.7",
|
|
51
|
+
"@bikdotai/bik-models": "^2.12.0",
|
|
51
52
|
"@lottiefiles/react-lottie-player": "^3.5.3",
|
|
52
53
|
"@popperjs/core": "^2.11.7",
|
|
53
54
|
"@tippyjs/react": "^4.2.6",
|
|
@@ -79,7 +80,6 @@
|
|
|
79
80
|
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
80
81
|
"@babel/preset-env": "^7.20.2",
|
|
81
82
|
"@babel/preset-react": "^7.18.6",
|
|
82
|
-
"@bikdotai/bik-models": "1.25.183",
|
|
83
83
|
"@changesets/cli": "^2.26.0",
|
|
84
84
|
"@commitlint/cli": "^17.4.1",
|
|
85
85
|
"@commitlint/config-conventional": "^17.4.0",
|