1"use strict";(globalThis.__LOADABLE_LOADED_CHUNKS__=globalThis.__LOADABLE_LOADED_CHUNKS__||[]).push([[2411,8868],{93399(e,t,n){n.r(t),n.d(t,{default:()=>g});var a=n(22224),s=n.n(a),l=n(41594),o=n.n(l),i=n(98483),r=n(64128),c=n(48059),d=n(79618),u=n(3602),m=n(75158),p=n(64982),h=n(63988);const g=(0,r.A)(function(e){let{onClose:t,sync_started:n}=e;const a=(0,i.wA)(),r=(0,m.Us)(),[d,g]=(0,l.useState)(0),[x,_]=(0,l.useState)(!1),y=(0,i.d4)(e=>{let{temp:t}=e;return t.marketing_software}),f=(0,i.d4)(c.Tp.loading),b=(0,i.d4)(c.Tp.sync_state),v=(0,i.d4)(e=>s().get(e,"marketing_platforms.sync_details",{})),j=(0,i.d4)(c.Tp.syncing_status),w=(0,i.d4)(e=>s().get(e,"marketing_platforms.pereferences",p.hv)),C=(0,i.d4)(e=>{const t=s().get(e,"marketing_platforms.platform_data",{});return{total_contacts:s().get(t,"total_contacts",0),total_duplicates:s().get(t,"total_duplicates",null),total_duplicate_emails_contacts:s().get(t,"total_duplicate_emails_contacts",null),duplicate_emails:s().get(t,"duplicate_emails_contacts",[])||[],invalid_emails:s().get(t,"invalid_emails_contacts",[])||[]}}),E=o().useMemo(()=>{const e=s().get(w,"industry",[]),t=s().get(w,"client_status",[]),n=s().get(w,"department",[]);return e&&e.length>0&&t&&t.length>0&&n&&n.length>0},[w,y]),k=[{label:"Preferences",content:(0,h.jsx)(p.bd,{mp_preferences:w,platform_data:C,sync_started:n,syncing_status:j,sync_state:b,marketing_software:y,can_sync:E,can_re_sync:x,onClose:t})}].concat(n?[{label:"Failed",content:(0,h.jsx)(p.Z3,{type:"failed_contacts",action:"FAILED",default_comments:"Invalid Email or Sync timeout"},"failed_contacts_tab"),onClick:function(){a((0,c.Yp)({failed_contacts:"y",limit:20,offset:0}))}},{label:"HUBSPOT"===y?"Deleted":"Archived",content:(0,h.jsx)(p.Z3,{type:"HUBSPOT"==y?"deleted_contacts":"archived_contacts",action:"HUBSPOT"==y?"DELETED":"ARCHIVED",default_comments:"HUBSPOT"==y?"Deleted contact":"Archived contact"},"archived_contacts_tab"),onClick:function(){const e="HUBSPOT"==y?"deleted_contacts":"archived_contacts";a((0,c.Yp)({[e]:"y",limit:20,offset:0}))}},{label:"Unsubscribed",content:(0,h.jsx)(p.Z3,{type:"unsubscribed_contacts",action:"UNSUBSCRIBED",default_comments:"Unsubscribed contact"},"unsubscribed_contacts_tab"),onClick:function(){a((0,c.Yp)({unsubscribed_contacts:"y",limit:20,offset:0}))}}]:[]);return(0,l.useEffect)(()=>{n&&a((0,c.Yp)()),a((0,c.zo)(r.company_id)),a((0,c.qf)({mp_prefs:w}))},[]),(0,l.useEffect)(()=>{const e=setTimeout(()=>{a(n?(0,c.Yp)():(0,c.qf)({mp_prefs:w}))},5e3);return b||(s().get(v,"failed",0)>0||s().get(v,"unsubscribed",0)>0||s().get(v,"pending",0)>0||s().get(v,"archived",0)>0||s().get(v,"deleted",0)>0?_(!0):_(!1),clearTimeout(e)),()=>e&&clearTimeout(e)},[n,v,b]),(0,h.jsx)(u.Theme,{"data-test-name":"MPPreferencesPopup",children:(0,h.jsx)(u.Popup,{width:10/12*100+"%",style:{padding:"5px 25px",fontFamily:u.themeOptions.fonts.join(",")},onClose:t,title:`${y?s().upperFirst(s().lowerCase(y)):""} Sync`,controls:(0,h.jsx)(u.Button,{onClick:t,children:"Close"}),children:(0,h.jsx)("div",{className:"row",style:{overflow:"auto",marginBottom:"100px"},children:(0,h.jsx)(u.Row,{children:(0,h.jsxs)(u.Col,{xs:!0,padded:!0,children:[(0,h.jsx)(u.TabBar,{padded:!0,children:k.map((e,t)=>(0,h.jsx)(u.Tab,{size:k.length,selected:t==d,onClick:()=>{g(t);let e=k[t].onClick;e&&e()},children:e.label},"tabs_"+t))}),f?(0,h.jsx)(u.Loading,{}):k[d]?k[d].content:null]})})})})})},{[c.Ay.name]:c.Ay.reducer,[d.Ay.name]:d.Ay.reducer})},29449(e,t,n){n.d(t,{A:()=>y});var a=n(41594),s=n(98483),l=n(22078),o=n(67564),i=n(63988);const r=()=>(0,i.jsx)("tr",{children:(0,i.jsx)("td",{colSpan:"12",children:(0,i.jsx)("p",{children:(0,i.jsx)("a",{href:"https://help.commonsku.com/knowledge/shops-overview",target:"_blank",children:"Learn more about commonsku Shops."})})})}),c=e=>{let{fee:t,chargedDate:n,onClick:a}=e;return(0,i.jsxs)("div",{"data-test-name":"ShopFeeRow",className:n===t.charged_date?"fee-box selected":"fee-box",onClick:a,children:[(0,i.jsx)("div",{className:"header-date",children:(0,l.kq)(t.charged_date)}),(0,i.jsxs)("div",{className:"header-fee",children:[(0,l.up)(t.charged_sum)," ",t.charged_currency_converted]}),n===t.charged_date&&(0,i.jsx)(p,{fee:t})]})},d=e=>{let{shop:t}=e;const{headerStyle:n,tdTableStyle:a,tableStyle:s,tbodyStyle:l}=_;return(0,i.jsx)("tr",{"data-test-name":"InvoiceTable",children:(0,i.jsx)("td",{colSpan:"5",style:a,children:(0,i.jsxs)("table",{className:"inner
1-table",style:s,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:"Project Name"}),(0,i.jsx)("td",{children:"Created"}),(0,i.jsx)("td",{style:{textAlign:"right"},children:"Value (Order Currency)"}),(0,i.jsxs)("td",{style:{textAlign:"right"},children:["Converted Value (",t.charged_currency_converted,")"]}),(0,i.jsxs)("td",{style:{textAlign:"right"},children:["Fee (",t.charged_currency_converted,")"]})]})}),(0,i.jsx)("tbody",{style:l,children:Object.values(t.invoices).map(e=>(0,i.jsx)(u,{invoice:e},e.order_id))})]})})})},u=e=>{let{invoice:t}=e;return(0,i.jsxs)("tr",{"data-test-name":"InvoiceRow",onClick:()=>o.x.open(`${o.x.S3_URL}/charged_invoices/${t.order_id}`,"_blank"),children:[(0,i.jsxs)("td",{children:["#",t.job_number," â ",t.job_name]}),(0,i.jsx)("td",{children:(0,l.kq)(t.date_created)}),(0,i.jsxs)("td",{style:{textAlign:"right"},children:[(0,l.up)(t.charged_order_subtotal)," ",t.charged_order_currency]}),(0,i.jsx)("td",{style:{textAlign:"right"},children:(0,l.up)(t.charged_subtotal_converted)}),(0,i.jsx)("td",{style:{textAlign:"right"},children:(0,l.up)(t.charged_fee)})]})},m=e=>{let{fee:t,title:n,show:s}=e;const[l,o]=(0,a.useState)(null);return s?(0,i.jsxs)("table",{"data-test-name":"ShopTableBase",className:"outer-table",children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("td",{children:"Shop Name"}),(0,i.jsx)("td",{children:"Client"}),(0,i.jsx)("td",{style:{textAlign:"right"},children:n}),(0,i.jsxs)("td",{style:{textAlign:"right"},children:["Total Value (",t.charged_currency_converted,")"]}),(0,i.jsxs)("td",{style:{textAlign:"right"},children:["Total Fee (",t.charged_currency_converted,")"]})]})}),(0,i.jsx)("tbody",{children:Object.values(t.shops).filter(e=>"Invoices"===n?e.shop_invoice_count&&e.shop_invoice_count>0:e.shop_charges_count&&e.shop_charges_count>0).map(e=>"Invoices"===n?(0,i.jsx)(h,{shop:e,selected:l===e.shop_id,onClick:()=>o(e.shop_id)},`${e.shop_id}-Invoices`):(0,i.jsx)(g,{shop:e},`${e.shop_id}-Charges`))})]},`${t.charged_date}-${n}-shops`):null},p=e=>{let{fee:t}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(m,{fee:t,title:"Invoices",show:t.invoice_count&&t.invoice_count>0}),(0,i.jsx)(m,{fee:t,title:"Charges",show:t.charges_count&&t.charges_count>0})]})},h=e=>{let{shop:t,selected:n,onClick:a}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("tr",{className:n?"outer-row selected":"outer-row",onClick:a,children:[(0,i.jsxs)("td",{children:["#",t.shop_number," â ",t.shop_name]}),(0,i.jsx)("td",{children:t.client_name}),(0,i.jsx)("td",{className:"invoice-count",style:{textAlign:"right"},children:t.shop_invoice_count}),(0,i.jsx)("td",{style:{textAlign:"right"},children:(0,l.up)(t.shop_invoice_subtotal)}),(0,i.jsx)("td",{style:{textAlign:"right"},children:(0,l.up)(t.shop_charged_sum)})]}),(0,i.jsx)(d,{shop:t})]})},g=e=>{let{shop:t}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("tr",{className:"outer-row",children:[(0,i.jsxs)("td",{children:["#",t.shop_number," â ",t.shop_name]}),(0,i.jsx)("td",{children:t.client_name}),(0,i.jsx)("td",{className:"invoice-count",style:{textAlign:"right"},children:t.shop_charges_count}),(0,i.jsx)("td",{style:{textAlign:"right"},children:(0,l.up)(t.shop_charges_subtotal)}),(0,i.jsx)("td",{style:{textAlign:"right"},children:(0,l.up)(t.shop_charges_sum)})]})})},x=e=>
1Object.values(e.entities.shops_fees),_={headerStyle:{top:"120px",background:"#EDF2F5"},tdTableStyle:{padding:0},tableStyle:{margin:0}},y=()=>{const[e,t]=(0,a.useState)(null),n=(0,s.d4)(x);return n.length>0?(0,i.jsx)("div",{"data-test-name":"ShopsFeesView",className:"shop-fees",children:n.map(n=>(0,i.jsx)(c,{chargedDate:e,onClick:()=>t(n.charged_date),fee:n},n.charged_date))}):(0,i.jsx)(r,{"data-test-name":"ShopsFeesView"})}},94255(e,t,n){n.d(t,{A:()=>o}),n(41594);var a=n(3602),s=n(75158),l=n(63988);function o(e){let{activeTab:t=null,samePageTabs:n=[],setActiveTab:o=null}=e;const i=[{title:"My Settings",key:"my-settings",link:"/admin_settings_new.php?tab=my-settings"},{title:"Manage Users",key:"users",link:"/admin_users_new.php"},{title:"Company Settings",key:"settings",link:"/admin_settings_new.php"},{title:"Billing",key:"billing",link:"/admin_settings_new.php?tab=billing"}];return(0,s.u7)(["FEATURE-ESSENTIAL","FEATURE-ADVANCED","FEATURE-ENTERPRISE"],!0)&&i.push({title:"Licenses",key:"licenses",link:"/admin_settings_new.php?tab=licenses"}),(0,l.jsx)(a.TabBar,{"data-test-name":"AdminSettingTopTabs",style:{marginBottom:"1rem"},children:i.map((e,s)=>(0,l.jsx)(a.Tab,{style:t===e.key?{borderBottomColor:"#EB1D6E"}:null,size:i.length,selected:t===e.key,onClick:()=>{-1!==n.indexOf(e.key)&&o?o(e.key):window.location.href=`https://${window.location.hostname}${e.link}`},children:e.title},"tabs_"+s))})}},35279(e,t,n){n.d(t,{A:()=>i});var a=n(41594),s=n(21519),l=n(98483),o=n(3915);function i(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.commissionClientRates),n=s.Tp.selectAll(t),i=t.loading;return(0,a.useEffect)(()=>{e((0,s.UK)())},[e]),[n,i,(0,a.useCallback)(t=>{(async()=>{t.commission_client_rate_id?await e((0,s.fk)({id:t.commission_client_rate_id,...t})):await e((0,s.B5)(t)),o.oR.success("Saved successfully")})()},[e]),(0,a.useCallback)(t=>{(async()=>{await e((0,s.LD)(t)),o.oR.success("Deleted successfully")})()},[e])]}},97836(e,t,n){n.d(t,{A:()=>l}),n(41594);var a=n(3602),s=n(63988);function l(e){let{title:t}=e;return(0,s.jsx)(a.Text,{"data-test-name":"DashboardPageTitle",style:{fontWeight:"600",fontSize:"32px",color:a.colors.neutrals[90],fontFamily:"skufont-regular"},children:t})}},27418(e,t,n){n.d(t,{A:()=>a});const a={DISTRIBUTOR_SOCIAL_FEATURE_ID:"f50cd437-e807-11e2-adb6-e811324a6a81",DISTRIBUTOR_ESSENTIAL_FEATURE_ID:"f9e5e614-32ed-11ef-9e25-302b4bf4e8ab",DISTRIBUTOR_ADVANCED_FEATURE_ID:"f9e5eb82-32ed-11ef-9e25-302b4bf4e8ab",DISTRIBUTOR_ENTERPRISE_FEATURE_ID:"f9e60ee6-32ed-11ef-9e25-302b4bf4e8ab",SUPPLIER_DORMANT_FEATURE_ID:"50d09f50-c49b-11e7-b6c6-a78bc432adcf",SUPPLIER_COMMUNITYBASIC_FEATURE_ID:"145ca04b-7270-11ed-983b-0ad1fa230847",SUPPLIER_COMMUNITYPLUS_FEATURE_ID:"19d58508-7270-11ed-983b-0ad1fa230847",SUPPLIER_CONNECTEDBASIC_FEATURE_ID:"1e2b78d1-7270-11ed-983b-0ad1fa230847",SUPPLIER_CONNECTEDPLUS_FEATURE_ID:"21ec7285-7270-11ed-983b-0ad1fa230847"}},50110(e,t,n){n.r(t),n.d(t,{default:()=>Rc});var a=n(41594),s=n.n(a),l=n(98483),o=n(24784),i=n(51904),r=n(2596),c=n(26926),d=n(28420),u=n(74766),m=n(97598),p=n(76603),h=n(23204),g=n(22078);const x=(0,h.pU)({selectId:e=>e.email_template_id,sortComparer:(e,t)=>(e.email_template_title+e.date_created).localeCompare(t.email_template_title+t.date_created)}),_=(0,h.Z0)({name:"emailTemplates",initialState:x.getInitialState({loading:"idle"}),reducers:{added:x.addOne,deleted:x.removeOne,loading(e,t){"idle"===e.loading&&(e.loading="pending")},loaded(e,t){"pending"===e.loading&&(e.loading="idle")},received(e,t){"pending"===e.loading&&(x.setAll(e,t.payload),e.loading="idle")},updated:x.updateOne}}),{added:y,deleted:f,loading:b,loaded:v,received:j,updated:w}=_.actions,C=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ADMIN";return async(t,n)=>{t(b());const a=await(0,g.oD)("GET","email-template",{parent_type:e});return t(j(a.json.email_templates)),a.json}},E=e=>async(t,n)=>{t(b());const a=await(0,g.oD)("POST","email-template",e);return t(y(Object.assign(a.json.email_template,{new:!0}))),t(v()),a.json.email_template},k=e=>async(t,n)=>{console.log("Update",e),t(b());const a=await(0,g.oD)("PUT","email-template/"+e.email_template_id,e);return t(w({id:e.email_template_id,changes:a.json.email_template})),t(v()),a.json.email_template},S=e=>async(t,n)=>{t(b());try{await(0,g.oD)("DELETE","email-template/"+e.email_template_id,{})}catch(e){return console.log("Failed to delete"),!1}return t(f(e.email_template_id)),t(v()),!0},I=x.getSelectors(),A=_.reducer;var T=n(24087);const D=(0,h.pU)({selectId:e=>e.commission_rate_id,sortComparer:(e,t)=>(e.commission_rate_label+e.commission_rate).localeCompare(t.commission_rate_label+t.commission_rate)}),R=(0,T.rh)("commissionRates",D),{added:L,deleted:P,loading:B,loaded:N,received:O,updated:U}=R.actions,F="commission-rate",M=D.getSelectors(),q=R.reducer,z=(0,h.pU)({selectId:e=>e.service_id,sortComparer:(e,t)=>e.service_name.localeCompare(t.service_name)}),G=(0,T.rh)("companyServices",z),{added:H,deleted:$,loading:W,loaded:Y,received:Q,updated:V}=G.actions,X="service",Z=z.getSelectors(),K=G.reducer,J=(0,h.pU)({selectId:e=>e.commission_margin_id,sortComparer:(e,t)=>parseInt(e.margin_min)<parseInt(t.margin_min)?-1:parseInt(e.margin_min)>parseInt(t.margin_min)?1:0}),ee=(0,T.rh)("commissionMarginRates",J),{added:te,deleted:ne,loading:ae,loaded:se,received:le,updated:oe}=ee.actions,ie="commission-margin-rate",re=J.getSelectors(),ce=ee.reducer;var de=n(21519);const ue=(0,h.pU)({selectId:e=>e.commission_sales_target_id,sortComparer:(e,t)=>parseInt(e.sales_target_min)<parseInt(t.sales_target_min)?-1:parseInt(e.sales_target_min)>parseInt(t.sales_target_min)?1:0}),me=(0,T.rh)("commissionSalesTargetRates",ue),{added:pe,deleted:he,loading:ge,loaded:xe,received:_e,updated:ye}=me.actions,fe="commission-sales-target-rate",be=ue.getSelectors(),ve=me.reducer,je=(0,T.Jz)(),we=(0,T.rh)("clientAccountStatus",je),{added:Ce,deleted:Ee,loading:ke,loaded:Se,received:Ie,updated:Ae}=we.actions,Te=(0,T.R9)(we.actions,"CLIENT"),{getAll:De,addItem:Re,updateItem:Le,deleteItem:Pe}=Te,Be=je.getSelectors(),Ne=we.reducer,Oe=(0,T.Jz)(),Ue=(0,T.rh)("supplierAccountStatus",Oe),{added:Fe,deleted:Me,loading:qe,loaded:ze,received:Ge,updated:He}=Ue.actions,$e=(0,T.R9)(Ue.actions,"SUPPLIER"),{getAll:We,addItem:Ye,updateItem:Qe,deleteItem:Ve}=$e,Xe=Oe.getSelectors(),Ze=Ue.reducer,Ke=(0,T.Jz)(),Je=(0,T.rh)("distributorAccountStatus",Ke),{added:et,deleted:tt,loading:nt,loaded:at,received:st,updated:lt}=Je.actions,ot=(0,T.R9)(Je.actions,"DISTRIBUTOR"),{getAll:it,addItem:rt,updateItem:ct,deleteItem:dt}=ot,ut=Ke.getSelectors(),mt=Je.reducer,pt=(0,h.pU)({selectId:e=>e.address_id,sortComparer:(e,t)=>(e.address_name+e.address_id).localeCompare(t.address_name+t.address_id)}),ht=(0,h.Z0)({name:"companyAddresses",initialState:pt.getInitialState({loading:"idle"}),reducers:{added:pt.addOne,deleted:pt.removeOne,loading(e,t){"idle"===e.loading&&(e.loading="pending")},loaded(e,t){"pending"===e.loading&&(e.loading="idle")}
1,received(e,t){"pending"===e.loading&&(pt.setAll(e,t.payload),e.loading="idle")},updated:pt.updateOne}}),{added:gt,deleted:xt,loading:_t,loaded:yt,received:ft,updated:bt}=ht.actions,vt=pt.getSelectors(),jt=ht.reducer;var wt=n(18265);const Ct=(0,h.Z0)({name:"userGeneralData",initialState:{loading:"idle",data:{}},reducers:{loading(e,t){"idle"===e.loading&&(e.loading="pending")},setData(e,t){e.data={...e.data,...t.payload},e.loading="idle"}}}),{setData:Et,loading:kt,loaded:St}=Ct.actions,It=Ct.reducer,At=(0,h.pU)({selectId:e=>e.company_term_id,sortComparer:(e,t)=>parseInt(e.display_order)<parseInt(t.display_order)?-1:parseInt(e.display_order)>parseInt(t.display_order)?1:0}),Tt=(0,T.rh)("companyTerms",At),{added:Dt,deleted:Rt,loading:Lt,loaded:Pt,received:Bt,updated:Nt}=Tt.actions,Ot=e=>async(t,n)=>{console.log("Update",e),t(Lt());const a=await(0,g.oD)("PUT","company-term/"+e.company_term_id,e);return t(Nt({id:e.company_term_id,changes:e})),t(Pt()),a.json.company_term},Ut=At.getSelectors(),Ft=Tt.reducer,Mt=(0,h.pU)({selectId:e=>e.next_action_type_id,sortComparer:(e,t)=>parseInt(e.display_order)<parseInt(t.display_order)?-1:parseInt(e.display_order)>parseInt(t.display_order)?1:0}),qt=(0,T.rh)("companyNextActionTypes",Mt),{added:zt,deleted:Gt,loading:Ht,loaded:$t,received:Wt,updated:Yt}=qt.actions,Qt="next-action-type",Vt=e=>async(t,n)=>{t(Ht());const a=await(0,g.oD)("PUT",Qt+"/"+e.next_action_type_id,e);return t(Yt({id:e.next_action_type_id,changes:a.json.next_action_type})),t($t()),a.json.next_action_type},Xt=Mt.getSelectors(),Zt=qt.reducer,Kt=(0,h.pU)({selectId:e=>e.imprint_id,sortComparer:(e,t)=>(e.imprint_name+e.imprint_id).localeCompare(t.imprint_name+t.imprint_id)}),Jt=(0,T.rh)("companyImprints",Kt),{added:en,deleted:tn,loading:nn,loaded:an,received:sn,updated:ln}=Jt.actions,on="imprint",rn=Kt.getSelectors(),cn=Jt.reducer,dn=(0,h.pU)({selectId:e=>e.tax_id,sortComparer:(e,t)=>1==e.tax_exempt?1==t.tax_exempt?(e.label+e.description+e.percent).localeCompare(t.label+t.description+t.percent):-1:1==t.tax_exempt?1:(e.label+e.description+e.percent).localeCompare(t.label+t.description+t.percent)}),un=(0,T.rh)("companyTaxes",dn),{added:mn,deleted:pn,loading:hn,loaded:gn,received:xn,updated:_n}=un.actions,yn="tax",fn=dn.getSelectors(),bn=un.reducer,vn=(0,h.pU)({selectId:e=>e.tax_nexus_id,sortComparer:(e,t)=>e.state.localeCompare(t.state)}),jn=(0,T.rh)("companyTaxNexus",vn),{added:wn,deleted:Cn,loading:En,loaded:kn,received:Sn,updated:In}=jn.actions,An="tax-nexus",Tn=vn.getSelectors(),Dn=jn.reducer,Rn=(0,h.pU)({selectId:e=>e.ship_method_id,sortComparer:(e,t)=>parseInt(e.ordering)<parseInt(t.ordering)?-1:parseInt(e.ordering)>parseInt(t.ordering)?1:0}),Ln=(0,T.rh)("companyShipMethods",Rn),{added:Pn,deleted:Bn,loading:Nn,loaded:On,received:Un,updated:Fn}=Ln.actions,Mn="ship-method",qn=e=>async(t,n)=>{console.log("Update",e),t(Nn());const a=await(0,g.oD)("PUT",Mn+"/"+e.ship_method_id,e);return t(Fn({id:e.ship_method_id,changes:e})),t(On()),a.json.tax},zn=Rn.getSelectors(),Gn=Ln.reducer,Hn=(0,h.pU)({selectId:e=>e.third_party_account_id,sortComparer:(e,t)=>(e.account_name+e.third_party_account_id).localeCompare(t.account_name+t.third_party_account_id)}),$n=(0,T.rh)("companyShipAccounts",Hn),{added:Wn,deleted:Yn,loading:Qn,loaded:Vn,received:Xn,updated:Zn}=$n.actions,Kn="third-party-shipping-account",Jn=Hn.getSelectors(),ea=$n.reducer,ta=(0,h.pU)({selectId:e=>e.exchange_rate_id,sortComparer:(e,t)=>(e.from_currency+e.to_currency).localeCompare(t.from_currency+t.to_currency)}),na=(0,T.rh)("companyExchangeRates",ta),{added:aa,deleted:sa,loading:la,loaded:oa,received:ia,updated:ra}=na.actions,ca="currency-exchange-rate",da=ta.getSelectors(),ua=na.reducer,ma=(0,h.pU)({selectId:e=>e.qbo_currency_id}),pa=(0,T.rh)("companyQboCurrencies",ma),{added:ha,loading:ga,loaded:xa,received:_a,updated:ya}=pa.actions,fa=ma.getSelectors(),ba=pa.reducer,va=(0,h.pU)({selectId:e=>e.qbo_tax_id}),ja=(0,T.rh)("companyQboTaxes",va),{added:wa,loading:Ca,loaded:Ea,received:ka,updated:Sa}=ja.actions,Ia=va.getSelectors(),Aa=ja.reducer,Ta=(0,h.pU)({selectId:e=>e.qbo_tax_account_id}),Da=(0,T.rh)("companyQboTaxAccounts",Ta),{added:Ra,loading:La,loaded:Pa,received:Ba,updated:Na}=Da.actions,Oa=Ta.getSelectors(),Ua=Da.reducer,Fa=(0,h.pU)({selectId:e=>e.qbo_custom_field_id}),Ma=(0,T.rh)("companyQboCustomFields",Fa),{added:qa,loading:za,loaded:Ga,received:Ha,updated:$a}=Ma.actions,Wa=Fa.getSelectors(),Ya=Ma.reducer,Qa=(0,h.pU)({selectId:e=>e.qbo_field_mapping_id}),Va=(0,T.rh)("companyQboFieldMappings",Qa),{added:Xa,loading:Za,loaded:Ka,received:Ja,updated:es}=Va.actions,ts=Qa.getSelectors(),ns=Va.reducer,as=(0,h.pU)({selectId:e=>e.qbo_class_id}),ss=(0,T.rh)("companyQboClasses",as),{added:ls,loading:os,loaded:is,received:rs,updated:cs}=ss.actions,ds=as.getSelectors(),us=ss.reducer,ms=(0,h.pU)({selectId:e=>e.benefit_id,sortComparer:(e,t)=>e.display_order-t.display_order}),ps=(0,T.rh)("companyBenefits",ms),{added:hs,deleted:gs,loading:xs,loaded:_s,received:ys,updated:fs}=ps.actions,bs="supplier-benefit",vs=ms.getSelectors(),js=ps.reducer,ws=(0,h.pU)({selectId:e=>e.division_id,sortComparer:(e,t)=>e.division_name.localeCompare(t.division_name)}),Cs=(0,h.Z0)({name:"companyDivisions",initialState:ws.getInitialState({loading:"idle"}),reducers:{loading(e,t){"idle"===e.loading&&(e.loading="pending")},received(e,t){"pending"===e.loading&&(ws.setAll(e,t.payload),e.loading="idle")}}}),{loading:Es,received:ks}=Cs.actions,Ss=ws.getSelectors(),Is=Cs.reducer,As=(0,h.pU)({selectId:e=>e.billing_period_id,sortComparer:(e,t)=>e.billing_period_start.localeCompare(t.billing_period_start)}),Ts=(0,h.Z0)({name:"billingPeriods",initialState:As.getInitialState({loading:"idle"}),reducers:{loading(e,t){"idle"===e.loading&&(e.loading="pending")},received(e,t){"pending"===e.loading&&(As.setAll(e,t.payload),e.loading="idle")}}}),{loading:Ds,received:Rs}=Ts.actions,Ls=As.getSelectors(),Ps=Ts.reducer,Bs=(0,h.pU)({selectId:e=>e.charge_id,sortComparer:(e,t)=>{let n=e.division_name.localeCompare(t.division_name);return n||(n=e.distributor_name.localeCompare(t.distributor_name),n||e.po_number.localeCompare(t.po_number))}}),Ns=(0,h.Z0)({name:"billingCharges",initialState:Bs.getInitialState({loading:"idle"}),reducers:{loading(e,t){"idle"===e.loading&&(e.loading="pending")},received(e,t){"pending"===e.loading&&(Bs.setAll(e,t.payload),e.loading="idle")}}}),{loading:Os,received:Us}=Ns.actions,Fs=Bs.getSelectors(),Ms=Ns.reducer;var qs=n(75385),zs=n(69097),Gs=n(67564),Hs=n(64982),$s=(0,Gs.Cj)();const Ws=$s.dropdowns?$s.dropdowns:{},Ys=$s.identity?$s.identity:{},Qs={display:m.A,temp:p.Ay,dropdowns:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ws,t=arguments.length>1?arguments[1]:void 0;return Object.assign({},e,(0,u.J5)(e,t),{divisions:(0,zs.A_)(e.divisions?e.divisions:[],t),suppliers:(0,zs.VR)(e.suppliers?e.suppliers:[],t),decorators:(0,qs.O9)(e.decorators?e.decorators:[],t)})},entities:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:$s.entities||{},t=arguments.length>1?arguments[1]:void 0;return Object.assign({},e,(0,u.K9)(e,t),{decorations:(0,qs.lE)(e.decorations?e.decorations:[],t),decorator_id:(0,qs.BM)(e.decorator_id?e.decorator_id:"",t)})},identity:function(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ys},emailTemplates:A,commissionRates:q,companyServices:K,commissionMarginRates:ce,commissionClientRates:de.Ay,commissionSalesTargetRates:ve,clientStatus:Ne,supplierStatus:Ze,distributorStatus:mt,companyAddresses:jt,companyGeneralData:wt.Ay,userGeneralData:It,companyTerms:Ft,companyNextActionTypes:Zt,companyImprints:cn,companyTaxes:bn,companyTaxNexus:Dn,companyShipMethods:Gn,companyShipAccounts:ea,companyExchangeRates:ua,companyQboCurrencies:ba,companyQboTaxAccounts:Ua,companyQboTaxes:Aa,companyQboCustomFields:Ya,companyQboFieldMappings:ns,companyQboClasses:us,companyBenefits:js,companyDivisions:Is,billingPeriods:Ps,billingCharges:Ms,[Hs.cY.name]:Hs.cY.reducer,[Hs.RJ.name]:Hs.RJ.reducer};var Vs=n(64128),Xs=(n(97494),n(3915)),Zs=n(3602),Ks=n(94255),Js=n(2340),el=n(39054),tl=n(22224),nl=n.n(tl),al=n(63988);function sl(e){let{label:t}=e;return(0,al.jsxs)("div",{"data-test-name":"AddButton",style:{display:"flex",alignItems:"center"},children:[(0,al.jsx)(Zs.AddIcon,{width:"1rem"})," ",(0,al.jsx)("span",{children:t||"Add New"})]})}var ll=n(24432);function ol(e){let{defaultAddressId:t,item:n,saveItem:s,deleteItem:l,saveCompanyData:o}=e;const[i,r]=(0,a.useState)(!1),[c,d,u]=(0,ll.A)({deleteItemCallback:l}),m={address_name:"",address_company:"",address_line_1:"",address_line_2:"",address_line_3:"",address_line_4:"",address_city:"",address_country:"",address_state:"",address_postal:"",parent_type:"",parent_id:""},[p,h]=(0,a.useState)(n||m),[g,x]=(0,a.useState)(m),_=el.Xr.map(e=>({label:e,value:e})),y=nl().get(el.xP,p.address_country,[]),f=[{value:"",label:""}].concat(y.map(e=>({label:e.name,value:e.name}))),b=(0,a.useCallback)(e=>{const t=e.target;h(e=>({...e,[t.name]:t.value}))},[]),v=(0,a.useCallback)(e=>{x(m);let t=0;for(const n of["address_line_1","address_country","address_city","address_postal"])""===e[n]&&(x(e=>({...e,[n]:"Required"})),t++);return e.address_postal&&!(0,el.cu)(e.address_postal)&&(x(e=>({...e,address_postal:"Invalid zip/postal code"})),t++),-1===["Canada","United States","Australia"].indexOf(e.address_country)||e.address_state||(x(e=>({...e,address_state:"Required"})),t++),!(t>0)},[]),j=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4;const a=""!==g[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyAddress.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(Zs.LabeledInput,{label:t||e,name:e,value:p[e],onChange:b}),a?(0,al.jsx)("span",{style:{color:"red"},children:g[e]}):""]})},w="State"+(-1!==["Canada","United States","Australia"].indexOf(p.address_country)?" *":"");let C=(0,al.jsx)(Zs.LabeledSelect,{label:w,name:"address_state",value:{label:p.address_state,value:p.address_state},options:f,onChange:e=>b({target:{name:"address_state",value:e.value}})});-1===["Canada","United States","Australia"].indexOf(p.address_country)&&(C=(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledInput,{className:"align-with-select",label:"State",name:"address_state",value:p.address_state,onChange:b})}));const E=(0,al.jsxs)(al.Fragment,{children:[j("address_name","Address Name",6),j("address_company","Address Company",6),j("address_line_1","Address Line 1 *",6),j("address_line_2","Address Line 2",6),j("address_line_3","Address Line 3",6),j("address_line_4","Address Line 4",6),j("address_city","City *",6),j("address_postal","Zip/Postal Code *"),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,children:[(0,al.jsx)(Zs.LabeledSelect,{label:"Country *",name:"address_country",value:{label:p.address_country,value:p.address_country},options:_,onChange:e=>{b({target:{name:"address_country",value:e.value}}),b({target:{name:"address_state",value:""}})}}),g.address_country?(0,al.jsx)("span",{style:{color:"red"},children:g.address_country}):""]}),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,children:[C,g.address_state?(0,al.jsx)("span",{style:{color:"red"},children:g.address_state}):""]}),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,style:{margin:"1rem 0"},children:[(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{v(p)&&(n||h(m),s({...n,...p}),r(!1))},children:n?"Save":"Add"}),(0,al.jsx)(Zs.Button,{secondary:!0,style:{marginLeft:"1rem"},size:"small",onClick:()=>{h(n||m),r(!1)},children:"Cancel"}),n&&"TENANT-BILLING"!=n.parent_type&&"TENANT-SHIPPING"!=n.parent_type&&n.address_id!==t?(0,al.jsx)(Zs.IconButton,{size:"small",ml:16,preset
1:"delete",onClick:()=>{u(n),d(!0)}}):null]}),c]});let k=(0,al.jsx)(Zs.Col,{sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{r(!0)},children:(0,al.jsx)(sl,{})})});return n&&(k=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Col,{sm:3,style:{fontSize:"1.1em",fontWeight:"bold",display:"flex",alignItems:"center"},children:n.address_name}),(0,al.jsxs)(Zs.Col,{sm:7,children:[(0,al.jsx)("div",{children:n.address_line_1}),(0,al.jsx)("div",{children:`${n.address_city} ${n.address_state} ${n.address_postal}`}),(0,al.jsx)("div",{children:n.address_country})]}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{display:"flex",alignItems:"center"},children:n.address_id===t?(0,al.jsx)(Zs.DefaultStar,{forceSelected:!0}):(0,al.jsx)("button",{onClick:e=>{o({tenant_default_address_id:n.address_id})},children:(0,al.jsx)(Zs.DefaultStar,{})})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{display:"flex",alignItems:"center"},children:(0,al.jsx)("div",{style:{width:"100%",textAlign:"right"},children:(0,al.jsx)(Zs.IconButton,{preset:"edit",onClick:()=>{r(!0)}})})})]})),i?E:k}function il(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.identity),n=(0,l.d4)(e=>e.companyAddresses),s=vt.selectAll(n),o=n.loading;(0,a.useEffect)(()=>{var n;e((n=t.company_id,async(e,t)=>{e(_t());const a=await(0,g.oD)("GET","address",{parent_id:n});return e(ft(a.json.addresses)),a.json}))},[e,t.company_id]);const i=(0,a.useCallback)(n=>{(async()=>{var a;n.address_id?await e((a={id:n.address_id,...n},async(e,t)=>{console.log("Update",a),e(_t());const n=await(0,g.oD)("PUT","address/"+a.address_id,a);return e(bt({id:a.address_id,changes:n.json.address})),e(yt()),n.json.account_status})):await e((e=>async(t,n)=>{t(_t());const a=await(0,g.oD)("POST","address",e);return t(gt(Object.assign(a.json.address,{new:!0}))),t(yt()),a.json.address})({...n,parent_type:"TENANT",parent_id:t.company_id})),Xs.oR.success("Saved successfully")})()},[e,t.company_id]),r=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{e(_t());try{await(0,g.oD)("DELETE","address/"+n.address_id,{})}catch(e){return console.log("Failed to delete"),!1}return e(xt(n.address_id)),e(yt()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[s,o,i,r]}var rl=n(26118),cl=n(47558);function dl(){const{data:e,save:t}=(0,rl.A)(),[n,,a,s]=il(),l=n.map((n,l)=>(0,al.jsx)("div",{"data-test-name":"AdminCompanyAddress","data-testid":`row-${l}`,children:(0,al.jsx)(Zs.Row,{style:{borderBottom:"1px solid #ececec",marginBottom:"10px",paddingBottom:"10px"},children:(0,al.jsx)(ol,{defaultAddressId:e.data.tenant_default_address_id,item:n,saveItem:a,deleteItem:s,saveCompanyData:t})})},n.address_id)),o=(0,al.jsx)(Zs.Row,{style:{marginBottom:"250px"},children:(0,al.jsx)(ol,{saveItem:a})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Add or update the billing and shipping addresses that appears at the bottom of your sales and purchase forms.",link:"https://help.commonsku.com/knowledge/company-contact-info"}),l,o]})}var ul=n(57233);const ml=e=>{let{item:t,saveItem:n,deleteItem:s,index:l,onMove:o,onDrop:i}=e;const[r,c]=(0,a.useState)(!1),[d,u,m]=(0,ll.A)({deleteItemCallback:s}),p=(0,a.useMemo)(()=>({terms_name:"",terms_id:"",display_order:"",date_created:"",company_type:"",company_id:"",company_term_id:""}),[]),[h,g]=(0,a.useState)(p);(0,a.useEffect)(()=>{g(t||p)},[p,t]);const[x,_]=(0,a.useState)(p),y=(0,a.useCallback)(e=>{const t=e.target;g(e=>({...e,[t.name]:t.value}))},[]),f=(0,a.useCallback)(e=>{_(p);let t=0;for(const n of["terms_name"])""===e[n].trim()&&(_(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[p]),b=(0,a.useCallback)(()=>{f(h)&&(n({...t,...h}),t||(g(p),c(!1)))},[p,h,t,n,f]),v=(0,al.jsx)(ul.E2,{index:l,onDrop:i,onMove:o,item:t,canDrag:Boolean(t),type:"Item",children:(0,al.jsxs)("div",{style:{width:"100%"},children:[(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:1,className:"align-self-center",children:t?(0,al.jsx)(Zs.HandleIcon,{color:"#DAE9EE",altText:h.terms_name||""}):""}),t||r?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a=""!==x[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyTerm.getTextInput",padded:!0,sm:t,children:[(0,al.jsx)(Zs.Input,{className:"no-margin-bottom",name:e,value:h[e],onChange:y,onBlur:n?b:null}),a?(0,al.jsx)("span",{style:{color:"red"},children:x[e]}):""]})}("terms_name",10,!!t):null,t||r?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{c(!0)},children:(0,al.jsx)(sl,{})})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"}
1,children:t?(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{m(t),u(!0)}}):r?(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{b()},children:"Add"}):null})]}),d]})});return v};var pl=n(76723);function hl(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyTerms),n=Ut.selectAll(t),[s,o,i]=(0,pl.A)(n,Ot),r=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(Lt());const n=await(0,g.oD)("GET","company-term",{});return e(Bt(n.json.company_terms)),n.json})},[e]);const c=(0,a.useCallback)(t=>{(async()=>{var n;t.company_term_id?await e(Ot({id:t.company_term_id,...t})):await e((n=t,async(e,t)=>{e(Lt());const a=await(0,g.oD)("POST","company-term",n);return e(Dt(Object.assign(a.json.company_term,{new:!0}))),e(Pt()),a.json.company_term})),Xs.oR.success("Saved successfully")})()},[e]),d=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(Lt());try{await(0,g.oD)("DELETE","company-term/"+n.company_term_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(Rt(n.company_term_id)),e(Pt()),!0})),Xs.oR.success("Deleted successfully");let a=0;for(const n of s)n.company_term_id!==t.company_term_id&&(a!=n.display_order&&await e(Ot({...n,display_order:a})),a++)})()},[e,s]);return[s,r,c,d,o,i]}function gl(){const[e,t,n,a,s,l]=hl(),o=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminCompanyTerm","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ml,{id:e.company_term_id,index:t++,item:e,saveItem:n,deleteItem:a,onMove:s,onDrop:l})})},e.company_term_id)),i=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ml,{saveItem:n})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Create custom payment terms for your clients and suppliers. You can drag and drop your preferred payment term to the top of the list to make it your default.",link:"https://help.commonsku.com/knowledge/payment-terms"}),o,i]})}function xl(e){let{data:t,loading:n,save:s}=e;const l=(0,a.useMemo)(()=>({next_job_number:"",next_presentation_form_number:"",next_order_form_number:"",next_purchase_order_form_number:"",po_with_job_number:0}),[]),o=t.form_numbers,[i,r]=(0,a.useState)(l),[c,d]=(0,a.useState)(l);(0,a.useEffect)(()=>{let e=l;o&&(e={next_job_number:parseInt(o.job_number)+1,next_presentation_form_number:parseInt(o.presentation_number)+1,next_order_form_number:parseInt(o.sales_order_number)+1,next_purchase_order_form_number:parseInt(o.purchase_order_number)+1,po_with_job_number:+t.po_with_job_number}),r(e)},[t.po_with_job_number,l,o]);const u=(0,a.useCallback)(e=>{const t=e.target;r(e=>({...e,[t.name]:t.value}))},[]),m=(0,a.useCallback)(e=>{d(l);let t=0;for(const n of["next_job_number","next_presentation_form_number","next_order_form_number","next_purchase_order_form_number"])""===e[n]&&(d(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[l]),p=(0,a.useCallback)(()=>{m(i)&&s(i)},[i,s,m]),h=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4;const a=""!==c[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyGeneralFormNumbers.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(Zs.LabeledIconInput,{label:t||e,name:e,value:i[e],onChange:u,onBlur:p,Icon:(0,al.jsx)("div",{children:"#"})}),a?(0,al.jsx)("span",{style:{color:"red"},children:c[e]}):""]})};return(0,al.jsxs)(Zs.Row,{children:[h("next_job_number","Next Project",6),h("next_presentation_form_number","Next Presentation",6),h("next_order_form_number","Next Order",6),h("next_purchase_order_form_number","Next Purchase Order",6),(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"right"},children:(0,al.jsx)(Zs.LabeledCheckbox,{label:(0,al.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[(0,al.jsx)("div",{style:{textAlign:"left",fontWeight:"bold"},children:"Add the project number as a prefix on each purchase order"}),(0,al.jsx)("div",{children:"This simplifies communications between your suppliers and decorators"})]}),checked:1===i.po_with_job_number,onChange:e=>{u({target:{name:"po_with_job_number",value:1===i.po_with_job_number?0:1}}),s({po_with_job_number:1===i.po_with_job_number?0:1})}})})]})}function _l(){const{data:e,loading:t,save:n}=(0,rl.A)();return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Project numbers are unique IDs for your sales and purchase forms. Choose where you'd like your project and form numbers to
1start (it must be higher than the current number), and they'll climb in ascending order as your team creates new projects.",link:"https://help.commonsku.com/knowledge/project-numbers"}),(0,al.jsx)(xl,{data:e.data,loading:t,save:n})]})}const yl=["USD","CAD","AUD","NZD","SGD","GBP","BBD","INR","EUR"],fl=[{value:"SHOP_DESIGN",label:"Templates"},{value:"TILE",label:"Tiles"},{value:"LIST",label:"List"},{value:"GALLERY",label:"Gallery"},{value:"SMART",label:"Smart Gallery"}],bl=[{value:"DETAIL",label:"Detail"},{value:"SUMMARY",label:"Summary"}],vl=[{value:"SHIPPING-DATE",label:"Shipping Date"},{value:"IN-HANDS-DATE",label:"In Hands Date"}],jl=[{value:"",label:" "},{value:"CUSTOMER-PO",label:"Customer PO"},{value:"CLIENT-REP",label:"Client Rep"},{value:"ORDER-REP",label:"Order Rep"},{value:"EVENT-TYPE",label:"Event Type"},{value:"IN-HANDS-DATE",label:"In Hands Date"},{value:"JOB-NAME",label:"Project Name"},{value:"JOB-NUMBER",label:"Project Number"},{value:"BILLING-CONTACT",label:"Billing Contact"}],wl=[{value:"",label:" "},{value:"QBO_BILLADDR_LINE1",label:"Billing Address Line 1"},{value:"QBO_BILLADDR_LINE2",label:"Billing Address Line 2"},{value:"QBO_BILLADDR_LINE3",label:"Billing Address Line 3"},{value:"QBO_BILLADDR_LINE4",label:"Billing Address Line 4"},{value:"QBO_BILLADDR_CITY",label:"Billing Address City"},{value:"QBO_BILLADDR_STATE",label:"Billing Address State"},{value:"QBO_BILLADDR_COUNTRY",label:"Billing Address Country"},{value:"QBO_BILLADDR_POSTAL",label:"Billing Address Postal"},{value:"QBO_SHIPADDR_LINE1",label:"Shipping Address Line 1"},{value:"QBO_SHIPADDR_LINE2",label:"Shipping Address Line 2"},{value:"QBO_SHIPADDR_LINE3",label:"Shipping Address Line 3"},{value:"QBO_SHIPADDR_LINE4",label:"Shipping Address Line 4"},{value:"QBO_SHIPADDR_CITY",label:"Shipping Address City"},{value:"QBO_SHIPADDR_STATE",label:"Shipping Address State"},{value:"QBO_SHIPADDR_COUNTRY",label:"Shipping Address Country"},{value:"QBO_SHIPADDR_POSTAL",label:"Shipping Address Postal"}],Cl=[{value:"",label:" "},{value:"client_name",label:"Client Name"},{value:"client_tenant_account_number",label:"Client Account Number"},{value:"invoice_number",label:"Invoice Number"},{value:"customer_po",label:"Customer PO"},{value:"bill_address_line_1",label:"Billing Address Line 1"},{value:"bill_address_line_2",label:"Billing Address Line 2"},{value:"bill_address_line_3",label:"Billing Address Line 3"},{value:"bill_address_line_4",label:"Billing Address Line 4"},{value:"bill_address_city",label:"Billing Address City"},{value:"bill_address_state",label:"Billing Address State"},{value:"bill_address_country",label:"Billing Address Country"},{value:"bill_address_postal",label:"Billing Address Postal"},{value:"ship_address_line_1",label:"Shipping Address Line 1"},{value:"ship_address_line_2",label:"Shipping Address Line 2"},{value:"ship_address_line_3",label:"Shipping Address Line 3"},{value:"ship_address_line_4",label:"Shipping Address Line 4"},{value:"ship_address_city",label:"Shipping Address City"},{value:"ship_address_state",label:"Shipping Address State"},{value:"ship_address_country",label:"Shipping Address Country"},{value:"ship_address_postal",label:"Shipping Address Postal"},{value:"billing_contact",label:"Billing Contact"},{value:"shipping_contact",label:"Shipping Contact"},{value:"client_rep",label:"Client Rep"},{value:"order_rep",label:"Order Rep"},{value:"job_number",label:"Project Number"},{value:"job_name",label:"Project Name"},{value:"client_tags",label:"Client Tags"},{value:"order_tags",label:"Order Tags"}],El=[{value:"",label:" "},{value:"client_name",label:"Client Name"},{value:"client_tenant_account_number",label:"Client Account Number"},{value:"client_rep",label:"Client Rep"},{value:"order_rep",label:"Order Rep"},{value:"job_number",label:"Project Number"},{value:"job_name",label:"Project Name"},{value:"client_tags",label:"Client Tags"},{value:"order_tags",label:"Order Tags"}];n(61990);var kl=n(58199);function Sl(){var e;const t=(0,l.wA)(),n=(0,l.d4)(e=>e.identity),s=null!==(e=(0,l.d4)(e=>e.dropdowns.users))&&void 0!==e?e:[],o=(0,l.d4)(e=>e.entities.users),i=s.filter(e=>"client_rep_commission_rate_id"in e&&"order_rep_commission_rate_id"in e&&"comb
1ined_rep_commission_rate_id"in e).map(e=>({...e,...o[e.user_id]}));return(0,a.useEffect)(()=>{t((0,kl.ce6)(n.company_id,n.company_type,!0))},[t,n.company_id,n.company_type]),[i,(0,a.useCallback)((e,n,a)=>{(async()=>{t((0,kl.F1A)(e.user_id,n,a,e[n])),Xs.oR.success("Saved successfully")})()},[t])]}var Il=n(90424);function Al(e){let{field:t,label:n,initialValue:s="",error:l,onSave:o,placeholder:i}=e;const[r,c]=(0,a.useState)(s);return(0,a.useEffect)(()=>{c(s)},[s]),(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.LabeledInput,{className:"align-with-select",label:n,name:t,value:r,onChange:e=>c(e.target.value),onBlur:()=>{r!==s&&o(r)},placeholder:i}),l?(0,al.jsx)("span",{style:{color:"red"},children:l}):""]})}function Tl(e){let{taxes:t,data:n,loading:s,save:l}=e;const[o]=Sl(),i=fl,r=(0,a.useMemo)(()=>({default_invoice_view:"",default_currency_id:"",default_shipdate_option:"",default_presentation_style:"",default_tax_id:"",default_margin:"",default_client_rep_id:"",custom_service:""}),[]),[c,d]=(0,a.useState)(r),[u,m]=(0,a.useState)(r),p=yl.map(e=>({label:e,value:e})),h=t.map(e=>({label:e.label,value:e.tax_id})),g=o.map(e=>{var t;return{label:(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Il.Ay,{src:(null===(t=e.user_image_paths)||void 0===t?void 0:t.small)||null,name:e.contact_full_name,round:!0,size:"30"})," ",e.contact_full_name]}),value:e.user_id}});(0,a.useEffect)(()=>{let e=r;n.default_currency_id&&(e={...e,default_invoice_view:n.default_invoice_view,default_currency_id:n.default_currency_id}),n.companyData&&(e={...e,default_presentation_style:n.companyData.default_presentation_style,default_shipdate_option:n.companyData.default_shipdate_option,default_tax_id:n.companyData.default_tax_id,default_margin:n.companyData.default_margin,default_client_rep_id:n.companyData.default_client_rep_id,custom_service:n.companyData.custom_service}),d(e)},[n.companyData,n.default_currency_id,n.default_invoice_view,n.default_presentation_style,n.default_shipdate_option,r]);const x=(0,a.useCallback)(e=>{const t=e.target;d(e=>({...e,[t.name]:t.value}))},[]),_=(0,a.useCallback)(e=>{m(r);let t=0;for(const n of["default_invoice_view","default_currency_id","default_shipdate_option","default_presentation_style","default_tax_id","default_margin","default_client_rep_id"])""===e[n]&&(m(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[r]),y=e=>{let{label:t,name:n,options:a}=e,s={label:c[n],value:c[n]};return"default_tax_id"===n||"default_client_rep_id"===n?s=a.filter(e=>e.value===c[n]):["default_presentation_style","default_shipdate_option","default_invoice_view"].includes(n)&&(s=a.find(e=>e.value===c[n])),(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.LabeledSelect,{label:t,name:n,value:s,options:a,onChange:e=>{x({target:{name:n,value:e.value}});const t={...c,[n]:e.value};_(t)&&l(t)}}),u[n]?(0,al.jsx)("span",{style:{color:"red"},children:u[n]}):""]})},f=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const a=""!==u[e];return(0,al.jsx)(Al,{"data-test-name":"CompanyGeneralFormNumbers.getTextInput",field:e,label:t,initialValue:c[e],error:a?u[e]:"",onSave:t=>{x({target:{name:e,value:t}});const n={...c,[e]:t};_(n)&&l(n)},placeholder:n})};return(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:y({label:"Default Invoice View",name:"default_invoice_view",options:bl})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:y({label:"Default Currency",name:"default_currency_id",options:p})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:y({label:"Default PO Date Option",name:"default_shipdate_option",options:vl})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:y({label:"Default Presentation",name:"default_presentation_style",options:i})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:y({label:"Default Tax",name:"default_tax_id",options:h})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:f("default_margin","Default Margin")}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:y({label:"Default Client Rep For Imported Clients",name:"default_client_rep_id",options:g})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:f("custom_service","Custom Service","Define a custom service for estimates, sales orders, and invoices")})]})}function Dl(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyTaxes),n=fn.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(hn());const n=await(0,g.oD)("GET",yn,{});return e(xn(n.json.taxes)),n.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{var n;t.tax_id?await e((n={id:t.tax_id,...t},async(e,t)=>{console.log("Update",n),e(hn());const a=await(0,g.oD)("PUT",yn+"/"+n.tax_id,n);return e(_n({id:n.tax_id,changes:n})),e(gn()),a.json.tax})):await e((e=>async(t,n)=>{t(hn());const a=await(0,g.oD)("POST",yn,e);return t(mn(Object.assign(a.json.tax,{new:!0}))),t(gn()),a.json.tax})(t)),Xs.oR.success("Saved successfully")})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(hn());try{await(0,g.oD)("DELETE",yn+"/"+n.tax_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(pn(n.tax_id)),e(gn()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,o,i]}function Rl(){const{data:e,loading:t,saveBoth:n}=(0,rl.A)(),[a]=Dl();return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Set your preferences for your commonsku sales and purchase forms.",link:"https://help.commonsku.com/knowledge/other-options"}),(0,al.jsx)(Tl,{data:e.data,loading:t,save:n,taxes:a})]})}const Ll=e=>{let{item:t,saveItem:n,deleteItem:s,index:l,onDrop:o,onMove:i}=e;const[r,c]=(0,a.useState)(!1),d=(0,a.useMemo)(()=>({active:"",label:"",display_order:"",date_created:"",company_type:"",company_id:"",next_action_type_id:""}),[]),[u,m]=(0,a.useState)(d),[p,h]=(0,a.useState)(d),[g,x,_]=(0,ll.A)({deleteItemCallback:s});(0,a.useEffect)(()=>{m(t||d)},[d,t]);const y=(0,a.useCallback)(e=>{const t=e.target;m(e=>({...e,[t.name]:t.value}))},[]),f=(0,a.useCallback)(e=>{h(d);let t=0;for(const n of["label"])""===e[n].trim()&&(h(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[d]),b=(0,a.useCallback)(()=>{f(u)&&(t||(m(d),c(!1)),n({...t,...u}))},[d,u,t,n,f]);return(0,al.jsx)(ul.E2,{"data-test-name":"CompanyNextActionType",index:l,onDrop:o,onMove:i,item:t,canDrag:Boolean(t),type:"Item",children:(0,al.jsxs)("div",{style:{width:"100%"},children:[(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{sm:1,className:"align-self-center",children:t?(0,al.jsx)(Zs.HandleIcon,{color:"#DAE9EE",altText:u.label||""}):""}),t||r?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a=""!==p[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyNextActionType.getTextInput",padded:!0,sm:t,children:[(0,al.jsx)(Zs.Input,{className:"no-margin-bottom",name:e,value:u[e],onChange:y,onBlur:n?b:null}),a?(0,al.jsx)("span",{style:{color:"red"},children:p[e]}):""]})}("label",10,!!t):null,t||r?null:(0,al.jsx)(Zs.Col,{sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{c(!0)},children:(0,al.jsx)(sl,{})})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"}
1,children:t?(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{x(!0),_(t)}}):r?(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{b()},children:"Add"}):null})]}),g]})})};function Pl(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyNextActionTypes),n=Xt.selectAll(t),[s,o,i]=(0,pl.A)(n,Vt),r=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(Ht());const n=await(0,g.oD)("GET",Qt,{});return e(Wt(n.json.next_action_types)),n.json})},[e]);const c=(0,a.useCallback)(t=>{(async()=>{var n;t.next_action_type_id?await e(Vt({id:t.next_action_type_id,...t})):await e((n=t,async(e,t)=>{e(Ht());const a=await(0,g.oD)("POST",Qt,n);return e(zt(Object.assign(a.json.next_action_type,{new:!0}))),e($t()),a.json.next_action_type})),Xs.oR.success("Saved successfully")})()},[e]),d=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{e(Ht());try{await(0,g.oD)("DELETE",Qt+"/"+n.next_action_type_id,{})}catch(e){return console.log("Failed to delete"),!1}return e(Gt(n.next_action_type_id)),e($t()),!0})),Xs.oR.success("Deleted successfully");let a=0;for(const n of s)n.next_action_type_id!==t.next_action_type_id&&(console.log("update order",a,n.display_order),a!=n.display_order&&await e(Vt({...n,display_order:a})),a++)})()},[e,s]);return[s,r,c,d,o,i]}function Bl(){const[e,t,n,a,s,l]=Pl(),o=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminNextActionType","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Ll,{id:e.next_action_type_id,index:t,item:e,saveItem:n,deleteItem:a,onMove:s,onDrop:l})})}
1,e.next_action_type_id)),i=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Ll,{saveItem:n})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Create custom Next Action Types to help your production team manage POs on their Production Reports. You can drag and drop your action items to match your order of operations.",link:"https://help.commonsku.com/knowledge/next-action-types"}),o,i]})}function Nl(e){let{item:t,saveItem:n,deleteItem:s}=e;const[l,o]=(0,a.useState)(!1),i=(0,a.useMemo)(()=>({imprint_name:"",imprint_id:""}),[]),[r,c]=(0,a.useState)(t||i),[d,u]=(0,a.useState)(i),[m,p,h]=(0,ll.A)({deleteItemCallback:s}),g=(0,a.useCallback)(e=>{const t=e.target;c(e=>({...e,[t.name]:t.value}))},[]),x=(0,a.useCallback)(e=>{u(i);let t=0;for(const n of["imprint_name"])""===e[n].trim()&&(u(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[i]),_=(0,a.useCallback)(()=>{x(r)&&(t||(c(i),o(!1)),n({...t,...r}))},[i,r,t,n,x]);let y=(0,al.jsxs)(al.Fragment,{children:[function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const a=""!==d[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyImprint.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(Zs.Input,{style:{marginBottom:"0"},name:e,value:r[e],onChange:g,onBlur:t?_:null}),a?(0,al.jsx)("span",{style:{color:"red"},children:d[e]}):""]})}("imprint_name",11),t?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:_,children:t?"Save":"Add"})}),t?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"},children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{h(t),p(!0)}})}):(0,al.jsx)(Zs.Col,{sm:1}),m]});return t||l||(y=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{o(!0)},children:(0,al.jsx)(sl,{})})})),y}function Ol(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyImprints),n=rn.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(nn());const n=await(0,g.oD)("GET",on,{"max-results":1e3});return e(sn(n.json.imprints)),n.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{var n;t.imprint_id?await e((n={id:t.imprint_id,...t},async(e,t)=>{console.log("Update",n),e(nn());const a=await(0,g.oD)("PUT",on+"/"+n.imprint_id,n);return e(ln({id:n.imprint_id,changes:n})),e(an()),a.json.imprint})):await e((e=>async(t,n)=>{t(nn());const a=await(0,g.oD)("POST",on,e);return t(en(Object.assign(a.json.imprint,{new:!0}))),t(an()),a.json.imprint})(t)),Xs.oR.success("Saved successfully")})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(nn());try{await(0,g.oD)("DELETE",on+"/"+n.imprint_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(tn(n.imprint_id)),e(an()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,o,i]}function Ul(){const[e,t,n,a]=Ol(),s=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminImprint","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Nl,{item:e,saveItem:n,deleteItem:a})})},e.imprint_id)),l=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Nl,{saveItem:n})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Add, edit, or remove imprint methods for your supplier and decorator POs.",link:"https://help.commonsku.com/knowledge/imprint-methods"}),s,l]})}function Fl(e){let{item:t,saveItem:n,deleteItem:s}=e;const[l,o]=(0,a.useState)(!1),i=(0,a.useMemo)(()=>({description:"",label:"",tax_id:"",percent:"",tax_exempt:0}),[]),[r,c]=(0,a.useState)(t||i),[d,u]=(0,a.useState)(i),m=(0,a.useCallback)(e=>{const t=e.target;c(e=>({...e,[t.name]:t.value}))},[]),p=(0,a.useCallback)(e=>{u(i);let t=0;for(const n of["label","percent"])if(""===e[n].toString().trim())u(e=>({...e,[n]:"Required"})),t++;else if("percent"===n){const a=Number(e[n]);(isNaN(a)||a>100||a<0)&&(u(e=>({...e,[n]:"Rate must be between 0 and 100"})),t++)}return!(t>0)},[i]),h=(0,a.useCallback)(()=>{p(r)&&(t||(c(i),o(!1)),n({...t,...r}))},[i,r,t,n,p]),g=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const a=""!==d[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyTax.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(Zs.Input,{style:{marginBottom:"0"},disabled:0==(null==t?void 0:t.editable)?"disabled":null,name:e,value:r[e],onChange:m,onBlur:e=>{t&&h(r)}}),a?(0,al.jsx)("span",{style:{color:"red"},children:d[e]}):""]})};let x=(0,al.jsxs)(al.Fragment,{children:[g("label",2),g("description",6),g("percent",2),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,className:"centered-checkbox",children:(0,al.jsx)(Zs.LabeledCheckbox,{checked:1===+r.tax_exempt,onChange:e=>{0!==+(null==t?void 0:t.editable)&&(m({target:{name:"tax_exempt",value:1===+r.tax_exempt?0:1}}),t&&n({...r,tax_exempt:1===+r.tax_exempt?0:1}))}})}),t?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>h(r),children:t?"Save":"Add"})})]});return t||l||(x=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{o(!0)},children:(0,al.jsx)(sl,{})})})),x}var Ml=n(46676);function ql(e){var t;let{item:n,saveItem:s,deleteItem:l}=e;const[o,i]=(0,a.useState)(!1),[r,c,d]=(0,ll.A)({deleteItemCallback:l}),u=(0,a.useMemo)(()=>({state:"",tax_nexus_id:"",tenant_id:""}),[]),m=nl().get(el.xP,"United States",[]).map(e=>({label:e.name,value:e.abbr})),[p,h]=(0,a.useState)(n||u),g=(0,a.useCallback)(e=>{const t=e.target;h(e=>({...e,[t.name]:t.value}))},[]),x=(0,a.useCallback)(()=>{s({...n,...p}),n||(h(u),i(!1))},[u,p,n,s]);let _=(0,al.jsx)(Zs.LabeledSelect,{name:"state",value:m.filter(e=>e.value===p.state),options:m,onChange:e=>g({target:{name:"state",value:e.value}})});return(0,al.jsxs)("div",{style:{width:"100%"},children:[(0,al.jsxs)(Zs.Row,{children:[n?(0,al.jsx)(Zs.Col,{padded:!0,sm:11,children:null===(t=m.filter(e=>e.value===p.state)[0])||void 0===t?void 0:t.label}):null,!n&&o?(0,al.jsx)(Zs.Col,{padded:!0,sm:11,children:_}):null,n||o?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{i(!0)},children:(0,al.jsx)(sl,{})})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"}
1,children:n?(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{d(n),c(!0)}}):o?(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{x()},children:"Add"}):null})]}),r]})}function zl(){const[e,t,n,s]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyTaxNexus),n=Tn.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(En());const n=await(0,g.oD)("GET",An,{});return e(Sn(n.json.tax_nexus)),n.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{let n;var a;n=t.tax_id?await e((a={id:t.tax_nexus_id,...t},async(e,t)=>{e(En());const n=await(0,g.oD)("PUT",An+"/"+a.tax_nexus_id,a);return e(In({id:a.tax_nexus_id,changes:a})),e(kn()),n.json.tax_nexus})):await e((e=>async(t,n)=>{let a;t(En());try{a=await(0,g.oD)("POST",An,e)}catch(e){return!1}return t(wn(Object.assign(a.json.tax_nexus,{new:!0}))),t(kn()),a.json.tax_nexus})(t)),!1===n?Xs.oR.error("Unable to add"):Xs.oR.success("Saved successfully")})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(En());try{await(0,g.oD)("DELETE",An+"/"+n.tax_nexus_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(Cn(n.tax_nexus_id)),e(kn()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,o,i]}(),o=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminCompanyTaxNexus","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ql,{item:e,saveItem:n,deleteItem:s})})},e.tax_nexus_id)),i=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ql,{saveItem:n})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("h5",{style:{textAlign:"center"},children:"Tax Nexus"}),o,i]})}var Gl=n(84685);function Hl(){var e;const[t,n,s,l]=Dl(),{data:o,saveExtra:i}=(0,rl.A)(),[r,c]=(0,a.useState)(!1);(0,a.useEffect)(()=>{var e;c("1"==(null===(e=o.data.companyData)||void 0===e?void 0:e.zip2tax)),(0,Gl.W1)()},[null===(e=o.data.companyData)||void 0===e?void 0:e.zip2tax]);const d=t.filter(e=>1===+e.editable).map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminTax","data-testid":`editable-row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Fl,{item:e,saveItem:s,deleteItem:l})})},e.tax_id)),u=t.filter(e=>0===+e.editable).map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminTax","data-testid":`non-editable-row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Fl,{item:e,saveItem:s,deleteItem:l})})},e.tax_id)),m=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Fl,{saveItem:s})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:r?"If you are a US distributor using QuickBooks Online's automated sales tax tool, select the state(s) in your tax nexus, and Zip2Tax will automatically apply tax rates to your sales forms based on the ship-to address.":"Create tax codes to apply to your sales and purchase forms. Once you've created your tax codes, you can add a client or supplier's default tax directly to their page.",link:r?"https://help.commonsku.com/knowledge/zip2tax-1":"https://help.commonsku.com/knowledge/tax-codes"}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:(0,al.jsx)(Zs.Button,{secondary:!r,className:r?"lighter-button":"white-button",style:{width:"100%"},onClick:e=>{i({zip2tax:0})},children:"Manually enter tax codes"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:(0,al.jsx)(Zs.Button,{secondary:r,className:r?"white-button":"lighter-button",style:{width:"100%"},onClick:e=>{i({zip2tax:1})},children:"Zip2Tax"})})]}),r?(0,al.jsx)(zl,{}):(0,al.jsxs)(al.Fragment,{children:[(0,al.jsxs)(Zs.Row,{children:[(0,al.jsxs)(Zs.Col,{padded:!0,sm:2,children:[(0,al.jsx)("b",{children:"Label"})," ",(0,al.jsx)(Zs.InfoIcon,{altText:"",style:{verticalAlign:"middle"},"data-padding":"8px 8px","data-html":!0,"data-tip":'<div style="padding: 10px; max-width: 300px;">The tax label identifies tax rates on your orders and should be an easily identifiable shorthand. For example, E, GST, or WA SEA.</div>',width:"16px"})]}),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,children:[(0,al.jsx)("b",{children:"Description"})," ",(0,al.jsx)(Zs.InfoIcon,{altText:"",style:{verticalAlign:"middle"},"data-padding":"8px 8px","data-html":!0,"data-tip":'<div style="padding: 10px; max-width: 300px;">The tax description is client-facing and describes what the tax rate includes. For example, Exempt, Government Sales Tax, or Seattle Sales Tax.</div>',width:"16px"})]}),(0,al.jsxs)(Zs.Col,{padded:!0,sm:2,children:[(0,al.jsx)("b",{children:"Rate"})," ",(0,al.jsx)(Zs.InfoIcon,{altText:"",style:{verticalAlign:"middle"},"data-padding":"8px 8px","data-html":!0,"data-tip":'<div style="padding: 10px; max-width: 300px;">The tax rate should be a percentage (0-100).</div>',width:"16px"})]}),(0,al.jsx)(Zs.Col,{padded:!0,sm:2,children:(0,al.jsx)("b",{children:"Tax Exempt"})})]}),u,d,m]}),(0,al.jsx)(Ml.default,{})]})}const $l=e=>{let{couriers:t,item:n,saveItem:s,deleteItem:l,index:o,onMove:i,onDrop:r}=e;const[c,d]=(0,a.useState)(!1),u=(0,a.useMemo)(()=>({courier_id:"",ship_method_name:"",ship_method_id:""}),[]),[m,p]=(0,a.useState)(u);(0,a.useEffect)(()=>{p(n||u)},[u,n]);const[h,g]=(0,a.useState)(u),x=null==t?void 0:t.find(e=>e.value===m.courier_id),[_,y,f]=(0,ll.A)({deleteItemCallback:l}),b=(0,a.useCallback)(e=>{const t=e.target;p(e=>({...e,[t.name]:t.value}))},[]),v=(0,a.useCallback)(e=>{g(u);let t=0;for(const n of["ship_method_name","courier_id"])""===e[n].trim()&&(g
1(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[u]),j=(0,a.useCallback)(()=>{v(m)&&(n||(p(u),d(!1)),s({...n,...m}))},[u,m,n,s,v]);let w=(0,al.jsx)(ul.E2,{index:o,onDrop:r,onMove:i,item:n,canDrag:Boolean(n),type:"Item",children:(0,al.jsx)("div",{style:{width:"100%"},children:(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{sm:1,className:"align-self-center",children:n?(0,al.jsx)(Zs.HandleIcon,{color:"#DAE9EE",altText:m.ship_method_name||""}):""}),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const a=""!==h[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyShipMethod.getTextInput",padded:!0,sm:t,children:[(0,al.jsx)(Zs.Input,{className:"no-margin-bottom",name:e,value:m[e],onChange:b,onBlur:e=>{n&&j(m)}}),a?(0,al.jsx)("span",{style:{color:"red"},children:h[e]}):""]})}("ship_method_name",3),(0,al.jsxs)(Zs.Col,{padded:!0,sm:7,children:[(0,al.jsx)(Zs.LabeledSelect,{label:"",name:"courier_id",value:x,options:t,onChange:e=>{b({target:{name:"courier_id",value:e.value}}),null!=n&&n.ship_method_id&&s({...m,courier_id:e.value})}}),""!==h.courier_id?(0,al.jsx)("span",{style:{color:"red"},children:h.courier_id}):""]}),n?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>j(m),children:n?"Save":"Add"})}),n?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"},children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{y(!0),f(n)}})}):(0,al.jsx)(Zs.Col,{sm:1}),_]})})});return n||c||(w=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{d(!0)},children:(0,al.jsx)(sl,{})})})),w};function Wl(){const e=(0,l.wA)(),[t,n]=(0,a.useState)([]);return(0,a.useEffect)(()=>{const{cancel:e,promise:t}=(0,g.vX)((0,g.oD)("GET","courier",{}));return t.then(e=>n(e.json.couriers.map(e=>({label:e.courier_label,value:e.courier_id}))),()=>{}),e},[e]),t}function Yl(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=(0,l.wA)(),n=(0,l.d4)(e=>e.companyShipMethods),s=zn.selectAll(n),o=n.loading,i=Wl(),r=(0,a.useMemo)(()=>e?s.filter(t=>t.tenant_id===e):s,[s,e]),[c,d,u]=(0,pl.A)(r,qn,"ordering");(0,a.useEffect)(()=>{t(async(e,t)=>{e(Nn());const n=await(0,g.oD)("GET",Mn,{});return e(Un(n.json.ship_methods)),n.json})},[t]);const m=(0,a.useCallback)(e=>{(async()=>{var n;e.ship_method_id?await t(qn({id:e.ship_method_id,...e})):await t((n={...e,ordering:c.length},async(e,t)=>{e(Nn());const a=await(0,g.oD)("POST",Mn,n);return e(Pn(Object.assign(a.json.ship_method,{new:!0}))),e(On()),a.json.ship_method})),Xs.oR.success("Saved successfully")})()},[t,c.length]),p=(0,a.useCallback)(e=>{(async()=>{var n;await t((n=e,async(e,t)=>{console.log("delete",n),e(Nn());try{await(0,g.oD)("DELETE",Mn+"/"+n.ship_method_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(Bn(n.ship_method_id)),e(On()),!0})),Xs.oR.success("Deleted successfully");let a=0;for(const n of c)n.ship_method_id!==e.ship_method_id&&(a!=n.ordering&&await t(qn({...n,ordering:a})),a++)})()},[t,c]);return[c,o,m,p,i,d,u]}function Ql(){const[e,t,n,a,s,l,o]=Yl();let i=0;const r=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminShipMethod","data-testid":`editable-row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)($l,{index:i++,item:e,saveItem:n,deleteItem:a,couriers:s,onMove:l,onDrop:o})})},e.ship_method_id)),c=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)($l,{saveItem:n,couriers:s})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Add your team's preferred shipping methods and couriers (FedEx, UPS, or Other). You can drag and drop your favorite method to the top of the list to make it your default.",link:"https://help.commonsku.com/knowledge/ship-method"}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:1}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Ship Method Name"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:7,children:(0,al.jsx)("b",{children:"Courier"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,children:(0,al.jsx)("b",{children:"Delete"})})]}),r,c,(0,al.jsx)(Ml.default,{})]})}var Vl=n(75158);const Xl=[{label:"Unavailable",value:"UNAVAILABLE"},{label:"Available",value:"AVAILABLE"},{label:"Required",value:"REQUIRED"}],Zl=function(e){var t,n;let{divisionId:s,couriers:l,item:o,saveItem:i,deleteItem:r,index:c,onMove:d,onDrop:u}=e;const m=(0,Vl.Us)(),{hasCapabilities:p}=(0,g.el)(m),[h,x]=(0,a.useState)(!1),_=(0,a.useMemo)(()=>({tenant_id:s,ship_method_name:"",carrier:"",service:"",courier_id:"",third_party:"UNAVAILABLE",is_pickup:!1}),[]),[y,f]=(0,a.useState)(o||_);(0,a.useEffect)(()=>{f(o||_)},[_,o]);const[b,v]=(0,a.useState)({..._,third_party:"",is_pickup:""}),j=null==l?void 0:l.find(e=>
1e.value===y.courier_id),w=Xl.find(e=>e.value===y.third_party),[C,E,k]=(0,ll.A)({deleteItemCallback:r}),S=(0,a.useCallback)(e=>{const t=e.target;f(e=>({...e,[t.name]:t.value}))},[]),I=(0,a.useCallback)(e=>{v(_);let t=0;for(const n of["ship_method_name","courier_id","third_party","is_pickup"])""===e[n]&&(v(e=>({...e,[n]:"Required"})),t++);if(p(["FEATURE-CONNECTEDPLUS"]))for(const n of["carrier","service"])""===e[n]&&(v(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[]),A=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4;const a=""!==b[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"SupplierShipMethod.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(Zs.LabeledInput,{label:t||e,name:e,value:y[e],onChange:S}),a?(0,al.jsx)("span",{style:{color:"red"},children:b[e]}):""]})},T=(0,al.jsxs)(al.Fragment,{children:[A("ship_method_name","Ship Method Name",6),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,children:[(0,al.jsx)(Zs.LabeledSelect,{label:"Courier",name:"courier_id",value:j,options:l,onChange:e=>{S({target:{name:"courier_id",value:e.value}}),null!=o&&o.ship_method_id&&i({...y,courier_id:e.value})}}),""!==b.courier_id?(0,al.jsx)("span",{style:{color:"red"},children:b.courier_id}):""]}),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,children:[(0,al.jsx)(Zs.LabeledSelect,{label:"Third Party Accounts",name:"third_party",value:w,options:Xl,onChange:e=>{S({target:{name:"third_parth",value:e.value}}),null!=o&&o.ship_method_id&&i({...y,third_party:e.value})}}),""!==b.third_party?(0,al.jsx)("span",{style:{color:"red"},children:b.third_party}):""]}),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,style:{marginTop:"2rem"},children:[(0,al.jsx)(Zs.LabeledCheckbox,{label:"Is Pickup?",name:"is_pickup",value:Number(null!==(t=null==o?void 0:o.is_pickup)&&void 0!==t?t:0),checked:Number(null!==(n=null==o?void 0:o.is_pickup)&&void 0!==n?n:0),onChange:()=>{var e,t;S({target:{name:"is_pickup",value:!Number(null!==(e=null==o?void 0:o.is_pickup)&&void 0!==e?e:0)}}),null!=o&&o.ship_method_id&&i({...y,is_pickup:!Number(null!==(t=null==o?void 0:o.is_pickup)&&void 0!==t?t:0)})}}),""!==b.is_pickup?(0,al.jsx)("span",{style:{color:"red"},children:b.is_pickup}):""]}),p(["FEATURE-CONNECTEDPLUS"])&&A("carrier","PromoStandards Carrier",6),p(["FEATURE-CONNECTEDPLUS"])&&A("service","PromoStandards Service",6),(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,style:{margin:"1rem 0"},children:[(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{I(y)&&(o||f(_),i({...o,...y}),x(!1))},children:o?"Save":"Add"}),(0,al.jsx)(Zs.Button,{secondary:!0,style:{marginLeft:"1rem"},size:"small",onClick:()=>{f(o||_),x(!1)},children:"Cancel"})]}),C]});let D=(0,al.jsx)(Zs.Col,{sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{x(!0)},children:(0,al.jsx)(sl,{})})});var R,L;return o&&(D=(0,al.jsx)(ul.E2,{index:c,onDrop:u,onMove:d,item:o,canDrag:Boolean(o),type:"Item",children:(0,al.jsxs)("div",{style:{width:"100%",display:"flex"},children:[(0,al.jsx)(Zs.Col,{sm:1,className:"align-self-center",children:o?(0,al.jsx)(Zs.HandleIcon,{color:"#DAE9EE",altText:o.ship_method_name||""}):""}),(0,al.jsx)(Zs.Col,{sm:3,style:{fontSize:"1.1em",fontWeight:"bold",display:"flex",alignItems:"center"},children:o.ship_method_name}),(0,al.jsx)(Zs.Col,{sm:3,style:{display:"flex",alignItems:"center"},children:null===(R=l.find(e=>e.value===o.courier_id))||void 0===R?void 0:R.label}),(0,al.jsxs)(Zs.Col,{sm:4,style:{display:"flex",alignItems:"center"},children:["3rd Party Shipping ",null===(L=Xl.find(e=>e.value===o.third_party))||void 0===L?void 0:L.label]}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{display:"flex",alignItems:"center"},children:(0,al.jsx)("div",{style:{width:"100%",textAlign:"right"},children:(0,al.jsx)(Zs.IconButton,{preset:"edit",onClick:()=>{x(!0)}})})})]})})),h?T:D};function Kl(){const[e]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyDivisions),n=Ss.selectAll(t),s=t.loading;return(0,a.useEffect)(()=>{e(async(e,t)=>{e(Es());const n=await(0,g.oD)("GET","division/toc",{type:"supplier"});return e(ks(n.json.divisions)),n.json})},[e]),[n,s]}(),[t,n]=(0,a.useState)(),[s,o,i,r,c,d,u]=Yl(t),m=(0,a.useMemo)(()=>{var t;return null!==(t=null==e?void 0:e.map(e=>({value:e.division_id,label:e.division_name})))&&void 0!==t?t:[]},[e]),p=m.find(e=>e.value===t);(0,a.useEffect)(()=>{var t;n(null==e||null===(t=e[0])||void 0===t?void 0:t.division_id)},[e]);const h=s.filter(e=>e.tenant_id===t).map((e,n)=>(0,al.jsx)("div",{"data-test-name":"AdminSupplierShipMethod","data-testid":`row-${n}`,children:(0,al.jsx)(Zs.Row,{style:{borderBottom:"1px solid #ececec",marginBottom:"10px",paddingBottom:"10px"},children:(0,al.jsx)(Zl,{index:n,onMove:d,onDrop:u,divisionId:t,couriers:c,item:e,saveItem:i,deleteItem:r},e.ship_method_id)})},e.ship_method_id)),x=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zl,{saveItem:i,divisionId:t,couriers:c})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Add or update the billing and shipping methods asnd couriers (FedEx, UPS, or Other). You can drag and drop your favorite method to the top of the list to make it your default.",link:"https://help.commonsku.com/knowledge/ship-method"}),(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(0,al.jsx)(Zs.LabeledSelect,{label:"Division",name:"division_id",value:p,options:m,onChange:e=>n(e.value)})})}),h,x]})}
1function Jl(e){let{couriers:t,item:n,saveItem:s,deleteItem:l}=e;const[o,i,r]=(0,ll.A)({deleteItemCallback:l}),[c,d]=(0,a.useState)(!1),u=(0,a.useMemo)(()=>({courier_id:"",account_name:"",account_number:"",account_postal:"",third_party_account_id:""}),[]),[m,p]=(0,a.useState)(n||u),[h,g]=(0,a.useState)(u),x=null==t?void 0:t.find(e=>e.value===m.courier_id),_=(0,a.useCallback)(e=>{const t=e.target;p(e=>({...e,[t.name]:t.value}))},[]),y=(0,a.useCallback)(e=>{g(u);let t=0;for(const n of["account_name","courier_id","account_number","account_postal"])""===e[n].trim()&&(g(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[u]),f=(0,a.useCallback)(()=>{y(m)&&(n||(p(u),d(!1)),s({...n,...m}))},[u,m,n,s,y]),b=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=""!==h[e],l=a?Zs.LabeledIconInput:Zs.Input;return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyShipAccount.getTextInput",padded:!0,sm:t,children:[(0,al.jsx)(l,{style:{marginBottom:"0"},Icon:(0,al.jsx)("div",{children:"#"}),name:e,value:m[e],onChange:_,onBlur:e=>{n&&f(m)}}),s?(0,al.jsx)("span",{style:{color:"red"},children:h[e]}):""]})};let v=(0,al.jsxs)(al.Fragment,{children:[b("account_name",4),(0,al.jsxs)(Zs.Col,{padded:!0,sm:2,children:[(0,al.jsx)(Zs.LabeledSelect,{label:"",name:"courier_id",value:x,options:t,onChange:e=>{_({target:{name:"courier_id",value:e.value}}),null!=n&&n.third_party_account_id&&s({...m,courier_id:e.value})}}),""!==h.courier_id?(0,al.jsx)("span",{style:{color:"red"},children:h.courier_id}):""]}),b("account_number",3,!0),b("account_postal",2),n?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>f(m),children:n?"Save":"Add"})}),n?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"},children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{i(!0),r(n)}})}):(0,al.jsx)(Zs.Col,{sm:1}),o]});return n||c||(v=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{d(!0)},children:(0,al.jsx)(sl,{})})})),v}function eo(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyShipAccounts),n=Jn.selectAll(t),s=t.loading,o=Wl();(0,a.useEffect)(()=>{e(async(e,t)=>{e(Qn());const n=await(0,g.oD)("GET",Kn,{});return e(Xn(n.json.third_party_shipping_accounts)),n.json})},[e]);const i=(0,a.useCallback)(t=>{(async()=>{var a;t.third_party_account_id?await e((a={id:t.third_party_account_id,...t},async(e,t)=>{console.log("Update",a),e(Qn());const n=await(0,g.oD)("PUT",Kn+"/"+a.third_party_account_id,a);return e(Zn({id:a.third_party_account_id,changes:a})),e(Vn()),n.json.tax})):await e((e=>async(t,n)=>{t(Qn());const a=await(0,g.oD)("POST",Kn,e);return t(Wn(Object.assign(a.json.third_party_shipping_account,{new:!0}))),t(Vn()),a.json.third_party_shipping_account})({...t,ordering:n.length})),Xs.oR.success("Saved successfully")})()},[e,n.length]),r=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(Qn());try{await(0,g.oD)("DELETE",Kn+"/"+n.third_party_account_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(Yn(n.third_party_account_id)),e(Vn()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,i,r,o]}function to(){const[e,t,n,a,s]=eo(),l=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminShipMethod","data-testid":`editable-row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Jl,{item:e,saveItem:n,deleteItem:a,couriers:s})})},e.third_party_account_id)),o=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Jl,{saveItem:n,couriers:s})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Add your company's shipping details so suppliers can ship POs on your company account. Make sure to choose the appropriate courier for each account (FedEx, UPS, or Other).",link:"https://help.commonsku.com/knowledge/3rd-party-shipping-accounts-2"}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:4,children:(0,al.jsx)("b",{children:"Account Name"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:2,children:(0,al.jsx)("b",{children:"Courier"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Account Number"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:2,children:(0,al.jsx)("b",{children:"Billing Postal/Zip Code"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,children:(0,al.jsx)("b",{children:"Delete"})})]}),l,o,(0,al.jsx)(Ml.default,{})]})}const no=e=>{let{moduleMap:t,defaultModule:n,initialModule:s,openCommonskuPayments:l=!1,paywallCtaUrl:o}=e;const i=(0,Vl.Us)(),[r,c]=(0,a.useState)(null!=s?s:n),d=t[r].component;let u=(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(d,{identity:i,inPopup:!0,paywallCtaUrl:o,openCommonskuPayments:l})});const m=Object.keys(t).filter(e=>t[e].show).map(e=>{const n=t[e].title;return(0,al.jsx)("li",{"data-test-name":"AdminTabbedInPopup",children:(0,al.jsx)("a",{href:"/",className:"module-tab"+(e===r?" active":""),onClick:t=>{t.preventDefault(),c(e)},children:n})},e)});return(0,al.jsxs)("div",{"data-test-name":"AdminTabbedInPopup",style:{display:"flex",flexDirection:"row",flexWrap:"nowrap",justifyContent:"flex-start",height:"100%",overflowY:"hidden"},children:[(0,al.jsx)("ul",{style:{minWidth:"250px",width:"250px",paddingTop:"20px",backgroundColor:"#E1F7FA",padding:0,margin:0,overflowY:"auto"},children:m}),(0,al.jsx)("div",{style:{flexGrow:1,padding:"0 2rem",height:"100%",overflowX:"hidden",overflowY:"auto"},children:u})]})};function ao(e){let{item:t,saveItem:n,deleteItem:s}=e;const[l,o]=(0,a.useState)((null==t?void 0:t.account_status_name)||""),[i,r]=(0,a.useState)(!!t),[c,d]=(0,a.useState)(""),[u,m,p]=(0,ll.A)({deleteItemCallback:s}),h=(0,a.useCallback)(()=>{""!==l.trim()?(d(""),t||(r(!1),o("")),n({...t,account_status_name:l})):d("Required")},[t,l,n]);let g=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsxs)(Zs.Col,{sm:11,children:[(0,al.jsx)(Zs.Input,{name:"name",value:l,onCh
1ange:e=>o(e.target.value),onBlur:e=>{t&&h()}}),""!==c?(0,al.jsx)("span",{style:{color:"red"},children:"Required"}):""]}),(0,al.jsx)(Zs.Col,{sm:1,style:{textAlign:"left",paddingLeft:"1rem"},children:t?(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{m(!0),p(t)}}):(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{h()},children:"Add"})}),u]});return i||(g=(0,al.jsx)(Zs.Col,{sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{r(!0)},children:(0,al.jsx)(sl,{})})})),g}function so(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.clientStatus),n=Be.selectAll(t),s=t.loading;return(0,a.useEffect)(()=>{e(De())},[e]),[n,s,(0,a.useCallback)(t=>{0!==t.account_status_name.length?(async()=>{t.account_status_id?await e(Le({id:t.account_status_id,...t})):await e(Re({...t,company_type:"CLIENT"})),Xs.oR.success("Saved successfully")})():Xs.oR.error("Please fill in status name.")},[e]),(0,a.useCallback)(t=>{(async()=>{await e(Pe(t)),Xs.oR.success("Deleted successfully")})()},[e])]}function lo(){const[e,t,n,a]=so(),s=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminClientStatus","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ao,{item:e,saveItem:n,deleteItem:a})})},e.account_status_id)),l=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ao,{saveItem:n})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Create custom statuses to help segment and analyze client activity on your reports, Clients, and Analytics tabs.",link:"https://help.commonsku.com/knowledge/client-details#status"}),s,l]})}function oo(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.supplierStatus),n=Xe.selectAll(t),s=t.loading;return(0,a.useEffect)(()=>{e(We())},[e]),[n,s,(0,a.useCallback)(t=>{0!==t.account_status_name.length?(async()=>{t.account_status_id?await e(Qe({id:t.account_status_id,...t})):await e(Ye({...t,company_type:"SUPPLIER"})),Xs.oR.success("Saved successfully")})():Xs.oR.error("Please fill in status name.")},[e]),(0,a.useCallback)(t=>{(async()=>{await e(Ve(t)),Xs.oR.success("Deleted successfully")})()},[e])]}function io(){const[e,t,n,a]=oo(),s=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminSupplierStatus","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ao,{item:e,saveItem:n,deleteItem:a})})},e.account_status_id)),l=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ao,{saveItem:n})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Create custom statutes to help segment your suppliers on your Suppliers tab.",link:"https://help.commonsku.com/knowledge/supplier-details#status"}),s,l]})}function ro(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.distributorStatus),n=ut.selectAll(t),s=t.loading;return(0,a.useEffect)(()=>{e(it())},[e]),[n,s,(0,a.useCallback)(t=>{0!==t.account_status_name.length?(async()=>{t.account_status_id?await e(ct({id:t.account_status_id,...t})):await e(rt({...t,company_type:"DISTRIBUTOR"})),Xs.oR.success("Saved successfully")})():Xs.oR.error("Please fill in status name.")},[e]),(0,a.useCallback)(t=>{(async()=>{await e(dt(t)),Xs.oR.success("Deleted successfully")})()},[e])]}function co(){const[e,t,n,a]=ro(),s=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminDistributorStatus","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ao,{item:e,saveItem:n,deleteItem:a})})},e.account_status_id)),l=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(ao,{saveItem:n})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Create custom statuses to help segment your distributors on your Distributors tab."}),s,l]})}const uo=()=>{const e=(0,Vl.Us)(),[t,n]=(0,a.useState)(0),s=[{label:"Client Statuses",content:(0,al.jsx)(lo,{}),show:"SUPPLIER"!==e.company_type},{label:"Supplier Statuses",content:(0,al.jsx)(io,{}),show:"SUPPLIER"!==e.company_type},{label:"Distributor Statuses",content:(0,al.jsx)(co,{}),show:"SUPPLIER"===e.company_type}].filter(e=>e.show);return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.TabBar,{padded:!0,children:s.map((e,a)=>(0,al.jsx)(Zs.Tab,{selected:t===a,onClick:()=>n(a),style:t===a?{borderBottomColor:"#EB1D6E"}:null,children:e.label},`tabs_${a}`))}),s[t]?s[t].content:null]})},mo=e=>{let{currencies:t,item:n,saveItem:s,deleteItem:l}=e;const[o,i]=(0,a.useState)(!1),r=(0,a.useMemo)(()=>({from_currency:"",to_currency:"",rate:""}),[]),[c,d]=(0,a.useState)(r);(0,a.useEffect)(()=>{d(n||r)},[r,n]);const[u,m]=(0,a.useState)(r),p=null==t?void 0:t.map(e=>({label:e.currency_id,value:e.currency_id})),[h,g,x]=(0,ll.A)({deleteItemCallback:l}),_=(0,a.useCallback)(e=>{const t=e.target;d(e=>({...e,[t.name]:t.value}))},[]),y=(0,a.useCallback)(e=>{m(r);let t=0;for(const n of["from_currency","to_currency","rate"])""===e[n].toString().trim()&&(m(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[r]),f=(0,a.useCallback)(()=>{y(c)&&(n||(d(r),i(!1)),s({...n,...c}))},[r,c,n,s,y]),b=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;return n?(0,al.jsx)(Zs.Col,{"data-test-name":"CompanyExchangeRate.getSelect",padded:!0,sm:t,style:{paddingTop:"12px"},children:c[e]}):(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyExchangeRate.getSelect",padded:!0,sm:t,children:[(0,al.jsx)(Zs.LabeledSelect,{isDisabled:!!n,label:"",name:"from_currency",value:null==p?void 0:p.find(t=>t.value===c[e]),options:p,onChange:t=>{_({target:{name:e,value:t.value}})}}),""!==u[e]?(0,al.jsx)("span",{style:{color:"red"},children:u[e]}):""]})};let v=(0,al.jsx)("div",{style:{width:"100%"},children:(0,al.jsxs)(Zs.Row,{children:[b("from_currency",2),b("to_currency",2),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const a=""!==u[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyExchangeRate.getTextInput",padded:!0,sm:t,children:[(0,al.jsx)(Zs.Input,{className:"no-margin-bottom",name:e,value:c[e],onChange:_,onBlur:e=>{n&&f(c)}}),a?(0,al.jsx)("span",{style:{color:"red"},children:u[e]}):""]})}("rate",7),n?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>f(c),children:n?"Save":"Add"})}),n?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"}
1,children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{g(!0),x(n)}})}):(0,al.jsx)(Zs.Col,{sm:1}),h]})});return n||o||(v=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{i(!0)},children:(0,al.jsx)(sl,{})})})),v};function po(){const[e,t,n,s,o]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyExchangeRates),n=da.selectAll(t),s=t.loading,[o,i]=(0,a.useState)([]);(0,a.useEffect)(()=>{e(async(e,t)=>{e(la());const n=await(0,g.oD)("GET",ca,{});return e(ia(n.json.exchange_rates)),n.json})},[e]),(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("GET","currency",{});console.log(e.json.currencies,"currency"),i(e.json.currencies||[])})()},[]);const r=(0,a.useCallback)(t=>{(async()=>{var n;t.exchange_rate_id?await e((n={id:t.exchange_rate_id,...t},async(e,t)=>{console.log("Update",n),e(la());const a=await(0,g.oD)("PUT",ca+"/"+n.exchange_rate_id,n);return e(ra({id:n.exchange_rate_id,changes:n})),e(oa()),a.json.exchange_rate})):await e((e=>async(t,n)=>{t(la());const a=await(0,g.oD)("POST",ca,e);return t(ia(a.json.exchange_rates)),a.json})(t)),Xs.oR.success("Saved successfully")})()},[e]),c=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(la());try{await(0,g.oD)("DELETE",ca+"/"+n.exchange_rate_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(sa(n.exchange_rate_id)),e(oa()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,r,c,o]}();(0,a.useEffect)(()=>{(null==e?void 0:e.length)>0&&(0,Gl.W1)()},[null==e?void 0:e.length]);let i=0;const r=e.map((e,t)=>(0,al.jsx)("div",{"data-test-name":"AdminExchangeRate","data-testid":`row-${t}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(mo,{index:i++,item:e,saveItem:n,deleteItem:s,currencies:o})})},e.exchange_rate_id)),c=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(mo,{saveItem:n,currencies:o})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Use currency conversion to simplify exchange rates on multicurrency orders (i.e., if you buy products in USD and sell them in CAD). Choose which currency you need to convert from, which to convert to, set your rate, and watch it automatically apply to your shops, sales forms, and supplier bills.",link:"https://help.commonsku.com/knowledge/how-to-create-and-adjust-your-margin-currency"}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:2,children:(0,al.jsx)("b",{children:"From"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:2,children:(0,al.jsx)("b",{children:"To"})}),(0,al.jsxs)(Zs.Col,{padded:!0,sm:7,children:[(0,al.jsx)("b",{children:"Rate"})," ",(0,al.jsx)(Zs.InfoIcon,{altText:"",style:{verticalAlign:"middle"},"data-padding":"8px 8px","data-html":!0,"data-tip":'<div style="padding: 10px">Info</div>',width:"16px"})]}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,children:(0,al.jsx)("b",{children:"Delete"})})]}),r,c,(0,al.jsx)(Ml.default,{})]})}function ho(e){let{item:t,saveItem:n,deleteItem:s}=e;const[l,o]=(0,a.useState)(t);(0,a.useEffect)(()=>o(t),[t]);const i=(0,a.useCallback)(e=>{const t=e.target;o(e=>({...e,[t.name]:t.value}))},[]),r=(0,a.useCallback)(()=>{n(l)},[l,n]),c=(0,a.useCallback)(()=>{t.supplier_benefit_id?s(t):n(t)},[t,n,s]);let d=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:4,children:(0,al.jsx)(Zs.LabeledCheckbox,{label:t.benefit_label,checked:!!t.supplier_benefit_id,onChange:c,value:t.benefit_id})}),function(e){var n;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;return(0,al.jsx)(Zs.Col,{"data-test-name":"CompanyBenefits.getTextInput",padded:!0,sm:a,children:(0,al.jsx)(Zs.Input,{style:{marginBottom:0},name:e,value:null!==(n=l[e])&&void 0!==n?n:"",disabled:!t.supplier_benefit_id,onChange:i,onBlur:r})})}("benefit_description",8)]});return d}function go(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyBenefits),n=vs.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{var n;e(xs());const a=await(0,g.oD)("GET",bs,{});return e(ys(null===(n=a.json)||void 0===n?void 0:n.supplier_benefits)),a.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{var n;t.supplier_benefit_id?(await e((n={id:t.supplier_benefit_id,...t},async(e,t)=>{console.log("Update",n),e(xs());const a=await(0,g.oD)("PUT",bs+"/"+n.supplier_benefit_id,n);return e(fs({id:n.benefit_id,changes:n})),e(_s()),a.json.supplier_benefit})),Xs.oR.success("Saved successfully")):await e((e=>async(t,n)=>{var a,s;t(xs());const l=await(0,g.oD)("POST",bs,e);return t(fs({id:e.benefit_id,changes:null===(a=l.json)||void 0===a?void 0:a.supplier_benefit})),t(_s()),null===(s=l.json)||void 0===s?void 0:s.supplier_benefit})(t))})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(xs());try{await(0,g.oD)("DELETE",bs+"/"+n.supplier_benefit_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(fs({id:n.benefit_id,changes:{supplier_benefit_id:"",benefit_description:""}})),e(_s()),!0}))})()},[e]);return[n,s,o,i]}function xo(){const[e,t,n,a]=go(),s=e.map(e=>(0,al.jsx)(Zs.Row,{"data-test-name":"AdminBenefits",children:(0,al.jsx)(ho,{item:e,saveItem:n,deleteItem:a})},e.benefit_id));return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Specify which benefits you offer distributors.",link:"https://help.commonsku.com/knowledge/september-2021-benefits-filter"}),s]})}const _o=()=>{var e;const t=(0,Vl.Us)(),n="SUPPLIER"===t.company_type?"status":"addresses";let a={addresses:{component:dl,title:"Company Contact Info",show:"SUPPLIER"!==t.company_type},tax:{component:Hl,title:"Tax",show:"SUPPLIER"!==t.company_type},terms:{component:gl,title:"Payment Terms",show:"SUPPLIER"!==t.company_type},exchangeRate:{component:po,title:"Currency Conversion",show:"SUPPLIER"!==t.company_type},formNumbers:{component:_l,title:"Project Numbers",show:"SUPPLIER"!==t.company_type},defaults:{component:Rl,title:"Defaults",show:"SUPPLIER"!==t.company_type},status:{component:uo,title:"Statuses",show:!0},shipMethod:{component:"SUPPLIER"===t.company_type?Kl:Ql,title:"Ship Methods",show:!0},shipAccount:{component:to,title:"Shipping Accounts",show:"SUPPLIER"!==t.company_type},imprints:{component:Ul,title:"Imprint Methods",show:"SUPPLIER"!==t.company_type},actionTypes:{component:Bl,title:"Next Action Types",show:"SUPPLIER"!==t.company_type},benefits:{component:xo,title:"Benefits",show:"SUPPLIER"===t.company_type}};const{data:{data:s}}=(0,rl.A)();return"1"!=(null==s||null===(e=s.companyData)||void 0===e?void 0:e.use_margin_currency)&&delete a.exchangeRate,(0,al.jsx)(no,{"data-test-name":"AdminTabbedSetup",moduleMap:a,defaultModule:n})};function yo(e){var t,n;let{title:a}=e;const s=(0,Vl.Us)(),{data:l}=(0,rl.A)(),[o]=il(),[i]=hl(),[r]=Dl(),[c]=Pl(),[d]=eo(),[u]=Ol(),[m]=so(),[p]=oo(),[h]=ro(),[g]=Yl(),[x]=go();return(0,al.jsxs)("div",{"data-test-name":"AdminSetupSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.GearIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:a}),"SUPPLIER"!==s.company_type&&(0,al.jsx)(Zs.LightIndicator,{name:`${null==o?void 0:o.length} addresses`,on:(null==o?void 0:o.length)>0}),"SUPPLIER"!==s.company_type&&(0,al.jsx)(Zs.LightIndicator,{name:`${null==i?void 0:i.length} payment terms`,on:(null==i?void 0:i.length)>0}),"SUPPLIER"!==s.company_type&&(0,al.jsx)(Zs.LightIndicator,{name:`${null==r?void 0:r.length} tax codes`,on:(null==r?void 0:r.length)>0}),"SUPPLIER"!==s.company_type&&(0,al.jsx)(Zs.LightIndicator,{name:`${null==c?void 0:c.length} next action types`,on:(null==c?void 0:c.length)>0}),"SUPPLIER"!==s.company_type&&(0,al.jsx)(Zs.LightIndicator,{name:`${null==d?void 0:d.length} shipping accounts`,on:(null==d?void 0:d.length)>0}),"SUPPLIER"!==s.company_type&&(0,al.jsx)(Zs.LightIndicator,{name:`${null==u?void 0:u.length} imprint methods`,on:(null==u?void 0:u.length)>0}),(0,al.jsx)(Zs.LightIndicator,{name:`${(null==m?void 0:m.length)+(null==p?void 0:p.length)+(null==h?void 0:h.length)} statuses`,on:(null==m?void 0:m.length)+(null==p?void 0:p.length)+(null==h?void 0:h.length)>0}),(0,al.jsx)(Zs.LightIndicator,{name:`${null==g?void 0:g.length} ship methods`,on:(null==g?void 0:g.length)>0}),"SUPPLIER"===s.company_type&&(0,al.jsx)(Zs.LightIndicator,{name:`${null==x||null===(t=x.filter(e=>e.supplier_benefit_id))||void 0===t?void 0:t.length} benefits`,on:(null==x||null===(n=x.filter(e=>e.supplier_benefit_id))||void 0===n?void 0:n.length)>0})]})]})}n(82783),n(96269);var fo=n(67530),bo=n(37337);function vo(e){let{item:t,saveItem:n,deleteItem:s}=e;const[l,o,i]=(0,ll.A)({deleteItemCallback:s}),[r,c]=(0,a.useState)(!1),d=(0,a.useMemo)(()=>({commission_client_rate_id:"",client_rate_label:"",multiplier:""}),[]),[u,m]=(0,a.useState)(t||d),[p,h]=(0,a.useState)(d),g=(0,a.useCallback)(e=>{const t=e.target;m(e=>({...e,[t.name]:t.value}))},[]),x=(0,a.useCallback)(e=>{h(d);let t=0;for(const n of["client_rate_label","multiplier"])if(""===e[n].toString().trim())h(e=>({...e,[n]:"Required"})),t++;else if("multiplier"===n){const a=Number(e[n]);isNaN(a)&&(h(e=>({...e,[n]:"Multiplier must be number"})),t++)}return!(t>0)},[d]),_=(0,a.useCallback)(()=>{x(u)&&(t||(m(d),c(!1)),n({...t,...u}))},[d,u,t,n,x]),y=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;const a=""!==p[e],s=Zs.Input;return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyCommissionClientRate.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(s,{style:{marginBottom:"0"},name:e,value:u[e],onChange:g,onBlur:e=>{t&&_(u)}}),a?(0,al.jsx)("span",{style:{color:"red"},children:p[e]}):""]})};let f=(0,al.jsxs)(al.Fragment,{children:[y("client_rate_label",8,!0),y("multiplier",3),t?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>_(u),children:t?"Save":"Add"})}),t?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"}
1,children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{o(!0),i(t)}})}):(0,al.jsx)(Zs.Col,{sm:1}),l]});return t||r||(f=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{c(!0)},children:(0,al.jsx)(sl,{})})})),f}var jo=n(35279);function wo(e){let{item:t,saveItem:n,sourceOptions:s}=e;const l=(0,a.useMemo)(()=>({commission_client_rate_id:""}),[]),[o,i]=(0,a.useState)(t||l),r=(0,a.useCallback)(e=>{const t=e.target;i(e=>({...e,[t.name]:t.value}))},[]);let c=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsxs)(Zs.Col,{padded:!0,sm:6,children:[(0,al.jsx)(Il.Ay,{name:t.client_name,round:!0,size:30})," ",t.client_name]}),function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,l=o[e];l||(l=null);const i=s.find(e=>e.value===l);return(0,al.jsx)(Zs.Col,{"data-test-name":"CompanyCommissionAssignClientRate.getSelect",sm:a,children:(0,al.jsx)(Zs.LabeledSelect,{name:e,value:i,options:s,onChange:a=>{r({target:{name:e,value:a.value}}),n(t.client_id,{commission_client_rate_id:a.value})}})})}("commission_client_rate_id")]});return c}function Co(){const[e,t,n]=function(){const[e,t]=(0,a.useState)([]),[n,s]=(0,a.useState)(null);let l=e;n&&(l=e.filter(e=>e.commission_client_rate_id===n));const o=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];s(n),(async()=>{var a;const s=await(0,g.oD)("GET","client",{"max-results":100,"order-by":"latest_use","order-dir":"desc","rate-id":n,search:e});t(null===(a=s.json)||void 0===a?void 0:a.clients)})()},[]);return[l,o,(0,a.useCallback)((e,t)=>{console.log("save data",t),(async()=>{await(0,g.oD)("PUT","account/"+e,{company_type:"CLIENT",commission_client_rate_id:t.commission_client_rate_id}),Xs.oR.success("Saved successfully")})()},[])]}(),[s]=(0,jo.A)(),[l,o]=(0,a.useState)({name:"",rate:""}),i=e.length>=100,r=[{value:"",label:""}].concat(s.map(e=>({label:`${e.client_rate_label} (x ${e.multiplier})`,value:e.commission_client_rate_id}))),c=(e||[]).map(e=>(0,al.jsx)(Zs.Row,{"data-test-name":"AdminCommissionAssignClientRate",children:(0,al.jsx)(wo,{item:e,sourceOptions:r,saveItem:n})},e.client_id+"-rate"));return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{sm:5,padded:!0,children:(0,al.jsx)(Zs.Input,{placeholder:"Search for a client",name:"search_client_name",onChange:e=>{const t=e.target.value;o(e=>({...e,name:t}))}})}),(0,al.jsx)(Zs.Col,{sm:5,padded:!0,children:(0,al.jsx)(Zs.LabeledSelect,{placeholder:"Any",name:"search_client_rate",options:r,onChange:e=>{o(t=>({...t,rate:e.value}))}})}),(0,al.jsx)(Zs.Col,{sm:2,padded:!0,children:(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{console.log("search filters",l),t(l.name,l.rate)},children:"Search"})})]}),i?(0,al.jsxs)("p",{children:["Too many clients to show. Only the first ",e.length," are shown. Please enter some criteria to narrow it down."]}):null,c]})}function Eo(e){let{item:t,nextItem:n,saveItem:s,deleteItem:l}=e;const[o,i,r]=(0,ll.A)({deleteItemCallback:l}),[c,d]=(0,a.useState)(!1),u=(0,a.useMemo)(()=>({commission_margin_id:"",margin_min:"",multiplier:""}),[]),[m,p]=(0,a.useState)(t||u),[h,g]=(0,a.useState)(u),x=(0,a.useCallback)(e=>{const t=e.target;p(e=>({...e,[t.name]:t.value}))},[]),_=(0,a.useCallback)(e=>{g(u);let t=0;for(const n of["margin_min","multiplier"])if(""===e[n].toString().trim())g(e=>({...e,[n]:"Required"})),t++;else if("margin_min"===n){const a=Number(e[n]);(isNaN(a)||a>100||a<0)&&(g(e=>({...e,[n]:"Minimum must be between 0 and 100"})),t++)}else if("multiplier"===n){const a=Number(e[n]);isNaN(a)&&(g(e=>({...e,[n]:"Multiplier must be number"})),t++)}return!(t>0)},[u]),y=(0,a.useCallback)(()=>{_(m)&&(t||(p(u),d(!1)),s({...t,...m}))},[u,m,t,s,_]),f=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];
1const s=""!==h[e],l=a?Zs.LabeledIconInput:Zs.Input;return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyCommissionMarginRate.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(l,{style:{marginBottom:"0"},iconPosition:"right",Icon:(0,al.jsx)("div",{children:"%"}),name:e,value:m[e],onChange:x,onBlur:e=>{t&&y(m)}}),s?(0,al.jsx)("span",{style:{color:"red"},children:h[e]}):""]})};let b=(0,al.jsxs)(al.Fragment,{children:[f("margin_min",4,!0),(0,al.jsx)(Zs.Col,{padded:!0,sm:4,children:(0,al.jsx)(Zs.LabeledIconInput,{disabled:!0,iconPosition:"right",Icon:(0,al.jsx)("div",{children:"%"}),value:t?(null==n?void 0:n.margin_min)||100:""})}),f("multiplier",3),t?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>y(m),children:t?"Save":"Add"})}),t?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"},children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{i(!0),r(t)}})}):(0,al.jsx)(Zs.Col,{sm:1}),o]});return t||c||(b=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{d(!0)},children:(0,al.jsx)(sl,{})})})),b}function ko(e){var t;let{item:n,saveItem:s,rates:l}=e;const o=(0,a.useMemo)(()=>({client_rep_commission_rate_id:"",order_rep_commission_rate_id:"",combined_rep_commission_rate_id:""}),[]),i=[{value:"",label:""}].concat(l.map(e=>({label:`${e.commission_rate_label} (${Number(e.commission_rate).toFixed(2)} % of ${e.commission_source.toLowerCase()})`,value:e.commission_rate_id}))),[r,c]=(0,a.useState)(n||o),d=(0,a.useCallback)(e=>{const t=e.target;c(e=>({...e,[t.name]:t.value}))},[]),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=r[e];n||(n=null);const a=i.find(e=>e.value===n);return(0,al.jsx)(Zs.Col,{"data-test-name":"CompanyCommissionPeopleRate.getSelect",sm:t,padded:!0,children:(0,al.jsx)(Zs.LabeledSelect,{name:e,value:a,options:i,onChange:t=>{d({target:{name:e,value:t.value}}),s(r,e,t.value)}})})};return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsxs)(Zs.Col,{padded:!0,sm:3,children:[(0,al.jsx)(Il.Ay,{src:(null===(t=n.user_image_paths)||void 0===t?void 0:t.small)||null,name:n.contact_full_name,round:!0,size:30})," ",n.contact_full_name]}),u("client_rep_commission_rate_id"),u("order_rep_commission_rate_id"),u("combined_rep_commission_rate_id")]})}function So(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.commissionRates),n=M.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(B());const n=await(0,g.oD)("GET",F,{});return e(O(n.json.commission_rates)),n.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{var n;t.commission_rate_id?await e((n={id:t.commission_rate_id,...t},async(e,t)=>{console.log("Update",n),e(B());const a=await(0,g.oD)("PUT",F+"/"+n.commission_rate_id,n);return e(U({id:n.commission_rate_id,changes:n})),e(N()),a.json.commission_rate})):await e((e=>async(t,n)=>{t(B());const a=await(0,g.oD)("POST",F,e);return t(L(Object.assign(a.json.commission_rate,{new:!0}))),t(N()),a.json.commission_rate})(t)),Xs.oR.success("Saved successfully")})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(B());try{await(0,g.oD)("DELETE",F+"/"+n.commission_rate_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(P(n.commission_rate_id)),e(N()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,o,i]}function Io(e){let{item:t,saveItem:n,deleteItem:s}=e;const[l,o,i]=(0,ll.A)({deleteItemCallback:s}),[r,c]=(0,a.useState)(!1),d=(0,a.useMemo)(()=>({commission_rate_id:"",commission_rate:"",commission_rate_label:"",commission_source:""}),[]),u=[{label:"Margin",value:"MARGIN"},{label:"Sales",value:"SUBTOTAL"}],[m,p]=(0,a.useState)(t||d),[h,g]=(0,a.useState)(d),x=u.find(e=>e.value===m.commission_source),_=(0,a.useCallback)(e=>{const t=e.target;p(e=>({...e,[t.name]:t.value}))},[]),y=(0,a.useCallback)(e=>{g(d);let t=0;for(const n of["commission_rate","commission_rate_label","commission_source"])""===e[n].toString().trim()&&(g(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[d]),f=(0,a.useCallback)(()=>{y(m)&&(t||(p(d),c(!1)),n({...t,...m}))},[d,m,t,n,y]),b=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];
1const s=""!==h[e],l=a?Zs.LabeledIconInput:Zs.Input;return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyCommissionRate.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(l,{style:{marginBottom:"4px"},iconPosition:"right",Icon:(0,al.jsx)("div",{children:"%"}),name:e,value:m[e],onChange:_,onBlur:e=>{t&&f(m)}}),s?(0,al.jsx)("span",{style:{color:"red"},children:h[e]}):""]})};let v=(0,al.jsxs)(al.Fragment,{children:[b("commission_rate_label",6),b("commission_rate",2,!0),(0,al.jsxs)(Zs.Col,{padded:!0,sm:3,children:[(0,al.jsx)(Zs.LabeledSelect,{label:"",name:"commission_source",value:x,options:u,onChange:e=>{_({target:{name:"commission_source",value:e.value}}),null!=t&&t.commission_rate_id&&n({...m,commission_source:e.value})}}),""!==h.commission_source?(0,al.jsx)("span",{style:{color:"red"},children:h.commission_source}):""]}),t?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>f(m),children:t?"Save":"Add"})}),t?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"},children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{o(!0),i(t)}})}):(0,al.jsx)(Zs.Col,{sm:1}),l]});return t||r||(v=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{c(!0)},children:(0,al.jsx)(sl,{})})})),v}function Ao(e){let{item:t,nextItem:n,saveItem:s,deleteItem:l}=e;const[o,i,r]=(0,ll.A)({deleteItemCallback:l}),[c,d]=(0,a.useState)(!1),u=(0,a.useMemo)(()=>({commission_sales_target_id:"",sales_target_min:"",multiplier:""}),[]),[m,p]=(0,a.useState)(t||u),[h,g]=(0,a.useState)(u),x=(0,a.useCallback)(e=>{const t=e.target;p(e=>({...e,[t.name]:t.value}))},[]),_=(0,a.useCallback)(e=>{g(u);let t=0;for(const n of["sales_target_min","multiplier"])if(""===e[n].toString().trim())g(e=>({...e,[n]:"Required"})),t++;else if("sales_target_min"===n){const a=Number(e[n]);(isNaN(a)||a<0)&&(g(e=>({...e,[n]:"Minimum must be between 0 and 100"})),t++)}else if("multiplier"===n){const a=Number(e[n]);(isNaN(a)||a<0)&&(g(e=>({...e,[n]:"Multiplier must be number"})),t++)}return!(t>0)},[u]),y=(0,a.useCallback)(e=>{_(e)&&(t||(p(u),d(!1)),s({...t,...e}))},[u,t,s,_]),f=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];
1const s=""!==h[e],l=a?Zs.LabeledIconInput:Zs.Input;return(0,al.jsxs)(Zs.Col,{"data-test-name":"CompanyCommissionSalesTargetRate.getTextInput",padded:!0,sm:n,children:[(0,al.jsx)(l,{style:{marginBottom:"0"},iconPosition:"right",Icon:(0,al.jsx)("div",{children:"%"}),name:e,value:m[e],onChange:x,onBlur:e=>{t&&y(m)}}),s?(0,al.jsx)("span",{style:{color:"red"},children:h[e]}):""]})};let b=(0,al.jsxs)(al.Fragment,{children:[f("sales_target_min",3,!0),(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"center"},children:"â"}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)(Zs.LabeledIconInput,{disabled:!0,iconPosition:"right",Icon:(0,al.jsx)("div",{children:"%"}),value:t?(null==n?void 0:n.sales_target_min)||"â":""})}),f("multiplier",3),t?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>y(m),children:t?"Save":"Add"})}),t?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{textAlign:"left",paddingLeft:"1rem"},children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{i(!0),r(t)}})}):(0,al.jsx)(Zs.Col,{sm:1}),o]});return t||c||(b=(0,al.jsx)(Zs.Col,{padded:!0,sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{className:"add-button",onClick:()=>{d(!0)},children:(0,al.jsx)(sl,{})})})),b}function To(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.commissionSalesTargetRates),n=be.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(ge());const n=await(0,g.oD)("GET",fe,{});return e(_e(n.json.commission_sales_target_rates)),n.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{var n;t.commission_sales_target_id?await e((n={id:t.commission_sales_target_id,...t},async(e,t)=>{console.log("Update",n),e(ge());const a=await(0,g.oD)("PUT",fe+"/"+n.commission_sales_target_id,n);return e(ye({id:n.commission_sales_target_id,changes:n})),e(xe()),a.json.commission_sales_target_rate})):await e((e=>async(t,n)=>{t(ge());const a=await(0,g.oD)("POST",fe,e);return t(pe(Object.assign(a.json.commission_sales_target_rate,{new:!0}))),t(xe()),a.json.commission_sales_target_rate})(t)),Xs.oR.success("Saved successfully")})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(ge());try{await(0,g.oD)("DELETE",fe+"/"+n.commission_sales_target_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(he(n.commission_sales_target_id)),e(xe()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,o,i]}function Do(e){var t;let{item:n,saveItem:s,rates:l}=e;const o=(0,a.useMemo)(()=>({sales_target:""}),[]),[i,r]=(0,a.useState)(o);(0,a.useEffect)(()=>{if(n){let e=o;e={sales_target:Number(n.sales_target).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g,",")},r(e)}},[o,n]);const c=(0,a.useCallback)(e=>{const t=e.target;let n=Number(t.value.replaceAll(",",""));isNaN(n)&&(n=0),r(e=>{const a=n.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g,",");return{...e,[t.name]:a}})},[]),d=(0,a.useMemo)(()=>l.map((e,t)=>{var n;const a=Number(i.sales_target.replaceAll(",",""));let s=Number((null===(n=l[t+1])||void 0===n?void 0:n.sales_target_min)/100*a).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g,",");return{min:Number(e.sales_target_min/100*a).toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g,","),max:isNaN(Number(s.replaceAll(",","")))?"â":s}}),[i.sales_target,l]);return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("td",{style:{borderRight:"1px dashed #ececec"},children:(0,al.jsxs)(Zs.Row,{style:{alignItems:"center"},children:[(0,al.jsx)(Zs.Col,{sm:1,padded:!0,children:(0,al.jsx)(Il.Ay,{src:(null===(t=n.user_image_paths)||void 0===t?void 0:t.small)||null,name:n.contact_full_name,round:!0,size:"30"})}),(0,al.jsx)(Zs.Col,{sm:5,padded:!0,children:n.contact_full_name}),(0,al.jsxs)(Zs.Col,{sm:6,padded:!0,style:{display:"flex",flexDirection:"row",alignItems:"center"},children:[(0,al.jsx)("span",{style:{marginRight:"0.5rem"},children:"$"}),(0,al.jsx)(Zs.Input,{style:{marginBottom:"0"},name:"sales_target",value:i.sales_target,onChange:c,onBlur:e=>{s(n,"sales_target",Number(e.target.value.replaceAll(",","")))}})]})]})}),d.map((e,t)=>(0,al.jsx)("td",{children:`$${e.min} - $${e.max}`},n.user_id+"-td-"+t))]})}function Ro(){const[e,t]=Sl(),[n]=To(),a=(e||[]).map(e=>(0,al.jsx)("tr",{"data-test-name":"AdminCommissionPeopleSalesTarget",children:(0,al.jsx)(Do,{item:e,rates:n,saveItem:t})},e.user_id+"-sales-target"));return(0,al.jsx)(al.Fragment,{children:(0,al.jsxs)("table",{children:[(0,al.jsx)("thead",{children:(0,al.jsxs)("tr",{children:[(0,al.jsx)("th",{style:{minWidth:"200px"},children:"Annual Sales Goal"}),n.map((e,t)=>{var a;const s=e.sales_target_min,l=(null===(a=n[t+1])||void 0===a?void 0:a.sales_target_min)||"â";return(0,al.jsx)("th",{"data-test-name":"AdminCommissionPeopleSalesTarget",children:`${s}% - [x${e.multiplier}] - ${l}%`},e.commission_sales_target_id+"-header")})]})}),(0,al.jsx)("tbody",{children:a})]})})}function Lo(e){let{data:t,save:n}=e;const s=(0,a.useMemo)(()=>({maximum_commission:""}),[]),[l,o]=(0,a.useState)(s),[i,r]=(0,a.useState)(s);(0,a.useEffect)(()=>{let e=s;t&&(e={...e,maximum_commission:Number(t.maximum_commission).toFixed(2)}),o(e)},[t,t.maximum_commission,s]);const c=(0,a.useCallback)(e=>{const t=e.target;o(e=>({...e,[t.name]:t.value}))},[]),d=(0,a.useCallback)(e=>{r(s);let t=0;for(const n of["maximum_commission"])if(""===e[n].toString().trim())r(e=>({...e,[n]:"Required"})),t++;else if("maximum_commission"===n){const a=Number(e[n]);(isNaN(a)||a>100||a<0)&&(r(e=>({...e,[n]:"Rate must be between 0 and 100"})),t++)}return!(t>0)},[s]),u=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(0,al.jsx)("h5",{style:{fontWeight:"bold",marginBottom:"-0.5rem"},children:"Maximum Commission (Threshold)"})})}),(0,al.jsx)(Zs.Row,{children:(0,al.jsxs)(Zs.Col,{padded:!0,sm:12,children:[(0,al.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledIconInput,{style:{maxWidth:"100px"},iconPosition:"right",Icon:(0,al.jsx)("div",{children:"%"}),className:"align-with-select",label:t||"",name:e,value:l[e],onChange:c,onBlur:e=>{d(l)&&n(l)}})})}("maximum_commission",""),(0,al.jsx)("div",{style:{marginLeft:"0.5rem"},children:"of Margin"})]}),""!==i.maximum_commission?(0,al.jsx)("span",{style:{color:"red"},children:i.maximum_commission}):""]})})]});return u}function Po(e){let{item:t,saveItem:n,deleteItem:s}=e;const l=(0,a.useMemo)(()=>({service_id:"",exclude_from_margin:"0"}),[]),[o,i]=(0,a.useState)(t||l);let r=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(0,al.jsx)("b",{children:t.service_name})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(0,al.jsxs)(Zs.ButtonsGroup,{children:[(0,al.jsx)(Zs.LabeledRadio,{label:"Included",checked:0==o.exclude_from_margin,onChange:e=>{i(e=>({...e,exclude_from_margin:"0"})),n({...t,exclude_from_margin:"0"})}}),(0,al.jsx)(Zs.LabeledRadio,{label:"Excluded",checked:1==o.exclude_from_margin,onChange:e=>{i(e=>({...e,exclude_from_margin:"1"})),n({...t,exclude_from_margin:"1"})}})]})})]});return r}const Bo={rate:{component:function(){const[e,,t,n]=So();(0,a.useEffect)(()=>{(null==e?void 0:e.length)>0&&(0,Gl.W1)()},[null==e?void 0:e.length]);const s=e.map(e=>(0,al.jsx)(Zs.Row,{"data-test-name":"AdminCommissionRate",children:(0,al.jsx)(Io,{item:e,saveItem:t,deleteItem:n})},e.commission_rate_id)),l=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Io,{saveItem:t})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Create a commission rate for each unique commission percentage. You can create a single rate if you pay all reps the same or create multiple rates for the different percentages.",link:"https://help.commonsku.com/knowledge/how-to-create-update-commissions#base-rate"}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:6,children:(0,al.jsx)("b",{children:"Label"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:2,children:(0,al.jsx)("b",{children:"Base Rate"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Type"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1})]}),s,l,(0,al.jsx)(Ml.default,{})]})},title:"Commission Rates",show:!0},people:{component:function(){const[e,t]=Sl(),[n]=So();let a=(e||[]).map(e=>(0,al.jsx)(Zs.Row,{"data-test-name":"AdminCommissionPeopleRate",children:(0,al.jsx)(ko,{item:e,rates:n,saveItem:t})},e.user_id));0===a.length&&(a=(0,al.jsx)(Zs.Loading,{}));const s=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("p",{children:"Assign your reps' commission rates based on their role within a project. You can set your reps' commissions to calculate on projects where:"}),(0,al.jsxs)("ul",{children:[(0,al.jsx)("li",{children:"They are the client rep only"}),(0,al.jsx)("li",{children:"They are the order rep only"}),(0,al.jsx)("li",{children:"They are both the client and order rep"})]})]});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:s,link:"https://help.commonsku.com/knowledge/how-to-create-update-commissions#apply"}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:3}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Client Rep Only"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Order Rep Only"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Client and Order Rep"})})]}),a,(0,al.jsx)(Ml.default,{})]})},title:"People",show:!0},service:{component:function(){const[e,,t,n]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyServices),n=Z.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(W());const n=await(0,g.oD)("GET",X,{});return e(Q(n.json.services)),n.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{var n;t.service_id?await e((n={id:t.service_id,...t},async(e,t)=>{console.log("Update",n),e(W());const a=await(0,g.oD)("PUT",X+"/"+n.service_id,n);return e(V({id:n.service_id,changes:n})),e(Y()),a.json.service})):await e((e=>async(t,n)=>{t(W());const a=await(0,g.oD)("POST",X,e);return t(H(Object.assign(a.json.service,{new:!0}))),t(Y()),a.json.service})(t)),Xs.oR.success("Saved successfully")})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(W());try{await(0,g.oD)("DELETE",X+"/"+n.service_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e($(n.service_id)),e(Y()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,o,i]}(),s=e.map((e,a)=>(0,al.jsx)("div",{"data-test-name":"AdminCompanyService","data-testid":`row-${a}`,children:(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Po,{item:e,saveItem:t,deleteItem:n})})},e.service_id));return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Choose to automatically include or exclude freight, fulfillment, and shipping on your margin and commission calculations.",link:"https://help.commonsku.com/knowledge/how-to-create-update-commissions#excludes"}),s,(0,al.jsx)(Ml.default,{})]})},title:"Excludes",show:!0}
1,maximum:{component:function(){const{data:e,save:t}=(0,rl.A)();return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Set a limit on the total commission payable on a project. If multiple reps are entitled to commissions, their rates will be proportionately reduced and will not exceed the allowable limit.",link:"https://help.commonsku.com/knowledge/how-to-create-update-commissions#threshold"}),(0,al.jsx)(Lo,{data:e.data,save:t})]})},title:"Maximum",show:!0},margin:{component:function(){const[e,,t,n]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.commissionMarginRates),n=re.selectAll(t),s=t.loading;(0,a.useEffect)(()=>{e(async(e,t)=>{e(ae());const n=await(0,g.oD)("GET",ie,{});return e(le(n.json.commission_margin_rates)),n.json})},[e]);const o=(0,a.useCallback)(t=>{(async()=>{var n;t.commission_margin_id?await e((n={id:t.commission_margin_id,...t},async(e,t)=>{console.log("Update",n),e(ae());const a=await(0,g.oD)("PUT",ie+"/"+n.commission_margin_id,n);return e(oe({id:n.commission_margin_id,changes:n})),e(se()),a.json.commission_margin_rate})):await e((e=>async(t,n)=>{t(ae());const a=await(0,g.oD)("POST",ie,e);return t(te(Object.assign(a.json.commission_margin_rate,{new:!0}))),t(se()),a.json.commission_margin_rate})(t)),Xs.oR.success("Saved successfully")})()},[e]),i=(0,a.useCallback)(t=>{(async()=>{var n;await e((n=t,async(e,t)=>{console.log("delete",n),e(ae());try{await(0,g.oD)("DELETE",ie+"/"+n.commission_margin_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",n),e(ne(n.commission_margin_id)),e(se()),!0})),Xs.oR.success("Deleted successfully")})()},[e]);return[n,s,o,i]}(),s=e.map((a,s)=>(0,al.jsx)(Zs.Row,{"data-test-name":"AdminCommissionMarginRate",children:(0,al.jsx)(Eo,{item:a,nextItem:e[s+1],saveItem:t,deleteItem:n})},a.commission_margin_id)),o=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Eo,{saveItem:t})});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Increase or decrease your team's commissions by applying a multiplier to their commission based on their final billed margin.",link:"https://help.commonsku.com/knowledge/how-to-create-update-commissions#table"}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:4,children:(0,al.jsx)("b",{children:"Margin Minimum"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:4,children:(0,al.jsx)("b",{children:"Margin Maximum"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Multiplier"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1})]}),s,o,(0,al.jsx)(Ml.default,{})]})},title:"Margin Table",show:!0},client:{component:function(){const[e,,t,n]=(0,jo.A)(),[s,l]=(0,a.useState)(!1);let o=null;s&&(o=(0,al.jsx)(Zs.Popup,{style:{padding:20,maxWidth:"1600px",zIndex:10001},width:"calc(100vw - 100px)",height:"calc(100vh - 100px)",header:(0,al.jsxs)(Zs.Row,{className:"popup-header",justify:"space-between",wrap:"nowrap",style:{alignItems:"flex-start"},children:[(0,al.jsx)("h2",{style:{margin:"0.2em"},children:"Client Rate"}),(0,al.jsx)("div",{children:(0,al.jsx)(Zs.Button,{onClick:()=>l(!1),children:"Done"})})]}),children:(0,al.jsx)(Co,{})}));const i=e.map((e,a)=>(0,al.jsx)(Zs.Row,{"data-test-name":"AdminCommissionClientRate",children:(0,al.jsx)(vo,{item:e,saveItem:t,deleteItem:n})},e.commission_client_rate_id)),r=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(vo,{saveItem:t})}),c=(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{l(!0)},children:"Assign Client Rates"},"people-button");return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Increase or decrease your team's commissions by applying a multiplier to their commission based on the client.",link:"https://help.commonsku.com/knowledge/how-to-create-update-commissions#client-rates",buttons:[c]}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:8,children:(0,al.jsx)("b",{children:"Label"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Multiplier"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1})]}),i,r,(0,al.jsx)(Ml.default,{}),o]})},title:"Client Rates",show:!0},salesTarget:{component:function(){const[e,,t,n]=To(),[s,l]=(0,a.useState)(!1);let o=null;s&&(o=(0,al.jsx)(Zs.Popup,{style:{padding:20,maxWidth:"1600px",zIndex:10001},width:"calc(100vw - 100px)",height:"calc(100vh - 100px)",header:(0,al.jsxs)(Zs.Row,{className:"popup-header",justify:"space-between",wrap:"nowrap",style:{alignItems:"flex-start"},children:[(0,al.jsx)("h2",{style:{margin:"0.2em"},children:"Assign Sales Goals"}),(0,al.jsx)("div",{children:(0,al.jsx)(Zs.Button,{onClick:()=>l(!1),children:"Done"})})]}),children:(0,al.jsx)(Ro,{})}));const i=e.map((a,s)=>(0,al.jsx)(Zs.Row,{"data-test-name":"AdminCommissionSalesTargetRate",children:(0,al.jsx)(Ao,{item:a,nextItem:e[s+1],saveItem:t,deleteItem:n})},a.commission_sales_target_id)),r=(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Ao,{saveItem:t})}),c=(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{l(!0)},children:"Assign Sales Goals"}
1,"people-button");return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:"Increase or decrease your team's commissions by applying a multiplier to their commission based on their annual sales goal attainment.",link:"https://help.commonsku.com/knowledge/how-to-create-update-commissions#sales-goal",buttons:[c]}),(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"% of Goal"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:1}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3}),(0,al.jsx)(Zs.Col,{padded:!0,sm:3,children:(0,al.jsx)("b",{children:"Multiplier"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:2})]}),i,r,o,(0,al.jsx)(Ml.default,{})]})},title:"Sales Goal",show:!0}},No=()=>(0,al.jsx)(no,{"data-test-name":"AdminTabbedCommission",moduleMap:Bo,defaultModule:"rate"});function Oo(e){let{title:t,paywalled:n}=e;const[a]=So();return(0,al.jsxs)("div",{"data-test-name":"AdminCommissionSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.PercentIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:t}),n?(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("p",{style:{marginBottom:0},children:"Upgrade to the Advanced tier to gain access to the Commissions Management feature."}),(0,al.jsx)(Zs.Link,{as:"a",href:"#",children:"Learn More"})]}):(0,al.jsx)(Zs.LightIndicator,{name:`${null==a?void 0:a.length} rates defined`,on:(null==a?void 0:a.length)>0})]})]})}var Uo=n(48059),Fo=n(79618),Mo=n(93399);function qo(){var e,t;const{data:n,loading:a,saveExtra:s}=(0,rl.A)(),l=1===(null==n||null===(e=n.data)||void 0===e||null===(t=e.companyData)||void 0===t?void 0:t.hubspot_import_enabled)||!1;return(0,al.jsx)("div",{"data-test-name":"AdminHubspotImportToggle",children:"pending"===a?(0,al.jsx)(Zs.SkubotSpinner,{size:"button",skubot:!1}):(0,al.jsx)(Zs.ToggleSwitchStyled,{size:"small",selected:l,onClick:()=>{s({hubspot_import_enabled:!l},!0)},style:{maxHeight:"25px",alignSelf:"center"}})})}const zo=`${Gs.x.location.protocol}//${Gs.x.location.host}/admin_settings_new.php`,Go=e=>{let{temp:t,marketing_platforms:n}=e;return n.platform_data.sync_started?"1"==n.platform_data.sync_started:"1"==t.sync_started},Ho=e=>{let{temp:t}=e;return t.marketing_software},$o=e=>{let{temp:t}=e;return t.hubspot_connected},Wo=e=>{let{temp:t}=e;return t.mailchimp_connected},Yo=e=>{let{temp:t}=e;return t.mailchimp_list_id},Qo=()=>{const e=(0,l.wA)(),t=(0,Vl.Us)(),n=(0,l.d4)(e=>{let{temp:t}=e;return t.wishpond_merchid}),s=(0,l.d4)(e=>{let{temp:t}=e;return t.wishpond_tracking}),o=(0,l.d4)(e=>{let{temp:t}=e;return t.wishpond_api}),[i,r]=(0,a.useState)({wishpond_merchid:n,wishpond_tracking:s,wishpond_api:o});(0,a.useEffect)(()=>{r({...i,wishpond_merchid:n,wishpond_tracking:s,wishpond_api:o})},[n,s,o]);const c=e=>t=>r({...i,[e]:t.target.value}),d={width:200,padding:4,marginTop:"-5px"};return(0,al.jsxs)("div",{"data-test-name":"WishpondView",id:"wishpond-settings",children:[(0,al.jsx)(Zs.Row,{children:(0,al.jsxs)(Zs.Col,{sm:12,children:[(0,al.jsx)("label",{children:"Wishpond's Merchant ID:"}),(0,al.jsx)("input",{type:"text",style:d,name:"wishpond_merchid",value:i.wishpond_merchid,placeholder:"merchant Id",onChange:c("wishpond_merchid")})]})}),(0,al.jsx)(Zs.Row,{children:(0,al.jsxs)(Zs.Col,{sm:12,children:[(0,al.jsx)("label",{children:"Wishpond's Tracking Key:"}),(0,al.jsx)("input",{type:"text",style:d,name:"wishpond_tracking",value:i.wishpond_tracking,placeholder:"tracking key",onChange:c("wishpond_tracking")})]})}),(0,al.jsx)(Zs.Row,{children:(0,al.jsxs)(Zs.Col,{sm:12,children:[(0,al.jsx)("label",{children:"Wishpond's API Key:"}),(0,al.jsx)("input",{type:"text",style:d,name:"wishpond_api",value:i.wishpond_api,placeholder:"API key",onChange:c("wishpond_api")})]})}),(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{sm:12,children:(0,al.jsx)(Zs.Button,{id:"save_wishpond",onClick:()=>e((0,Uo.YV)(t.company_id,{wishpond_merchid:i.wishpond_merchid.trim(),wishpond_tracking:i.wishpond_tracking.trim(),wishpond_api:i.wishpond_api.trim()})),size:"small",children:"Save"})})})]})},Vo=e=>{let{sync_started:t}=e;const n=(0,l.wA)(),a=(0,Vl.Us)(),s=(0,l.d4)($o),o=(0,Vl.u7)(["FEATURE-FULL","FEATURE-ADVANCED","FEATURE-ENTERPRISE"],
1!0);return(0,al.jsx)("div",{"data-test-name":"HubspotView",id:"hubspot-settings",children:(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{sm:12,padded:!0,children:(0,al.jsx)(Zs.LightIndicator,{name:s?"Connected to HubSpot":"Not connected",on:s})}),(0,al.jsx)(Zs.Col,{sm:12,padded:!0,style:{marginBottom:"20px"},children:(0,al.jsx)(Zs.ShowPopup,{popup:Zo,render:e=>{let{onClick:l}=e;return(0,al.jsxs)(Zs.Button,{"data-test-name":"HubspotView",id:"hubspot_popup_btn",type:"button",size:"small",onClick:()=>{(!s||(t?(alert("Sync has already started, please stop sync and try again."),0):(Gs.x.confirm("Are you sure you want to disconnect?")&&n((0,Uo.Qc)(a.company_id)),0)))&&l()},children:[s?"Disconnect":"Connect to"," HubSpot"]})}})}),s&&o?(0,al.jsx)(Zs.Col,{sm:6,padded:!0,children:(0,al.jsxs)(Zs.Row,{style:{backgroundColor:Zs.colors.navy.lightest,borderRadius:"10px",padding:"10px",height:"300px",alignItems:"flex-start",paddingTop:"30px"},children:[(0,al.jsxs)(Zs.Col,{sm:12,style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"10px"},children:[(0,al.jsx)("img",{width:120,src:"/images/hubspot-logo-text.svg",alt:"Hubspot"}),(0,al.jsx)(Zs.ArrowIcon,{direction:"right",size:"large",color:Zs.colors.pink[60]}),(0,al.jsx)("img",{width:120,src:"/images/commonsku-main-logo-blue.svg",alt:"commonsku"})]}),(0,al.jsxs)(Zs.Col,{sm:12,style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"10px"},children:[(0,al.jsx)(qo,{})," Sync from hubspot to commonsku"]}),(0,al.jsx)(Zs.Col,{sm:12,style:{textAlign:"center"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>Gs.x.location.href="/clients.php?tab=hubspot",children:"View Sync"})}),(0,al.jsx)(Zs.Col,{sm:12,style:{textAlign:"center"},children:"Contacts will be assigned to your default client rep."})]})}):null,(0,al.jsx)(Zs.Col,{sm:6,padded:!0,children:(0,al.jsxs)(Zs.Row,{style:{backgroundColor:Zs.colors.navy.lightest,borderRadius:"10px",padding:"10px",height:"300px",alignItems:"flex-start",paddingTop:"30px"},children:[(0,al.jsxs)(Zs.Col,{sm:12,style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:"10px"},children:[(0,al.jsx)("img",{width:120,src:"/images/commonsku-main-logo-blue.svg",alt:"commonsku"}),(0,al.jsx)(Zs.ArrowIcon,{direction:"right",size:"large",color:Zs.colors.pink[60]}),(0,al.jsx)("img",{width:120,src:"/images/hubspot-logo-text.svg",alt:"Hubspot"})]}),(0,al.jsx)(Zs.Col,{sm:12,style:{textAlign:"center"},children:"Sync from commonsku to hubspot"}),(0,al.jsx)(Zs.Col,{sm:12,style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center"},children:(0,al.jsx)("div",{id:"show-mp-preferences-button",children:(0,al.jsx)(Zs.ShowPopup,{popup:Mo.default,render:e=>{let{onClick:n}=e;return(0,al.jsx)(Zs.Button,{"data-test-name":"HubspotView",id:"configure_mp_preferences",type:"button",size:"small",onClick:n,...s?{}:{disabled:"disabled"},children:t?"View Sync":"Configure"})},sync_started:t})})})]})})]})})},Xo=e=>{let{sync_started:t}=e;const n=(0,l.wA)(),s=(0,Vl.Us)(),o=(0,l.d4)(Wo),i=(0,l.d4)(Yo),r=(0,l.d4)(e=>{let{temp:t,temp_data:n}=e;return n.mailchimp_lists&&n.mailchimp_lists.length>0?n.mailchimp_lists:t.mailchimp_lists}),[c,d]=(0,a.useState)({mailchimp_list_id:i});(0,a.useEffect)(()=>{d({...c,mailchimp_list_id:i})},[i]);const u=e=>Ko(e,"mailchimp",function(){n((0,p.fD)({mailchimp_connected:!0})),n((0,Fo.oT)())},()=>n((0,Uo.w5)()));return(0,al.jsx)(al.Fragment,{children:(0,al.jsxs)("div",{id:"mailchimp-settings",children:[(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{sm:12,children:(0,al.jsx)(Zs.LightIndicator,{name:o?"Connected to Mailchimp":"Not connected",on:o})}),(0,al.jsx)(Zs.Col,{sm:12,children:(0,al.jsxs)(Zs.Button,{size:"small",id:"connect_mailchimp",onClick:()=>o?t?(alert("Sync has already started, please stop sync and try again."),!1):(Gs.x.confirm("Are you sure you want to disconnect?")&&n((0,Uo.ll)(s.company_id)),!1):(Jo({path:`/marketing_platform_oauth.php?platform=mailchimp&redirect_url=${zo}`,callback:u}),!0),children:[o?"Disconnect":"Connect to"," Mailchimp"]})})]}),(0,al.jsx)(Zs.Row,{children:(0,al.jsxs)(Zs.Col,{sm:12,children:[(0,al.jsx)("label",{children:"Select Audience:"}),(0,al.jsxs)("select",{name:"mailchimp_list_id",...t||!o?{disabled:"disabled"}:{},value:c.mailchimp_list_id,onChange:e=>{d({...c,mailchimp_list_id:e.target.value}),n((0,Uo.kY)(s.company_id,e.target.value))},children:[(0,al.jsx)("option",{value:"",children:"Select Audience..."}),r&&r.length>0?r.map((e,t)=>(0,al.jsx)("option",{value:e.id,children:e.name},"mc_list_"+t)):null]}),(0,al.jsx)("button",{id:"mailchimp_refresh_lists",...t||!o?{disabled:"disabled"}:{},onClick:()=>n((0,Fo.oT)()),children:"ð"}),(0,al.jsx)("div",{style:{fontStyle:"italic",width:550,marginTop:10},children:(0,al.jsx)("p",{children:"Please make sure there is an audie
1nce is selected before continuing any further. If you do not see any, please create one in Mailchimp and click refresh button and select."})})]})}),(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{sm:12,children:(0,al.jsx)("div",{id:"show-mp-preferences-button",children:(0,al.jsx)(Zs.ShowPopup,{popup:Mo.default,render:e=>{let{onClick:n}=e;return(0,al.jsx)(Zs.Button,{"data-test-name":"MailchimpView",size:"small",id:"configure_mp_preferences",type:"button",onClick:n,style:{marginRight:10},...c.mailchimp_list_id&&o?{}:{disabled:"disabled"},children:t?"View Sync":"Configure"})},sync_started:t})})})})]})})},Zo=e=>{let{onClose:t}=e;const n=(0,l.wA)(),a=(0,l.d4)($o),s=e=>Ko(e,"hubspot",function(){n((0,p.fD)({hubspot_connected:!0})),t()},()=>n((0,Uo.w5)()));return(0,al.jsx)(Zs.Theme,{"data-test-name":"HubspotOnboardingPopup",children:(0,al.jsx)(Zs.Popup,{width:10/12*100+"%",style:{padding:"5px 25px",fontFamily:Zs.themeOptions.fonts.join(","),maxWidth:"fit-content",height:"350px"},onClose:t,title:"Connect HubSpot",controls:(0,al.jsx)(Zs.Button,{onClick:t,children:"Close"}),children:(0,al.jsx)("div",{className:"row",style:{overflow:"auto",marginBottom:"100px",fontSize:"1rem"},children:(0,al.jsx)(Zs.Row,{style:{paddingTop:"30px"},children:(0,al.jsxs)(Zs.Col,{xs:!0,padded:!0,children:[(0,al.jsxs)(Zs.Text,{as:"p",style:{paddingBottom:"10px",fontSize:"1rem"},children:["To learn more about HubSpot and special offers available please click 'Contact Us' and search for 'HubSpot'.",(0,al.jsx)("br",{}),"When prompted, request to speak directly with our support team."]}),(0,al.jsxs)(Zs.ButtonsGroup,{children:[(0,al.jsx)(Zs.Button,{style:{marginRight:"10px"},onClick:g.WY,cta:!0,children:"Contact Us"}),(0,al.jsxs)(Zs.Button,{onClick:function(){Jo({path:`/marketing_platform_oauth.php?platform=hubspot&redirect_url=${zo}`,callback:s})},children:[a?"Disconnect":"Connect"," HubSpot"]})]})]})})})})})},Ko=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;try{if("/marketing_platform_oauth.php"==e.location.pathname&&e.location.search.includes(`?platform=${t}&code=`))return n&&n(),e.closed||e.close(),!0;if(e.closed)return a&&a(),!0}catch(e){console.info(e)}return!1};function Jo(e){if(!e.path)return null;const t={width:Math.floor(.5*Gs.x.outerWidth),height:Math.floor(.5*Gs.x.outerHeight)};t.width<1e3&&(t.width=800),t.height<800&&(t.height=800),t.left=Math.floor(Gs.x.screenX+(Gs.x.outerWidth-t.width)/2),t.top=Math.floor(Gs.x.screenY+(Gs.x.outerHeight-t.height)/8);const n=`toolbar=0,scrollbars=1,status=1,resizable=1,location=1,menuBar=0,\n width=${t.width},height=${t.height},\n left=${t.left},top=${t.top}`;e.windowName=e.windowName||"ConnectWithOAuth",e.windowOptions=e.windowOptions||n;const a=Gs.x.open(e.path,e.windowName,e.windowOptions),s=Gs.x.setInterval(function(){const t=!!e.callback&&e.callback(a);(a.closed||t)&&Gs.x.clearInterval(s)},1e3)}const ei=e=>{const t=(0,l.wA)(),n=(0,Vl.Us)(),s=(0,l.d4)(Ho),o=(0,l.d4)(Wo),i=(0,l.d4)(Go),[c,d]=(0,a.useState)({marketing_software:s||""});(0,a.useEffect)(()=>{d({...c,marketing_software:s||""})},[s]),(0,a.useEffect)(()=>{t((0,Fo.CG)({"max-results":4294967296,parent_type:n.company_type,parent_id:n.company_id,report:!0,exclude_default_company_users:!0})),t((0,Fo.$3)()),t((0,Fo.un)({resource_type:"CLIENT"})),t((0,Fo.hq)()),t((0,Fo.yk)({company_type:"CLIENT"})),t((0,Fo.Uq)({"max-results":4294967296,parent_type:"CLIENT"})),t((0,Uo.Rk)(n.company_id)),"MAILCHIMP"===c.marketing_software&&o&&t((0,Fo.oT)())},[]);const u=e=>{d({...c,marketing_software:e}),t((0,Uo.NY)(n.company_id,e,!1))};return(0,al.jsxs)(r.A,{"data-test-name":"MarketingSoftwareAppNew",children:[(0,al.jsxs)("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"Mailchimp",checked:"MAILCHIMP"==c.marketing_software,onChange:e=>{u("MAILCHIMP")}}),(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"Wishpond",checked:"WISHPOND"==c.marketing_software,onChange:e=>{u("WISHPOND")}}),(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"HubSpot",checked:"HUBSPOT"==c.marketing_software,onChange:e=>{u("HUBSPOT")}}),(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"None",checked:!c.marketing_software,onChange:e=>{u("")}})]}),"WISHPOND"==c.marketing_software?(0,al.jsx)(Qo,{}):"MAILCHIMP"==c.marketing_software?(0,al.jsx)(Xo,{sync_started:i}):"HUBSPOT"==c.marketing_software?(0,al.jsx)(Vo,{sync_started:i}):null]})};function ti(e){let{reloadData:t}=e;const n="https://"+window.location.hostname+"/qbo_request_token.php",s=(0,a.useRef)(null),l=(0,a.useCallback)(()=>{console.log("Do something hereeee"),t()},[t]),o=(0,a.useCallback)(()=>{setTimeout(()=>{const e=setInterval(()=>{null===s.current&&(s.current=window.open("","ippPopupWindow")),s.current.closed&&(console.log("quickbook is closed. do something"),l(),clearInterval(e))},1e3)},3e3)},[l]);return(0,a.useEffect)(()=>{const e=document.createElement("script");e.src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js",e.async=!0,e.onload=()=>{const e=document.createElement("script");e.innerHTML=`\n intuit.ipp.anywhere.setup({\n menuProxy: '',\n grantUrl: '${n}'\n });\n `,e.type="text/javascript",document.body.appendChild(e),setTimeout(()=>{document.getElementsByClassName("intuitPlatformConnectButton")[0].addEventListener("click",()=>{o()})},1e3)},document.body.appendChild(e)},[n,o]),(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:(0,al.jsxs)(al.Fragment,{children:["Click the Connect to QuickBooks button below to authorize commonsku and QuickBooks Online to connect and ",(0,al.jsx)("a",{href:"https://appcenter.intuit.com/cmsimages/promo/intuit_app_data_sharing/dynamicDataSharing/DataSharingFrame.html?scopes=com.intuit.quickbooks.accounting",target:"_blank",children:"share data for the purpose of our integration"}),", following commonsku's ",(0,al.jsx)("a",{href:"https://commonsku.com/terms",target:"_blank",children:"terms of service"})," and ",(0,al.jsx)("a",{href:"https://commonsku.com/privacy",target:"_blank",children:"privacy policy"}),". For added security, we will prompt you to reconnect commonsku and QuickBooks every 6 months. However, you can disconnect the integration anytime."]}),link:"https://help.commonsku.com/knowledge/connect-to-quickbooks-online"}),(0,al.jsx)(Zs.LightIndicator,{name:"Not connected",on:!1}
1),(0,al.jsx)("div",{dangerouslySetInnerHTML:{__html:"<ipp:connectToIntuit></ipp:connectToIntuit>"}})]})}n(33218);const ni=(e,t)=>{for(const n of t)if(n.ref==e)return n;return null};function ai(e){let{qboCurrencies:t,qboAccounts:n}=e;const[s,o]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyQboCurrencies),n=fa.selectAll(t);(0,a.useEffect)(()=>{e(async(e,t)=>{e(ga());const n=await(0,g.oD)("GET","qbo-currency",{});return e(_a(n.json.qbo_currencies)),n.json})},[e]);const s=(0,a.useCallback)(t=>{(async()=>{var n;console.log("save qbo currency item",t),t.qbo_currency_id?await e((n={id:t.qbo_currency_id,...t},async(e,t)=>{console.log("Update",n),e(ga());const a=await(0,g.oD)("PUT","qbo-currency/"+n.qbo_currency_id,n);return e(ya({id:n.qbo_currency_id,changes:n})),e(xa()),a.json.qbo_currency})):await e((e=>async(t,n)=>{t(ga());const a=await(0,g.oD)("POST","qbo-currency",e);return t(ha(Object.assign(a.json.qbo_currency,{new:!0}))),t(xa()),a.json.qbo_currency})({...t}))})()},[e]);return[n,s]}(),i=n.filter(e=>"Accounts Payable"===e.AccountType);if(i.unshift({Name:""}),0===t.length)return(0,al.jsx)(Zs.Loading,{"data-test-name":"Currency"});const r=e=>{var a;const l=s.filter(t=>t.currency_id===e),r=null===(a=l[0])||void 0===a?void 0:a.qbo_account_ref,c=ni(r,n);return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledSelect,{isClearable:!0,placeholder:"Select an accounts payable",label:"",options:i.map(e=>({label:e.Name,value:e.ref})),value:c?{label:c.Name,value:c.ref}:null,onChange:n=>{let a={qbo_account_ref:(n=null===n?{label:"",value:""}:n).value,currency_id:e,qbo_currency_ref:t.indexOf(e)+1};l.length>0&&(a={...l[0],...a}),o(a)}})})},c=t.map(e=>(0,al.jsxs)(Zs.Row,{"data-test-name":"Currency",children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)(Zs.Input,{value:e,disabled:!0,style:{height:"42px"}})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:r(e)})]},"qbo-currency-"+e));return(0,al.jsx)(al.Fragment,{children:c})}const si={get_tax_codes:"TaxCode",get_items:"Item",get_accounts:"Account",get_custom_fields:"CustomField",get_currencies:"CompanyCurrency",get_classes:"Class"},li=e=>({action:"get_entity",entity_name:si[e]});function oi(e){let{qboAccounts:t,qboItems:n}=e;const[s,o,i]=function(){const e=(0,l.wA)(),[t,n]=(0,a.useState)([]),s=(0,a.useCallback)((e,t)=>{console.log("saveQboAccount",e,t),(async()=>{await(0,g.oD)("PUT","qbo-account/"+t.qbo_account_id,e),n(n=>{const a=[];for(const s of n)s.qbo_account&&s.qbo_account.qbo_account_id===t.qbo_account_id&&(s.qbo_account={...s.qbo_account,...e}),a.push(s);return console.log(a,"new"),a})})()},[]),o=(0,a.useCallback)((e,t)=>{console.log("saveQboAccount",e,t),(async()=>{await(0,g.oD)("PUT","qbo-item/"+t.qbo_item_id,e),n(n=>{const a=[];for(const s of n)s.qbo_item&&s.qbo_item.qbo_item_id===t.qbo_item_id&&(s.qbo_item={...s.qbo_item,...e}),a.push(s);return console.log(a,"new"),a})})()},[]);return(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("GET","line-item-type",{});n(e.json.line_item_types)})()},[e]),[t,s,o]}(),r=t.filter(e=>"Accounts Payable"===e.AccountType),c=t.filter(e=>"Bank"===e.AccountType),d=t.filter(e=>"Cost of Goods Sold"===e.AccountType||"Expense"===e.AccountType);if(0===s.length)return(0,al.jsx)(Zs.Loading,{"data-test-name":"LineItemType"});const u={BILL:"Select an accounts payable","INVOICE-SERVICE":"Select a service","BILL-SERVICE":"Select a COGS or expense account","BILL-ITEM":"Select a COGS or expense account","INVOICE-ITEM":"Select a non-inventory product","INVOICE-SYSTEM":"Select a system (ie. credit card fees)","FORWARD-BANK":"Select a bank account","FORWARD-PROCESSING-FEES":"Select a COGS or expense account"},m=(e,a)=>{let s=[],l=null;if(e){s="BILL"===a.line_item_type_name?r:"FORWARD-BANK"===a.line_item_type_name?c:d,s=s.map(e=>({label:e.Name,value:e.ref}));const e=a.qbo_account_ref;l=e?ni(e,t):null,l=l?{label:l.Name,value:l.ref}:null}else{s=n.map(e=>({label:e.name,value:e.ref}));const e=a.qbo_item_ref;l=e?ni(e,n):null,l=l?{label:l.name,value:l.ref}:null}return s.unshift({label:"",value:""}),(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledSelect,{isClearable:!0,placeholder:u[a.line_item_type_name]||"Select a product or service",label:"",options:s,value:l,onCh
1ange:t=>{t=null===t?{label:"",value:""}:t,e?o({qbo_account_ref:t.value},a):i({qbo_item_ref:t.value},a)}})})},p=s.map(e=>{const t=!!e.qbo_account,n=t?e.qbo_account:e.qbo_item;return(0,al.jsxs)(Zs.Row,{"data-test-name":"LineItemType",children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)(Zs.Input,{value:n.line_item_type_label,disabled:!0,style:{height:"42px"}})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:m(t,n)})]},"qbo-currency-"+n.line_item_type_id)});return(0,al.jsx)(al.Fragment,{children:p})}function ii(e){let{qboTaxCodes:t}=e;const[n]=Dl(),[s,o]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyQboTaxes),n=Ia.selectAll(t);(0,a.useEffect)(()=>{e(async(e,t)=>{e(Ca());const n=await(0,g.oD)("GET","qbo-tax",{});return e(ka(n.json.qbo_taxes)),n.json})},[e]);const s=(0,a.useCallback)(t=>{(async()=>{var n;console.log("save qbo tax",t),t.qbo_tax_id?await e((n={id:t.qbo_tax_id,...t},async(e,t)=>{console.log("Update",n),e(Ca());const a=await(0,g.oD)("PUT","qbo-tax/"+n.qbo_tax_id,n);return e(Sa({id:n.qbo_tax_id,changes:n})),e(Ea()),a.json.qbo_tax})):await e((e=>async(t,n)=>{t(Ca());const a=await(0,g.oD)("POST","qbo-tax",e);return t(wa(Object.assign(a.json.qbo_tax,{new:!0}))),t(Ea()),a.json.qbo_tax})({...t}))})()},[e]);return[n,s]}();if(0===t.length)return(0,al.jsx)(Zs.Loading,{"data-test-name":"Tax"});const i=(e,t)=>{const a=n.map(e=>({label:e.label,value:e.tax_id}));let s=null;return t&&(s=a.filter(e=>-1!==t.tax_ids.indexOf(e.value))),(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledSelect,{label:"",placeholder:"Select a tax code",isMulti:!0,options:a,value:s,onChange:n=>{let a={qbo_tax_code_ref:e,tax_ids:(n=null===n?[{label:"",value:""}]:n).map(e=>e.value)};t&&(a={...t,...a}),o(a)}})})},r=t.map(e=>{var t;const n=e.ref,a=null===(t=s.filter(e=>e.qbo_tax_code_ref==n))||void 0===t?void 0:t[0];return a&&a.qbo_tax_id,(0,al.jsxs)(Zs.Row,{"data-test-name":"Tax",children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)(Zs.Input,{value:e.name,disabled:!0,style:{height:"42px"}})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:i(n,a)})]},"qbo-tax-qbo-mapping-"+n)});return(0,al.jsx)(al.Fragment,{children:r})}function ri(e){let{qboAccounts:t}=e;const[n]=Dl(),[s,o]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyQboTaxAccounts),n=Oa.selectAll(t);(0,a.useEffect)(()=>{e(async(e,t)=>{e(La());const n=await(0,g.oD)("GET","qbo-tax-account",{});return e(Ba(n.json.qbo_tax_accounts)),n.json})},[e]);const s=(0,a.useCallback)(t=>{(async()=>{var n;console.log("save qbo tax account item",t),t.qbo_tax_account_id?await e((n={id:t.qbo_tax_account_id,...t},async(e,t)=>{console.log("Update",n),e(La());const a=await(0,g.oD)("PUT","qbo-tax-account/"+n.qbo_tax_account_id,n);return e(Na({id:n.qbo_tax_account_id,changes:n})),e(Pa()),a.json.qbo_tax_account})):await e((e=>async(t,n)=>{t(La());const a=await(0,g.oD)("POST","qbo-tax-account",e);return t(Ra(Object.assign(a.json.qbo_tax_account,{new:!0}))),t(Pa()),a.json.qbo_tax_account})({...t}))})()},[e]);return[n,s]}(),i=t.filter(e=>"Other Current Liability"===e.AccountType);if(i.unshift({Name:""}),0===n.length)return(0,al.jsx)(Zs.Loading,{"data-test-name":"TaxCode"});const r=e=>{var n;const a=s.filter(t=>t.tax_id===e.tax_id),l=null===(n=a[0])||void 0===n?void 0:n.qbo_account_ref,r=ni(l,t);return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledSelect,{isClearable:!0,placeholder:"Select a liability account",label:"",options:i.map(e=>({label:e.Name,value:e.ref})),value:r?{label:r.Name,value:r.ref}:null,onChange:t=>{let n={qbo_account_ref:(t=null===t?{label:"",value:""}:t).value,tax_id:e.tax_id};a.length>0&&(n={...a[0],...n}),o(n)}})})},c=n.map(e=>(0,al.jsxs)(Zs.Row,{"data-test-name":"TaxCode",children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)(Zs.Input,{value:e.label,disabled:!0,style:{height:"42px"}})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:r(e)})]},"qbo-tax-account-"+e.tax_id));return(0,al.jsx)(al.Fragment,{children:c})}function ci(e){let{qboCustomFields:t}=e;const[n,s]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyQboCustomFields),n=Wa.selectAll(t),s=(0,a.useCallback)(t=>(async()=>{console.log("save qbo custom field item",t);let n=null;var a;return n=t.qbo_custom_field_id?await e((a={id:t.qbo_custom_field_id,...t},async(e,t)=>{console.log("Update",a),e(za());const n=await(0,g.oD)("PUT","qbo-custom-field/"+a.qbo_custom_field_id,a);return e($a({id:a.qbo_custom_field_id,changes:a})),e(Ga()),n.json.qbo_custom_field})):await e((e=>async(t,n)=>{t(za());const a=await(0,g.oD)("POST","qbo-custom-field",e);return t(qa(Object.assign(a.json.qbo_custom_field,{new:!0}))),t(Ga()),a.json.qbo_custom_field})({...t})),n})(),[e]);return[n,s]}(),[o,i]=(0,a.useState)([]);(0,a.useEffect)(()=>{i(t)},[t]);const r=e=>{const t=e.mapped_field?jl.filter(t=>t.value===e.mapped_field)[0]:null;return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledSelect,{isClearable:!0,placeholder:"Select a commonsku option",label:"",options:jl,value:t,onChange:async t=>{t=null===t?{label:"",value:""}:t;let n={qbo_custom_field_id:e.qbo_custom_field_id,mapped_field:t.value,qbo_custom_field_ref:e.qbo_custom_field_ref};const a=await s(n);i(n=>{const s=[];for(const l of n)l.StringValue===e.StringValue?s.push({...l,qbo_custom_field_id:a.qbo_custom_field_id,mapped_field:t.value}):s.push(l);return s})}})})},c=o.map(e=>(0,al.jsxs)(Zs.Row,{"data-test-name":"CustomField",children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)(Zs.Input,{value:e.StringValue,disabled:!0,style:{height:"42px"}})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:r(e)})]},"qbo-currency-"+e.StringValue));return(0,al.jsx)(al.Fragment,{children:c})}function di(e){let{qboInvoiceFields:t}=e;const[n,s]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyQboFieldMappings),n=ts.selectAll(t),s=(0,a.useCallback)(t=>(async()=>{console.log("save qbo field mapping item",t);let n=null;var a;return n=t.qbo_field_mapping_id?await e((a={id:t.qbo_field_mapping_id,...t},async(e,t)=>{console.log("Update",a),e(Za());const n=await(0,g.oD)("PUT","qbo-field-mapping/"+a.qbo_field_mapping_id,a);return e(es({id:a.qbo_field_mapping,changes:a})),e(Ka()),n.json.qbo_field_mapping})):await e((e=>async(t,n)=>{t(Za());const a=await(0,g.oD)("POST","qbo-field-mapping",e);return t(Xa(Object.assign(a.json.qbo_field_mapping,{new:!0}))),t(Ka()),a.json.qbo_field_mapping})({...t})),n})(),[e]);return[n,s]}(),[o,i]=(0,a.useState)([]);if((0,a.useEffect)(()=>{i(t)},[t]),0===t.length)return(0,al.jsx)(Zs.Loading,{"data-test-name":"FieldMapping"});const r=e=>{const t=e.csku_field?Cl.filter(t=>t.value===e.csku_field)[0]:null;return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledSelect,{isClearable:!0,placeholder:"Select a commonsku option",label:"",options:Cl,value:t,onChange:async t=>{t=null===t?{label:"",value:""}:t;let n={qbo_field:e.qbo_field,csku_field:t.value,mapping_type:"INVOICE"};const a=await s({...e,...n});i(n=>{const s=[];for(const l of n)l.qbo_field===e.qbo_field?s.push({...l,qbo_field_mapping_id:a.qbo_field_mapping_id,csku_field:t.value}):s.push(l);return s})}})})},c=o.map(e=>{const t=wl.filter(t=>t.value===e.qbo_field)[0];return(0,al.jsxs)(Zs.Row,{"data-test-name":"FieldMapping",children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)(Zs.Input,{value:null==t?void 0:t.label,disabled:!0,style:{height:"42px"}})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:r(e)})]},"qbo-field-mapping-"+e.qbo_field)});return(0,al.jsx)(al.Fragment,{children:c})}
1function ui(e){let{qboClasses:t}=e;const[n,s]=function(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.companyQboClasses),n=ds.selectAll(t),s=(0,a.useCallback)(t=>(async()=>{console.log("save qbo class reference item",t);let n=null;var a;return n=t.qbo_class_id?await e((a={id:t.qbo_class_id,...t},async(e,t)=>{console.log("Update",a),e(os());const n=await(0,g.oD)("PUT","qbo-class/"+a.qbo_class_id,a);return e(cs({id:a.qbo_class,changes:a})),e(is()),n.json.qbo_class})):await e((e=>async(t,n)=>{t(os());const a=await(0,g.oD)("POST","qbo-class",e);return t(ls(Object.assign(a.json.qbo_class,{new:!0}))),t(is()),a.json.qbo_class})({...t})),n})(),[e]);return[n,s]}(),[o,i]=(0,a.useState)({});if((0,a.useEffect)(()=>{i(t[0])},[t]),0===t.length)return(0,al.jsx)(Zs.Loading,{"data-test-name":"ClassReference"});const r=(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)(Zs.Input,{value:"Class Ref",disabled:!0,style:{height:"42px"}})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:(e=>{const t=null!=e&&e.csku_field?El.filter(t=>t.value===e.csku_field)[0]:null;return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Zs.LabeledSelect,{isClearable:!0,placeholder:"Select a commonsku option",label:"",options:El,value:t,onChange:async t=>{let n={csku_field:(t=null===t?{label:"",value:""}:t).value};const a=await s({...e,...n});i(e=>({...e,...a}))}})})})(o)})]},"qbo-class-"+(null==o?void 0:o.company_id));return(0,al.jsx)(al.Fragment,{children:r})}var mi=n(19399);function pi(e){var t,n,s,l,o,i,r,c,d,u,m;let{data:p,save:h,disconnect:x}=e;const[_,y,f,b,v,j,w,C,E]=function(){const[e,t]=(0,a.useState)([]),[n,s]=(0,a.useState)([]),[l,o]=(0,a.useState)(!0),[i,r]=(0,a.useState)([]),[c,d]=(0,a.useState)([]),[u,m]=(0,a.useState)([]),[p,h]=(0,a.useState)([]),[x,_]=(0,a.useState)([]);(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("POST","quickbooks",li("get_tax_codes"),null,null,null,!1),t=[];for(const n in e.json.taxes)t.push({name:e.json.taxes[n],ref:n});r(t)})()},[]);const y=async()=>{o(!0);try{const e=await(0,g.oD)("POST","quickbooks",li("get_items"),null,null,null,!1),t=[];for(const n in e.json.items)t.push({name:e.json.items[n],ref:n});s(t)}catch(e){console.error("Failed to fetch QBO items:",e)}finally{o(!1)}};return(0,a.useEffect)(()=>{y()},[]),(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("POST","quickbooks",li("get_accounts"),null,null,null,!1),t=[];for(const n in e.json.accounts)t.push({...e.json.accounts[n],ref:n});d(t)})()},[]),(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("POST","quickbooks",li("get_custom_fields"),null,null,null,!1),t=[];for(const n in e.json.custom_fields)t.push(e.json.custom_fields[n]);m(t)})()},[]),(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("POST","quickbooks",li("get_currencies"),null,null,null,!1),n=[];for(const t in e.json.currencies)n.push(e.json.currencies[t]);t(n)})()},[]),(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("POST","quickbooks",{action:"get_invoice_fields"},null,null,null,!1),t=[];for(const n in e.json.invoice_fields)t.push(e.json.invoice_fields[n]);h(t)})()},[]),(0,a.useEffect)(()=>{(async()=>{const e=await(0,g.oD)("POST","quickbooks",li("get_classes"),null,null,null,!1),t=[];for(const n in e.json.classes)t.push(e.json.classes[n]);_(t)})()},[]),[e,n,i,c,u,p,x,l,y]}(),[k,S,I]=(0,ll.A)({deleteItemCallback:x,message:"Disconnecting will clear your token and you will need to re-authenticate.",deleteLabel:"Disconnect",showUndoMessage:!1}),A="US"===(null==p||null===(t=p.companyData)||void 0===t?void 0:t.qbo_country),T=(0,Vl.Us)(),D=(null==T||null===(n=T.user_flags)||void 0===n?void 0:n.includes(mi.Y2))&&1===(null==p||null===(s=p.companyData)||void 0===s?void 0:s.commonsku_payments);return(0,al.jsxs)("div",{"data-test-name":"AdminQuickbooksSetup",children:[(0,al.jsx)(cl.A,{message:"Use the dropdowns below to map your commonsku items and taxes to QuickBooks Online (QBO). Don't see the QBO account you're looking for? Try disconnecting and reconnecting the integration to pull an up-to-date list of accounts.",link:"https://help.commonsku.com/knowledge/connect-to-quickbooks-online"}),(0,al.jsx)(Zs.LightIndicator,{name:`Connected to ${null==p||null===(l=p.companyData)||void 0===l?void 0:l.qbo_company_name}`,on:!0}),(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{I({}),S(!0)},children:"Disconnect from QuickBooks"}),_.length>0?(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("h5",{className:"section-title",children:"Multicurrency Accounts Payable"}),(0,al.jsx)("p",{children:"Select the relevant accounts payable for each foreign currency."}),(0,al.jsxs)(Zs.Row,{style:{marginBottom:"1rem"},children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)("b",{children:"Currency"})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"}
1,children:(0,al.jsx)("b",{children:"QuickBooks Online Account Payable"})})]}),(0,al.jsx)(ai,{qboCurrencies:_,qboAccounts:b})]}):null,(0,al.jsx)("h5",{className:"section-title",children:"Chart of Accounts"}),(0,al.jsxs)("p",{children:["Select the appropriate QBO accounts for your commonsku bills, items, and services. Avalara Invoice Tax mapping is only necessary for teams using ",(0,al.jsx)("a",{href:"https://help.commonsku.com/knowledge/commonsku-avalara",target:"_blank",rel:"noreferrer",children:"Avalara in commonsku"}),".",D?(0,al.jsxs)(al.Fragment,{children:[" commonsku payments mappings are only necessary for teams using ",(0,al.jsx)("a",{href:"https://help.commonsku.com/knowledge/connect-to-quickbooks-online",target:"_blank",rel:"noreferrer",children:"commonsku payments"}),"."]}):null]}),(0,al.jsxs)(Zs.Row,{style:{marginBottom:"1rem"},children:[C||y&&0!==y.length?null:(0,al.jsxs)(Zs.AlertNotification,{alertType:"warn",style:{width:"100%",marginBottom:"1rem"},children:["We're having trouble connecting to QuickBooks. This request timed out. Please try again or check your internet connection.",(0,al.jsx)(Zs.Button,{variant:"primary",size:"small",style:{marginLeft:"1rem"},onClick:()=>E(),children:"Retry"})]}),(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)("b",{children:"Item Type"})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:(0,al.jsx)("b",{children:"QuickBooks Online Account"})})]}),(0,al.jsx)(oi,{qboCurrencies:_,qboAccounts:b,qboItems:y}),(0,al.jsx)("h5",{className:"section-title",children:A?1===+(null==p||null===(o=p.companyData)||void 0===o?void 0:o.qbo_partner_tax_enabled)?"Invoice Tax":"Invoice Taxes":"Taxes"}),A?(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.LightIndicator,{name:"QuickBooks Online automated sales tax is "+(1===+(null==p||null===(i=p.companyData)||void 0===i?void 0:i.qbo_partner_tax_enabled)?"enabled":"disabled"),on:1===+(null==p||null===(r=p.companyData)||void 0===r?void 0:r.qbo_partner_tax_enabled)}),(0,al.jsxs)("p",{children:["QuickBooks Online offers automated sales tax calculations for US companies."," ",(0,al.jsx)("a",{target:"_blank",href:"https://community.intuit.com/articles/1567657-set-up-and-use-automated-sales-tax",rel:"noreferrer",children:"Learn how to set up and use automated sales tax in QuickBooks Online."})]})]}):(0,al.jsx)("p",{children:"Match your QBO tax names to commonsku tax codes."}),1===+(null==p||null===(c=p.companyData)||void 0===c?void 0:c.qbo_partner_tax_enabled)?null:(0,al.jsxs)(al.Fragment,{children:[(0,al.jsxs)(Zs.Row,{style:{marginBottom:"1rem"},children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)("b",{children:"QuickBooks Online Tax Name"})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:(0,al.jsx)("b",{children:"commonsku Tax Codes"})})]}),(0,al.jsx)(ii,{qboTaxCodes:f})]}),A?(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("h5",{className:"section-title",children:1===+(null==p||null===(d=p.companyData)||void 0===d?void 0:d.qbo_partner_tax_enabled)&&A?"Bill Tax":"Bill Taxes"}),(0,al.jsx)("p",{children:"Match your commonsku tax codes to your QBO liability accounts. Each commonsku tax code must map to a unique QBO liability account. This mapping is only necessary for teams paying supplier bills tax."}),(0,al.jsxs)(Zs.Row,{style:{marginBottom:"1rem"},children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)("b",{children:"commonsku Tax Codes"})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:(0,al.jsx)("b",{children:"QuickBooks Online Liability Account"})})]}),(0,al.jsx)(ri,{qboAccounts:b})]}):null,(0,al.jsx)("h5",{className:"section-title",children:"Custom Fields"}),(0,al.jsx)("p",{children:"Map important information from your commonsku invoice to your QBO invoiceâs custom fields by choosing from the available commonsku options."}),(0,al.jsxs)(Zs.Row,{style:{marginBottom:"1rem"},children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)("b",{children:"QuickBooks Online Custom Fields"})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:(0,al.jsx)("b",{children:"commonsku Options"})})]}),(0,al.jsx)(ci,{qboCustomFields:v}),0===+(null==p||null===(u=p.companyData)||void 0===u?void 0:u.qbo_field_mapping_enabled)?null:(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("h5",{className:"section-title",children:"Invoice Address Fields"}),(0,al.jsx)("p",{children:"Map important information from your commonsku invoice to your QBO invoice's address fields by choosing from the available commonsku options."}),(0,al.jsxs)(Zs.Row,{style:{marginBottom:"1rem"},children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)("b",{children:"Qu
1ickBooks Online Invoice Address Fields"})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:(0,al.jsx)("b",{children:"commonsku Options"})})]}),(0,al.jsx)(di,{qboInvoiceFields:j})]}),w.length>0?(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("h5",{className:"section-title",children:"Class Tracking"}),(0,al.jsx)("p",{children:1===+(null==p||null===(m=p.companyData)||void 0===m?void 0:m.qbo_partner_tax_enabled)?"Organize your QBO transactions by class by choosing from the available commonsku options.":"Organize your QBO invoices by class by choosing from the available commonsku options."}),(0,al.jsxs)(Zs.Row,{style:{marginBottom:"1rem"},children:[(0,al.jsx)(Zs.Col,{sm:6,children:(0,al.jsx)("b",{children:"QuickBooks Online Class Reference Field"})}),(0,al.jsx)(Zs.Col,{sm:6,style:{paddingLeft:"1rem"},children:(0,al.jsx)("b",{children:"commonsku Options"})})]}),(0,al.jsx)(ui,{qboClasses:w})]}):null,k]})}function hi(){const{data:e,saveExtra:t,reloadData:n,disconnectQuickbook:a}=(0,rl.A)(),s=!(null==e||!e.data.companyData.qbo_oauth_date_created);return(0,al.jsx)(al.Fragment,{children:s?(0,al.jsx)(pi,{data:e.data,save:t,disconnect:a}):(0,al.jsx)(ti,{reloadData:n})})}var gi=n(14778),xi=n.n(gi);const _i={"Purchase Orders":[{key:"PO.NEW",value:"Purchase Order Created"},{key:"PO.UPDATED",value:"Purchase Order Modified"}],"Sales Orders":[{key:"SO.UPDATED",value:"Sales Order Modified"}],Finance:[{key:"EXPORT.INVOICES",value:"Export Invoices"},{key:"EXPORT.BILLS",value:"Export Bills"},{key:"INVOICE.PAID",value:"Invoice Paid"}]},yi=e=>{var{value:t,onChange:n}=e,l=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(a=Object.getOwnPropertySymbols(e);s<a.length;s++)t.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(e,a[s])&&(n[a[s]]=e[a[s]])}return n}(e,["value","onChange"]);const[o,i]=(0,a.useState)(null!=t?t:""),r=(0,Vl.d7)(function(){return n(...arguments)});return(0,a.useEffect)(()=>{i(t)},[t]),s().createElement(Zs.Input,Object.assign({},l,{onChange:e=>(i(e.target.value),r(e)),value:o}))};function fi(e){let{webhook:t,readOnlyEvents:n,onChange:l,onDelete:o}=e;var i;const[r,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(!1),[m,p]=(0,a.useState)(""),h=null!==(i=_i[t.webhook_group_name])&&void 0!==i?i:[],{webhook_url:x}=t||{},_=(0,g.Dp)(h,"key","value"),y=(0,a.useCallback)(e=>{try{const t=new URL(e);if(!/http?/.test(t.protocol))return void p("Is Not Valid URL")}catch(e){return void p("Is Not Valid URL")}p("")},[]);return(0,a.useEffect)(()=>{y(x)},[x]),s().createElement(s().Fragment,null,s().createElement(Zs.TR,null,s().createElement(Zs.TD,{style:{width:"25%",backgroundColor:"#FFFFFF"}},s().createElement(Zs.Select,{isClearable:!1,value:_.find(e=>e.value===t.event),onChange:e=>l({event:e.value}),options:_,isDisabled:n,placeholder:"Select Event"})),s().createElement(Zs.TD,{style:{width:"45%",backgroundColor:"#FFFFFF"}},s().createElement(yi,{style:{marginBottom:"0",borderColor:m?"red":null},onChange:e=>{y(e.target.value),l({webhook_url:e.target.value})},value:t.webhook_url})),s().createElement(Zs.TD,{style:{width:"15%",backgroundColor:"#FFFFFF"}},s().createElement(Zs.ToggleSwitchStyled,{onClick:()=>{if(!t.webhook_url||!t.event||m)return u(!0),!1;l({active:!t.active})},style:t.webhook_url&&t.event&&!m?{float:"left"}:{float:"left",pointerEvents:"none",opacity:"0.4"},selected:t.active})),!n&&s().createElement(Zs.TD,{style:{width:"15%",backgroundColor:"#FFFFFF"}},s().createElement(Zs.IconButton,{style:{background:"#D10411",borderColor:"transparent"},iconPosition:"left",size:"small",Icon:Zs.TrashIcon,onClick:()=>{c(!0)}},"Delete"))),r&&s().createElement(Zs.ConfirmPopup,{confirmText:"Are you sure you want to delete this webhook?",onDelete:()=>{o(t),c(!1)},onClose:()=>c(!1)}),d&&s().createElement(Zs.Popup,{title:"Error",style:{width:"500px",height:"200px"},onClose:()=>u(!1),header:s().createElement(Zs.Row,{className:"popup-header",justify:"space-between",wrap:"nowrap",style:{alignItems:"flex-start"}},s().createElement("h2",{style:{margin:"0.2em",fontFamily:"skufont-demibold",fontSize:26,fontWeight:500,lineHeight:"26px",color:Zs.colors.neutrals[90]}},"Add Token"),s().createElement("div",null,s().createElement(Zs.XIcon,{cursor:"pointer",onClick:()=>u(!1),mt:2,ml:10,size:"large"})))},s().createElement("div",null,s().createElement(Zs.AlertNotification,{alertType:"warn",learnMore:!1,style:{marginTop:10,whiteSpace:"pre-wrap"}},"Unable to activate webhook until both Type and URL are set.."),s().createElement(Zs.Csku,{className:"popup-buttons",style:{paddingLeft:"319px"}},s().createElement(Zs.Button,{variant:"secondary",onClick:()=>u(!1),mr:24},"Ok")))))}
1var bi=function(e,t,n,a){return new(n||(n=Promise))(function(s,l){function o(e){try{r(a.next(e))}catch(e){l(e)}}function i(e){try{r(a.throw(e))}catch(e){l(e)}}function r(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,i)}r((a=a.apply(e,t||[])).next())})};const vi=(0,h.pU)({selectId:e=>null==e?void 0:e.tenant_webhook_id}),ji=(0,h.pU)({selectId:e=>null==e?void 0:e.tenant_webhook_group_id}),wi=(0,h.Z0)({name:"tenant_webhooks",initialState:{loading:"idle",webhooks:vi.getInitialState(),webhook_groups:ji.getInitialState()},reducers:{webhookGroupUpdated(e,t){ji.upsertOne(e.webhook_groups,t)},webhookGroupReceived(e,t){ji.setAll(e.webhook_groups,t)},webhookAdded(e,t){vi.addOne(e.webhooks,t)},webhookUpdated(e,t){vi.upsertOne(e.webhooks,t)},webhookReceived(e,t){vi.setAll(e.webhooks,t)},webhookRemoved(e,t){vi.removeOne(e.webhooks,t)},loading(e,t){e.loading="pending"},loaded(e,t){e.loading="idle"}}}),{loading:Ci,loaded:Ei,webhookReceived:ki,webhookAdded:Si,webhookUpdated:Ii,webhookRemoved:Ai,webhookGroupUpdated:Ti,webhookGroupReceived:Di}=wi.actions,Ri=vi.getSelectors(),Li=ji.getSelectors(),Pi=wi.reducer;function Bi(){const e=(0,l.wA)(),t=(0,Vl.Us)(),n=(0,l.d4)(e=>e.tenant_webhooks),s=Ri.selectAll(n.webhooks),o=Li.selectAll(n.webhook_groups),i=n.loading;(0,a.useEffect)(()=>{e((e,t)=>bi(void 0,void 0,void 0,function*(){const n=t();let a=[];e(Ci(n));const s=yield(0,g.oD)("GET","tenant-webhooks",{});return a=s.json,e(ki(s.json.tenant_webhooks)),e(Di(s.json.tenant_webhook_groups)),e(Ei(n)),a}))},[e,t.company_id]);const r=(0,a.useCallback)((t,n)=>e(((e,t)=>(n,a)=>bi(void 0,void 0,void 0,function*(){const s=a();n(Ci(s));try{const a=yield(0,g.oD)("PUT","tenant-webhooks",{webhook_group_name:e,password:t,action:"update_password"});return n(Ti(a.json.tenant_webhook_group)),a}finally{n(Ei(s))}}))(t,n)),[e]),c=(0,a.useCallback)(t=>{var{tenant_webhook_id:n}=t,a=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(a=Object.getOwnPropertySymbols(e);s<a.length;s++)t.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(e,a[s])&&(n[a[s]]=e[a[s]])}return n}(t,["tenant_webhook_id"]);return e(n?((e,t)=>(n,a)=>bi(void 0,void 0,void 0,function*(){const s=a();n(Ci(s));try{const a=yield(0,g.oD)("PUT",`tenant-webhooks/${e}`,t);return n(Ii(a.json.tenant_webhook)),a}finally{n(Ei(s))}}))(n,a):(e=>(t,n)=>bi(void 0,void 0,void 0,function*(){const a=n();t(Ci(a));try{const n=yield(0,g.oD)("POST","tenant-webhooks",e);return t(Si(n.json.tenant_webhook)),n}finally{t(Ei(a))}}))(a))},[e]),d=(0,a.useCallback)(t=>{return e((n=t,(e,t)=>bi(void 0,void 0,void 0,function*(){const a=t();e(Ci(a));try{const t=yield(0,g.oD)("DELETE",`tenant-webhooks/${n}`);return e(Ai(n)),t}finally{e(Ei(a))}})));var n},[e]);return{webhooksData:s,webhookGroupsData:o,loading:i,updatePassword:r,updateOrCreateWebhook:c,deleteWebhook:d}}const Ni=(0,Vs.A)(function(e){let{webhookGroupName:t,readOnlyEvents:n=!1}=e;const{webhooksData:l,webhookGroupsData:o,updatePassword:i,updateOrCreateWebhook:r,deleteWebhook:c}=Bi(),[d,u]=(0,a.useState)(""),[m,p]=(0,a.useState)([]),[h,g]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{var e;if(l&&p((0,tl.filter)(l,{webhook_group_name:t})),o){const n=(0,tl.find)(o,{webhook_group_name:t});u(null!==(e=null==n?void 0:n.password)&&void 0!==e?e:"")}},[l,o,t]),s().createElement("div",{style:{position:"relative",height:"100%"}},s().createElement("div",{className:"column tip",style:{marginBottom:20}},"A webhook is an HTTP callback. This option allows commonsku to POST client invoices and supplier bills to your predefined URL. Contact ",s().createElement("a",{href:"mailto:[email protected]"},"[email protected]")," to learn more."),s().createElement("div",{style:{width:"375px"}},s().createElement(Zs.LabeledInput,{label:s().createElement("div",null,s().createElement("div",{style:{float:"left"}},"Password "),s().createElement("div",{style:{width:24,float:"right"},onClick:()=>g(e=>!e)},s().createElement(Zs.EyeIcon,{hide:!h}))),name:"password",placeholder:"Your webhooks password",type:h?"text":"password",value:d,onBlur:e=>{i(t,d)},onChange:e=>{u(e.target.value)},autoComplete:"off"})),s().createElement(Zs.Table,{style:{border:"1px solid #d7d7d7"}},s().createElement(Zs.THead,null,s().createElement(Zs.TR,{style:{background:"#EDF4F7"}},s().createElement(Zs.TH,null,"Type"),s().createElement(Zs.TH,null,"URL"),s().createElement(Zs.TH,null,"Active"),!n&&s().createElement(Zs.TH,null,"Actions"))),s().createElement(Zs.TBody,null,
1null==m?void 0:m.map((e,t)=>s().createElement(fi,{webhook:e,readOnlyEvents:n,key:t,onChange:n=>{return a=this,s=void 0,o=function*(){const a=Object.assign(Object.assign({},e),n);p(xi()(m,{$splice:[[t,1,a]]})),r(a)},new((l=void 0)||(l=Promise))(function(e,t){function n(e){try{r(o.next(e))}catch(e){t(e)}}function i(e){try{r(o.throw(e))}catch(e){t(e)}}function r(t){var a;t.done?e(t.value):(a=t.value,a instanceof l?a:new l(function(e){e(a)})).then(n,i)}r((o=o.apply(a,s||[])).next())});var a,s,l,o},onDelete:e=>{let{tenant_webhook_id:n}=e;p(xi()(m,{$splice:[[t,1]]})),n&&c(n)}})))),s().createElement("div",null,!n&&s().createElement(Zs.Link,{style:{padding:"5px 7px"},onClick:()=>{p(xi()(m,{$push:[{tenant_webhook_id:"",webhook_group_name:t,label:"",webhook_url:"",event:"",active:!1}]}))}},"+ Add Webhook")))},{tenant_webhooks:Pi}),Oi=e=>{let{paywallCtaUrl:t}=e;return s().createElement(Zs.Row,null,s().createElement("div",{style:{display:"flex",background:"#E1F7FA",marginLeft:"20px",marginRight:"20px",padding:"20px"}},s().createElement("div",null,s().createElement("p",null,"Enterprise Administrators can configure and connect their webhooks and APIs through the commonsku admin settings."),s().createElement("p",{style:{marginTop:"10px"}},"This allows for integration into 3rd party applications that are not existing integrations with commonsku.")),s().createElement("div",{style:{marginLeft:"25px"}},s().createElement(Zs.Button,{variant:"secondary",size:"large",style:{width:"186px"},onClick:()=>{window.location.href=`${t}`}},"Learn More"),s().createElement(Zs.IconButton,{variant:"error",size:"large",Icon:Zs.MailIcon,style:{marginTop:"10px",width:"186px"},onClick:()=>{window.location.href="mailto:[email protected]"}},"Contact Us"))))};var Ui=n(23652),Fi=n(38506),Mi=n(27418);const qi=e=>{var t;let{component:n,...a}=e;const s=(0,Vl.Us)(),{company:l}=(0,Fi.A)(s.company_id),o=(null==l?void 0:l.feature_id)===Mi.A.DISTRIBUTOR_ENTERPRISE_FEATURE_ID||null!=s&&null!==(t=s.user_flags)&&void 0!==t&&t.includes("WEBHOOKS_ENABLED")?n:Oi;return(0,al.jsx)(o,{"data-test-name":"PaywallWrapper",...a})},zi={purchase_orders:{component:e=>(0,al.jsx)(qi,{...e,component:Ni,webhookGroupName:"Purchase Orders"}),title:"Purchase Orders",show:!0},sales_orders:{component:e=>(0,al.jsx)(qi,{...e,component:Ni,webhookGroupName:"Sales Orders"}),title:"Sales Orders",show:!0},finance:{component:e=>(0,al.jsx)(qi,{...e,component:Ni,readOnlyEvents:!0,webhookGroupName:"Finance"}),title:"Finance",show:!0}},Gi=(0,Vs.A)(e=>{let{paywallCtaUrl:t}=e;return(0,al.jsx)(no,{"data-test-name":"AdminTabbedWebhooksAPI",moduleMap:zi,defaultModule:"finance",paywallCtaUrl:t})},{companyGeneralDataById:wt.Ay});function Hi(e){let{paywallCtaUrl:t}=e;const[n,s]=(0,a.useState)(null),l=(0,a.useCallback)(()=>{s(!1)},[]),o=(0,Ui.default)(Zs.Popup)` 2 .popup-content { 3 display: flex; 4 flex-direction: column; 5 } 6 `,i=(0,al.jsxs)(o,{className:"tabbed",contentClassName:"webhooksAPI",style:{padding:0,maxWidth:"1600px",width:"calc(100vw - 100px)",height:"calc(100vh - 100px)"},noHeader:!0,children:[(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{children:(0,al.jsx)("h2",{style:{margin:"1rem",fontSize:"24px",fontWeight:"bold"},children:"Webhooks & API"})})}),(0,al.jsx)(Zs.XIcon,{size:"large",style:{position:"absolute",right:16,cursor:"pointer",top:16,zIndex:9},onClick:l}),(0,al.jsx)(Gi,{paywallCtaUrl:t})]}),r=(0,al.jsx)("div",{children:(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{s(!0)},children:"Configure Webhooks"},"configure-button")});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:["A webhook is an HTTP callback. This option allows commonsku to POST client invoices and supplier bills to",(0,al.jsx)("br",{},"br1"),"your predefined URL. This would allow the data into your approved 3rd party systems.",(0,al.jsx)("br",{},"br2"),(0,al.jsx)("br",{},"br3"),(0,al.jsx)("p",{children:"Use the Webhooks popup to configure webhooks."})],showLink:!1,buttons:[r],style:{backgroundColor:"#E1F7FA",color:"#2A4D63",textAlign:"center",display:"block"}}),n&&i]})}var $i=n(97728);function Wi(e){let{reloadData:t}=e;const n=(0,a.useRef)(null),s=(0,a.useCallback)(()=>{t()},[t]),l=(0,a.useCallback)(()=>{setTimeout(()=>{const e=setInterval(()=>
6{n.current.closed&&(console.log("xero popup is closed. do something"),s(),clearInterval(e))},1e3)},3e3)},[s]),o=(0,a.useCallback)(()=>{(async()=>{const e=await(0,g.oD)("GET","oauth2-provider/xero",{}),t=window.screen.width,a=window.screen.height,s=t>800?800:t,o=a>800?800:a,i={width:s,height:o,top:(a-o)/2,left:(t-s)/2};console.log(i),n.current=window.open(e.json.authorization_url,"OAuth2 Popup",Object.keys(i).map(e=>e+"="+i[e]).join(",")),l()})()},[l]);return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:(0,al.jsxs)(al.Fragment,{children:["Click the Connect to Xero button below to authorize commonsku and Xero to connect and share data for the purpose of our integration, following ",(0,al.jsx)("a",{href:"https://www.xero.com/ca/legal/terms/",target:"_blank",children:"Xero's terms of use"})," and commonsku's ",(0,al.jsx)("a",{href:"https://commonsku.com/terms",target:"_blank",children:"terms of service"})," and"," ",(0,al.jsx)("a",{href:"https://commonsku.com/privacy",target:"_blank",children:"privacy policy"}),". You can disconnect the integration anytime."]}),link:"https://help.commonsku.com/knowledge/connect-to-xero"}),(0,al.jsx)(Zs.LightIndicator,{name:"Not connected",on:!1}),(0,al.jsx)(Zs.Button,{size:"small",onClick:o,children:"Connect to Xero"})]})}const Yi=()=>{const[e,t]=(0,a.useState)([]),[n,s]=(0,a.useState)({});return(0,a.useEffect)(()=>{(0,g.oD)("GET","line-item-type",{}).then(e=>{let{json:t}=e;s((0,tl.keyBy)((0,tl.filter)((0,tl.map)(t.line_item_types,"xero_account")),"xero_account_id"))}),(0,g.oD)("POST","xero",{action:"get_accounts"}).then(e=>{let{json:n}=e;t(n.accounts)})},[]),(0,al.jsxs)("table",{"data-test-name":"XeroAccountsTable",children:[(0,al.jsx)("thead",{children:(0,al.jsxs)("tr",{children:[(0,al.jsx)("th",{children:"Line item type"}),(0,al.jsx)("th",{children:"Xero Account Code"})]})}),(0,al.jsx)("tbody",{children:(0,tl.map)(n,(t,a)=>{let{line_item_type_label:l,xero_account_code:o}=t;return(0,al.jsxs)("tr",{"data-test-name":"XeroAccountsTable",children:[(0,al.jsx)("td",{children:(0,al.jsx)("input",{name:"line_item_type_label",disabled:"disabled",type:"text",value:l})}),(0,al.jsxs)("td",{className:"xero-account-code",children:[(0,al.jsx)("input",{name:"xero_account_id",type:"hidden",value:a}),(0,al.jsxs)("select",{name:"xero_account_code","data-placeholder":"Select an Account",value:o,onChange:e=>{(0,g.oD)("PUT",`xero-account/${a}`,{xero_account_code:e.target.value}).then(e=>{let{json:t}=e;const a=(0,tl.get)(t,"xero_account");s({...n,[(0,tl.get)(a,"xero_account_id")]:a})})},children:[(0,al.jsx)("option",{}),(0,tl.map)(e,(e,t)=>{let{Code:n,Name:a}=e;return(0,al.jsxs)("option",{"data-test-name":"XeroAccountsTable",value:n,children:[n," - ",a]},t)})]})]})]},a)})})]})},Qi=()=>{const[e,t]=(0,a.useState)({}),[n]=Dl();return(0,a.useEffect)(()=>{Promise.all([(0,g.oD)("POST","xero",{action:"get_tax_rates"}),(0,g.oD)("GET","xero-tax",{},null,null,null,!1)]).then(e=>{let[n,a]=e;const s=(0,tl.filter)((0,tl.get)(n,"json.tax_rates"),e=>"ACTIVE"===e.Status),l=(0,tl.keyBy)((0,tl.get)(a,"json.xero_taxes"),"xero_tax_type"),o=s.reduce((e,t)=>({...e,[t.TaxType]:{tax_ids:[],xero_tax_type:t.TaxType,xero_tax_label:t.Name,...l[t.TaxType]}}),{});t(o)})},[]),(0,al.jsxs)("table",{"data-test-name":"XeroTaxesTable",children:[(0,al.jsx)("thead",{children:(0,al.jsxs)("tr",{children:[(0,al.jsx)("th",{children:"Xero Tax Rate Name"}),(0,al.jsx)("th",{children:"commonsku Tax Codes"})]})}),(0,al.jsx)("tbody",{children:(0,tl.map)(e,(a,s)=>{let{xero_tax_id:l,xero_tax_type:o,xero_tax_label:i,tax_ids:r}=a;const c=(0,tl.map)(n,e=>{let{tax_id:t,label:n}=e;return{value:t,label:n}});return(0,al.jsxs)("tr",{"data-test-name":"XeroTaxesTable",children:[(0,al.jsx)("td",{className:"xero-tax",children:(0,al.jsx)("input",{name:"xero_tax_label",type:"text",disabled:"disabled",value:i})}),(0,al.jsx)("td",{className:"commonsku-tax-codes",style:{minWidth:400},children:(0,al.jsx)(Zs.Select,{isMulti:!0,placeholder:"Select some commonsku Tax Codes",value:(0,tl.filter)(c,e=>{let{value:t}=e;return r.indexOf(t)>-1}),options:c,onChange:n=>{const a={xero_tax_type:o,tax_ids:(0,tl.map)(n,"value")};(l?(0,g.oD)("PUT",`xero-tax/${l}`,a):(0,g.oD)("POST","xero-tax",a)).then(n=>{let{json:a}=n;const s=(0,tl.get)(a,"xero_tax");t({...e,[(0,tl.get)(s,"xero_tax_type","")]:s})})}})})]},s)})})]})},Vi=e=>{let{reloadData:t}=e;const[n,s]=(0,a.useState)("loading");return(0,a.useEffect)(()=>{(0,g.oD)("POST","xero",{action:"get_connections"}).then(e=>{let{json:t}=e;console.log(t.connections,"connections"),s((0,tl.isEmpty)(t.connections)?"disconnected":"connected")})},[]),(0,al.jsx)("div",{"data-test-name":"XeroAdminNew",className:"expandable",children:"loading"===n?(0,al.jsx)($i.A,{}):"disconnected"===n?(0,al.jsx)(Wi,{reloadData:t}):(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(cl.A,{message:(0,al.jsx)(al.Fragment,{children:"Use the dropdowns below to map your commonsku items and taxes to Xero. Don't see the Xero account you're looking for? Try disconnecting and reconnecting the integration to pull an up-to-date list of accounts."}),link:"https://help.commonsku.com/knowledge/connect-to-xero"}),(0,al.jsx)(Zs.LightIndicator,{name:"Connected to Xero",on:!0}),(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{(0,g.oD)("POST","xero",{action:"disconnect"}).then(()=>{s("disconnected")})},children:"Disconnect from Xero"}),(0,al.jsx)(Yi,{}),(0,al.jsx)(Qi,{})]})})};function Xi(){const{reloadData:e}=(0,rl.A)();return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Vi,{reloadData:e})})}function Zi(e){var t;let{paywallCtaUrl:n}=e;const{data:{data:a},loading:s,saveExtra:l}=(0,rl.A)(),o=null==a||null===(t=a.companyData)||void 0===t?void 0:t.accounting_software,i=(e,t)=>{l({[e]:t})};return"idle"!==s?(0,al.jsx)(Zs.Loading,{"data-test-name":"AccountingIntegration"}):(0,al.jsxs)(r.A,{"data-test-name":"AccountingIntegration",children:[(0,al.jsxs)("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"QuickBooks",checked:"QBO"===o,onChange:e=>{i("accounting_software","QBO")}}),(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"Xero",checked:"XERO"===o,onChange:e=>{i("accounting_software","XERO")}}),(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"Custom Webhook",checked:"WEBHOOK"===o,onChange:e=>{i("accounting_software","WEBHOOK")}}),(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"XML Export",checked:"XML"===o,onChange:e=>{i("accounting_software","XML")}}),(0,al.jsx)(Zs.LabeledRadioInButton,{flexGrow:!0,label:"CSV Export",checked:!o,onChange:e=>{i("accounting_software","")}})]}),(0,al.jsx)("div",{style:{padding:"1em 0"},children:"XERO"===o?(0,al.jsx)(Xi,{}):"QBO"===o?(0,al.jsx)(hi,{}):"WEBHOOK"===o?(0,al.jsx)(Hi,{save:l,data:null==a?void 0:a.companyData,paywallCtaUrl:n}):null})]})}var Ki=n(50225);function Ji(e){let{globalFilter:t,handleGlobalSearch:n}=e;return(0,al.jsx)(Zs.LabeledIconInput,{"data-test-name":"GlobalFilter",Icon:(0,al.jsx)(Zs.SearchIcon,{}),label:"",placeholder:"Filter",value:t||"",onChange:e=>{n(e.target.value||"")},iconLabelStyles:{background:"white"},iconColor:Zs.colors.neutrals[50],containerStyle:{marginBottom:10,width:"100%"}})}const er=[{Header:"Name",accessor:"contact_full_name",Cell:e=>{let{value:t,row:n}=e;const a=(0,tl.get)(n.original,["user_image_paths","small"])||"/images/user-avatar3-120x120.png";return(0,al.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,al.jsx)(Zs.Avatar,{pic:a,shape:"circle",size:"medium",mr:"16"})," ",t]})}},{Header:"Email",accessor:"contact_email"},{Header:"Login ID",accessor:"sage_username",Cell:e=>{let{value:t,row:{index:n,original:s},column:{id:l},updateUsersData:o,duplicatedUsernames:i}=e;const[r,c]=(0,a.useState)(t),d=(0,tl.includes)(i,r);return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Input,{"data-id":`username_${n}`,error:d,style:{marginBottom:0},value:r,onChange:e=>{c((0,tl.toLower)(e.target.value))},onBlur:()=>{o(n,l,r)}}),d&&(0,al.jsx)("div",{style:{color:Zs.colors.errors[60],lineHeight:"24px",fontSize:14},children:"Canât have duplicate user names"})]})}},{Header:"Authentication Key",accessor:"sage_auth_key",Cell:e=>{let{value:t,row:{index:n},column:{id:s},updateUsersData:l,data:o}=e;const[i,r]=(0,a.useState)(t||"");return(0,al.jsx)(Zs.Input,{type:"password","data-id":`auth_key_${n}`,style:{marginBottom:0},placeholder:(0,tl.get)(o,[n,"has_sage_auth_key"])?"********":"",value:i,onChange:e=>{r((0,tl.trim)(e.target.value))},onBlur:()=>{l(n,s,(0,tl.trim)(i))}})},disableSortBy:!0}],tr=function(e){let{users:t,onChange:n}=e;const[s,l]=(0,a.useState)({}),o=(0,a.useMemo)(()=>(0,tl.map)(t,(e,t)=>{var n;const a=null!==(n=s[t])&&void 0!==n?n:null;return(0,tl.isMatch)(e,a)?e:{...e,...a}}),[t,s]),i=(0,tl.keys)((0,tl.pickBy)((0,tl.groupBy)(o,"sage_username"),(e,t)=>e.length>1&&!(0,tl.isEmpty)(t))),r=i.length>0;(0,a.useEffect)(()=>{const e=(0,tl.differenceWith)(o,t,tl.isEqual);!(0,tl.isEmpty)(e)&&n&&n({updatedUsers:e,hasConflict:r})},[r,n,o,t]);const{getTableProps:c,getTableBodyProps:d,headerGroups:u,rows:m,prepareRow:p,state:h,setGlobalFilter:g}=(0,Ki.useTable)({columns:er,data:o,duplicatedUsernames:i,updateUsersData:(0,a.useCallback)((e,t,n)=>{l(a=>({...a,[e]:{...a[e],[t]:n}}))},[]),autoResetGlobalFilter:!1},Ki.useGlobalFilter,Ki.useSortBy);return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Row,{style:{width:"100%",position:"sticky",top:"0px",paddingTop:"37px",background:Zs.colors.neutrals.white,zIndex:100},children:(0,al.jsx)(Ji,{globalFilter:h.globalFilter,handleGlobalSearch:g})}),(0,al.jsx)(Zs.Row,{style:{position:"relative",flexGrow:2,display:"initial"},children:(0,al.jsxs)(Zs.Table,{className:"table",...c(),style:{border:"none",borderCollapse:"separate"},children:[(0,al.jsx)(Zs.THead,{style:{position:"sticky",top:"88px"},children:u.map(e=>(0,al.jsx)(Zs.TR,{...e.getHeaderGroupProps(),style:{paddingLeft:16},children:e.headers.map(e=>(0,al.jsxs)(Zs.TH,{...e.getHeaderProps(e.getSortByToggleProps()),style:{background:Zs.colors.neutrals[20]},children:[e.render("Header"),e.canSort?e.isSorted?e.isSortedDesc?(0,al.jsx)(Zs.FilledChevronIcon,{direction:"down",style:{width:"auto",verticalAlign:"middle"}}):(0,al.jsx)(Zs.FilledChevronIcon,{direction:"up",style:{width:"auto",verticalAlign:"middle"}}):(0,al.jsx)(Zs.FilledChevronIcon,{direction:"updown",style:{width:"auto",verticalAlign:"middle"}}):""]}))}))}),(0,al.jsx)(Zs.TBody,{...d(),children:m.map(e=>(p(e),(0,al.jsx)(Zs.TR,{"data-test-name":"SageUserTable",...e.getRowProps(),children:e.cells.map(e=>(0,al.jsx)(Zs.TD,{"data-test-name":"SageUserTable",...e.getCellProps(),style:{padding:"10px",fontSize:16,background:Zs.colors.neutrals.white,cursor:"auto"},children:e.render("Cell")}))})))})]})})]})},nr=Ui.default.div` 7 background: linear-gradient(${e=>
7e.directionUp?"180deg":"0deg"}, #DFEEF4 0%, rgba(166, 194, 198, 0.00) 100%); 8 ${e=>e.directionUp?"":"bottom: 0;"} 9 position: absolute; 10 height: 48px; 11 width: 100%; 12 display: flex; 13 justify-content: center; 14 align-items: center; 15 z-index: 1000; 16 cursor: pointer; 17`;function ar(e){let{data:t,save:n}=e;const s=(0,a.useMemo)(()=>({sage_account:"",sage_login:"",sage_password:"",sage_token:"",use_sage_connect:""}),[]),o=(0,l.wA)(),i=(0,Vl.Us)(),{hasUserFlags:r}=(0,g.el)(i),[c,d]=(0,a.useState)(!0),[u,m]=(0,a.useState)(!0),[p,h]=(0,a.useState)(s),[x,_]=(0,a.useState)(s),[y,f]=(0,a.useState)([]),[b,v]=(0,a.useState)(!1),[j,w]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=s;e={sage_account:t.sage_account,sage_login:t.sage_login,sage_password:t.sage_password,sage_token:t.sage_token,use_sage_connect:t.use_sage_connect},h(e)},[t.cardconnect_merchid,t.sage_account,t.sage_login,t.sage_password,t.sage_token,t.use_sage_connect,s]);const C=(0,a.useRef)(null),E=e=>{const t=C.current;if(t){const n=t.scrollTop;let a;"up"===e?a=Math.max(n-300,0):"down"===e&&(a=Math.min(n+300,t.scrollHeight-t.clientHeight)),t.scroll({top:a,behavior:"smooth"})}},k=(0,a.useCallback)(()=>{const e=C.current;if(e){const t=0===e.scrollTop,n=10,a=e.scrollHeight-e.scrollTop-e.clientHeight<n;t!==c&&d(t),a!==u&&m(a)}},[c,u]);(0,a.useEffect)(()=>{const e=new ResizeObserver(e=>{k()});return e.observe(C.current),()=>e.disconnect()},[k]);const S=(0,a.useCallback)(e=>{const t=e.target;h(e=>({...e,[t.name]:t.value}))},[]),I=(0,a.useCallback)(e=>{_(s);let t=0;for(const n of["sage_account","sage_login","sage_password"])""===e[n]&&(_(e=>({...e,[n]:"Required"})),t++);return t<=0},[s]),A=(0,a.useCallback)(e=>{let{updatedUsers:t,hasConflict:n}=e;f(t),v(n)},[]),T=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4;const s=""!==x[e];return(0,al.jsxs)(Zs.Col,{"data-test-name":"Sage.getTextInput",padded:!0,sm:n,xl:a,children:[(0,al.jsx)(Zs.LabeledInput,{label:t||e,name:e,value:p[e],onChange:S}),s?(0,al.jsx)("span",{style:{color:"red"},children:x[e]}):""]})};return(0,al.jsxs)("div",{"data-test-name":"Sage",style:{display:"flex",flexDirection:"column",height:"100%",justifyContent:"space-between"},children:[(0,al.jsxs)(Zs.Row,{style:{overflow:"auto",width:"100%"},onScroll:k,ref:C,children:[!c&&(0,al.jsx)("div",{style:{height:0,position:"sticky",top:0,width:"100%",zIndex:999},children:(0,al.jsx)(nr,{directionUp:!0,onClick:()=>E("up"),children:(0,al.jsx)(Zs.DoubleArrowIcon,{direction:"up"})})}),(0,al.jsxs)(Zs.Row,{style:{width:"100%"},children:[T("sage_account","SAGE Account",6,3),T("sage_login","License Login",6,3),T("sage_password","License Password",6,3),T("sage_token","Authentication Key",6,3)]}),(0,al.jsxs)(Zs.Row,{style:{alignItems:"center",width:"100%",marginTop:10},children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:4,xl:2,children:(0,al.jsx)(Zs.Button,{size:"small",onClick:()=>{""!==p.sage_token||1==t.use_sage_connect?Gs.x.confirm(1==t.use_sage_connect?"Are you sure you want to disable SAGE Connect?":"Ready To Opt In? By selecting yes, you are activating the SAGE Connect integration offering (200 queries per month, per SAGE Total Access user). Please contact your SAGE rep for pricing and membership details.")&&n({...p,use_sage_connect:1==t.use_sage_connect?0:1}):alert("Cannot Enable SAGE Connect, please enter SAGE Token.")},children:1==t.use_sage_connect?"Disable Sage Connect":"Enable Sage Connect"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:8,xl:3,children:(0,al.jsx)("a",{href:"https://help.commonsku.com/knowledge/sage",target:"_blank",style:{fontWeight:"600",fontSize:"14px"},children:"Setup and Integration Details"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:12,xl:7,children:(0,al.jsxs)("div",{children:[(0,al.jsx)("div",{children:"To use SAGE Connect, please ensure that you have filled out all the fields above."}),(0,al.jsxs)("div",{children:["Contact SAGE For pricing and membership details: ",(0,al.jsx)("strong",{children:"(800) 925-7243"})," or ",(0,al.jsx)("a",{href:"mailto:[email protected]",children:"[email protected]"})]})]})})]}),(0,tl.isEmpty)(t.users)?(0,al.jsx)(Zs.Row,{style:{width:"100%",marginTop:37},children:(0,al.jsx)(Zs.Col,{xs:!0,style:{alignSelf:"100%",textAlign:"center"},children:(0,al.jsx)(Zs.Loading,{})})}):(0,al.jsx)(tr,{users:t.users,onChange:A}),!u&&(0,al.jsx)("div",{style:{height:0,position:"sticky",bottom:0,width:"100%"},children:(0,al.jsx)(nr,{onClick:()=>E("down"),children:(0,al.jsx)(Zs.DoubleArrowIcon,{direction:"down"})})})]}),(0,al.jsx)(Zs.Row,{style:{placeSelf:"flex-end"},children:(0,al.jsxs)(Zs.Col,{padded:!0,sm:12,style:{display:"flex",gap:16,alignItems:"center"},children:[b&&(0,al.jsx)("div",{style:{color:Zs.colors.errors[60],fontSize:14},children:"Please ensure that all user names are unique before saving"}),(0,al.jsx)(Zs.Button,{size:"small",onClick:async()=>
17{if(I(p)){if(w(!0),(0,tl.isMatch)(t,p)||await n(p,!1),!(0,tl.isEmpty)(y)){const{json:e}=await(0,g.oD)("PUT","user",{actionName:"bulk_update",users:y,parent_id:i.company_id,parent_type:i.company_type});o((0,wt.XO)({...t,...p,users:(0,tl.map)(t.users,t=>(0,tl.find)(e.users,{user_id:t.user_id})||t)}))}w(!1)}},disabled:j||b,children:j?"Updating":"Save"})]})})]})}function sr(){const{data:{data:e},save:t}=(0,rl.A)();return(0,al.jsx)(ar,{"data-test-name":"AdminSage",data:e,save:t})}var lr=n(79177),or=n(38123),ir=n.n(or),rr=n(89703);function cr(){const[e,t]=(0,a.useState)(""),[n,s]=(0,a.useState)(""),[o,i]=(0,a.useState)(Zs.colors.primary1.main),[r,c]=(0,a.useState)(!1),d=(0,l.wA)(),u=(0,Vl.Us)(),m=(0,rr.B_)();return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Row,{children:(0,al.jsx)("div",{className:"column tip",children:"Promodata is the leading Australian promotional product database. Containing products from over 100 APPA Suppliers, Promodata is a subscription-based service only available to APPA distributors. To access Promodata within Commonsku you will need to enter your unique Promodata API key. For further information on obtaining an API key or Promodata licensing contact [email protected]"})}),"ACTIVE"===m?(0,al.jsxs)("div",{style:{paddingTop:"15px"},children:[(0,al.jsx)("p",{children:"Promodata token is configured."}),(0,al.jsx)(Zs.Button,{onClick:()=>{window.confirm("Are you sure you want to delete existing promodata token?")&&(d((0,kl.Nlk)(u.company_id,{promodata_access_token:""})),Xs.oR.info("Existing Promodata token is deleted. You can save new token."),s(""),t(""))},children:"Delete Token"})]}):(0,al.jsxs)(al.Fragment,{children:[(0,al.jsxs)(Zs.Row,{style:{paddingTop:"20px"},children:[(0,al.jsx)(Zs.Col,{md:4,children:(0,al.jsx)(Zs.Label,{style:{fontWeight:"bold"},children:"Promodata Token"})}),(0,al.jsx)(Zs.Col,{md:8,children:(0,al.jsx)(Zs.Input,{value:e,onChange:e=>t(e.target.value)})})]}),(0,al.jsx)(Zs.Row,{children:r?(0,al.jsx)(Zs.Col,{style:{marginTop:"15px"},children:(0,al.jsx)(Zs.Spinner,{})}):e&&(0,al.jsx)(Zs.Button,{style:{float:"right"},onClick:()=>{c(!0),s("");const t=ir()();d((0,kl.Nlk)(u.company_id,{promodata_access_token:e})).then(e=>{let{payload:n}=e;const a=(0,tl.get)(n,"company_data.promodata_date_checked");(0,tl.isEmpty)(n.error)?ir()(a).isValid()&&t.isBefore(a)?(i(Zs.colors.primary1.main),s("Promodata token has been successfully added.")):(i(Zs.colors.errors.main),s("Token is invalid or expired. If you are unable to access Promodata after entering your unique API key, contact [email protected] for assistance.")):(i(Zs.colors.errors.main),s(" ".concat(n.error)))}).finally(()=>{c(!1)})},children:"Save Promodata Token"})}),n&&(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{md:12,style:{color:o,marginTop:"15px"},children:n})})]})]})}function dr(){return(0,al.jsx)(cr,{"data-test-name":"AdminPromodata"})}const ur=e=>{let{paywallCtaUrl:t}=e;return s().createElement("div",{style:{display:"flex",flexDirection:"row",flexWrap:"nowrap",justifyContent:"flex-start",height:"100%",overflowY:"hidden"}},s().createElement("div",{style:{flexGrow:1,marginLeft:16,height:"100%",overflowX:"hidden",overflowY:"auto"}},s().createElement("div",{style:{background:Zs.colors.teal[20],color:Zs.colors.neutrals[100],padding:32,gap:"2rem",display:"flex",alignItems:"center",marginBottom:"4rem"}},s().createElement("div",{style:{flex:"1 0 0"}},s().createElement("h4",null,"Upgrade to Advanced to Unlock the Avalara Integration"),s().createElement("p",null,"Connecting commonsku with Avalara AvaTax provides an easy, fast, and accurate automated tax solution to save you time and money.")),s().createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"flex-start",gap:"1rem"}},s().createElement(Zs.Link,{target:"_blank",as:"a",href:t},s().createElement(Zs.IconButton,{size:"large",cta:!0},"Contact Us")))),s().createElement("div",{style:{display:"flex",alignSelf:"stretch",gap:"2rem",alignItems:"flex-start"}},s().createElement("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"1.6875rem",flex:"1 0 0",width:"37.5rem",color:Zs.colors.neutrals[100]}},s().createElement("div",{style:{display:"flex",height:"4.5rem",justifyContent:"center",alignItems:"center"}},s().createElement("img",{src:"../../../images/paywalls/cskuX.png",style:{width:"15rem"}}),s().createElement("img",{src:"../../../images/paywalls/avalara.png",style:{width:"15rem"}})),s().createElement("p",{style:{width:"37.5rem"}},"Fully automate and customize your tax calculations based on your jurisdictions with Avalara's AvaTax solution. Say goodbye to manual calculations and tracking, and hello to effortless tax compliance.")))))},mr=e=>{let{paywallCtaUrl:t}=e;return s().createElement("div",{style:{display:"flex",flexDirection:"row",flexWrap:"nowrap",justifyContent:"flex-start",height:"100%",overflowY:"hidden"}},s().createElement("div",{style:{flexGrow:1,marginLeft:16,height:"100%",overflowX:"hidden",overflowY:"auto"}},s().createElement("div",{style:{background:Zs.colors.teal[20],color:Zs.colors.neutrals[100],padding:32,gap:"2rem",display:"flex",alignItems:"center",marginBottom:"4rem"}},s().createElement("div",{style:{flex:"1 0 0"}},s().createElement("h4",null,"Upgrade to Advanced to Unlock the Marketing Automation Integrations"),s().createElement("p",null,"Connect your marketing automation platform with commonsku to seamlessly communicate with your clients and free up valuable time for your team.")),s().createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"flex-start",ga
17p:"1rem"}},s().createElement(Zs.Link,{target:"_blank",as:"a",href:t},s().createElement(Zs.IconButton,{size:"large",cta:!0},"Contact Us")))),s().createElement("div",{style:{display:"flex",alignSelf:"stretch",gap:"2rem",alignItems:"flex-start"}},s().createElement("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"1.6875rem",flex:"1 0 0",color:Zs.colors.neutrals[100]}},s().createElement("img",{src:"../../images/paywalls/mc.png",style:{width:"15rem"}}),s().createElement("p",null,"Sync your contacts from commonsku to Mailchimp, and begin elevating your marketing strategy with email campaigns and landing pages.")),s().createElement("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"1.6875rem",flex:"1 0 0",color:Zs.colors.neutrals[100]}},s().createElement("img",{src:"../../images/paywalls/hubspot.png",style:{width:"15rem"}}),s().createElement("p",null,"Sync your contacts from commonsku to Hubspot to nurture your clients and prospects with email campaigns, landing pages, and social media management.")),s().createElement("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"1.6875rem",flex:"1 0 0",color:Zs.colors.neutrals[100]}},s().createElement("img",{src:"../../images/paywalls/zapier.png",style:{width:"15rem"}}),s().createElement("p",null,"Unlock a variety of time-saving automations for your team, and connect the applications in your tech stack to create powerful processes with Zapier.")))))};var pr=n(29225);const hr=(0,Vs.A)(e=>{var t,n;let{paywallCtaUrl:s}=e;const l=(0,Vl.Us)(),o=(0,Vl.u7)(["CONNECT-ZAPIER"])&&!(0,tl.isEmpty)(null===pr.A||void 0===pr.A||null===(t=pr.A.zapier)||void 0===t?void 0:t.embed_client_id),[i,r]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{const e=document.createElement("script");e.type="module",e.src="https://cdn.zapier.com/packages/partner-sdk/v0/zapier-elements/zapier-elements.esm.js",e.onload=()=>r(!0),document.body.appendChild(e);const t=document.createElement("link");t.rel="stylesheet",t.href="https://cdn.zapier.com/packages/partner-sdk/v0/zapier-elements/zapier-elements.css",document.head.appendChild(t)},[]),i?(0,al.jsx)(al.Fragment,{children:o?(0,al.jsx)("zapier-workflow",{"sign-up-email":l.login_email,"sign-up-first-name":l.user_first_name,"sign-up-last-name":l.user_last_name,"client-id":null===pr.A||void 0===pr.A||null===(n=pr.A.zapier)||void 0===n?void 0:n.embed_client_id,theme:"light","intro-copy-display":"show","manage-zaps-display":"hide","guess-zap-display":"hide","app-search-bar-display":"show"}):(0,al.jsx)(Zs.Row,{children:(0,al.jsxs)("div",{style:{display:"flex",background:Zs.colors.primary1[20],marginLeft:"20px",marginRight:"20px",padding:"20px"},children:[(0,al.jsxs)("div",{children:[(0,al.jsx)("h4",{children:"Upgrade to Advanced to integrate with Zapier"}),(0,al.jsx)("p",{children:"Advanced Administrators can configure and connect their webhooks and APIs through the commonsku admin settings."}),(0,al.jsx)("p",{children:"This allows for integration into 3rd party applications that are not existing integrations with commonsku."})]}),(0,al.jsxs)("div",{style:{marginLeft:"25px"},children:[(0,al.jsx)(Zs.Button,{variant:"secondary",size:"large",style:{width:"186px"},onClick:()=>{window.location.href=s},children:"Learn More"}),(0,al.jsx)(Zs.IconButton,{variant:"error",size:"large",Icon:Zs.MailIcon,style:{marginTop:"10px",width:"186px"},onClick:()=>{window.location.href="mailto:[email protected]"},children:"Contact Us"})]})]})})}):(0,al.jsx)(Zs.Loading,{})},{companyGeneralDataById:wt.Ay}),gr=()=>s().createElement(Zs.Link,{as:"a",href:"https://www.shipstation.com/docs/api/",target:"_blank"},"ShipStation account."),xr={200:{message:s().createElement(s().Fragment,null,"Connection Successful"),type:"success"},400:{message:s().createElement(s().Fragment,null,"Connection failed. Find your API Key and Secret pair in your ",s().createElement(gr,null)),type:"error"},403:{message:s().createElement(s().Fragment,null,"Connection failed. You are not authorized to complete this request."),type:"error"},500:{message:s().createElement(s().Fragment,null,"Connection failed. An error occurred while connecting to ShipStation. Please contact support if the problem persists."),type:"error"}},_r=Ui.default.div` 18 display: flex; 19 flex-direction: row; 20 width: 100%; 21 gap: 24px; 22 margin-top: 24px !important; 23 margin-bottom: 24px !important; 24 25 > * { 26 flex: 1; 27 } 28`,yr=Ui.default.div` 29 display: flex; 30 flex-direction: row; 31 gap: 16px; 32`,fr=e=>{let{isLoading:t,alertType:n,alertMessage:a,fields:l,submitLabel:o,isSubmitting:i,isSubmitDisabled:r,onSubmit:c,submittingSpinnerStyle:d}=e;return t?s().createElement(Zs.SkubotSpinner,{style:{margin:"auto"}}):s().createElement(s().Fragment,null,s().createElement(Zs.AlertNotification,{alertType:n},a),s().createElement(_r,null,l.map((e,t)=>s().createElement(Zs.LabeledInput,{key:`${e.label}-${t}`,label:e.label,type:e.type,placeholder:e.placeholder,style:{marginBottom:0},value:e.value,disabled:e.disabled,onChange:t=>e.onChange(t.target.value)}))),s().createElement(yr,null,s().createElement(Zs.Button,{variant:"primary",size:"medium",disabled:r,onClick:c},i?s().createElement(Zs.SkubotSpinner,{size:"button",skubot:!1,style:d}):o)))};
32var br=function(e,t,n,a){return new(n||(n=Promise))(function(s,l){function o(e){try{r(a.next(e))}catch(e){l(e)}}function i(e){try{r(a.throw(e))}catch(e){l(e)}}function r(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,i)}r((a=a.apply(e,t||[])).next())})};const vr=()=>{const[e,t]=(0,a.useState)(!0),[n,l]=(0,a.useState)(!1),[o,i]=(0,a.useState)(null),[r,c]=(0,a.useState)(""),[d,u]=(0,a.useState)(""),m=(0,a.useRef)(""),p=(0,a.useRef)("");(0,a.useEffect)(()=>{br(void 0,void 0,void 0,function*(){var e,n,a,s;try{const s=yield(0,g.oD)("GET","shipstation-settings",{});i(null===(e=null==s?void 0:s.response)||void 0===e?void 0:e.status);const l=(null===(n=null==s?void 0:s.json)||void 0===n?void 0:n.key)||"",o=(null===(a=null==s?void 0:s.json)||void 0===a?void 0:a.secret)||"";c(l),u(o),m.current=l,p.current=o,t(!1)}catch(e){console.error("Failed to test connection:",e),i(null===(s=null==e?void 0:e.response)||void 0===s?void 0:s.status),t(!1)}})},[]);const h=r!==m.current||d!==p.current,x=!r||!d||n||!h,{alertMessage:_,alertType:y}=function(e){let{statusCode:t}=e;return(0,a.useMemo)(()=>{if(null!==t&&t in xr){const e=xr[t];return{alertMessage:e.message,alertType:e.type}}return{alertMessage:s().createElement(s().Fragment,null,"Find your API Key and Secret pair in your ",s().createElement(gr,null)),alertType:"neutral"}},[t])}({statusCode:o});return s().createElement(fr,{isLoading:e,alertType:y,alertMessage:_,fields:[{label:"API Key",value:r,onChange:c},{label:"API Secret",value:d,onChange:u}],submitLabel:"Test Connection",isSubmitting:n,isSubmitDisabled:x,onSubmit:()=>br(void 0,void 0,void 0,function*(){var e,t,n,a;l(!0);try{const a=yield(0,g.oD)("PUT","shipstation-settings",{key:r.trim(),secret:d.trim()});i(null===(e=null==a?void 0:a.response)||void 0===e?void 0:e.status);const s=(null===(t=null==a?void 0:a.json)||void 0===t?void 0:t.key)||"",o=(null===(n=null==a?void 0:a.json)||void 0===n?void 0:n.secret)||"";c(s),u(o),m.current=s,p.current=o,l(!1)}catch(e){console.error("Failed to connect shipstation:",e),i(null===(a=null==e?void 0:e.response)||void 0===a?void 0:a.status),l(!1)}}),submittingSpinnerStyle:{margin:"auto 42px"}})};var jr=n(90485);const wr=()=>{var e;const{credentialStatus:t,isLoading:n,reload:l}=(0,jr.ID)(!0),[o,i]=(0,a.useState)(null),[r,c]=(0,a.useState)(""),[d,u]=(0,a.useState)(!1),[m,p]=(0,a.useState)(null),h=(0,a.useRef)(null),x=null!=o?o:n?"":null!==(e=t.account_id)&&void 0!==e?e:"",_=null!=m?m:t.configured?"success":"info",y=x.trim(),f=r.trim(),b=Boolean(y)&&Boolean(f),v=h.current===y,j=d||!b||"success"===_&&v,w="success"===_?{alertType:"success",message:"Connection successful!"}:"error"===_?{alertType:"error",message:s().createElement(s().Fragment,null,"We couldn't verify your credentials. Check your ",s().createElement(Zs.Link,{as:"a",href:"https://www.fulfillengine.com/",target:"_blank",rel:"noreferrer noopener"},"Fulfill Engine")," Account ID and API Key and try again.")}:{alertType:"neutral",message:s().createElement(s().Fragment,null,"Find your Account ID and API Key in your ",s().createElement(Zs.Link,{as:"a",href:"https://www.fulfillengine.com/",target:"_blank",rel:"noreferrer noopener"},"Fulfill Engine")," account.")};return s().createElement(fr,{isLoading:n,alertType:w.alertType,alertMessage:w.message,fields:[{label:"Account ID",value:x,disabled:d,onChange:e=>{i(e),p("info")}},{label:"API Key",type:"password",value:r,placeholder:t.configured?"****************":"",disabled:d,onChange:e=>{c(e),p("info")}}],submitLabel:"Test Connection",isSubmitting:d,isSubmitDisabled:j,onSubmit:()=>{return e=void 0,n=void 0,s=function*(){const e=x.trim(),n=r.trim();u(!0),p("info");try{const a={account_id:e,api_key:n};t.division_id&&(a.division_id=t.division_id),yield(0,g.oD)("PUT",(0,jr.ot)(),a),yield l(),h.current=e,c(""),p("success")}catch(e){p("error")}finally{u(!1)}},new((a=void 0)||(a=Promise))(function(t,l){function o(e){try{r(s.next(e))}catch(e){l(e)}}function i(e){try{r(s.throw(e))}catch(e){l(e)}}function r(e){var n;e.done?t(e.value):(n=e.value,n instanceof a?n:new a(function(e){e(n)})).then(o,i)}r((s=s.apply(e,n||[])).next())});var e,n,a,s},submittingSpinnerStyle:{margin:"auto 28px"}})},Cr=e=>{var t;let{paywallCtaUrl:n,openCommonskuPayments:a=!1}=e;const s=(0,Vl.u7)(["HAS-MARKETING-INTEGRATIONS"]),l=(0,Vl.u7)(["HAS-SHIPSTATION"]),o=(0,Vl.Ju)("POD_ENABLED"),i={marketing:{component:s?ei:mr,title:"Marketing",show:!0},creditcard:{component:mi.Ay,title:"Payments",show:!0},accounting:{component:Zi,title:"Accounting",show:!0},sage:{component:sr,title:"SAGE",show:!0},avalara:{component:(0,Vl.u7)(["HAS-AVALARA"])?lr.A:ur,title:"Avalara",show:!0},promodata:{component:dr,title:"Promo Data",show:!0},shipstation:{component:vr,title:"ShipStation",show:l},"fulfill-engine":{component:wr,title:"Fulfill Engine",show:o}};return(0,tl.isEmpty)(null===pr.A||void 0===pr.A||null===(t=pr.A.zapier)||void 0===t?void 0:t.embed_client_id)||(i.zapier={component:hr,title:"Zapier",show:!0}),(0,al.jsx)(no,{"data-test-name":"AdminTabbedIntegration",moduleMap:i,defaultModule:s?"marketing":"creditcard",initialModule:a?"creditcard":void 0,openCommonskuPayments:a,paywallCtaUrl:n})};function Er(e){const t=(0,l.wA)(),n=(0,l.d4)(e=>e.emailTemplates),s=I.selectAll(n),o=n.loading;return(0,a.useEffect)(()=>{t(C("ADMIN"))},[t]),[s,o,(0,a.useCallback)(n=>{(async()=>{let a=null;a=n.email_template_id?await t(k({id:n.email_template_id,...n})):await t(E(n)),Xs.oR.success("Saved successfully"),e(a)})()},[t,e]),(0,a.useCallback)(n=>{(async()=>{await t(S(n)),Xs.oR.success("Deleted successfully"),e("first")})()},[t,e])]}var kr=n(12743);function Sr(e){let{item:t,saveItem:n,deleteItem:s}=e;const l=(0,a.useMemo)(()=>({email_template_text:"",email_template_title:""}),[]),[o,i]=(0,a.useState)(l),[r,c]=(0,a.useState)(l);(0,a.useEffect)(()=>{i(t||l)},[l,t]);const[d,u,m]=(0,ll.A)({deleteItemCallback:s,message:"You are about to delete the template "+o.email_template_title+"."}),p=(0,a.useCallback)(e=>{const t=e.target;i(e=>({...e,[t.name]:t.value}))},[]),h=(0,a.useCallback)(e=>{c(l);let t=0;for(const n of["email_template_title","email_template_text"])""===e[n].trim()&&(c(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[l]),g=(0,a.useCallback)(()=>{h(o)&&(t||i(l),n({...t,...o}))},[l,o,t,n,h]);let x=(0,al.jsxs)(Zs.Row,{children:[function(e,n){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4;const s=""!==r[e],l=Zs.LabeledInput;return(0,al.jsxs)(Zs.Col,{"data-test-name":"EmailTemplate.getTextInput",padded:!0,sm:a,children:[(0,al.jsx)(l,{label:n,name:e,value:o[e],onChange:p,onBlur:e=>{t&&g(o)}}),s?(0,al.jsx)("span",{style:{color:"red"},children:r[e]}):""]})}("email_template_title","Template Name",11),t?null:(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{alignSelf:"center"},children:(0,al.jsx)(Zs.Button,{size:"small",onClick:e=>g(o),children:t?"Save":"Add"})}),t?(0,al.jsx)(Zs.Col,{padded:!0,sm:1,style:{alignSelf:"center"}
32,children:(0,al.jsx)(Zs.IconButton,{preset:"delete",onClick:()=>{u(!0),m(t)}})}):null,(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(0,al.jsx)(kr.A,{value:o.email_template_text,onChange:e=>{p({target:{name:"email_template_text",value:e}})},onBlur:()=>{t&&g(o)}})}),""!==r.email_template_text?(0,al.jsx)("span",{style:{color:"red"},children:r.email_template_text}):"",d]});return x}const Ir=()=>{const[e,t]=(0,a.useState)("first"),[n,,s,l]=Er(t);(0,a.useEffect)(()=>{"first"===e&&(null==n?void 0:n.length)>0&&t(n[0])},[n,e]);let o=(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(Sr,{item:e,saveItem:s,deleteItem:l})});const i=n.map(n=>(0,al.jsx)("li",{"data-test-name":"AdminEmailTemplate",children:(0,al.jsx)("a",{href:"/",className:"module-tab"+(n.email_template_id===(null==e?void 0:e.email_template_id)?" active":""),onClick:e=>{e.preventDefault(),t(n)},children:n.email_template_title})},n.email_template_id));return(0,al.jsxs)("div",{"data-test-name":"AdminEmailTemplate",style:{display:"flex",flexDirection:"row",flexWrap:"nowrap",justifyContent:"flex-start",height:"100%",overflowY:"hidden"},children:[(0,al.jsxs)("div",{style:{display:"flex",flexDirection:"column",minWidth:"250px",width:"250px",paddingTop:"20px",backgroundColor:"#E1F7FA",padding:0,margin:0,overflowY:"hidden",paddingBottom:"40px"},children:[(0,al.jsx)("ul",{style:{listStyle:"none",margin:"0",overflowY:"auto",paddingBottom:"20px"},children:i}),(0,al.jsx)("div",{style:{position:"absolute",bottom:"0"},children:(0,al.jsxs)("a",{style:{display:"flex",alignItems:"center",width:"250px"},href:"/",className:"module-tab"+(null===e?" active":""),onClick:e=>{e.preventDefault(),t(null)},children:[(0,al.jsx)(Zs.AddIcon,{width:"1rem"})," ",(0,al.jsx)("span",{children:"Add Template"})]})},"new")]}),(0,al.jsx)("div",{style:{flexGrow:1,padding:"0 2rem",height:"100%",overflowX:"hidden",overflowY:"auto"},children:o})]})};var Ar=n(18981);const Tr=()=>(0,al.jsx)(Ar.U,{"data-test-name":"AdminCompanySalesTarget",role:"management"}),Dr=e=>{let{message:t}=e;const[n]=Sl(),a=t||"You don't have permission to edit Company Settings. Please contact one of your team's admins to make changes:",s=(n||[]).map(e=>{var t;return"Admin"!==e.role_name?null:(0,al.jsx)(Zs.Row,{"data-test-name":"ContactAdmin",children:(0,al.jsxs)(Zs.Col,{sm:12,padded:!0,children:[(0,al.jsx)(Il.Ay,{src:(null===(t=e.user_image_paths)||void 0===t?void 0:t.small)||null,name:e.contact_full_name,round:!0,size:"30"})," ",e.contact_full_name," (",e.contact_email,")"]})},e.user_id)});return(0,al.jsx)(Zs.Row,{"data-test-name":"ContactAdmin",children:(0,al.jsx)(Zs.Col,{sm:12,children:(0,al.jsxs)(Zs.Box,{style:{padding:"15px",margin:"15px"},children:[(0,al.jsx)("div",{children:a}),s]})})})};function Rr(e){let{title:t}=e;const[n,,,]=Er();return(0,al.jsxs)("div",{"data-test-name":"AdminEmailTemplateSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.MailIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:t}),(0,al.jsx)(Zs.LightIndicator,{name:`${null==n?void 0:n.length} templates`,on:(null==n?void 0:n.length)>0})]})]})}var Lr=n(10219);function Pr(e){let{title:t}=e;const n=(0,l.wA)(),s=(0,l.d4)(e=>{var t;return null===(t=e.dropdowns)||void 0===t?void 0:t.decorators});return(0,a.useEffect)(()=>{n((0,Lr.IO)())},[n]),(0,al.jsxs)("div",{"data-test-name":"AdminDecoratorMatrixSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.TableIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:t}),(0,al.jsx)(Zs.LightIndicator,{name:`${null==s?void 0:s.length} decorators configured`,on:(null==s?void 0:s.length)>0})]})]})}function Br(e){let{title:t}=e;const{data:{data:n}}=(0,rl.A)(),a=(null==n?void 0:n.job_templates)||[];return(0,al.jsxs)("div",{"data-test-name":"AdminProjectTemplateSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.TemplateIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:t}),(0,al.jsx)(Zs.LightIndicator,{name:`${null==a?void 0:a.length} templates configured`,on:(null==a?void 0:a.length)>0})]})]})}var Nr=n(93664);function Or(e){let{title:t,paywalled:n}=e;const s=(0,Vl.Us)(),{hasCapabilities:o}=(0,g.el)(s),i=o(["MODIFY-SETTINGS"]),r=(new Date).getFullYear(),c=(0,l.wA)(),[d,u]=(0,a.useState)(0),[m,p]=(0,a.useState)(0);(0,a.useEffect)(()=>{(async()=>{var e,t;const[n,a]=await Promise.all([(0,g.oD)("GET","page/get-targets-management",{start_stamp:(0,g.yw)(new Date(r,0,1)),end_stamp:(0,g.yw)(new Date(r+1,0,1))},null,null,null,!1),(0,g.oD)("GET","page/get-targets-management",{start_stamp:(0,g.yw)(new Date(r-1,0,1)),end_stamp:(0,g.yw)(new Date(r,0,1))},null,null,null,!1)]);u(null===(e=n.json.payload)||void 0===e?void 0:e.reduce((e,t)=>
32(parseInt(String(null==t?void 0:t.invoice_target).replaceAll(",",""))||0)+e,0)),p(null===(t=a.json.payload)||void 0===t?void 0:t.reduce((e,t)=>(parseInt(String(null==t?void 0:t.invoice_target).replaceAll(",",""))||0)+e,0))})()},[r,c]);const h=m>0?i?`total: $${(0,Nr.bZ)(m)}`:"set up":"not set up",x=d>0?i?`total: $${(0,Nr.bZ)(d)}`:"set up":"not set up";return(0,al.jsxs)("div",{"data-test-name":"AdminCompanySalesTargetSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.TargetIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:t}),n?(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)("p",{style:{marginBottom:0},children:"Upgrade to the Advanced tier to gain access to the Targets feature."}),(0,al.jsx)(Zs.Link,{as:"a",href:"#",children:"Learn More"})]}):(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.LightIndicator,{name:`${r-1} targets ${h}`,on:m>0}),(0,al.jsx)(Zs.LightIndicator,{name:`${r} targets ${x}`,on:d>0})]})]})]})}function Ur(e){var t,n,a,s,l,o,i;let{title:r}=e;const{data:{data:c}}=(0,rl.A)(),d=(0,rr.B_)(),u=(0,Vl.u7)(["HAS-SHIPSTATION"]),m=(0,Vl.Ju)("POD_ENABLED"),{credentialStatus:p}=(0,jr.ID)(m);let h=null==c||null===(t=c.companyData)||void 0===t?void 0:t.accounting_software;const g=null==c||null===(n=c.companyData)||void 0===n?void 0:n.marketing_software,x=null==c||null===(a=c.companyData)||void 0===a?void 0:a.credit_card_software,_=(null==c?void 0:c.sage_account)&&"1"==(null==c?void 0:c.use_sage_connect),y=null==c||null===(s=c.companyData)||void 0===s?void 0:s.avalara_enable,f=null!==(l=null==c?void 0:c.users)&&void 0!==l?l:[],b=1===(null==c||null===(o=c.companyData)||void 0===o?void 0:o.shipstation_api_v1_enabled);h||(h="CSV");const v=null!=c&&null!==(i=c.companyData)&&void 0!==i&&i.commonsku_payments?"COMMONSKU_PAYMENTS":x||null,j=(0,tl.filter)(f,e=>!(0,tl.isEmpty)((0,tl.trim)(e.sage_username))).length;return(0,al.jsxs)("div",{"data-test-name":"AdminTabbedIntegrationSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.IntegrationsIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:r}),(0,Vl.u7)(["HAS-MARKETING-INTEGRATIONS"])&&(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Marketing Integration",g?(0,al.jsxs)(al.Fragment,{children:[": ",{MAILCHIMP:"Mailchimp",WISHPOND:"Wishpond",HUBSPOT:"HubSpot"}[g]]}):" not configured"]}),on:!!g}),(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Credit Card Integration",v?(0,al.jsxs)(al.Fragment,{children:[": ",{CARDCONNECT:"Fiserv",STRIPE:"Stripe",COMMONSKU_PAYMENTS:"commonsku payments"}[v]]}):" not configured"]}),on:!!v}),(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Accounting Integration",h?(0,al.jsxs)(al.Fragment,{children:[": ",{QBO:"Quickbooks Online",XERO:"Xero",WEBHOOK:"Custom Webhook",XML:"XML Export",CSV:"CSV Export"}[h]]}):" not configured"]}),on:!!h}),(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["SAGE ",_?" configured":" not configured"]}),on:!!_}),(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Credentials entered for ",j,"/",f.length," users"]}),on:j==f.length}),(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Promodata Token ","ACTIVE"===d?" configured":"EXPIRED"===d?" expired":" not configured"]}),on:"ACTIVE"===d}),(0,Vl.u7)(["HAS-AVALARA"])&&(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Avalara ",y?" configured":" not configured"]}),on:!!y}),u&&(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["ShipStation ",b?" configured":" not configured"]}),on:!!b}),m&&(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Print on Demand ",p.configured?" configured":" not configured"]}),on:!!p.configured})]})]})}const Fr=(0,Vs.A)(function(e){var t;let{title:n}=e;const{webhooksData:a}=Bi(),s=(null===(t=(0,tl.filter)(a,e=>e.active))||void 0===t?void 0:t.length)>0;return(0,al.jsxs)("div",{"data-test-name":"AdminTabbedWebhooksAPISummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.IntegrationsIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:n}),(0,al.jsx)(Zs.LightIndicator,{name:(0,al.jsxs)(al.Fragment,{children:["Webhooks ",s?" configured":" not configured"]}),on:s}),(0,al.jsx)(Zs.LightIndicator,{name:"API tokens not configured",on:!1}
32)]})]})},{tenant_webhooks:Pi}),Mr=(e,t,n,a)=>{const s=null!=a&&0===e?a:1===e?t:n;return"string"==typeof s?s:s(e)},qr=(e,t,n)=>{const a=e.values[n],s=t.values[n];return a.localeCompare(s,void 0,{sensitivity:"base"})},zr=e=>{let{tags:t,height:n,error:l,loading:o,selectedTags:i,onSelectTags:r}=e;const c=(0,a.useCallback)(e=>{null!=r&&r(e)},[r]),d=(0,a.useMemo)(()=>[{Header:s().createElement(Zs.Label,null,"Tag Name"),accessor:"label",sortType:qr},{Header:s().createElement(Zs.Label,null,"Projects"),accessor:"projects"},{Header:s().createElement(Zs.Label,null,"Clients"),accessor:"clients"},{Header:s().createElement(Zs.Label,null,"Contacts"),accessor:"contacts"},{Header:s().createElement(Zs.Label,null,"Suppliers"),accessor:"suppliers"},{Header:s().createElement(Zs.Label,null,"Products"),accessor:"products"}],[]);return l?s().createElement(Gr,{Icon:s().createElement(Zs.AlertIcon,{size:"huge"})},s().createElement(Zs.Text,{style:{color:Zs.colors.error}},"Unable to retrieve tags")):o?s().createElement(Gr,{Icon:s().createElement(Zs.Loading,null)},s().createElement(Zs.Text,{style:{color:Zs.colors.teal[65]}},"Retrieving tags...")):s().createElement(Zs.VirtualTableStyles,{className:"tag-table-wrapper",scrollIndicators:!0},s().createElement(Zs.SelectionTable,{className:"tag-table",height:n,data:t,columns:d,selectedRows:i,onSelectionChange:c}))},Gr=e=>{let{Icon:t,children:n}=e;return s().createElement("div",{className:"tag-table-status"},s().createElement(Zs.Row,null,s().createElement(Zs.Col,null,t)),s().createElement(Zs.Row,null,s().createElement(Zs.Col,null,n)))};const Hr=e=>{let{onAddTag:t,isDuplicateTag:n,disabled:l,highlight:o}=e;const[i,r]=(0,a.useState)(),[c,d]=(0,a.useState)(""),u=(0,Vl.Us)(),{hasCapabilities:m}=(0,g.el)(u),p=m(["CREATE-TAGS"]),h=(0,a.useCallback)(()=>{return e=void 0,a=void 0,l=function*(){try{if(null!=i)return;if(n(c))return void r("This tag already exists!");const{json:e}=yield(0,g.oD)("POST","tag",{action:"create",label:c}),a={id:e.tag_id,label:e.label,projects:0,products:0,clients:0,contacts:0,suppliers:0};t(a),d("")}catch(e){r("Unable to create tag")}},new((s=void 0)||(s=Promise))(function(t,n){function o(e){try{r(l.next(e))}catch(e){n(e)}}function i(e){try{r(l.throw(e))}catch(e){n(e)}}function r(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s(function(e){e(n)})).then(o,i)}r((l=l.apply(e,a||[])).next())});var e,a,s,l},[c]),x=(0,a.useCallback)(e=>{const t=e.target.value;d(t),t.includes(",")?r("Commas are not permitted in tags!"):r(void 0)},[]);return s().createElement("div",{className:"add-tag "+(o?"with-highlight":"no-highlight")},s().createElement("div",{className:"add-tag-controls"},null!=o&&o&&s().createElement("div",{className:"button-highlight"}),s().createElement(Zs.Input,{className:"add-tag-input",name:"add-tag",placeholder:"Tag name to add",value:c,onChange:x,disabled:l||!p}),s().createElement(Zs.Button,{size:"medium",onClick:h,disabled:l||!p||null!=i||0===c.length},"Add Tag")),null!=i&&s().createElement("span",{className:"add-tag-error"},i))},$r=e=>{const{tag:t,selectable:n,selected:a,onSelect:l}=e;return null!=n&&n?s().createElement("div",{className:"selectable-tag-label"},s().createElement(Zs.LabeledRadioInButton,{label:t.label,checked:a,onChange:null!=l?()=>l(t):void 0})):s().createElement("div",{className:"tag-label"},t.label)};const Wr=e=>`${e} tags`,Yr=()=>{const[e,t]=(0,a.useState)(),[n,l]=(0,a.useState)(!0),[o,i]=(0,a.useState)(!1);(0,a.useEffect)(()=>{var e,n,a,s;e=void 0,n=void 0,s=function*(){try{const{json:e}=yield(0,g.oD)("GET","tagged-resource/summary",{});t(e.count)}catch(e){i(!0)}finally{l(!1)}},new((a=void 0)||(a=Promise))(function(t,l){function o(e){try{r(s.next(e))}catch(e){l(e)}}function i(e){try{r(s.throw(e))}catch(e){l(e)}}function r(e){var n;e.done?t(e.value):(n=e.value,n instanceof a?n:new a(function(e){e(n)})).then(o,i)}r((s=s.apply(e,n||[])).next())})},[]);const r=!o&&!n&&null!=e&&e>0;return s().createElement("div",{style:{display:"flex"}},s().createElement("div",null,s().createElement(Zs.TagIcon,{size:"large",mr:16,color:"#DAE9EE"})),s().createElement("div",null,s().createElement("h5",null,"Tags"),s().createElement(Zs.LightIndicator,{name:n?"Loading tags...":o||null==e?"Unable to fetch tag count":Mr(e,"1 tag",Wr,"No tags added"),on:r})))};const Qr={table:{Title:()=>s().createElement(Zs.Row,{className:"tag-table-title"},s().createElement("span",{className:"title-text"},"Manage Tags"),s().createElement(Zs.Link,{className:"help-link",as:"a",href:"https://help.commonsku.com/knowledge/tags",target:"_blank",rel:"noreferrer"},s().createElement(Zs.InfoIcon,{size:"medium"}),"learn more")),View:e=>{let{tags:t,selectedTags:n,isFetchingTags:l,fetchingTagsError:o,onNewTags:i,onSelect:r,onUpdateView:c}=e;const[d,u]=(0,a.useState)(0),[m,p]=(0,a.useState)(""),[h,x]=(0,a.useState)([]),_=(0,a.useRef)(),y=(0,Zs.useWindowSize)(),f=(0,Vl.Us)(),{hasCapabilities:b}=(0,g.el)(f),v=b(["MODIFY-TAGS","DELETE-TAGS"]),j=b(["DELETE-TAGS"]),w=l||o;(0,a.useLayoutEffect)(()=>{null!=_.current&&u(_.current.offsetHeight)},[y]);const C=(0,a.useCallback)(e=>e.label.toLowerCase().includes(m.trim()),[m]);(0,a.useEffect)(()=>{x(t.filter(C))},[C,t]);const E=(0,a.useCallback)(e=>{const n=e.target.value.toLowerCase();p(n),x(t.filter(C))},[C]);return s().createElement("div",{className:"admin-tags"},s().createElement(Zs.Row,{className:"admin-tags-actions"},s().createElement(Zs.Col,null,s().createElement(Zs.LabeledIconInput,{className:"filter-tags",name:"filter",Icon:s().createElement(Zs.SearchIcon,null),value:m,onChange:E,placeholder:"Filter",disabled:w}))),s().createElement(Zs.Row,{className:"admin-tags-content",ref:_},s().createElement(zr,{tags:h,height:d,loading:l,error:o,selectedTags:n,onSelectTags:r})),s().createElement(Zs.Row,{className:"admin-tags-actions",justify:"space-between"},s().createElement(Hr,{onAddTag:e=>i([e]),isDuplicateTag:e=>t.some(t=>t.label===e),disabled:w}),s().createElement("div",null,s().createElement(Zs.IconButton,{size:"medium",style:{marginRight:8},Icon:s().createElement(Zs.TrashIcon,null),disabled:!j||0===n.length,onClick:()=>c("delete")},"Delete Selected"),s().createElement(Zs.IconButton,{size:"medium",Icon:s().createElement(Zs.MergeIcon,null),disabled:!v||n.length<2,onClick:()=>c("merge")},"Merge Selected"))))}},delete:{Title:e=>{let{tagCount:t,onBack:n}=e;return s().createElement(Zs.Row,{className:"delete-tags-title"},s().createElement(Zs.ArrowIcon,{size:"large",direction:"left",onClick:n,pointer:!0}),s().createElement("span",null,"Are you sure you want to delete ",Mr(t,"this tag",e=>`these ${e} tags`),"?"))},View:e=>{let{selectedTags:t,onRemoveTags:n,onUpdateView:l}=e;const[o,i]=(0,a.useState)(!1),[r,c]=(0,a.useState)(!1),d=(0,a.useCallback)(()=>{var e,a,s,o,r;i(!0),e=t,a=void 0,s=void 0,r=function*(){try{yield(0,g.oD)("POST","tagged-resource",{action:"multi-delete",tag_ids:e.map(e=>e.id)}),n(e),l("table")}catch(e){c(!0)}finally{i(!1)}},new((o=void 0)||(o=Promise))(function(e,t){function n(e){try{i(r.next(e))}catch(e){t(e)}}function l(e){try{i(r.throw(e))}catch(e){t(e)}}function i(t){var a;t.done?e(t.value):(a=t.value,a instanceof o?a:new o(function(e){e(a)})).then(n,l)}i((r=r.apply(a,s||[])).next())})},[]);return s().createElement("div",{className:"delete-tags"},o&&s().createElement("div",{className:"delete-overlay"},s().createElement(Zs.Row,{className:"delete-indicator"},s().createElement(Zs.Col,null,s().createElement(Zs.Loading,null)),s().createElement(Zs.Col,null,s().createElement(Zs.Text,{style:{color:Zs.colors.teal[65]}},"Deleting...")))),s().createElement(Zs.Row,{className:"delete-tags-alert"},s().createElement(Zs.AlertNotification,{alertType:"neutral"},Mr(t.length,"1 tag",e=>`${e} tags`)," will be deleted. You cannot undo this action.")),r&&s().createElement(Zs.Row,{className:"delete-tags-alert"},s().createElement(Zs.AlertNotification,{alertType:"error"},"Unable to delete tags.")),s().createElement(Zs.Row,{className:"tag-container"},t.map(e=>s().createElement($r,{tag:e,key:e.id}))),s().createElement(Zs.Row,{className:"delete-tags-actions",justify:"flex-end"},s().createElement(Zs.Button,{size:"medium",secondary:!0,onClick:()=>l("table")},"Cancel"),s().createElement(Zs.Button,{size:"medium",variant:"error",onClick:d},"Delete")))}},merge:{Title:e=>{let{tagCount:t,onBack:n}=e;return s().createElement(Zs.Row,{className:"delete-tags-title"},s().createElement(Zs.ArrowIcon,{size:"large",direction:"left",onClick:n,pointer:!0}),s().createElement("span",null,"Merge ",t," Tags"))},View:e=>{let{selectedTags:t,onNewTags:n,onRemoveTags:l,onUpdateView:o}=e;const[i,r]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)(t[0]),p=(0,a.useCallback)(()=>{var e,a,s,i,c,m;r(!0),e=u.id,a=t,s=void 0,i=void 0,m=function*(){try{yield(0,g.oD)("POST","tagged-resource",{action:"merge",tag_id:e,tags_to_merge:a.map(e=>e.id)}),l(a);const t=Object.assign(Object.assign({},u),{projects:h("projects"),clients:h("clients"),contacts:h("contacts"),suppliers:h("suppliers"),products:h("products")});n([t]),o("table")}catch(e){d(!0)}finally{r(!1)}},new((c=void 0)||(c=Promise))(function(e,t){function n(e){try{l(m.next(e))}catch(e){t(e)}}function a(e){try{l(m.throw(e))}catch(e){t(e)}}function l(t){var s;t.done?e(t.value):(s=t.value,s instanceof c?s:new c(function(e){e(s)})).then(n,a)}l((m=m.apply(s,i||[])).next())})},[u,t]),h=(0,a.useCallback)(e=>t.reduce((t,n)=>t+n[e],0),[t]);return s().createElement("div",{className:"merge-tags"},i&&s().createElement("div",{className:"merging-overlay"},s().createElement(Zs.Row,{className:"merging-indicator"},s().createElement(Zs.Col,null,s().createElement(Zs.Loading,null)),s().createElement(Zs.Col,null,s().createElement(Zs.Text,{style:{color:Zs.colors.teal[65]}},"Merging...")))),s().createElement(Zs.Row,{className:"merge-tags-alert"},s().createElement(Zs.AlertNotification,{alertType:"neutral"},s().createElement("div",null,s().createElement("b",null,"Select which tag you want to keep.")," ","The other "," "+Mr(t.length-1,"tag",e=>`${e} tags`)," will be replaced with the one you select. This will affect"," "+Mr(h("projects"),"1 project",e=>`${e} projects`),","," "+Mr(h("clients"),"1 client",e=>`${e} clients`),","," "+Mr(h("contacts"),"1 contact",e=>`${e} contacts`),","," "+Mr(h("suppliers"),"1 supplier",e=>`${e} suppliers`),", and ",Mr(h("products"),"1 product",e=>`${e} products`),".",s().createElement("br",null),s().createElement("br",null),"You cannot undo this action."))),c&&s().createElement(Zs.Row,{className:"merge-tags-alert"},s().createElement(Zs.AlertNotification,{alertType:"error"},"Unable to merge tags.")),s().createElement(Zs.Row,{className:"tag-container"},t.map(e=>s().createElement($r,{key:e.id,tag:e,selectable:!0,selected:u===e,onSelect:m}))),s().createElement(Zs.Row,{className:"merge-tags-actions",justify:"flex-end"},s().createElement(Zs.Button,{size:"medium",secondary:!0,onClick:()=>o("table")},"Cancel"),s().createElement(Zs.Button,{size:"medium",onClick:p},'Merge to "',u.label,'"')))}},"no-tags":{Title:()=>
32null,View:e=>{let{onNewTags:t,onUpdateView:n}=e;const l=(0,a.useRef)(null),o=(0,a.useRef)(null),i=(0,a.useRef)(null),[r,c]=(0,a.useState)(0),[d,u]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(null==i.current)return;const e=new ResizeObserver(()=>{if(null==l.current||null==o.current)return;const e=l.current.offsetTop,t=o.current.offsetTop,n=getComputedStyle(l.current),a=l.current.offsetWidth-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight);c(t-e),u(a)});return e.observe(i.current),()=>e.disconnect()},[]);const m=(0,a.useCallback)(e=>{t([e]),n("table")},[t]);return s().createElement("div",{className:"no-tags",ref:i},s().createElement("div",{className:"no-tags-content"},s().createElement(Zs.Row,{className:"no-tags-info"},s().createElement(Zs.H1,null,"You have no tags set up"),"Tags are a powerful tool to organize commonsku on a micro-level.",s().createElement("ul",null,s().createElement("li",null,"Tag ",s().createElement("b",null,"projects")," to group reporting on a project level. Track reorders, referral sources, or whether the order was made through a commonsku Shop."),s().createElement("li",null,"Tag ",s().createElement("b",null,"clients"),", and filter reports by those tags."),s().createElement("li",null,"Tag ",s().createElement("b",null,"contacts"),", to organize and find them."),s().createElement("li",null,"Tag ",s().createElement("b",null,"suppliers")," to more easily find them. Do they offer free samples? Do you have EQP with them?"),s().createElement("li",null,"Tag ",s().createElement("b",null,"products")," to quickly find them when adding them to an order."))),s().createElement(Zs.Row,{className:"no-tags-cta",ref:l},s().createElement(Zs.H2,null,"Start adding tags below"),'"Preferred", "EQP", etc.',r>300&&s().createElement("div",{className:"arrow-container"},s().createElement(Zs.EmptyStateArrow,{direction:"down",size:"medium",style:{height:r,width:d},transform:`scale(${r/500*1.6})`})))),s().createElement(Zs.Row,{className:"no-tags-actions",ref:o},s().createElement(Hr,{onAddTag:m,isDuplicateTag:()=>!1,highlight:!0}),s().createElement("a",{href:"https://help.commonsku.com/knowledge/tags",target:"_blank",rel:"noreferrer"},s().createElement(Zs.IconButton,{className:"info-button",Icon:s().createElement(Zs.InfoIcon,null)},"Learn more about tags"))))}}},Vr=e=>{let{setTitle:t}=e;const[n,l]=(0,a.useState)([]),[o,i]=(0,a.useState)("table"),[r,c]=(0,a.useState)([]),[d,u]=(0,a.useState)(!1),[m,p]=(0,a.useState)(!0),h=Qr[o].View,x=Qr[o].Title;return(0,a.useEffect)(()=>{var e,t,n,a;e=void 0,t=void 0,a=function*(){try{const{json:e}=yield(0,g.oD)("GET","tagged-resource/detailed-summary",{}),t=e.tagged_resources.map(e=>({id:e.tag_id,label:e.label,projects:Number(e.num_projects),products:Number(e.num_products),clients:Number(e.num_clients),contacts:Number(e.num_contacts),suppliers:Number(e.num_suppliers)}));c(t),0===t.length&&i("no-tags")}catch(e){u(!0)}finally{p(!1)}},new((n=void 0)||(n=Promise))(function(s,l){function o(e){try{r(a.next(e))}catch(e){l(e)}}function i(e){try{r(a.throw(e))}catch(e){l(e)}}function r(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,i)}r((a=a.apply(e,t||[])).next())})},[]),(0,a.useEffect)(()=>t(s().createElement(x,{tagCount:n.length,onBack:()=>i("table")})),[o]),s().createElement("div",{className:"admin-tags-wrapper"},s().createElement(h,{tags:r,selectedTags:n,isFetchingTags:m,fetchingTagsError:d,onNewTags:e=>{c([...e,...r])},onRemoveTags:e=>{c(r.filter(t=>!e.includes(t))),l([])},onSelect:l,onUpdateView:i}))},Xr=e=>{let{paywallCtaUrl:t}=e;return s().createElement("div",{style:{flexGrow:1,margin:"60px 16px 20px",height:"100%",overflowX:"hidden",overflowY:"auto"}},s().createElement("div",{style:{background:Zs.colors.teal[20],color:Zs.colors.neutrals[100],padding:32,gap:"2rem",display:"flex",alignItems:"center",marginBottom:"4rem"}},s().createElement("div",{style:{flex:"1 0 0"}},s().createElement("h4",{style:{marginBottom:0}},"Upgrade to Advanced to Unlock Commissions Management")),s().createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"flex-start",ga
32p:"1rem"}},s().createElement(Zs.Link,{target:"_blank",as:"a",href:t},s().createElement(Zs.IconButton,{size:"large",cta:!0},"Contact Us")))),s().createElement("div",{style:{display:"flex",alignSelf:"stretch",gap:"2rem",alignItems:"flex-start"}},s().createElement("div",{style:{display:"flex",paddingLeft:"2rem",alignItems:"flex-start",gap:"4rem",alignSelf:"stretch",color:Zs.colors.neutrals[100]}},s().createElement("p",{style:{flex:"1 0 0",alignSelf:"stretch",fontSize:"1.3rem"}},"Streamline your team's commission payments with commonsku. By unlocking access to the Commission Management feature with the Advanced package you can set individual commission rates, set rates by project role, set commission limits and multipliers, and more!"),s().createElement("div",{style:{display:"flex",height:"300px",justifyContent:"center",alignItems:"center"}},s().createElement("img",{src:"../../../images/paywalls/cloverconnect-2.svg",style:{width:"300px",display:"flex",justifyContent:"center",alignItems:"center",marginRight:16}})))))},Zr=e=>{let{paywallCtaUrl:t}=e;return s().createElement("div",{style:{flexGrow:1,marginTop:45,height:"100%",overflowX:"hidden",overflowY:"auto"}},s().createElement("div",{style:{background:Zs.colors.teal[20],color:Zs.colors.neutrals[100],padding:32,gap:"2rem",display:"flex",alignItems:"center",marginBottom:"4rem"}},s().createElement("div",{style:{flex:"1 0 0"}},s().createElement("h4",{style:{marginBottom:0}},"Upgrade to Advanced to Unlock Targets")),s().createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"flex-start",gap:"1rem"}},s().createElement(Zs.Link,{target:"_blank",as:"a",href:t},s().createElement(Zs.IconButton,{size:"large",cta:!0},"Contact Us")))),s().createElement("div",{style:{display:"flex",alignSelf:"stretch",gap:"2rem",alignItems:"flex-start"}},s().createElement("div",{style:{display:"flex",paddingLeft:"2rem",alignItems:"flex-start",gap:"4rem",alignSelf:"stretch",color:Zs.colors.neutrals[100]}},s().createElement("p",{style:{flex:"1 0 0",alignSelf:"stretch",fontSize:"1.3rem"}},"Set the standard for you team by implementing Targets in commonsku. By unlocking access to the Targets feature with the Advanced package, managers can define their team's KPIs, set monthly targets on booked orders, invoiced orders, or both. "),s().createElement("div",{style:{display:"flex",height:"300px",justifyContent:"center",alignItems:"center"}},s().createElement("img",{src:"../../../images/paywalls/client-interactions.svg",style:{width:"300px",display:"flex",justifyContent:"center",alignItems:"center",marginRight:16}})))))},Kr=(0,Ui.default)(Zs.Popup)` 33 .popup-content { 34 display: flex; 35 flex-direction: column; 36 } 37`,Jr=e=>{var t,n,s;let{openCommonskuPayments:l=!1}=e;const o=(0,Vl.Us)(),[i,r]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),{hasCapabilities:u}=(0,g.el)(o),m=u(["MODIFY-SETTINGS"]),p=u(["CREATE-TAGS","MODIFY-TAGS","DELETE-TAGS"],!0),h=u(["HAS-COMMISSIONS"]),x=u(["HAS-SALES-TARGETS"]);Sl();const{company:_}=(0,Fi.A)(o.company_id),y="SUPPLIER"===o.company_type?"/vendor.php?id="+o.company_id:"/distributor.php?id="+o.company_id,f=(null==_?void 0:_.feature_id)===Mi.A.DISTRIBUTOR_ENTERPRISE_FEATURE_ID||(null==o||null===(t=o.user_flags)||void 0===t?void 0:t.includes("WEBHOOKS_ENABLED")),b={companyPage:{component:null,title:"Company Page",link:y,content:(0,al.jsx)(Zs.LightIndicator,{name:"Configured",on:!0}),icon:null!=o&&null!==(n=o.company_avatar)&&void 0!==n&&n.medium?(0,al.jsx)(Il.Ay,{src:(null==o||null===(s=o.company_avatar)||void 0===s?void 0:s.medium)||null,name:null==o?void 0:o.company_name,round:!0,size:30,style:{marginRight:"16px"}}):null,height:"SUPPLIER"===o.company_type?"160px":null,show:!0},emailTemplates:{component:Ir,title:"Email Templates",isTabbed:!0,summary:Rr,show:"SUPPLIER"!==o.company_type},decoration:{component:Js.A,title:"Decorator Matrix",summary:Pr,show:"SUPPLIER"!==o.company_type,editPermission:"MODIFY-DECORATOR-MATRIX"},projectTemplates:{component:null,title:"Project Templates",link:"/admin_setting_project_templates.php",summary:Br,show:"SUPPLIER"!==o.company_type},commission:{component:h?No:Xr,popupTitle:h?"Commissions":"",title:"Commissions",isTabbed:!0,summary:Oo,height:"120px",show:"SUPPLIER"!==o.company_type,paywalled:!h,popupStyle:h?void 0:{maxWidth:"63rem",height:"auto",margin:16}},targets:{component:x?Tr:Zr,popupTitle:x?"Edit Targets":"",title:"Targets",summary:Or,height:"120px",show:"SUPPLIER"!==o.company_type,paywalled:!x,popupStyle:x?void 0:{maxWidth:"60rem",height:"auto"}},setup:{component:_o,title:"Setup",isTabbed:!0,summary:yo,height:"SUPPLIER"===o.company_type?"160px":"360px",show:!0}
37,integrations:{component:Cr,title:"Integrations",isTabbed:!0,height:"360px",summary:Ur,show:"SUPPLIER"!==o.company_type},tags:{component:Vr,contentClassName:"tags-popup-content",title:"Tags",popupTitle:"Manage Tags",summary:Yr,show:p&&"SUPPLIER"!==o.company_type},webhooksAPI:{component:Oi,contentClassName:"webhooksAPI",title:"Webhooks & API",popupTitle:"Upgrade To Enterprise To Unlock Webhooks",summary:Fr,isTabbed:!0,show:!0,popupStyle:{maxWidth:"822px",maxHeight:"363px"},...f?{component:Gi,popupTitle:"Webhooks & API",popupStyle:{}}:{}}},v=(0,a.useCallback)(()=>{r(null),d(null)},[]);(0,a.useEffect)(()=>{l&&r("integrations")},[l]);let j=null;if(i){var w;const e=b[i].component,t=null!==(w=b[i].popupStyle)&&void 0!==w?w:{};var C,E;if(e)null==c&&d(null!==(E=b[i].popupTitle)&&void 0!==E?E:b[i].title),j=(0,al.jsxs)(Kr,{className:b[i].isTabbed?"tabbed":"non-tabbed",contentClassName:null!==(C=b[i].contentClassName)&&void 0!==C?C:null,height:"calc(100vh - 100px)",style:{padding:b[i].isTabbed?0:null,maxWidth:"1600px",width:"calc(100vw - 100px)",...t},noHeader:!0,children:[""!==c&&(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{children:(0,al.jsx)("h2",{style:{margin:b[i].isTabbed?"1rem":null,marginBottom:b[i].isTabbed?null:"1rem",fontSize:"24px",fontWeight:"bold"},children:c})})}),(0,al.jsx)(Zs.XIcon,{size:"large",style:{position:"absolute",right:16,cursor:"pointer",top:16,zIndex:9},onClick:v}),(0,al.jsx)(e,{paywallCtaUrl:"https://meetings.hubspot.com/aaronkucherawy/upgrade-questions",identity:o,inPopup:!0,setTitle:d,openCommonskuPayments:l})]})}const k=[],S=Object.keys(b).filter(e=>b[e].show).map(e=>{var t,n,a,s,l,o;const i=null!==(t=b[e].summary)&&void 0!==t?t:null,c=null!==(n=b[e].link)&&void 0!==n?n:null,d=null!==(a=b[e].height)&&void 0!==a?a:null,p=null!==(s=b[e].content)&&void 0!==s?s:null,h=null!==(l=b[e].icon)&&void 0!==l?l:null,g=null!==(o=b[e].paywalled)&&void 0!==o?o:null,x=b[e].editPermission&&u(b[e].editPermission),_=m||x;return x&&k.push(b[e].title),(0,al.jsx)(Zs.Col,{"data-test-name":"AdminSettings",lg:6,sm:12,children:(0,al.jsx)(Zs.Box,{style:{padding:"15px",margin:"15px",opacity:_?"1":"0.5",cursor:_?"pointer":"default"},onClick:t=>{_&&(c?window.open(c):r(e))},children:(0,al.jsx)("div",{style:{height:d||"80px",overflow:"hidden"},children:i?(0,al.jsx)(i,{title:b[e].title,paywalled:g}):(0,al.jsxs)("div",{style:{display:"flex"},children:[(0,al.jsx)("div",{children:h||(0,al.jsx)(Zs.GearIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:b[e].title}),p?(0,al.jsx)("div",{className:"tile-summary-content",children:p}):null]})]})})})},e)});let I=null;return!m&&k.length>0&&(I="You only have permission to edit "+k.join(", ")+". Please contact one of your team's admins to edit other tiles:"),(0,al.jsxs)(al.Fragment,{children:[m?null:(0,al.jsx)(Dr,{message:I}),(0,al.jsx)(Zs.Row,{children:S}),j]})},ec=(0,a.forwardRef)((e,t)=>(0,al.jsx)(fo.Q,{backend:bo.t2,children:(0,al.jsx)(Jr,{innerRef:t,...e})})),tc=(0,Vs.A)(ec,{companyGeneralDataById:wt.Ay});function nc(e){let{data:t,save:n}=e;const s=(0,a.useMemo)(()=>({user_email_signature:""}),[]),[l,o]=(0,a.useState)(s);(0,a.useEffect)(()=>{o({user_email_signature:t.user_email_signature})},[t.user_email_signature,s]);const i=(0,a.useCallback)(e=>{const t=e.target;o(e=>({...e,[t.name]:t.value}))},[]),r=(0,a.useCallback)((0,tl.debounce)(e=>{e.user_email_signature!=t.user_email_signature&&n(e)},2e3),[n]);return(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(0,al.jsx)(kr.A,{value:l.user_email_signature,onChange:e=>{i({target:{name:"user_email_signature",value:e}}),r({user_email_signature:e})}})})})}function ac(){const e=(0,l.wA)(),t=(0,l.d4)(e=>e.identity),n=(0,l.d4)(e=>e.userGeneralData),s=n.loading,o=(0,a.useCallback)(async()=>{var a;n.user_email_signature||await e((a=t.user_id,async(e,t)=>{e(kt());const n=await(0,g.oD)("GET",`user/${a}`,{});return e(Et(n.json.user)),n.json.user}))},[n.user_email_signature,e,t.user_id]);(0,a.useEffect)(()=>{o()},[o]);const i=(0,a.useCallback)(n=>(async()=>{const a=await e(((e,t)=>async(n,a)=>{n(kt());let s={};
37try{s=await(0,g.oD)("PUT",`user/${e}`,t)}catch(e){return console.log("Failed to update",e.json.error),e.json.error}return n(Et(s.json.user)),!0})(t.user_id,n));return!0===a?Xs.oR.success("Saved successfully"):Xs.oR.error(a),a})(),[e,t.user_id]);return[n,s,i]}const sc=()=>{const[e,t,n]=ac();return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(nc,{data:e.data,loading:t,save:n})})};function lc(e){let{data:t,save:n}=e;const s=(0,a.useMemo)(()=>({esp_account:"",esp_default_market:"",esp_login:"",esp_password:""}),[]),[l,o]=(0,a.useState)(s),[i,r]=(0,a.useState)(s);(0,a.useEffect)(()=>{let e=s;e={...e,esp_account:t.esp_account,esp_default_market:t.esp_default_market,esp_login:t.esp_login,esp_password:t.esp_password},o(e)},[t.esp_account,t.esp_default_market,t.esp_login,t.esp_password,s]);const c=(0,a.useCallback)(e=>{const t=e.target;o(e=>({...e,[t.name]:t.value}))},[]),d=(0,a.useCallback)(e=>{r(s);let t=0;if(""!==e.esp_account||""!==e.esp_login||""!==e.esp_password)for(const n of["esp_account","esp_login","esp_password"])""===e[n]&&(r(e=>({...e,[n]:"Required"})),t++);return!(t>0)},[s]),u=(0,a.useCallback)(async e=>{if(!d(e))return;const t=await n(e);!0!==t&&r(e=>({...e,esp_login:t,esp_account:"",esp_password:""}))},[n,d]),m=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"text";const a=""!==i[e];return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.LabeledInput,{placeholder:"Type Here",style:{marginBottom:"0"},error:a,type:n,className:"align-with-select",label:t||e,name:e,value:l[e],onChange:c}),a?(0,al.jsx)(Zs.AlertNotification,{alertType:"error",children:i[e]}):""]})};return(0,al.jsxs)(Zs.Row,{children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:m("esp_account","ASI Number")}),(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:m("esp_login","Username (one license per user)")}),(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:m("esp_password","Password","password")}),(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(()=>{let{label:e,name:t,options:n}={label:"Default Market",name:"esp_default_market",options:[{label:"CAN",value:"CANALL"},{label:"USA",value:"USAALL"}]};const a=n.filter(e=>e.value===l[t]);return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.LabeledSelect,{label:e,name:t,value:a,options:n,onChange:e=>{c({target:{name:t,value:e.value}})}}),i[t]?(0,al.jsx)("span",{style:{color:"red"},children:i[t]}):""]})})()}),(0,al.jsx)(Zs.Col,{padded:!0,sm:12,children:(0,al.jsx)(Zs.Button,{onClick:()=>{u(l)},children:"Save"})})]})}const oc=()=>{const[e,t,n]=ac();return(0,al.jsx)(al.Fragment,{children:(0,al.jsx)(lc,{data:e.data,loading:t,save:n})})},ic=()=>{var e,t;const n=(0,Vl.Us)(),[{data:s}]=ac(),[l,o]=(0,a.useState)(null),i={__html:null==s?void 0:s.user_email_signature},r=(0,g.OG)(s),c=(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Progress,{style:{height:"10px"},value:r.sumCompleted,max:r.sumAll}),(0,al.jsx)("div",{style:{marginTop:"12px"},children:r.notCompleted.slice(0,5).map(e=>(0,al.jsxs)("div",{"data-test-name":"AdminMySettings",style:{display:"flex",alignItems:"center"},children:[(0,al.jsx)(Zs.InfoIcon,{width:"16px",color:"#FFD302"}),(0,al.jsx)("span",{style:{marginLeft:"8px"},children:e.label})]},e.key))})]}),d={profilePage:{component:null,title:"Profile",link:"/user.php?id="+n.user_id,content:c,height:"190px",icon:null!=n&&null!==(e=n.user_image_paths)&&void 0!==e&&e.medium?(0,al.jsx)(Il.Ay,{src:(null==n||null===(t=n.user_image_paths)||void 0===t?void 0:t.medium)||null,name:null==n?void 0:n.user_first_name,round:!0,size:30,style:{marginRight:"16px"}}):null,show:!0},emailSignature:{component:sc,title:"Email Signature",content:(0,al.jsx)("div",{dangerouslySetInnerHTML:i}),height:"190px",icon:(0,al.jsx)(Zs.EditIcon,{size:"large",mr:16,color:"#DAE9EE"}),maxWidth:"800px",show:!0},esp:{component:oc,title:"ESP",popupTitle:"ESP Integration",content:(0,al.jsx)(Zs.LightIndicator,{name:s.esp_account?"Configured":"Not configured",on:!!s.esp_account}),icon:(0,al.jsx)(Zs.EpsIcon,{size:"large",mr:16,color:"#DAE9EE"}),show:"SUPPLIER"!==n.company_type}},u=(0,a.useCallback)(()=>{o(null)},[]);let m=null;if(l){var p;const e=d[l].component,t=null!==(p=d[l].maxWidth)&&void 0!==p?p:"600px";e&&(m=(0,al.jsx)(Zs.Popup,{className:d[l].isTabbed?"tabbed":"non-tabbed",style:{padding:d[l].isTabbed?0:20,maxWidth:t,maxHeight:"650px"},width:"calc(100vw - 100px)",height:"calc(100vh - 100px)",header:(0,al.jsxs)(Zs.Row,{className:"popup-header",justify:"space-between",wrap:"nowrap",style:{alignItems:"flex-start"},children:[(0,al.jsx)("h2",{style:{margin:"0.2em"},children:d[l].popupTitle||d[l].title}),(0,al.jsx)("div",{children:(0,al.jsx)(Zs.Button,{onClick:u,children:"Done"})})]}),children:(0,al.jsx)(e,{identity:n,inPopup:!0})}))}const h=Object.keys(d).filter(e=>d[e].show).map(e=>{var t,n,a,s,l;const i=null!==(t=d[e].summary)&&void 0!==t?t:null,r=null!==(n=d[e].link)&&void 0!==n?n:null,c=null!==(a=d[e].height)&&void 0!==a?a:null,u=null!==(s=d[e].content)&&void 0!==s?s:null,m=null!==(l=d[e].icon)&&void 0!==l?l:null;return(0,al.jsx)(Zs.Col,{"data-test-name":"AdminMySettings",lg:6,sm:12,children:(0,al.jsx)(Zs.Box,{style:{padding:"15px",margin:"15px"},onClick:t=>{r?window.open(r):o(e)},children:(0,al.jsx)("div",{style:{height:c||"80px",overflow:"hidden"},children:i?(0,al.jsx)(i,{title:d[e].title}):(0,al.jsxs)("div",{style:{display:"flex"},children:[(0,al.jsx)("div",{children:m||(0,al.jsx)(Zs.GearIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{style:{flexGrow:1},children:[(0,al.jsx)("h5",{children:d[e].title}),u?(0,al.jsx)("div",{className:"tile-summary-content",children:u}):null]})]})})})},e)});return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Row,{children:h}),m]})};var rc=n(29449);function cc(e){var t;let{title:n,data:a,canEdit:s}=e;const{last4:l,exp_month:o,exp_year:i}=(null==a||null===(t=a.stripe_default_payment_method)||void 0===t?void 0:t.card)||{last4:!1,exp_month:0,exp_year:0};return(0,al.jsxs)("div",{"data-test-name":"AdminBillingPaymentSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.CreditCardIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:n}),(0,al.jsx)(Zs.LightIndicator,{name:l?s?`....${l} expires ${o}/${i}`:"configured":"No payment info",on:!!l})]})]})}const dc=e=>Object.values(e.entities.shops_fees);function uc(e){let{title:t}=e;const n=(0,l.d4)(dc);let a="No shop fees";return n.length>0&&(a=`Latest fee from ${(0,g.kq)(n[0].charged_date)} for ${(0,g.up)(n[0].charged_sum)} ${n[0].charged_currency_converted}`),(0,al.jsxs)("div",{"data-test-name":"AdminBillingShopFeeSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.ShopIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:t}),(0,al.jsx)("p",{className:"tile-summary-content",children:a})]})]})}function mc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=(0,l.wA)(),n=(0,l.d4)(e=>e.billingPeriods),s=Ls.selectAll(n),o=n.loading;return(0,a.useEffect)(()=>{t((e=>async(t,n)=>{t(Ds());const a=await(0,g.ip)("billing-period",{status:e,limit:60});return t(Rs(a.json.billing_periods)),a.json})(e))},[t,e]),[s,o]}function pc(e){let{title:t}=e;const[n]=mc("CLOSED");let a="No purchase order fees";if(n.length>0){const e=n.sort((e,t)=>
37t.billing_period_end.localeCompare(e.billing_period_end))[0];a=`Latest fee from ${e.billing_period_name} for $${(0,g.up)(e.po_fees)}`}return(0,al.jsxs)("div",{"data-test-name":"AdminBillingPOFeeSummary",style:{display:"flex"},children:[(0,al.jsx)("div",{children:(0,al.jsx)(Zs.ReceiptLongIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{children:[(0,al.jsx)("h5",{children:t}),(0,al.jsx)("p",{className:"tile-summary-content",children:a})]})]})}var hc=n(29064);const gc=Ui.createGlobalStyle` 38 .react-table-sticky .row.sticky { 39 max-width: initial; 40 margin-left: 0; 41 margin-right: 0; 42 } 43`;function xc(){const[e]=mc("CLOSED"),[t,n]=(0,a.useState)(),s=(0,a.useMemo)(()=>e.map(e=>({value:e.billing_period_id,label:e.billing_period_name})),[e]),o=e.find(e=>e.billing_period_id===t),i=o&&o.artifacts.find(e=>"SUPPLIER-BILLING-REPORT"===e.artifact_type),[r,c]=function(e){const t=(0,l.wA)(),n=(0,l.d4)(e=>e.billingCharges),s=Fs.selectAll(n),o=n.loading;return(0,a.useEffect)(()=>{var n;e&&t((n=e,async(e,t)=>{e(Os());const a=await(0,g.oD)("GET","charge",{billing_period_id:n});return e(Us(a.json.charges)),a.json}))},[t,e]),[s,o]}(t),[d,u]=(0,Zs.useWindowSize)(),[m,p]=((e,t)=>{let n=Math.min(1600,e-100)-40-2,a=Math.min(1600,t-100)-40-2;return[Math.floor(n),Math.floor(.9*a)]})(d,u),[h,x]=(0,a.useState)(p),_=(0,a.useRef)(null);(0,a.useEffect)(()=>{_.current&&x(p-Math.ceil(_.current.clientHeight))},[t,p,_]);const y=(0,a.useMemo)(()=>[{Header:(0,al.jsx)(Zs.Label,{children:"Division"}),accessor:"division_name",width:Math.floor(.2*m)},{Header:(0,al.jsx)(Zs.Label,{children:"Distributor"}),accessor:"distributor_name",width:Math.floor(.2*m)},{Header:(0,al.jsx)(Zs.Label,{children:"Accounts"}),accessor:(e,t)=>{var n,a;return null!==(n=null!==(a=e.account_number)&&void 0!==a?a:e.supplier_account)&&void 0!==n?n:e.promo_api_account},id:"account",Cell:e=>{let{row:t}=e;return(0,al.jsxs)(al.Fragment,{children:[t.original.account_number&&(0,al.jsx)("div",{children:t.original.account_number}),t.original.supplier_account&&(0,al.jsx)("div",{children:t.original.supplier_account}),t.original.promo_api_account&&(0,al.jsx)("div",{children:t.original.promo_api_account})]})},width:Math.floor(.15*m)},{Header:(0,al.jsx)(Zs.Label,{children:"PO #"}),accessor:"po_number",width:Math.floor(.15*m)},{Header:(0,al.jsx)(Zs.Label,{children:"Submit Method"}),accessor:"submit_method",Cell:e=>{let{value:t}=e;return(0,al.jsx)(al.Fragment,{children:"epo"===t?"ePO":"Manual"})},width:Math.floor(.1*m)},{Header:(0,al.jsx)(Zs.Label,{children:"PO Total"}),accessor:"po_total",Cell:e=>{let{value:t,row:n}=e;return(0,al.jsxs)(al.Fragment,{children:["$",(0,g.up)(t)," ",n.original.po_currency]})},width:Math.floor(.1*m)},{Header:(0,al.jsx)(Zs.Label,{children:"Fee Total"}),accessor:"fee_total",Cell:e=>{let{value:t,row:n}=e;return(0,al.jsxs)(al.Fragment,{children:["$",(0,g.up)(t)," ",n.original.fee_currency]})},width:Math.floor(.1*m)}],[m]),f=(0,a.useRef)(null),b=(0,a.useRef)(null),v=(0,a.useRef)(null),j=(0,a.useRef)(null),w=(0,a.useRef)(null),[C,E]=(0,a.useState)(0),k=(0,a.useCallback)(()=>{E(parseInt(f.current.innerText)||0)},[E]),S=(0,a.useCallback)((e,t)=>{console.log(e),console.log(t)},[]),I=(0,al.jsx)(Zs.HeadlessTable,{columns:y,data:r,rowIdFIeld:"charge_id",defaultSort:{id:"division_name",desc:!1},defaultScrollOffset:0,defaultHorizontalOffset:0,onChangeSelected:k,pageIndexDivRef:b,sortDirectionDivRef:v,currentColumnsDivRef:j,minHeight:h,pagination:!1,scrollOffsetDivRef:f,horizontalOffsetDivRef:w,onChangeSortOrColumns:S}),A=r.reduce((e,t)=>{var n,a;return{po_totals:{...e.po_totals,[t.po_currency]:(null!==(n=e.po_totals[t.po_currency])&&void 0!==n?n:0)+Number(t.po_total)},fee_totals:{...e.fee_totals,[t.fee_currency]:(null!==(a=e.fee_totals[t.fee_currency])&&void 0!==a?a:0)+Number(t.fee_total)}}},{po_totals:{},fee_totals:{}}),T="pending"===c,D=!!t&&"idle"===c;return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(gc,{}),(0,al.jsxs)(Zs.Row,{ref:_,children:[(0,al.jsx)(Zs.Col,{padded:!0,sm:2,children:(0,al.jsx)(Zs.LabeledSelect,{label:"Billing Period",name:"billing_period_id",value:s.find(e=>e.value===t),options:s,onChange:e=>n(e.value)})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:2,style:{alignSelf:"center"},children:i&&(0,al.jsx)(hc.A,{artifact_id:i.billing_period_artifact_id,filename:`PO-Billing-${o.billing_period_name.replaceAll(" ","")}.csv`,style:{marginTop:"1rem"},children:"Billing Report"})}),(0,al.jsx)(Zs.Col,{padded:!0,sm:8,children:D&&(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Label,{children:"Total Fees"}),Object.keys(A.fee_totals).map(e=>(0,al.jsxs)("div",{children:["$",(0,g.up)(A.fee_totals[e])," ",e]},e))]})})]}),(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{sm:12,children:T?(0,al.jsx)(Zs.Loading,{}):D?I:null})})]})}const _c=e=>{let{data:t}=e;return(0,al.jsx)(Zs.Row,{"data-test-name":"LicenceInfo",children:(0,al.jsx)(Zs.Col,{sm:12,children:(0,al.jsx)(Zs.Box,{style:{padding:"15px",margin:"15px"},children:(0,al.jsxs)("div",{children:["You are using ",t.activeUsers||0," of ",t.quantity||0," licenses. Go to the ",(0,al.jsx)("a",{href:"/admin_users_new.php",children:"Manage Users"})," tab to change the number of licenses."]})})})})},yc={COMMUNITYBASIC:{icon:Zs.CommunityIcon,name:"Community"},COMMUNITYPLUS:{icon:Zs.CommunityIcon,name:"Community+"}
43,CONNECTEDBASIC:{icon:Zs.ConnectedIcon,name:"Connected"},CONNECTEDPLUS:{icon:Zs.ConnectedPlusIcon,name:"Connected+"}},fc=e=>{var t,n,a,s;let{feature_name:l}=e;const o=null!==(t=null===(n=yc[l])||void 0===n?void 0:n.name)&&void 0!==t?t:l[0].toUpperCase()+l.slice(1).toLowerCase(),i=null!==(a=null===(s=yc[l])||void 0===s?void 0:s.icon)&&void 0!==a?a:Zs.CommunityIcon;return(0,al.jsx)(Zs.Row,{"data-test-name":"PlanInfo",children:(0,al.jsx)(Zs.Col,{sm:12,children:(0,al.jsxs)(Zs.Box,{style:{padding:"15px",margin:"15px",display:"flex",alignItems:"center"},children:[(0,al.jsx)(i,{size:"large",mr:16})," You are on the ",o," plan"]})})})},bc=(0,Vs.A)(function(e){let{title:t}=e;var n;const{data:{data:a}}=(0,rl.A)();let l;const o=a.churning?"end":"automatically renew",i=null!==(n=a.churning)&&void 0!==n?n:a.renewal_date;return l=`Your contract will ${o} on ${ir()(i).format("MMM [1st] YYYY")}`,s().createElement("div",{style:{display:"flex"}},s().createElement("div",null,s().createElement(Zs.UsersIcon,{size:"large",mr:16,color:"#DAE9EE"})),s().createElement("div",null,s().createElement("h5",null,t),s().createElement("p",{className:"tile-summary-content"},l)))},{companyGeneralData:wt.Ay});const vc=(0,Vs.A)(function(e){let{onClose:t,identity:n}=e;const{data:{data:l},loading:o,save:i}=(0,rl.A)(),[r,c]=(0,a.useState)(),[d,u]=(0,a.useState)(),[m,p]=(0,a.useState)(),[h,x]=(0,a.useState)(!1),[_,y]=(0,a.useState)(!0),[f,b]=(0,a.useState)(),[v,j]=(0,a.useState)(),[w,C]=(0,a.useState)(!1),[E,k]=(0,a.useState)(!1),S="idle"!==o||_;let I,A,T,D,R;(0,a.useEffect)(()=>{l.renewal_feature_id&&l.renewal_date&&(c(l.renewal_feature_id),u(l.renewal_payment_model),p(l.renewal_licenses))},[l]),(0,a.useEffect)(()=>{(0,g.oD)("GET","stripe",{}).then(e=>{let{json:t}=e;y(!1);const{stripe_info:n,active_users:a}=t||{};(null==n?void 0:n.stripe_subscription_item)?(j(a),b(n.stripe_subscription_item.quantity)):C(!0)},()=>{y(!1),C(!0)})},[]),I=`Your contract will automatically renew on ${ir()(l.renewal_date).format("MMM [1st] YYYY")}`,A="Use the settings below to set your license renewal preferences.",T=s().createElement("div",null,"I'm authorized to make changes to our contract"),D="Feature Level",R=`You currently have ${f} contracted licenses and ${v===f?"all":v} in use by assigned users.`;const L=()=>{return e=this,n=void 0,s=function*(){if(!E){k(!0);try{yield i({action:"contract-changes",distributorId:l.tenant_id,renewalFeatureId:r,renewalPaymentModel:d,renewalLicenses:m},!0),t()}catch(e){k(!1)}}},new((a=void 0)||(a=Promise))(function(t,l){function o(e){try{r(s.next(e))}catch(e){l(e)}}function i(e){try{r(s.throw(e))}catch(e){l(e)}}function r(e){var n;e.done?t(e.value):(n=e.value,n instanceof a?n:new a(function(e){e(n)})).then(o,i)}r((s=s.apply(e,n||[])).next())});var e,n,a,s},P=w?"An error occurred during your account configuration, please contact commonsku support.":"You are all set. Your account configuration has been updated.",B=!S&&w?s().createElement(s().Fragment,null,s().createElement("p",{style:{margin:"65px 100px",fontSize:24,textAlign:"center"}},P)):s().createElement(s().Fragment,null,s().createElement(Zs.AlertNotification,{href:"https://help.commonsku.com/knowledge/essentials-advanced",learnMore:!0,target:"_blank"},"Use the settings below to set your license renewal preferences."),s().createElement(Zs.Col,{style:{minHeight:370}},S?s().createElement(Zs.Row,{pt:175,style:{minHeight:395}},s().createElement(Zs.Loading,null)):s().createElement(s().Fragment,null,s().createElement(Zs.Row,{mt:20},s().createElement(Zs.Label,{mb:5},"Feature Level"),s().createElement(Zs.LabeledRadioInButton,{label:"Essentials",checked:r===Mi.A.DISTRIBUTOR_ESSENTIAL_FEATURE_ID,onChange:()=>c(Mi.A.DISTRIBUTOR_ESSENTIAL_FEATURE_ID)}),s().createElement(Zs.LabeledRadioInButton,{label:"Advanced",checked:r===Mi.A.DISTRIBUTOR_ADVANCED_FEATURE_ID,onChange:()=>c(Mi.A.DISTRIBUTOR_ADVANCED_FEATURE_ID)})),s().createElement(Zs.Row,{mt:10},s().createElement(Zs.Label,{mb:5},"Would you like to pay annually (with a discount) or monthly?"),s().createElement(Zs.LabeledRadioInButton,{label:"Monthly",checked:"MONTH"===d,onChange:()=>u("MONTH")}),s().createElement(Zs.LabeledRadioInButton,{label:"Annually 10% discount",checked:"YEAR"===d,onChange:()=>u("YEAR")})),s().createElement(Zs.Row,{mt:10},s().createElement(Zs.LabeledCheckbox,{label:"Remove unused licenses upon renewal",checked:"ACTIVE_USERS"===m,onChange:e=>p(e.target.checked?"ACTIVE_USERS":"CONTRACTED_LICENSES")})),s().createElement(Zs.Row,{mt:10},s().createElement("p",null,R)),s().createElement(Zs.Row,{mt:20},s().createElement(Zs.LabeledCheckbox,{label:T,checked:h,onChange:()=>x(!h)})))));return s().createElement(s().Fragment,null,s().createElement("div",{style:{display:"flex",justifyContent:"space-between"}},s().createElement(Zs.Typography.H2,{style:{marginBottom:10}},I),s().createElement(Zs.XIcon,{cursor:"pointer",onClick:t,mt:2,ml:10,size:"large"})),B,s().createElement(Zs.Col,null,s().createElement(Zs.Row,{justify:"right",mt:20},w&&s().createElement(Zs.Button,{variant:"primary",onClick:t,disabled:S},"Done"),!w&&s().createElement(Zs.Button,{onClick:()=>L(),disabled:!h||S||E}
43,"Save"))))},{companyGeneralData:wt.Ay}),jc=e=>()=>(0,g.oD)("POST","stripe",{action:"create-billing-portal",type:e}).then(e=>{let{json:t}=e;Gs.x.open((0,tl.get)(t,"session.url"))}),wc=jc("CHANGE_PAYMENT_METHOD_PORTAL"),Cc=jc("BILLING_HISTORY_PORTAL"),Ec=jc("LEGACY_HISTORY_PORTAL"),kc=(0,Vs.A)(()=>{const e=(0,Vl.Us)(),[t,n]=(0,a.useState)(null),[s,l]=(0,a.useState)(!1),[o,i]=(0,a.useState)(""),[r,c]=(0,a.useState)({quantity:0,activeUsers:0,hasLegacyAccount:!1}),[d,u]=(0,a.useState)({}),{hasCapabilities:m,isTenant:p}=(0,g.el)(e),h=m(["MODIFY-SETTINGS"]),x=m(["FEATURE-CONNECTEDBASIC","FEATURE-CONNECTEDPLUS"],!0),_=p()&&m("FEATURE-FULL"),{data:{data:y}}=(0,rl.A)();(0,a.useEffect)(()=>{l(!0),(0,g.oD)("GET","stripe",{}).then(e=>{let{json:t}=e;const{stripe_info:n,active_users:a}=t||{};c({quantity:(0,tl.get)(n,"stripe_subscription_item.quantity",0),activeUsers:a||0,hasLegacyAccount:!!n.stripe_has_legacy_account}),u(n),l(!1)},()=>i("No payment information found."))},[]);const f={paymentMethod:{component:null,title:"Payment Method",onclick:wc,summary:cc,show:!0},shopFees:{component:rc.A,title:"Shop Fees",summary:uc,show:"SUPPLIER"!==e.company_type},poFees:{component:xc,title:"Purchase Order Fees",summary:pc,show:x},history:{component:null,title:"Billing History",onclick:Cc,content:"Click to view your billing history",icon:(0,al.jsx)(Zs.HistoryIcon,{size:"large",mr:16,color:"#DAE9EE"}),show:!0},contractRenewal:{component:y.churning?null:vc,title:"Renewal",summary:bc,show:!0,noHeader:!0,popupStyle:{maxWidth:"50rem",height:"auto",maxHeight:"initial"},defaultCursor:!!y.churning},legacyHistory:{component:null,title:"Billing History (Before July 2021)",onclick:Ec,content:"Click to view your billing history before commonsku's July 2021 Stripe account update.",icon:(0,al.jsx)(Zs.HistoryIcon,{size:"large",mr:16,color:"#DAE9EE"}),show:r.hasLegacyAccount}};r.hasLegacyAccount||delete f.legacyHistory;const b=(0,a.useCallback)(()=>{n(null)},[]);if(s)return(0,al.jsx)(Zs.Loading,{"data-test-name":"AdminBilling"});if(""!==o)return(0,al.jsx)("p",{"data-test-name":"AdminBilling",children:o});let v=null;if(t){var j;const n=f[t].component,a=null!==(j=f[t].popupStyle)&&void 0!==j?j:{};n&&(v=(0,al.jsx)(Zs.Popup,{className:f[t].isTabbed?"tabbed":"non-tabbed",style:{padding:f[t].isTabbed?0:20,maxWidth:"1600px",width:"calc(100vw - 100px)",height:"calc(100vh - 100px)",...a},noHeader:!!f[t].noHeader,header:f[t].noHeader?null:(0,al.jsxs)(Zs.Row,{className:"popup-header",justify:"space-between",wrap:"nowrap",style:{alignItems:"flex-start"},children:[(0,al.jsx)("h2",{style:{margin:"0.2em"},children:f[t].title}),(0,al.jsx)("div",{children:(0,al.jsx)(Zs.Button,{onClick:b,children:"Done"})})]}),children:(0,al.jsx)(n,{identity:e,inPopup:!0,onClose:b})}))}const w=Object.keys(f).filter(e=>f[e].show).map(e=>{var t,a,s,l,o,i;const r=null!==(t=f[e].summary)&&void 0!==t?t:null,c=null!==(a=f[e].onclick)&&void 0!==a?a:null,u=null!==(s=f[e].height)&&void 0!==s?s:null,m=null!==(l=f[e].content)&&void 0!==l?l:null,p=null!==(o=f[e].icon)&&void 0!==o?o:null,g=null!==(i=f[e].defaultCursor)&&void 0!==i?i:null;return(0,al.jsx)(Zs.Col,{"data-test-name":"AdminBilling",lg:6,sm:12,children:(0,al.jsx)(Zs.Box,{style:{padding:"15px",margin:"15px",cursor:h&&!g?"pointer":"default"},onClick:t=>{h&&(c?c():n(e))},children:(0,al.jsx)("div",{style:{height:u||"80px",overflow:"hidden"},children:r?(0,al.jsx)(r,{title:f[e].title,data:d,canEdit:h}):(0,al.jsxs)("div",{style:{display:"flex"},children:[(0,al.jsx)("div",{children:p||(0,al.jsx)(Zs.GearIcon,{size:"large",mr:16,color:"#DAE9EE"})}),(0,al.jsxs)("div",{style:{flexGrow:1},children:[(0,al.jsx)("h5",{children:f[e].title}),m?(0,al.jsx)("div",{className:"tile-summary-content",children:m}):null]})]})})})},e)});return(0,al.jsxs)(al.Fragment,{children:[h?"SUPPLIER"===e.company_type?(0,al.jsx)(fc,{feature_name:e.features}):_?(0,al.jsx)(_c,{data:r}):null:(0,al.jsx)(Dr,{message:"You don't have permission to edit Billing Settings. Please contact one of your team's admins to make changes:"}),(0,al.jsx)(Zs.Row,{children:w}),v]})},{companyGeneralData:wt.Ay});function Sc(e){let{state:{quantity:t,activeUsers:n},onSave:l,company:o}=e;const[i,r]=(0,a.useState)(t),[c,d]=(0,a.useState)(!1),[u,m]=(0,a.useState)(!1),p=e
43=>{return t=this,n=void 0,s=function*(){d(!0),yield l(e),d(!1)},new((a=void 0)||(a=Promise))(function(e,l){function o(e){try{r(s.next(e))}catch(e){l(e)}}function i(e){try{r(s.throw(e))}catch(e){l(e)}}function r(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,i)}r((s=s.apply(t,n||[])).next())});var t,n,a,s},h=c?s().createElement(Zs.Loading,{mt:60}):s().createElement(s().Fragment,null,s().createElement("div",{style:{width:"320px",marginTop:"30px"}},s().createElement("span",{style:{fontWeight:"bold"}},"Users:"),s().createElement("span",{style:{float:"right"}},n)),s().createElement("div",{style:{width:"390px",fontWeight:"bold",marginTop:"35px"}},s().createElement("span",{style:{fontWeight:"bold",marginTop:"15px",display:"inline-block"}},"Licenses:"),s().createElement("span",{style:{float:"right"}},s().createElement(Zs.InputStepper,{initialValue:t,max:999,min:t,onChange:e=>{r(parseInt(`${e}`))},disabled:!!o.churning}))),s().createElement("div",{style:{marginTop:50}},s().createElement(Zs.LabeledCheckbox,{label:s().createElement("div",null,"Iâm authorized to make changes to our contract"),checked:u,onChange:()=>m(!u),disabled:!!o.churning}))),g=o.churning?"Your contract is ending, you cannot change your license count.":"Additional licenses are committed through the end of the term.";return s().createElement(s().Fragment,null,s().createElement(Zs.AlertNotification,{href:"https://help.commonsku.com/knowledge/add-and-remove-users",learnMore:!0,target:"_blank"},g),h,s().createElement(Zs.Button,{disabled:!u||c||i===t||!!o.churning,style:{position:"absolute",bottom:"20px",right:"20px"},onClick:()=>{p(i)}},"Save"))}const Ic=(0,Vs.A)(()=>{const e=(0,Vl.Us)(),[t,n]=(0,a.useState)(null),[l,o]=(0,a.useState)(!1),[i,r]=(0,a.useState)(""),[c,d]=(0,a.useState)({quantity:0,activeUsers:0}),u=(0,Vl.u7)(["MODIFY-SETTINGS"]),{company:m}=(0,Fi.A)(e.company_id),p=e=>{return t=void 0,n=void 0,s=function*(){e<2||(yield(0,g.oD)("POST","stripe",{action:"change-plan",quantity:e}),d({quantity:e,activeUsers:c.activeUsers}))},new((a=void 0)||(a=Promise))(function(e,l){function o(e){try{r(s.next(e))}catch(e){l(e)}}function i(e){try{r(s.throw(e))}catch(e){l(e)}}function r(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a(function(e){e(n)})).then(o,i)}r((s=s.apply(t,n||[])).next())});var t,n,a,s};(0,a.useEffect)(()=>{o(!0),(0,g.oD)("GET","stripe",{}).then(e=>{let{json:t}=e;var n,a;o(!1);const{stripe_info:s,active_users:l}=t||{};s.stripe_subscription_item?d({quantity:null!==(a=null===(n=null==s?void 0:s.stripe_subscription_item)||void 0===n?void 0:n.quantity)&&void 0!==a?a:0,activeUsers:l||0}):r("Unable to retrieve plans")},()=>r("No payment information found"))},[]);const h={licenses:{component:Sc,title:"Licenses",content:`${c.quantity} licenses`,icon:s().createElement(Zs.UsersIcon,{size:"large",mr:16,color:"#DAE9EE"}),show:!0}},x=(0,a.useCallback)(()=>{n(null)},[]);if(l)return s().createElement(Zs.Loading,{mt:30});if(""!==i)return s().createElement("p",{style:{textAlign:"center",fontWeight:"bolder",fontSize:"18px",margin:"30px auto",color:"rgb(229, 38, 51)"}},i);let _=null;if(t){const n=h[t].component;n&&(_=s().createElement(Zs.Popup,{className:h[t].isTabbed?"tabbed":"non-tabbed",style:{padding:h[t].isTabbed?0:20,maxWidth:"800px",maxHeight:"450px"},width:"calc(100vw - 100px)",height:"calc(100vh - 100px)",header:s().createElement(Zs.Row,{className:"popup-header",justify:"space-between",wrap:"nowrap",style:{alignItems:"flex-start"}},s().createElement("h2",{style:{margin:"0.2em"}},h[t].title),s().createElement("div",null,s().createElement(Zs.Button,{onClick:x},"Done")))},s().createElement(n,{identity:e,inPopup:!0,state:c,onSave:p,company:m})))}const y=Object.keys(h).filter(e=>h[e].show).map(e=>{var t,a,l,o,i;const r=null!==(t=h[e].summary)&&void 0!==t?t:null,d=null!==(a=h[e].onclick)&&void 0!==a?a:null,p=null!==(l=h[e].height)&&void 0!==l?l:null,g=null!==(o=h[e].content)&&void 0!==o?o:null,x=null!==(i=h[e].icon)&&void 0!==i?i:null;return s().createElement(Zs.Col,{key:e,lg:6,sm:12},s().createElement(Zs.Box,{style:{padding:"15px",margin:"15px",cursor:u?"pointer":"default"},onClick:t=>{u&&(d?d():n(e))}},s().createElement("div",{style:{height:p||"80px",overflow:"hidden"}},r?s().createElement(r,{title:h[e].title,state:c,company:m,canEdit:u}):s().createElement("div",{style:{display:"flex"}},s().createElement("div",null,x||s().createElement(Zs.GearIcon,{size:"large",mr:16,color:"#DAE9EE"})),s().createElement("div",{style:{flexGrow:1}},s().createElement("h5",null,h[e].title),g?s().createElement("div",{className:"tile-summary-content"},g):null)))))});return s().createElement(s().Fragment,null,!u&&s().createElement(Dr,{message:"You don't have permission to edit Licenses Settings. Please contact one of your team's admins to make changes:"}),s().createElement(Zs.Row,null,y),_)},{companyGeneralDataById:wt.Ay}),Ac=()=>{const[e,t]=(0,a.useState)("settings"),n=(0,Vl.Us)(),{hasCapabilities:s}=(0,g.el)(n),{shouldOpen:l}=(s(["MODIFY-SETTINGS"]),(0,Vl.b6)());(0,a.useEffect)(()=>{const e=new URLSearchParams(window.location.search).get("tab");e&&t(e)},[]),(0,a.useEffect)(()=>{l&&t("settings")},[l]);let o={settings:tc,"my-settings":ic,billing:kc,licenses:Ic}[e];return(0,al.jsxs)(al.Fragment,{children:[(0,al.jsx)(Zs.Row,{children:(0,al.jsx)(Zs.Col,{sm:12,style:{display:"flex",flexDirection:"row"},children:(0,al.jsx)("div",{style:{flexGrow:1},children:(0,al.jsx)(Ks.A,{activeTab:e,samePageTabs:["my-settings","settings","billing","licenses"],setActiveTab:t})})})}),(0,al.jsx)(o,{openCommonskuPayments:"settings"===e&&l})]})};var Tc=n(97836);const Dc=(0,n(78566).Ay)(),Rc=(0,Vs.A)(()=>{const e=(0,l.d4)(c.ag);return(0,al.jsxs)(Zs.Theme,{"data-test-name":"AdminSettingsNewApp",children:[(0,al.jsx)(Dc,{theme:{fontFamily:"'skufont-regular', 'sans-serif', 'Roboto'"}}),(0,al.jsxs)(r.A,{children:[(0,al.jsx)(o.A,{}),(0,al.jsx)(i.A,{popups:e,children:(0,al.jsx)("div",{className:"main-content csku-styles",style:{paddingRight:"24px",background:"#EDF4F7",paddingBottom:"24px"},children:(0,al.jsxs)("div",{className:"row full-width",style:{paddingLeft:"1.25rem"},children:[(0,al.jsx)("div",{style:{paddingLeft:"0.75rem",paddingTop:"1rem"},children:(0,al.jsx)(Tc.A,{title:"Settings"})}),(0,al.jsx)(Ac,{})]})})}),(0,al.jsx)(d.A,{popups:e}),(0,al.jsx)(Xs.N9,{autoClose:3e3,hideProgressBar:!0})]})]})},Qs,!0)},18981(e,t,n){n.d(t,{U:()=>m});var a=n(3602),s=n(41594),l=n(98483),o=n(3902),i=n(58199),r=n(22078),c=n(93664),d=n(82654),u=n(63988);function m(e){const{role:t,filters:n}=e,m=(0,s.useMemo)(()=>new Date,[]),p="show_invoice_targets",h=(0,o.$E)((0,l.d4)(d.ZW),"user_id",e=>e.contact_first_name+" "+e.contact_last_name,!1),g=(0,l.d4)(e=>
43e.identity),x=g.user_id,_=g.tenant_id,[y,f]=(0,s.useState)("sales"===t?h.filter(e=>e.value==x)[0]:{label:"All Reps",value:""}),[b,v]=(0,s.useState)({label:m.getFullYear(),value:m.getFullYear()}),[j,w]=(0,s.useState)(1==g.show_invoice_targets),[C,E]=(0,s.useState)(1==g.show_sales_order_targets),k=(0,l.wA)(),S=(e,t)=>{const a=e.target_id,s=Math.abs(t.target.value.replaceAll(",",""));0===a?k((0,i.ms)({rep_id:y.value,target_value:s,target_type:t.target.name,month:c.yz.indexOf(e.month)+1,year:b.value})):"sales_target_value"===t.target.name?k((0,i.fy0)(e.target_id,s,null,{filters:JSON.stringify(n)})):k((0,i.fy0)(e.target_id,null,s,{filters:JSON.stringify(n)}))},I=(e,t)=>{e===p?w(!t):E(!t),k((0,i.L1I)(_,e,!t))},A=(0,l.d4)(e=>e.entities.targets_management),T=(0,l.d4)(e=>e.entities.loading_analytics_popup[c.G0]),[D,R]=(0,s.useState)([]);return(0,s.useEffect)(()=>{R(A)},[A]),(0,s.useEffect)(()=>{k((0,i.k_m)({rep_id:"sales"===t?h.filter(e=>e.value===x)[0].value:"",start_stamp:(0,r.yw)(new Date(m.getFullYear(),0,1)),end_stamp:(0,r.yw)(new Date(m.getFullYear()+1,0,1))}))},[]),(0,u.jsx)("div",{"data-test-name":"SetTargetTabledWindow",className:"set-target-div",children:(0,u.jsxs)("table",{className:"table table-striped",children:[(0,u.jsx)("thead",{}),(0,u.jsxs)("tbody",{style:{border:"none"},children:["sales"===t?null:(0,u.jsxs)("tr",{className:"disable-hover",children:[(0,u.jsx)("td",{style:{backgroundColor:"#EDF4F7",width:"28%",color:"#2A4D63"},children:"Show on dashboard"}),(0,u.jsx)("td",{colSpan:2,style:{textAlign:"center"},children:(0,u.jsx)(a.LabeledCheckbox,{labelStyle:{marginRight:0},checked:j,onChange:e=>I(p,j)})}),(0,u.jsx)("td",{colSpan:2,style:{textAlign:"center"},children:(0,u.jsx)(a.LabeledCheckbox,{checked:C,onChange:e=>I("show_sales_order_targets",C)})})]}),(0,u.jsxs)("tr",{style:{color:"#2A4D63"},className:"disable-hover",children:[(0,u.jsx)("td",{style:{backgroundColor:"#EDF4F7",width:"28%"},children:(0,u.jsx)(a.LabeledSelect,{isDisabled:"sales"===t,style:{color:"#2A4D63"},name:"rep_user",options:[{label:"All Reps",value:""}].concat(h),value:y,onChange:e=>(e=>{f(e);const t=b.value?b.value:m.getFullYear();k((0,i.k_m)({rep_id:e.value,start_stamp:(0,r.yw)(new Date(t,0,1)),end_stamp:(0,r.yw)(new Date(t+1,0,1))}))})(e)})}),(0,u.jsx)("td",{colSpan:2,style:{fontWeight:"bold",textAlign:"center"},children:"Invoices"}),(0,u.jsx)("td",{colSpan:2,style:{fontWeight:"bold",textAlign:"center"},children:"Sales Orders in Production"})]}),(0,u.jsxs)("tr",{style:{color:"#2A4D63"},className:"disable-hover",children:[(0,u.jsx)("td",{style:{backgroundColor:"#EDF4F7",width:"28%"},children:(0,u.jsx)(a.LabeledSelect,{name:"year",options:c.Wg,value:b,onChange:e=>{return v(t=e),void k((0,i.k_m)({rep_id:y.value,start_stamp:(0,r.yw)(new Date(t.value,0,1)),end_stamp:(0,r.yw)(new Date(t.value+1,0,1))}));var t}})}),(0,u.jsx)("td",{style:{textAlign:"center"},children:"Target"}),(0,u.jsxs)("td",{style:{textAlign:"center"},children:["Last Year ",(0,u.jsx)("br",{}),"(actual)"]}),(0,u.jsx)("td",{style:{textAlign:"center"},children:"Target"}),(0,u.jsxs)("td",{style:{textAlign:"center"},children:["Last Year ",(0,u.jsx)("br",{}),"(actual)"]})]}),T?c.yz.map((e,t)=>(0,u.jsxs)("tr",{style:{color:"#2A4D63"},children:[(0,u.jsx)("td",{style:{padding:"0rem 0rem 1rem 0.6rem",backgroundColor:"#EDF4F7"},children:e}),0===t?(0,u.jsxs)("td",{rowSpan:6,colSpan:4,children:[(0,u.jsx)(a.Loading,{}),(0,u.jsx)("p",{style:{padding:10,margin:0,textAlign:"center",color:"#00A0B6",fontSize:"1.3rem"},children:"Loading..."})]}):(0,u.jsx)(u.Fragment,{})]},t)):(0,u.jsxs)(u.Fragment,{children:[null==D?void 0:D.map((e,n)=>(0,u.jsxs)("tr",{style:{color:"#2A4D63"},children:[(0,u.jsx)("td",{style:{padding:"2px 8px",backgroundColor:"#EDF4F7"},children:e.month}),(0,u.jsx)("td",{style:{padding:"2px 8px"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:""===y.value||"sales"===t,style:{color:""===y.value||"sales"===t?"#899CA9":"#2A4D63"},name:"sales_target_value",value:e.invoice_target,onChange:e=>{const t=e.target.value;R(e=>e.map((e,a)=>a===n?{...e,invoice_target:t}:e))},onBlur:t=>S(e,t),onFocus:e=>e.target.select()})}),(0,u.jsx)("td",{style:{padding:"0rem 1rem 0rem 0.3rem"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:!0,readOnly:!0,value:(0,c.bZ)(e.invoice_value)})}),(0,u.jsx)("td",{style:{padding:"0rem 0rem 0rem 1rem"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:""===y.value||"sales"===t,style:{color:""===y.value||"sales"===t?"#899CA9":"#2A4D63"},name:"in_production_target_value",value:e.sales_orders_target,onCh
43ange:e=>{const t=e.target.value;R(e=>e.map((e,a)=>a===n?{...e,sales_orders_target:t}:e))},onBlur:t=>S(e,t),onFocus:e=>e.target.select()})}),(0,u.jsx)("td",{style:{padding:"0rem 1.6rem 0rem 0.3rem"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:!0,readOnly:!0,value:(0,c.bZ)(e.sales_orders_value)})})]})),(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{style:{padding:"0rem 0rem 0rem 8px",backgroundColor:"#EDF4F7"},children:(0,u.jsx)("b",{children:"Total"})}),(0,u.jsx)("td",{style:{padding:"4px 8px"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:!0,name:"sales_target_total",readOnly:!0,value:(0,c.bZ)(null==D?void 0:D.reduce((e,t)=>(parseInt(t.invoice_target.replaceAll(",",""))||0)+e,0))})}),(0,u.jsx)("td",{style:{padding:"0rem 1rem 0rem 0.3rem"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:!0,readOnly:!0,value:(0,c.bZ)(null==D?void 0:D.reduce((e,t)=>parseInt(t.invoice_value)+e,0))})}),(0,u.jsx)("td",{style:{padding:"0rem 0rem 0rem 1rem"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:!0,readOnly:!0,name:"in_production_total",value:(0,c.bZ)(null==D?void 0:D.reduce((e,t)=>(parseInt(t.sales_orders_target.replaceAll(",",""))||0)+e,0))})}),(0,u.jsx)("td",{style:{padding:"0rem 1.6rem 0rem 0.3rem"},children:(0,u.jsx)(a.LabeledInput,{noMargin:!0,disabled:!0,readOnly:!0,value:(0,c.bZ)(null==D?void 0:D.reduce((e,t)=>parseInt(t.sales_orders_value)+e,0))})})]})]})]})]})})}},38506(e,t,n){n.d(t,{A:()=>i});var a=n(41594),s=n(18265),l=n(98483),o=n(3915);function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"DISTRIBUTOR";const n=(0,l.wA)(),i=(0,l.d4)(e=>e.companyGeneralDataById),r="SUPPLIER"===t?"supplier":"tenant",c=(0,a.useCallback)(()=>{n((0,s.bQ)(e,r)),n((0,s.Zr)(e))},[n,e,r]);(0,a.useEffect)(()=>{i.data.active||c()},[c,i.data.active]);const d=(0,a.useCallback)(function(t){let a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(async()=>{try{await n((0,s.O6)(e,r,t)),a&&o.oR.success("Saved successfully")}catch(e){o.oR.error("Cannot save Company data",{autoClose:!1}),c()}})()},[n,e,r,c]),u=(0,a.useCallback)(t=>{let{featureId:a,paymentModel:l,syncChangesStripe:i,stripePriceId:r,renewalDate:d,showToast:u=!0}=t;return(async()=>{try{await n((0,s.O9)(e,a,l,i,r,d)),u&&o.oR.success("Saved successfully")}catch(e){o.oR.error("Cannot save Feature Level",{autoClose:!1}),c()}})()},[n,e,c]);return{company:i.data,loading:i.loading,save:d,saveFeature:u}}},21519(e,t,n){n.d(t,{Ay:()=>b,B5:()=>x,LD:()=>y,Tp:()=>f,UK:()=>g,fk:()=>_});var a=n(23204),s=n(22078),l=n(24087);const o=(0,a.pU)({selectId:e=>e.commission_client_rate_id,sortComparer:(e,t)=>(e.client_rate_label+String(e.multiplier)).localeCompare(t.client_rate_label+String(t.multiplier))}),i=(0,l.rh)("commissionClientRates",o),{added:r,deleted:c,loading:d,loaded:u,received:m,updated:p}=i.actions,h="commission-client-rate",g=()=>async(e,t)=>{e(d());const n=await(0,s.oD)("GET",h,{});return e(m(n.json.commission_client_rates)),n.json},x=e=>async(t,n)=>{t(d());const a=await(0,s.oD)("POST",h,e);return t(r(Object.assign(a.json.commission_client_rate,{new:!0}))),t(u()),a.json.commission_client_rate},_=e=>async(t,n)=>{console.log("Update",e),t(d());const a=await(0,s.oD)("PUT",h+"/"+e.commission_client_rate_id,e);return t(p({id:e.commission_client_rate_id,changes:e})),t(u()),a.json.commission_client_rate},y=e=>async(t,n)=>{console.log("delete",e),t(d());try{await(0,s.oD)("DELETE",h+"/"+e.commission_client_rate_id,{})}catch(e){return console.log("Failed to delete"),!1}return console.log("deleted",e),t(c(e.commission_client_rate_id)),t(u()),!0},f=o.getSelectors(),b=i.reducer},24087(e,t,n){n.d(t,{Jz:()=>l,R9:()=>i,rh:()=>o});var a=n(23204),s=n(22078);const l=()=>(0,a.pU)({selectId:e=>e.account_status_id,sortComparer:(e,t)=>(e.account_status_name+e.account_status_id).localeCompare(t.account_status_name+t.account_status_id)}),o=(e,t)=>(0,a.Z0)({name:e,initialState:t.getInitialState({loading:"idle"}),reducers:{added:t.addOne,deleted:t.removeOne,loading(e,t){"idle"===e.loading&&(e.loading="pending")},loaded(e,t){"pending"===e.loading&&(e.loading="idle")},received(e,n){"pending"===e.loading&&(t.setAll(e,n.payload),e.loading="idle")},updated:t.updateOne}}),i=function(e){let{loading:t,received:n,added:a,loaded:l,updated:o,deleted:i}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"CLIENT";return{getAll:()=>async(e,a)=>{e(t());const l=await(0,s.oD)("GET","account-status",{company_type:r});return e(n(l.json.account_statuses)),l.json},addItem:e=>async(n,o)=>{n(t());const i=await(0,s.oD)("POST","account-status",e);return n(a(Object.assign(i.json.account_status,{new:!0}))),n(l()),i.json.account_status},updateItem:e=>async(n,a)=>{console.log(r,"Update client status",e),n(t());const i=await(0,s.oD)("PUT","account-status",e);return n(o({id:e.account_status_id,changes:i.json.account_status})),n(l()),i.json.account_status},deleteItem:e=>async(n,a)=>{n(t());try{await(0,s.oD)("DELETE","account-status/"+e.account_status_id,{})}catch(e){return console.log("Failed to delete"),!1}return n(i(e.account_status_id)),n(l()),!0}}}},61990(e,t,n){n.d(t,{Ay:()=>g});var a=n(22224),s=n.n(a),l=n(23204),o=n(75174);n(22078);const i=(0,l.Z0)({name:"users",initialState:{data:{},loading:{},errors:{}},reducers:{setUsers(e,t){e.data=t.payload},fetchUsersSuccess(e,t){e.data=t.payload.reduce((e,t)=>
43({...e,[t.user_id]:t}),{})},fetchUserSuccess(e,t){e.data={...e.data,[t.payload.user_id]:{...e.data[t.payload.user_id]||{},...t.payload}}},usersFailure(e,t){e.errors=t.payload},setLoading(e,t){e.loading=t.payload},updateLoading(e,t){e.loading={...e.loading,...t.payload}}}}),{setUsers:r,fetchUsersSuccess:c,fetchUserSuccess:d,usersFailure:u,setLoading:m,updateLoading:p}=i.actions,h=e=>s().get(e,["users","data"],{}),g=((0,o.Mz)(h,e=>e),(0,o.Mz)(e=>e.users.loading,e=>e),(0,o.Mz)(e=>e.users.errors,e=>e),(0,o.Mz)(h,e=>Object.values(e).map(e=>({label:e.contact_full_name,value:e.user_id}))),(0,o.Mz)(h,e=>Object.values(e).filter(e=>!!e.user_mask).map(e=>({...e,mask:e.user_mask}))),i.reducer)}}]); 44//# sourceMappingURL=AdminSettingsNewApp.759419f0.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.