1"use strict";(globalThis.__LOADABLE_LOADED_CHUNKS__=globalThis.__LOADABLE_LOADED_CHUNKS__||[]).push([[6438],{97836(e,t,r){r.d(t,{A:()=>o}),r(41594);var a=r(3602),s=r(63988);function o(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})}},62611(e,t,r){r.d(t,{A:()=>L});var a=r(22224),s=r.n(a),o=r(75206),n=r.n(o),l=r(41594),i=r.n(l),d=r(3602),p=r(98483),_=r(46676),c=r(28363),u=r(22078),y=r(83176),g=r(20001),S=r(60794),m=(r(4439),r(93664)),h=r(67564),T=r(63988);const O=e=>e.order_date_created||e.date_created||"";h.Al.getElementById("root")||h.Al.getElementById("resku");var E=r(51405),b=r(84685),A=r(38718),x=r(58199),P=r(77962);function R(e){return"object"==typeof e&&s().keys(e).length>0}const v=e=>{let{row:t,style:r={}}=e;return(0,T.jsx)("div",{"data-test-name":"ProjectRepsPics",style:r,children:(0,T.jsxs)(E.Al,{children:[(0,T.jsx)(E.Ay,{backgroundColor:d.colors.primary,name:t.original.client_rep_full_name||"Client Rep","data-tip":t.original.client_rep_full_name||"Client Rep","data-for":"client-rep-avatar",...R(t.original.client_rep_file)?{src:(0,u.AE)(t.original.client_rep_file)}:R(t.original.client_rep_user_image_path)?{user_image_paths:t.original.client_rep_user_image_paths}:{}}),(0,T.jsx)(E.Ay,{backgroundColor:t.original.sales_rep_id!==t.original.client_rep_id?d.colors.primary200:d.colors.primary,name:t.original.order_rep_full_name||"Order Rep","data-tip":t.original.order_rep_full_name||"Order Rep","data-for":"sales-rep-avatar",...R(t.original.order_rep_file)?{src:(0,u.AE)(t.original.order_rep_file)}:R(t.original.order_rep_user_image_paths)?{user_image_paths:t.original.order_rep_user_image_paths}:{}})]})})},I=e=>{let{row:t,style:r={}}=e;return(0,T.jsxs)("div",{style:r,children:[(0,T.jsxs)(d.Link,{as:"a",href:`/project/${t.original.job_number}`,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),children:[t.original.job_number," - ",t.original.job_name]}),(0,T.jsx)("span",{style:{display:"block"},children:t.original.client_name})]})},f=e=>{let{row:t,style:r={}}=e;const a=(0,p.d4)(e=>s().get(e.entities.statuses,[t.original.status_id])||P.Tp.byId(e,t.original.status_id));return(0,T.jsxs)("div",{"data-test-name":"ProjectStage",style:r,children:[(0,T.jsx)("span",{style:{display:"inline-block"},children:(0,T.jsx)(d.CircleProgressIcon,{percentage:s().get(c.Y$,[t.original.order_type,"order"],0)/5*100,text:"In"===c.fz[t.original.order_type]?"â":c.fz[t.original.order_type],textStyle:"In"===c.fz[t.original.order_type]?{fontSize:28}:{}})}),(0,T.jsxs)("span",{style:{display:"inline-block",paddingLeft:"10px",verticalAlign:"top",paddingTop:10},children:[(0,T.jsx)(d.Text,{style:{display:"block"},children:t.original.order_type}),(0,T.jsx)("span",{style:{display:"block"},children:s().get(a,"status_name","")||t.original.status_name})]})]})},C=i().memo(e=>{let{row:t,value:r,onUpdateData:a,report_type:o,style:n={}}=e;const[i,p]=(0,l.useState)(r),_=o===g.mG.PROJECTS_WITH_NO_BUDGET.type;return(0,l.useEffect)(()=>{p(r)},[r]),(0,T.jsx)("div",{style:n,onClick:e=>{_&&(e.preventDefault(),e.stopPropagation())},children:_?(0,T.jsx)(d.LabeledIconInput,{name:`project-budget-${s().get(t,["original","job_id"],"")}`,Icon:(0,T.jsx)(d.DollarIcon,{style:{paddingLeft:8,paddingRight:0}}),value:i,onChange:e=>p(e.target.value),onBlur:e=>{a&&a({job_id:t.original.job_id,order_id:t.original.order_id,field:"total_budget",value:e.target.value,previous_value:t.original.total_budget})}}):(0,T.jsx)(d.Text,{style:{display:"block",color:d.colors.special2},children:(0,u.Y6)(i)})})}),j=e=>{let{row:t,value:r,onUpdateData:a,report_type:s,style:o={}}=e;const[n,i]=(0,l.useState)(r),d=s===g.mG.OVERDUE_IN_HANDS_DATE_PROJECTS.type;(0,l.useEffect)(()=>{i(r)},[r]);const p=n?(0,u.yw)(new Date((0,u._U)(n))):"";return(0,T.jsx)("div",{"data-test-name":"ProjectInHandsDate",style:o,onClick:e=>{d&&(e.preventDefault(),e.stopPropagation())},children:d?(0,T.jsx)(y.Ay,{customInput:(0,T.jsx)(y.B_,{date:n}),showMonthDropdown:!0,showYearDropdown:!0,value:n,onChange:e=>{a&&a({job_id:t.original.job_id,order_id:t.original.order_id,field:"date_inhandsdate",value:e,previous_value:t.original.date_inhandsdate,index:t.index})},portalId:"root-portal",style:{width:"100%"}}):(0,T.jsx)("span",{children:p})})},D=e=>{let{row:t,value:r,style:a={}}=e;return(0,T.jsx)("div",{"data-test-name":"ProjectDateCreated",style:a,children:(0,T.jsx)("span",{children:r?(0,u.yw)(new Date((0,u._U)(r))):""})})},N=h.Al.getElementById("root")||h.Al.getElementById("resku"),L=e=>{let{report_type:t,loadReportTotal:r,showDateCreated:a=!1,defaultSort:o={id:"date_inhandsdate",desc:!0}}=e;const c=(0,p.wA)();let y=m.h6.includes(t);const h=(0,p.d4)(e=>y?e.entities.analytics_report_data[t]:e.reports.data[t]),E=(0,p.d4)(e=>y?e.entities.loading_analytics_popup[t]:g.Tp.loading(e)[t]),R=(0,A.A)()[1],[L,k]=(0,l.useState)(!1),[U,w]=(0,l.useState)(!1),F=i().useMemo(()=>(h?h.data:[])||[],[h,t]);(0,l.useEffect)(()=>{c((0,P.ug)())},[c]),(0,l.useEffect)(()=>{(0,b.W1)(),w(!1)},[F]);const W=i().useMemo(()=>
1{if(!L)return L;return s().find(F,e=>e.job_id===L.job_id&&e.order_id===L.order_id)||L},[L,F]),G=i().useCallback(e=>k(e),[]),V=i().useCallback((e,a)=>{let{job_id:s,order_id:o,field:n,index:l}=a;w(!0);const i={job_id:s,order_id:o,[n]:e[n]};return"date_inhandsdate"===n?i.order_date_inhandsdate=e[n]:"total_budget"===n&&(["SALES ORDER","INVOICE"].includes(e.order_type)?i.total_subtotal=e[n]:i.total_budget=e[n]),c(y?(0,x.$a9)({index:l,job_id:s,report_type:t,data:i}):(0,g.xb)({index:l,job_id:s,report_type:t,data:i})),["date_inhandsdate","total_budget","order_type","status_id"].includes(n)&&r&&r(t),e},[c,y,r,t]),$=i().useCallback(e=>{let{job_id:t,order_id:r,field:a,value:s,previous_value:o,index:n,shouldRemoteUpdate:l=!0}=e;l?(0,u.oD)("PUT",["date_inhandsdate","status_id"].includes(a)?`order/${r}`:`project/${t}`,{[a]:s}).then(e=>{let{json:s}=e;const o=s.order||s.project;return V(o,{job_id:t,order_id:r,field:a,index:n}),o}):V({job_id:t,order_id:r,field:a,index:n,[a]:s},{job_id:t,order_id:r,field:a,index:n})},[V]),B=i().useMemo(()=>[{Header:()=>(0,T.jsx)("div",{children:"Client & Order Rep"}),accessor:e=>`${e.order_rep_full_name} ${e.client_rep_full_name}`,sticky:"left",Cell:v,noDrag:!0,minWidth:175,maxWidth:500,id:"sales_rep_id"},{Header:()=>(0,T.jsx)("div",{children:"Project"}),accessor:e=>`${e.job_number}-${e.job_name} ${e.client_name}`,Cell:I,sticky:"left",noDrag:!0,minWidth:280,maxWidth:500,id:"job_id"},{Header:()=>(0,T.jsx)("div",{children:"Stage"}),accessor:e=>`${e.order_type} ${e.status_id}`,Cell:f,sticky:"left",noDrag:!0,minWidth:270,maxWidth:500,id:"order_type"},{Header:()=>(0,T.jsx)("div",{children:"Budget/Total"}),accessor:e=>function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return["SALES ORDER","INVOICE"].includes(e.order_type)?Object.values(m.eo.MARGIN_BY_CLIENT.type).includes(t)?e.total_margin_amount:e.total_subtotal:e.total_budget}(e,t),Cell:C,sticky:"left",noDrag:!0,minWidth:140,maxWidth:500,id:"total_budget"},{Header:()=>(0,T.jsx)("div",{children:"In-Hands Date"}),accessor:e=>(e=>e.order_date_inhandsdate||e.date_inhandsdate||"")(e),Cell:j,sticky:"left",noDrag:!0,minWidth:210,maxWidth:500,id:"date_inhandsdate"}].concat(a?[{Header:()=>(0,T.jsx)("div",{children:"Created Date"}),accessor:O,Cell:D,sticky:"left",noDrag:!0,minWidth:210,maxWidth:500,id:"date_created"}]:[]),[a,t]),M=(0,l.useCallback)(e=>L&&L.job_id===e.job_id&&L.order_id===e.order_id?k(!1):k(e),[L]),Y=i().useMemo(()=>R<251?100:R<351?150:R<540?R-280:R<700?R-350>450?450:R-350:R<850?R-300>450?450:R-300:500,[R]),H=i().useCallback(()=>k(!1),[]),J=i().useMemo(()=>s().get(W,["job_id"],null),[W]),z=i().useMemo(()=>"INVOICE"!==s().get(W,["order_type"],null)?"":s().get(W,["order_id"],null),[W]);return(0,T.jsxs)(T.Fragment,{children:[n().createPortal((0,T.jsx)(S.A,{project:W,onClose:H,onUpdate:$,isAnalytics:y,projectId:J,orderId:z,loading:E}),N),(0,T.jsxs)(d.SimpleWindowedTableStyles,{rowClickable:!0,style:E?{display:"none"}:{},children:[(0,T.jsx)(d.SimpleWindowedTable,{columns:B,data:F,defaultSort:o,onClickRow:M,onScroll:b.W1,onUpdateData:$,useTableProps:{autoResetPage:!U,autoResetGroupBy:!U,autoResetSortBy:!U,autoResetFilters:!U,autoResetRowState:!U,report_type:t,onClickProject:G},height:Y}),(0,T.jsx)(_.default,{id:"client-rep-avatar"}),(0,T.jsx)(_.default,{id:"sales-rep-avatar"})]}),E?(0,T.jsx)(d.Row,{children:(0,T.jsx)(d.Col,{xs:!0,style:{alignSelf:"100%",textAlign:"center"},children:(0,T.jsx)(d.Loading,{})})}):null]})}},13404(e,t,r){r.d(t,{Ay:()=>p,Pl:()=>i});var a=r(41594),s=r.n(a),o=r(3602),n=(r(22224),r(63988));const l={color:"#0f3d51",fontSize:"1em",fontWeight:"bold"},i=e=>{let{color:t="primary",startText:r="",highlightText:a,endText:s="",style:i={},children:d}=e;return(0,n.jsxs)("span",{style:{...l,...i},children:[r," ",(0,n.jsx)("span",{style:{color:"cta"===t?o.colors.cta:o.colors.primary,borderBottom:"dashed"},children:a})," ",s,d]})},d=e=>{let{colSizes:t={xs:12},title:r,value:a,components:s={},id:i="",boxStyle:d={},boxHeight:p={},..._}=e;return(0,n.jsx)(o.Col,{"data-test-name":"WidgetCardBox",padded:!0,...t,children:(0,n.jsx)(o.Box,{padded:!0,style:{padding:20,marginTop:0,...d,...p},children:(0,n.jsxs)(o.Row,{style:{width:"100%"},children:[(0,n.jsxs)(o.Col,{xs:12,style:{paddingBottom:10},children:[s.Title||(0,n.jsx)("span",{style:l,children:r}),(0,n.jsx)(o.Wrapper,{style:{float:"right",maxWidth:35,width:35},px:10,id:"export_menu_"+i,className:"custom-tools",custom:"\n & > ul {\n top: auto !important;\n bottom: auto !important;\n right: auto !important;\n left: auto !important;\n position: inherit !important;\n float: right !important;\n }\n "})]}),_.children]})})})},p=s().memo(d)},77777(e,t,r){r.d(t,{Ay:()=>w,CM:()=>B,M9:()=>H,Oi:()=>D,PL:()=>$,S7:()=>M,YJ:()=>v,_5:()=>J,ot:()=>V,ue:()=>i,yj:()=>Y});var a=r(22224),s=r.n(a),o=r(23204),n=r(22078),l=r(28363);const i={entities:{reports:{supplierPOs:{totals_by_totals:{},totals_by_tenant:{},totals_by_supplier:{},totals_by_order_rep:{},totals_by_client_rep:{}},supplierEvents:{totals_by_totals:{},totals_by_tenant:{},totals_by_supplier:{},totals_by_product:{},totals_by_industry:{},totals_by_events:{}},supplierProducts:{totals_by_product:{}},supplierPresales:{totals_by_order_rep:{},totals_by_client_rep:{}}},billing_periods:{},tenants:{},suppliers:{},supplier_tags:[],products:{},supplierPOs:[],supplierEvents:[],supplierProducts:[],supplierPresales:[]},loading:{supplierPOStats:!1,supplierEventStats:!1,supplierPOs:!1,supplierEvents:!1,supplierStats:!1,supplierProducts:!1,supplierPresales:!1,billing_periods:!1}},d=(0,o.Z0)({name:"dashboard",initialState:i,reducers:{setLoading(e,t){e.loading={...e.loading,...t.payload}},fetchBillingPeriodsSuccess(e,t){var r;e.entities.billing_periods=(null!==(r=t.payload)&&void 0!==r?r:[]).reduce((e,t)=>
1({...e,[t.billing_period_id]:t}),{})},fetchBillingPeriodsFailure(e,t){e.entities.billing_periods=!1},fetchSupplierPresalesSuccess(e,t){let r=s().get(t.payload,"data",[]);const a=s().get(t.payload,"params",{}),o=a.group_by,n=a.totals_by,l=a.with_others;if(o)if(["totals","tags","tenants_count"].includes(n)){let e=!0;["tags","tenants_count"].includes(n)&&(e=!1);const{data:t,years:s,labels:l}=W([...r],o,{...a,totals_by:n,sortByCurrent:e});r={[`totals_by_${n}`]:{data:t,years:s,labels:l}}}else if(n){const e=G([...r],{totals_by:n,group_by:o,until:s().get(a,"until",25),with_others:l});r={[`totals_by_${n}`]:{data:e}}}else r={data:r};else r=["totals","tags","tenants_count"].includes(n)?{[`totals_by_${n}`]:{data:r}}:n?{[`totals_by_${n}`]:{data:r}}:{data:r};return e.entities.reports.supplierPresales={...e.entities.reports.supplierPresales,...r},e},fetchSupplierProductsSuccess(e,t){let r=s().get(t.payload,"data",[]);const a=s().get(t.payload,"params",{}),o=a.group_by,n=a.totals_by,l=a.with_others;if(o)if(["totals","tags","tenants_count"].includes(n)){let e=!0;["tags","tenants_count"].includes(n)&&(e=!1);const{data:t,years:s,labels:l}=W([...r],o,{...a,totals_by:n,sortByCurrent:e});r={[`totals_by_${n}`]:{data:t,years:s,labels:l}}}else if(n){const e=G([...r],{totals_by:n,group_by:o,until:s().get(a,"until",25),with_others:l});r={[`totals_by_${n}`]:{data:e}}}else r={data:r};else r=["totals","tags","tenants_count"].includes(n)?{[`totals_by_${n}`]:{data:r}}:n?{[`totals_by_${n}`]:{data:r}}:{data:r};return e.entities.reports.supplierProducts={...e.entities.reports.supplierProducts,...r},e},fetchSupplierPOStatsSuccess(e,t){let r=s().get(t.payload,"data",[]);const a=s().get(t.payload,"params",{}),o=a.group_by,n=a.totals_by,l=a.with_others;if(o)if(["totals","tags","tenants_count"].includes(n)){let e=!0;["tags","tenants_count"].includes(n)&&(e=!1);const{data:t,years:s,labels:l}=W([...r],o,{...a,totals_by:n,sortByCurrent:e});r={[`totals_by_${n}`]:{data:t,years:s,labels:l}}}else if(n){const e=G([...r],{totals_by:n,group_by:o,until:s().get(a,"until",25),with_others:l});r={[`totals_by_${n}`]:{data:e}}}else r={data:r};else r=["totals","tags","tenants_count"].includes(n)?{[`totals_by_${n}`]:{data:r}}:n?{[`totals_by_${n}`]:{data:r}}:{data:r};return e.entities.reports.supplierPOs={...e.entities.reports.supplierPOs,...r},e},fetchSupplierPOStatsFailure(e,t){},fetchSupplierProductsFailure(e,t){},fetchSupplierPresalesFailure(e,t){},fetchSupplierEventStatsSuccess(e,t){let r=s().get(t.payload,"data",[]);const a=s().get(t.payload,"params",{}),o=a.group_by,n=a.totals_by,l=a.with_others;if(o)if(["totals","tags","tenants_count"].includes(n)){let e=!0;["tags","tenants_count"].includes(n)&&(e=!1);const{data:t,years:s,labels:l}=W([...r],o,{...a,totals_by:n,sortByCurrent:e});r={[`totals_by_${n}`]:{data:t,years:s,labels:l}}}else if(n){const e=G([...r],{totals_by:n,group_by:o,until:s().get(a,"until",25),with_others:l});r={[`totals_by_${n}`]:{data:e}}}else r={data:r};else r=["totals","tags","tenants_count"].includes(n)?{[`totals_by_${n}`]:{data:r}}:n?{[`totals_by_${n}`]:{data:r}}:{data:r};return e.entities.reports.supplierEvents={...e.entities.reports.supplierEvents,...r},e},fetchSupplierEventStatsFailure(e,t){},fetchSupplierPOsSuccess(e,t){e.entities.supplierPOs=t.payload},fetchSupplierPOsFailure(e,t){},fetchSupplierEventsSuccess(e,t){e.entities.supplierEvents=t.payload},fetchSupplierEventsFailure(e,t){},fetchTenantsSuccess(e,t){e.entities.tenants={...e.entities.tenants,...t.payload}},fetchTenantsFailure(e,t){},fetchSuppliersSuccess(e,t){e.entities.suppliers={...e.entities.suppliers,...t.payload}},fetchSuppliersFailure(e,t){},fetchSupplierTagsSuccess(e,t){e.entities.supplier_tags=(0,n.i2)(t.payload,"tag_id")},fetchSupplierTagsFailure(e,t){},fetchProductsSuccess(e,t){t.payload.append?e.entities.products={...e.entities.products,...t.payload.products}:e.entities.products=t.payload},fetchProductsFailure(e,t){},updateProductState(e,t){e.entities.products={...e.entities.products,[t.payload.product_id]:t.payload.product}},updateProductsState(e,t){e.entities.products={...e.entities.products,...t.payload}},clearSupplierPOsState(e,t){e.entities.supplierPOs=[]},clearSupplierEventsState(e,t){e.entities.supplierEvents=[]}}}),{setLoading:p,fetchSupplierPOsSuccess:_,fetchSupplierPOsFailure:c,fetchSupplierEventsSuccess:u,fetchSupplierEventsFailure:y,fetchSupplierPOStatsSuccess:g,fetchSupplierPOStatsFailure:S,fetchSupplierEventStatsSuccess:m,fetchSupplierEventStatsFailure:h,fetchTenantsSuccess:T,fetchTenantsFailure:O,fetchSuppliersSuccess:E,fetchSuppliersFailure:b,fetchSupplierTagsSuccess:A,fetchSupplierTagsFailure:x,fetchProductsSuccess:P,fetchProductsFailure:R,updateProductState:v,updateProductsState:I,fetchBillingPeriodsSuccess:f,fetchBillingPeriodsFailure:C,clearSupplierPOsState:j,clearSupplierEventsState:D,fetchSupplierProductsSuccess:N,fetchSupplierProductsFailure:L,fetchSupplierPresalesSuccess:k,fetchSupplierPresalesFailure:U}=d.actions,w={[d.name]:d.reducer};function F(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{keys:t=[],data:r=[],year:a=l.Ec.getFullYear(),month:o="01",group_by:n=!1,group:i=!1,gr_by_val:d=!1,i:p=!1,j:_=!1}=e||{},c=s().includes(t,i),u=(window.location.pathname,"month"===n&&0===p&&l.Y_.includes(d)),y="quarter"===n&&0===p&&l._Y.includes(d);return c||u||y||(r[i]={tenant_counts:"0",group_by:i,total:"0",totals:"0",date_created:`${a}-${o}-01 10:01:01`,original:!1,[`y${p+1}`]:"0",[`y${p+1}_totals`]:"0",[`y${p+1}_group_by`]:d,[`y${p+1}_tenant_counts`]:"0",year:a,fillOpacity:.7,categoryX:d}
1),r[i]&&(r[i]={...r[i],[`y${p+1}`]:r[i].totals,[`y${p+1}_totals`]:r[i].totals,[`y${p+1}_tenant_counts`]:r[i].tenant_counts,[`y${p+1}_group_by`]:d,[`y${p+1}_year`]:a,year:a,fillOpacity:.7,...s().get(e,"extraOptions",{}),categoryX:d},"month"!=n&&"quarter"!=n||(r[i][`y${p+1}_gr${_+1}`]=r[i].totals),("month"==n&&l.Ec.getMonth()==_||"quarter"==n&&(0,l.I)(l.Ec.getMonth())==d||"year"==n&&l.Ec.getFullYear()==a)&&(r[i].fillOpacity=1)),s().get(r,i,null)}function W(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{sortByCurrent:!0,totals_by:""},a=[],o={};const n=r.date_to?r.date_to.split("-")[0]:l.Ec.getFullYear()+"",i=parseInt(n),d=[n,i-1+"",i-2+""],p=[];let _={};s().forEach(e,e=>{e.group_by=String(e.group_by);const t=e.group_by.split(" ").length>1?e.group_by.split(" ")[1]:e.group_by.split(" ")[0];s().includes(d,t)||d.push(t),s().includes(p,e.group_by)||p.push(e.group_by),o[e.group_by]={...e,year:t}}),d.sort((e,t)=>t-e);const c={totals_by:r.totals_by,group_by:t,keys:p,data:o};return s().forEach(d,(e,r)=>
1{"month"==t?s().forEach(l.US,(t,a)=>{F({i:r,j:a,group:`${t} ${e}`,year:e,gr_by_val:t,month:t,...c})}):"quarter"==t?s().forEach(l.GM,(t,a)=>{F({i:r,j:a,group:`${t} ${e}`,year:e,gr_by_val:t,month:t,...c})}):"year"==t&&F({i:r,group:e,year:e,gr_by_val:e,month:"01",...c})}),Object.keys(o).sort((e,a)=>{if("month"==t){let t=l.US;return r.sortByCurrent&&(t=l.Vl),t.indexOf(e.split(" ")[0])-t.indexOf(a.split(" ")[0])}if("quarter"==t){let t=l.GM;return r.sortByCurrent&&(t=l.Rw),t.indexOf(e.split(" ")[0])-t.indexOf(a.split(" ")[0])}return e.split(" ")-a.split(" ")[0]}).forEach(e=>_[e]=o[e]),"month"==t?a=l.US:"quarter"==t?a=l.GM:"year"==t&&(a=d),{data:_,labels:a,years:d}}function G(e,t){let{totals_by:r,group_by:a,until:o=10,with_others:i}=t;const d="quarter"==a?(0,l.I)(l.Ec.getMonth()):"month"==a?l.Ec.getMonth():l.Ec.getFullYear(),p=s().filter(e,e=>(e.group_by=String(e.group_by),"month"==a?l.US[d]==e.group_by.split(" ")[1]:"quarter"==a?"Q"+d==e.group_by.split(" ")[1]:d==e.group_by.split(" ")[1])),_=l.US[0==d?11:d-1],c=0==d?l.Ec.getFullYear()-1:l.Ec.getFullYear(),u="Q"+(1==d?4:d-1),y=1==d?l.Ec.getFullYear()-1:l.Ec.getFullYear(),g=d-1,S=s().filter(e,e=>(e.group_by=String(e.group_by),"month"==a?_==e.group_by.split(" ")[1]&&c==e.group_by.split(" ")[2]:"quarter"==a?u==e.group_by.split(" ")[1]&&y==e.group_by.split(" ")[2]:g==e.group_by.split(" ")[1])),m={defaultImage:["tenant","tenants_count","order_rep","order_client_rep","industry","events"].includes(r)?"/images/user-avatar3-36x36.png":"/images/404.png"};return r&&(e=p.map((e,t)=>({gr1_subData:e.subData,gr1_totals:e.totals,gr1_tenant_name:e.tenant_name,[`gr1_${r}_name`]:e[`${r}_name`],gr1_img_src:(0,n.AE)(s().get(e,"file",{}),"small",m),[`gr1_${r}_id`]:e[`${r}_id`],gr1_group_by:String(e.group_by),gr1_group:d,gr1:"month"==a?l.US[d]:"quarter"==a?"Q"+d:String(d),hidden:t>25,isActive:e.active,tooltipText:0==e.active?"This rep is no longer active with commonsku.":"",opacity:0==e.active?.4:1})).concat(S.map((e,t)=>({gr2_subData:e.subData,gr2_totals:e.totals,gr2_tenant_name:e.tenant_name,[`gr2_${r}_name`]:e[`${r}_name`],gr2_img_src:(0,n.AE)(s().get(e,"file",{}),"small",m),[`gr2_${r}_id`]:e[`${r}_id`],gr2_group_by:e.group_by+"",gr2_group:("month"==a?0==d?11:d-1:"quarter"==a&&1==d?4:d-1)+"",gr2:("month"==a?_:"quarter"==a?u:d-1)+"",hidden:t>25,isActive:e.active,tooltipText:0==e.active?"This rep is no longer active with commonsku.":"",opacity:0==e.active?.4:1})))),e}const V=()=>async(e,t)=>{const r=t();if(!r.dashboard.loading.billing_periods&&!1!==r.dashboard.entities.billing_periods){e(p({billing_periods:!0}));try{const{json:t}=await(0,n.oD)("GET","billing-period",{});t?t.error?e(C(t.error)):e(f(t.billing_periods)):e(C("Unable to fetch billing periods."))}catch(t){e(C("Unable to fetch billing periods."))}finally{e(p({billing_periods:!1}))}}},$=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return async t=>{const r=s().get(e,"group_by",!1),a=s().get(e,"totals_by",!1);t(p({[`SUPPLIER_POS_${a}_${r}`]:!0}));try{const{json:o}=await(0,n.oD)("INDEX","supplier-po-stat",e);if(o&&!o.error){const r=s().get(o,"pos",[]);t(g({data:r,params:e}))}else o.error?t(g(o.error)):t(S("Cannot fetch pos."));t(p({[`SUPPLIER_POS_${a}_${r}`]:!1}))}catch(e){console.error("ERROR|fetchSupplierPOStats| ",e),t(S("Cannot fetch pos."))}}},B=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return async t=>{const r=s().get(e,"group_by",!1),a=s().get(e,"totals_by",!1);t(p({[`SUPPLIER_PRESALES_${a}_${r}`]:!0}));try{const{json:r}=await(0,n.oD)("INDEX","supplier-po-stat",e);if(r&&!r.error){const a=s().get(r,"pos");t(k({data:a,params:e}))}else t(U("Cannot fetch events."))}catch(e){console.error("ERROR|fetchSupplierEventStats| ",e),t(U("Cannot fetch events."))}return t(p({[`SUPPLIER_PRESALES_${a}_${r}`]:!1})),null}},M=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return async r=>{r(p({SUPPLIER_EVENTS:!0}));try{const{json:a}=await(0,n.oD)(t?"INDEX":"GET",t?"supplier-event-stat":"supplier/get-events-data",e);if(a&&!a.error){const e=s().get(a,"events");r(u(e))}else r(y("Cannot fetch events."))}catch(e){console.error("ERROR|fetchSupplierEvents| ",e),r(y("Cannot fetch events."))}return r(p({SUPPLIER_EVENTS:!1})),null}},Y=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async r=>{r(p({product:!0}));try{r(p({product:!1}));const{json:a}=await(0,n.oD)("GET",`product/${e}`,t);if(a&&!a.error){const e=s().get(a,"product",{}),t=(0,n.i2)([e],"product_id");r(P({products:t,append:!0}))}else r(R("Cannot fetch product."))}catch(e){r(p({product:!1})),console.error("ERROR|fetchProduct| ",e),r(R("Cannot fetch product"))}}},H=function(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{type:e,totals_by:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"totals",group_by:t.group_by,c
1ompare_previous:t.compare_previous||0,tenant_id:t.tenant_id||"",limit:t.limit||"",with_others:t.with_others||0,until:t.until||"",division_id:t.division_id||"",with_tenants:t.with_tenants||"",order_rep_id:t.order_rep_id||"",order_client_rep_id:t.order_client_rep_id||"",tenant_ids:t.tenant_ids||"",supplier_account_ids:t.supplier_account_ids||"",supplier_tags:t.supplier_tags||"",date_from:t.date_from,date_to:t.date_to,month:t.month||"",quarter:t.quarter||"",year:t.year||"",prev_year:t.prev_year||"",prev_quarter:t.prev_quarter||"",prev_month:t.prev_month||"",prev_date_from:t.prev_date_from||"",prev_date_to:t.prev_date_to||""}},J=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return async t=>{function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SUPPLIER_POS",t=arguments.length>1?arguments[1]:void 0;return e.includes("SUPPLIER_POS")?S(t):e.includes("SUPPLIER_PRODUCTS")?L(t):e.includes("SUPPLIER_PRESALES")?U(t):h(t)}t(p({supplierStats:!0}));try{const a=e.map((t,r)=>{const a=H(t.type,t.totals_by,t.params);return e[r].params=a,t.type.includes("SUPPLIER_POS")||t.type.includes("SUPPLIER_PRESALES")?(0,n.oD)("INDEX","supplier-po-stat",a,null,null,null,!1):t.type.includes("SUPPLIER_EVENTS")||t.type.includes("SUPPLIER_PRODUCTS")?(0,n.oD)("INDEX","supplier-event-stat",a,null,null,null,!1):void 0}),o=await Promise.all(a);return t(p({supplierStats:!1})),o.forEach((a,o)=>{const n=e[o],i=n.type.includes("SUPPLIER_POS")||n.type.includes("SUPPLIER_PRESALES")?"pos":"events";try{const{json:e}=a;if(e&&!e.error){let r=s().get(e,i,[]);"totals"==n.totals_by&&(r=function(e,t,r){let a=e;const s={tenant_counts:"0",..."SUPPLIER_POS"===r?{totals:"0.0000",po_total:"0.0000"}:{event_count:"0",totals:"0"}};return"month"===t?e.filter(e=>-1!==(e.month_yr||"").indexOf(l.Ec.getFullYear()-1)).length>0||l.US.forEach((t,r)=>{-1===e.findIndex(e=>e.group_by==t+" "+l.Ec.getFullYear())&&a.push({month_yr:l.Ec.getFullYear()+"-"+(r+1+"").padStart(2,"0")+"-01",group_by:t+" "+l.Ec.getFullYear(),...s}),-1===e.findIndex(e=>e.group_by==t+" "+(l.Ec.getFullYear()-1))&&a.push({month_yr:l.Ec.getFullYear()-1+"-"+(r+1+"").padStart(2,"0")+"-01",group_by:t+" "+(l.Ec.getFullYear()-1),...s}),-1===e.findIndex(e=>e.group_by==t+" "+(l.Ec.getFullYear()-2))&&a.push({month_yr:l.Ec.getFullYear()-2+"-"+(r+1+"").padStart(2,"0")+"-01",group_by:t+" "+(l.Ec.getFullYear()-2),...s})}):"quarter"===t?l.GM.forEach((t,r)=>{-1===e.findIndex(e=>e.group_by==t+" "+l.Ec.getFullYear())&&a.push({month_yr:l.Ec.getFullYear()+"-"+(r+1+"").padStart(2,"0")+"-01",group_by:t+" "+l.Ec.getFullYear(),...s}),-1===e.findIndex(e=>e.group_by==t+" "+(l.Ec.getFullYear()-1))&&a.push({month_yr:l.Ec.getFullYear()-1+"-"+(r+3+"").padStart(2,"0")+"-01",group_by:t+" "+(l.Ec.getFullYear()-1),...s})}):"year"===t&&(e.filter(e=>-1!==(e.month_yr||"").indexOf(l.Ec.getFullYear()-1)).length>0||a.push({month_yr:l.Ec.getFullYear()-1+"-01-01",group_by:""+(l.Ec.getFullYear()-1),...s}),e.filter(e=>-1!==(e.month_yr||"").indexOf(l.Ec.getFullYear()-2)).length>0||a.push({month_yr:l.Ec.getFullYear()-2+"-01-01",group_by:""+(l.Ec.getFullYear()-2),...s})),a}(r,n.params.group_by,n.type)),t(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SUPPLIER_POS",t=arguments.length>1?arguments[1]:void 0;return e.includes("SUPPLIER_POS")?g(t):e.includes("SUPPLIER_PRODUCTS")?N(t):e.includes("SUPPLIER_PRESALES")?k(t):m(t)}(n.type,{data:r,params:n.params}))}else t(r(n.type,`Cannot fetch ${i}.`))}catch(e){console.error(`ERROR|fetch_${n.type}| `,e),t(r(n.type,`Cannot fetch .${i}`))}}),o}catch(e){t(p({supplierStats:!1})),console.error("ERROR|fetchMultipleSupplierStats"),console.error(e)}}}},76189(e,t,r){r.d(t,{k8:()=>ot,fz:()=>p.fz,Y$:()=>p.Y$,Ux:()=>p.Ux,pl:()=>p.pl});var a=r(22224),s=r.n(a),o=r(41594),n=r.n(o),l=r(98483),i=r(80785),d=r(3602),p=r(28363),_=r(83751),c=r(77777),u=r(22078),y=r(84685),g=r(75158),S=r(23637),m=r(63988);const h=e=>()=>window.open(`/product.php?id=${e.product_id}&source=${e.source}&sku=${e.product_supplier_code}`,"_blank"),T=e=>e.esp?e.esp.Rating:0,O=e=>{let{product_id:t,product:r,addOnClick:a=!0,showRating:o=!0}=e;return(0,m.jsx)(d.Product,{"data-test-name":"Product",product_id:t,name:r.product_name,supplier:r.supplier_name,sku:"#"+(r.product_supplier_co
1de||""),source:r.source,price:s().isNumber(r.cost1)?(0,u.up)(r.cost1):"",currency:r.currency_id,picture:r.product_img_original,onClick:a?h(r):null,rating:o?T(r):0},t)},E=n().memo(O),b=e=>"SUPPLIER"===e.company_type,A=function(e){const{product_id:t,onClosePanel:r,product_data:a,supplierStatsData:n}={product_data:{},supplierStatsData:{},...e},i=(0,l.wA)(),p=(0,g.Us)(),_=(0,l.d4)((0,S.oo)(t)),u=(0,l.d4)(S.Qi),y=(0,l.d4)(S.NE);return(0,o.useEffect)(()=>{const e=document.querySelectorAll("#root > .resku")[0];if(t){e&&(e.style.position="fixed",e.style.zIndex="100");const r=function(e){let{product_id:t,supplierStatsData:r,group_by:a="tenant"}=e;const o=s().get(r,"isPrev",!1),n={product_id:t,group_by:a};return s().get(r,"tenant_id",!1)&&(n.tenant_id=r.tenant_id),s().get(r,"division_id",!1)&&(n.division_id=r.division_id),s().get(r,(o?"prev_":"")+"year",!1)&&(n.year=r[(o?"prev_":"")+"year"]),s().get(r,(o?"prev_":"")+"month",!1)&&(n.month=r[(o?"prev_":"")+"month"]),s().get(r,"quarter",!1)&&(n.quarter=r[(o?"prev_":"")+"quarter"]),s().get(r,(o?"prev_":"")+"date_from",!1)&&(n.date_from=r[(o?"prev_":"")+"date_from"]),s().get(r,(o?"prev_":"")+"date_to",!1)&&(n.date_to=r[(o?"prev_":"")+"date_to"]),s().get(r,"type",!1)&&(n.type=r.type),n}({product_id:t,supplierStatsData:n,group_by:"tenant"});b(p)?i((0,c.S7)(r,!0)):i((0,c.yj)(t))}else e&&(e.style.position=null,e.style.zIndex=null)},[t]),(0,m.jsx)(d.SidePanel,{"data-test-name":"ProductSidepanel",style:{paddingBottom:15,overflow:"auto"},visible:t,animationDuration:t?1050:400,from:"right",height:100,title:_.product_name||a.product_name||"",fullWidthTitle:!0,backdrop:!0,bodyScrollable:!1,controls:(0,m.jsxs)(m.Fragment,{children:[b(p)?null:(0,m.jsx)(d.Button,{mr:10,onClick:h,children:"Product Page"}),(0,m.jsx)(d.Button,{onClick:()=>r(),children:"Close"})]}),children:(0,m.jsx)(d.Row,{children:t?(0,m.jsx)(m.Fragment,{children:b(p)?(0,m.jsx)(d.Col,{xs:!0,padded:!0,children:(0,m.jsxs)(d.Table,{children:[(0,m.jsx)(d.THead,{children:(0,m.jsxs)(d.TR,{children:[(0,m.jsx)(d.TH,{padded:!0,children:"Distributor"}),(0,m.jsxs)(d.TH,{padded:!0,children:["Totals ",(0,m.jsx)("span",{style:{fontStyle:"italic"},children:a.totals?`(${a.totals})`:null})]})]})}),(0,m.jsx)(d.TBody,{children:y.SUPPLIER_EVENTS?(0,m.jsx)(d.TR,{style:{textAlign:"center"},children:(0,m.jsx)(d.TD,{colSpan:2,children:(0,m.jsx)(d.Loading,{height:40})})}):u&&u.length>0?u.map((e,t)=>(0,m.jsxs)(d.TR,{"data-test-name":"ProductSidepanel",children:[(0,m.jsx)(d.TD,{padded:!0,children:e.tenant_name}),(0,m.jsx)(d.TD,{padded:!0,children:e.totals})]},"product_spo_"+t)):null})]})}):(0,m.jsx)(d.Col,{xs:!0,padded:!0,children:y.product?(0,m.jsx)(d.Loading,{}):(0,m.jsx)(E,{product_id:t,product:_,addOnClick:!b(p),showRating:!1})})}):null})})},x=(0,i.Ay)({resolved:{},chunkName:()=>"SupplierCharts",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>Promise.all([r.e(2023),r.e(4460)]).then(r.bind(r,49370)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>49370},{ssr:!1}),P=(0,i.Ay)({resolved:{},chunkName:()=>"SupplierReportDownloads",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e(976).then(r.bind(r,71184)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>71184},{ssr:!1}),R=[{label:"Sales",value:"SALES"},{label:"Pre-Sales",value:"PRESALES"}],v=[{label:"Client Reps",value:"order_client_rep"},{label:"Order Reps",value:"order_rep"}],I=[{label:"Client Reps",value:"order_client_rep"},{label:"Order Reps",value:"order_rep"}],f=function(e){const t=(0,l.wA)(),r=(0,l.d4)(e=>e.identity),a=(0,l.d4)(S.wW),[i,g]=(0,o.useState)({group_by:"month",compare_previous:1,tenant_id:null,division_id:"",supplier_tags:"",rep_type:"order_rep",rep_type_presales:"order_rep"}),[h,T]=(0,o.useState)(!1),[O,E]=(0,o.useState)(!1),[b,f]=(0,o.useState)("SALES");(0,o.useEffect)(function(){const e=[];"SALES"===b&&e.push({type:"SUPPLIER_POS",totals_by:"totals",params:{...(0,_.vb)(i.group_by,i.compare_previous,"totals"),group_by:i.group_by,c
1ompare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id}},{type:"SUPPLIER_PRODUCTS",totals_by:"product",params:{group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous,"product"),with_others:1,until:25}},{type:"SUPPLIER_POS",totals_by:"tenant",params:{group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous,"tenant"),with_others:1,until:25}}),"PRESALES"===b&&e.push({type:"SUPPLIER_EVENTS",totals_by:"industry",params:{group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous,"industry"),with_others:1,until:25}},{type:"SUPPLIER_EVENTS",totals_by:"totals",params:{...(0,_.vb)(i.group_by,i.compare_previous,"totals"),group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id}},{type:"SUPPLIER_EVENTS",totals_by:"product",params:{group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous,"product"),with_others:1,until:25}},{type:"SUPPLIER_EVENTS",totals_by:"tenant",params:{group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous,"tenant"),with_others:1,until:25}},{type:"SUPPLIER_EVENTS",totals_by:"events",params:{group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous,"events"),with_others:1,until:25}}),i.tenant_id||("SALES"===b&&e.push({type:`SUPPLIER_POS_TENANTS_COUNT_${i.group_by.toUpperCase()}`,totals_by:"tenants_count",params:{group_by:i.group_by,compare_previous:i.compare_previous,...(0,_.vb)(i.group_by,i.compare_previous,"tenants_count"),with_others:1,until:25,division_id:i.division_id}}),"PRESALES"===b&&e.push({type:`SUPPLIER_EVENTS_TENANTS_COUNT_${i.group_by.toUpperCase()}`,totals_by:"tenants_count",params:{group_by:i.group_by,compare_previous:i.compare_previous,...(0,_.vb)(i.group_by,i.compare_previous,"tenants_count"),with_others:1,until:25,division_id:i.division_id}})),t((0,c._5)(e))},[i.group_by,i.compare_previous,i.tenant_id,i.division_id,b]),(0,o.useEffect)(()=>{if("PRESALES"===b){const e=(0,c.M9)("SUPPLIER_PRESALES",i.rep_type_presales,{...(0,_.vb)(i.group_by,i.compare_previous,i.rep_type_presales),group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...i.tenant_id?{tenant_id:i.tenant_id}:{with_tenants:1,until:25,limit:25}});t((0,c.CM)(e))}},[b,i.rep_type_presales,i.tenant_id,i.compare_previous,i.group_by,i.division_id]),(0,o.useEffect)(()=>{const e=(0,c.M9)("SUPPLIER_POS",i.rep_type,{...(0,_.vb)(i.group_by,i.compare_previous,i.rep_type),group_by:i.group_by,compare_previous:i.compare_previous,tenant_id:i.tenant_id,division_id:i.division_id,...i.tenant_id?{tenant_id:i.tenant_id}:{with_tenants:1,until:25,limit:25}});t((0,c.PL)(e))},[i.rep_type,i.group_by,i.compare_previous,i.tenant_id,i.division_id]);const C=n().useMemo(()=>[{label:"Select Division",value:""}].concat(r.divisions.map(e=>({label:e.division_name,value:e.division_id}))),[r.divisions]),j={showPopup:T,group_by:i.group_by,division_id:i.division_id,tenant_id:i.tenant_id};return(0,m.jsxs)(m.Fragment,{children:[h?(0,m.jsx)(y.jG,{...h,onClosePopup:()=>T(!1)}):null,(0,m.jsx)(A,{onClosePanel:()=>(async()=>{E(!1),await(0,u.cb)(),await new Promise(e=>{t((0,c.YJ)({key:O.product_id,val:{}}))}),await new Promise(e=>{t((0,c.Oi)())})})(),product_id:s().get(O,"product_id",!1),product_data:s().get(O,"product_data",{}),supplierStatsData:s().get(O,"supplierStatsData",{})}),(0,m.jsx)(d.Row,{children:(0,m.jsxs)(d.TabBar,{style:{marginBottom:10,marginLeft:"15px"},children:[R.map((e,t)=>(0,m.jsx)(d.Tab,{style:{borderBottomColor:d.colors.cta,fontSize:18},selected:e.value===b,onClick:()=>f(e.value),children:e.label},t)),(0,m.jsx)(d.Tab,{style:{borderBottomColor:d.colors.cta,fontSize:18},selected:"DOWNLOAD-REPORTS"===b,onClick:()=>f("DOWNLOAD-REPORTS"),children:"Download Reports"})]})}),["SALES","PRESALES"].includes(b)?(0,m.jsxs)(d.Row,{end:!0,children:[(0,m.jsx)(d.
1Col,{padded:!0,end:!0,xs:6,md:3,style:{textAlign:"left"},children:(0,m.jsx)(y.l6,{isClearable:!0,placeholder:"Search for distributor",options:a,value:i.tenant_id,onChange:e=>g({...i,tenant_id:e?e.value:null}),isTenant:!0})}),(0,m.jsx)(d.Col,{padded:!0,xs:6,md:3,style:{textAlign:"left"},children:(0,m.jsx)(y.l6,{placeholder:"Select Division",options:C,value:i.division_id,onChange:e=>g({...i,division_id:e?e.value:""})})}),(0,m.jsx)(d.Col,{padded:!0,end:!0,offset:3,xs:6,md:3,style:{textAlign:"left"},children:(0,m.jsx)(d.Toggle,{children:p.i9.map((e,t)=>(0,m.jsx)(d.ToggleLink,{id:e.value,selected:i.group_by===e.value,onClick:t=>{g({...i,group_by:e.value})},children:e.label},t))})})]}):null,(0,m.jsxs)(d.Row,{style:{display:"SALES"===b?"flex":"none"},children:[i.tenant_id?null:(0,m.jsx)(x,{type:"SUPPLIER_POS",chart_type:"line",totals_by:"tenants_count",colSizes:{xs:12,md:i.supplier_tags.length>0?6:12},filters:(0,_.vb)(i.group_by,i.compare_previous,"tenants_count"),...j}),(0,m.jsx)(x,{type:"SUPPLIER_POS",chart_type:"bar",totals_by:"totals",isSparkline:!1,colSizes:{xs:12,md:12,lg:12},filters:(0,_.vb)(i.group_by,i.compare_previous,"totals"),...j}),(0,m.jsx)("div",{style:{display:i.tenant_id?"none":"contents"},children:(0,m.jsx)(x,{type:"SUPPLIER_POS",chart_type:"pie",totals_by:"tenant",colSizes:{xs:12,lg:6},show_previous:!0,filters:(0,_.vb)(i.group_by,i.compare_previous,"tenant"),...j})}),(0,m.jsx)(x,{type:"SUPPLIER_POS",chart_type:"bar_bullet",totals_by:i.rep_type,colSizes:{xs:12,lg:6},show_previous:!0,getTooltipText:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"gr1";return`{${e}}: [bold]{valueX.value}[/]\nDistributor: {${e}_tenant_name}`},filters:(0,_.vb)(i.group_by,i.compare_previous,i.rep_type),titleSelect:{placeholder:"Select Rep Type...",options:v,value:i.rep_type,onChange:e=>{g({...i,rep_type:e})}},...j}),(0,m.jsx)(x,{type:"SUPPLIER_PRODUCTS",chart_type:"bar_bullet",totals_by:"product",colSizes:{xs:12,lg:6},show_previous:!0,filters:(0,_.vb)(i.group_by,i.compare_previous),showSidepanel:E,getSidepanelData:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"gr1";return{isPrev:"gr2"==t,supplierStatsData:{totals:e[`${t}_totals`],group:e[t],tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous),isPrev:"gr2"==t,type:"SUPPLIER_PRODUCTS"},product_id:e[`${t}_product_id`],product_data:{product_id:e[`${t}_product_id`],product_name:e[`${t}_product_name`],totals:e[`${t}_totals`],img_src:e[`${t}_img_src`],group:e[t],isPrev:"gr2"==t}}},...j})]}),(0,m.jsxs)(d.Row,{style:{display:"PRESALES"===b?"flex":"none"},children:[i.tenant_id?null:(0,m.jsx)(x,{type:"SUPPLIER_EVENTS",chart_type:"line",totals_by:"tenants_count",colSizes:{xs:12,md:i.supplier_tags.length>0?6:12},filters:(0,_.vb)(i.group_by,i.compare_previous,"tenants_count"),...j}),(0,m.jsx)(x,{type:"SUPPLIER_EVENTS",chart_type:"bar",totals_by:"totals",isSparkline:!1,colSizes:{xs:12,md:12,lg:12},filters:(0,_.vb)(i.group_by,i.compare_previous,"totals"),...j}),i.tenant_id?null:(0,m.jsx)(x,{type:"SUPPLIER_EVENTS",chart_type:"pie",totals_by:"tenant",colSizes:{xs:12,lg:6},show_previous:!0,filters:(0,_.vb)(i.group_by,i.compare_previous),...j}),(0,m.jsx)(x,{type:"SUPPLIER_EVENTS",chart_type:"pie",totals_by:"industry",colSizes:{xs:12,lg:6},show_previous:!0,filters:(0,_.vb)(i.group_by,i.compare_previous,"industry"),...j}),(0,m.jsx)(x,{type:"SUPPLIER_EVENTS",chart_type:"pie",totals_by:"events",colSizes:{xs:12,lg:6},show_previous:!0,filters:(0,_.vb)(i.group_by,i.compare_previous,"events"),...j}),(0,m.jsx)(x,{type:"SUPPLIER_EVENTS",chart_type:"bar_bullet",totals_by:"product",colSizes:{xs:12,lg:6},show_previous:!0,filters:(0,_.vb)(i.group_by,i.compare_previous),showSidepanel:E,getSidepanelData:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"gr1";return{isPrev:"gr2"==t,supplierStatsData:{totals:e[`${t}_totals`],group:e[t],tenant_id:i.tenant_id,division_id:i.division_id,...(0,_.vb)(i.group_by,i.compare_previous),isPrev:"gr2"==t,type:"SUPPLIER_EVENTS"},product_id:e[`${t}_product_id`],product_data:{product_id:e[`${t}_product_id`],product_name:e[`${t}_product_name`],totals:e[`${t}_totals`],img_src:e[`${t}_img_src`],group:e[t],isPrev:"gr2"==t}}},...j}),(0,m.jsx)(x,{type:"SUPPLIER_PRESALES",chart_type:"bar_bullet",totals_by:i.rep_type_presales,colSizes:{xs:12,lg:6},show_previous:!0,filters:(0,_.vb)(i.group_by,i.compare_previous),titleSelect:{placeholder:"Select Rep Type...",options:I,value:i.rep_type_presales,onChange:e=>{g({...i,rep_type_presales:e})}},...j})]}),(0,m.jsx)(d.Row,{style:{display:"DOWNLOAD-REPORTS"===b?"flex":"none"},children:(0,m.jsx)(P,{})})]})};
1var C=r(20001),j=r(83075),D=r(1390),N=r(62611);const L=(0,i.Ay)({resolved:{},chunkName:()=>"OpenOrdersCharts",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>Promise.all([r.e(2023),r.e(9979)]).then(r.bind(r,25365)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>25365},{ssr:!1}),k=(0,i.Ay)({resolved:{},chunkName:()=>"POsByStatusChart",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>r.e(794).then(r.bind(r,10938)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>10938},{ssr:!1}),U=(0,i.Ay)({resolved:{},chunkName:()=>"ProjectionChart",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>Promise.all([r.e(2023),r.e(5352)]).then(r.bind(r,41986)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>41986},{ssr:!1}),w=(0,i.Ay)({resolved:{},chunkName:()=>"StuckInStageChart",isReady(e){const t=this.resolve(e);return!0===this.resolved[t]&&!!r.m[t]},importAsync:()=>Promise.all([r.e(2023),r.e(3758)]).then(r.bind(r,44980)),requireAsync(e){const t=this.resolve(e);return this.resolved[t]=!1,this.importAsync(e).then(e=>(this.resolved[t]=!0,e))},requireSync(e){const t=this.resolve(e);return r(t)},resolve:()=>44980},{ssr:!1}),F=function(e){let{text:t,total:r=null,checked:a=!1,title:s=null,onClick:o=null,style:n={},clickable:l,textWrapperStyle:i={color:"#2A4D63"},titleStyle:p={},totalStyle:_={color:d.colors.neutrals[100]},loading:c=!1,showWarning:u=!1,showPS:g=!1,...S}=e;const h={textAlign:"center",margin:0,fontFamily:d.themeOptions.fontFamilies.regular,color:a?"#4ade96":"#000000"};return(0,m.jsx)(y.D4,{"data-test-name":"DashboardNumberTile",style:{textAlign:"center",background:a?"#f6fffb":"#ffffff",overflowY:"auto",cursor:l||o?"pointer":"auto",maxHeight:195,height:"100%",margin:"auto",display:"flex",alignItems:"center",flexDirection:"column",position:"relative",padding:"16px",...n},onClick:o,...S,children:c?(0,m.jsx)(d.Loading,{}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{style:{height:"100%"}}),function(){if(a)return null;const e={...h,fontSize:"24px",fontWeight:"bold",display:"inline-block",verticalAlign:"middle",color:d.colors.neutrals[100],..._};return(0,m.jsxs)("div",{"data-test-name":"DashboardNumberTile.renderHeaderTotal",style:{textAlign:"center"},children:[(0,m.jsx)("span",{style:{paddingRight:10},children:null!==r?(0,m.jsx)(d.Text,{style:e,children:r}):null}),u?(0,m.jsx)("div",{style:{position:"absolute",top:0,right:0},children:(0,m.jsx)(d.AlertIcon,{mt:8,mr:8,style:{verticalAlign:"middle"}})}):null,g?(0,m.jsx)("div",{style:{position:"absolute",top:0,right:0},children:(0,m.jsx)(d.ConnectedPlusIcon,{size:"large",style:{verticalAlign:"middle"}})}):null]})}(),(0,m.jsxs)("div",{"data-test-name":"DashboardNumberTile.renderBody",style:{height:"100%",textAlign:"center",verticalAlign:"middle"},children:[function(){if(!a)return null;const e={color:"#01D374",fontFamily:d.themeOptions.fontFamilies.regular};return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.CompletedCheckmarkIcon,{size:"huge"}),(0,m.jsx)("div",{style:e,children:"Excellent!"})]})}(),function(){const e={display:"block",fontSize:"16px",fontWeight:"600",fontFamily:d.themeOptions.fontFamilies.regular,margin:"0 0 5px 0",...p},r={...h,fontFamily:d.themeOptions.fontFamilies.regular,fontSize:"14px",minHeight:"42px",display:"block",...i};return(0,m.jsxs)(m.Fragment,{children:[s&&!a?(0,m.jsx)("p",{style:e,children:s}):null,(0,m.jsx)(d.Text,{as:"p",style:r,children:t})]})}()]}),(0,m.jsx)("div",{style:{height:"100%"}})]})})};var W=r(66416);const G=e=>0===e?"#DADADA":"#000000",V=e=>{let{salesReports:t,loading:r}=e;const a=t.projectsWithNoBudget.totals||0,s=t.projectsWithNoInhandsDate.totals||0,o=t.presalesPendingClientApproval.totals||0,n=t.soPendingClientApproval.totals||0,l=t.openOrderStatusTotals.sales_order_num_client_approved||0,i=t.o
1penOrderStatusTotals.sales_order_num_client_change_requested||0,d=t.potentialRepeatOrders.totals||0,p=t.clientWithNoRecentActivity.totals||0;return[{clickable:a>0,checked:0===a,total:a,title:"Projects",text:0===a?"All projects have a budget":"No budget",loading:r[C.mG.PROJECTS_WITH_NO_BUDGET.type],report_type:C.mG.PROJECTS_WITH_NO_BUDGET.type,showWarning:a>0,cb:C._Q,params:{}},{clickable:s>0,checked:0===s,total:s,title:"Projects",text:0===s?"All projects have an in-hands date":"Overdue",loading:r[C.mG.OVERDUE_IN_HANDS_DATE_PROJECTS.type],report_type:C.mG.OVERDUE_IN_HANDS_DATE_PROJECTS.type,showWarning:s>0,cb:C._Q,params:{}},{clickable:l>0,total:l,title:"Sales Orders",text:"Client approved",loading:r[C.mG.OPEN_ORDER_STATUS_TOTALS.type],report_type:C.mG.OPEN_ORDER_STATUS_TOTALS.type,checked:0===l,showWarning:l>0,cb:C.sg,params:{order_type:"SALES ORDER",status_name:"Client Approved"},totalStyle:{color:G(l)}},{clickable:i>0,total:i,title:"Sales Orders",text:"Client change requested",loading:r[C.mG.OPEN_ORDER_STATUS_TOTALS.type],report_type:C.mG.OPEN_ORDER_STATUS_TOTALS.type,checked:0===i,showWarning:i>0,cb:C.sg,params:{order_type:"SALES ORDER",status_name:"Client Change Requested"},totalStyle:{color:G(i)}},{clickable:o>0,total:o,title:"Pre-sales",text:"Client review",loading:r[C.mG.PRESALES_PENDING_CLIENT_APPROVAL.type],report_type:C.mG.PRESALES_PENDING_CLIENT_APPROVAL.type,cb:C._Q,params:{},totalStyle:{color:G(o)}},{clickable:n>0,total:n,title:"Sales Orders",text:"Pending client approval",loading:r[C.mG.SALES_ORDERS_PENDING_CLIENT_APPROVAL.type],report_type:C.mG.SALES_ORDERS_PENDING_CLIENT_APPROVAL.type,cb:C._Q,params:{},totalStyle:{color:G(n)}},{clickable:d>0,total:d,title:"Sales Orders",text:"Potential repeat",loading:r[C.mG.POTENTIAL_REPEAT_ORDERS.type],report_type:C.mG.POTENTIAL_REPEAT_ORDERS.type,showDateCreated:!0,defaultSort:{id:"date_created",desc:!1},cb:C.sg,params:{order_type:"SALES ORDER",last_year_orders:90},totalStyle:{color:G(d)}},{clickable:p>0,total:p,type:"clients-list",title:"Clients",text:"No recent activity",loading:r[C.mG.CLIENTS_WITH_NO_RECENT_ACTIVITY.type],report_type:C.mG.CLIENTS_WITH_NO_RECENT_ACTIVITY.type,data:Object.values(t.clientWithNoRecentActivity.data||{}),totalStyle:{color:G(p)}}]},$=function(e){let{salesReports:t={},salesTeamId:r="",salesRepId:a,salesRepType:s,onClickTile:o,style:n={}}=e;const i=(0,l.wA)(),p=(0,g.Us)(),_=(0,l.d4)(C.Tp.loading),c=e=>()=>{const t=C.mG[e.report_type];e.cb&&i(e.cb(t.route,e.report_type,{report_type:e.report_type,get_data:1,rep_type:s,rep_id:"GROUP"===a?"":a,team_id:r,...e.params||{}})),o&&o({...e,type:e.type||"projects-list",title:e.text||""})};return(0,m.jsx)(m.Fragment,{children:(0,m.jsx)(W.A,{deps:[t,_,p],children:V({salesReports:t,loading:_,identity:p}).map((e,t)=>(0,m.jsx)(d.Col,{xs:!0,sm:4,lg:3,padded:!0,style:{textAlign:"center",height:185,...n},children:(0,m.jsx)(F,{...e,style:{height:170,width:160},...e.clickable?{onClick:c(e)}:{}})},"DashboardNumberTile"+t))})})};function B(e){let{dashboardType:t,formUUID:r,onClose:a}=e;return(0,m.jsx)(m.Fragment,{children:(0,m.jsxs)(d.Row,{children:[(0,m.jsx)(d.Col,{xs:!0,style:{padding:30,textAlign:"center"},children:(0,m.jsx)(d.Text,{style:{color:"#7b98ac"},children:"Do you have a suggestion that will make our Dashboards or Analytics pages more useful? Please fill out this form for the commonsku team to review."})}),(0,m.jsx)(d.Col,{xs:!0,style:{padding:30},children:(0,m.jsx)(y.W5,{id:"hbspt-form-"+r,className:"hbspt-form",region:"na1",portalId:"7611209",formId:"d119e019-f037-43e0-bebc-a7982b14c368",onSubmit:()=>a&&a(),onReady:e=>{},loading:(0,m.jsx)("div",{style:{textAlign:"center"},children:(0,m.jsx)(d.Loading,{})})})})]})})}const M=function(e){let{dashboardType:t,onClose:r}=e;const a=n().useRef("");function s(){document.querySelector(".popup-content")?(document.querySelector(".popup-content").style.maxHeight="1100px",document.querySelector(".popup-content").style.height="calc(100% - 80px)"):setTimeout(()=>{s()},100)}return(0,o.useEffect)(()=>(s(),a.current=(0,u.lk)(),()=>{a.current=""}
1),[]),(0,m.jsx)(d.Popup,{"data-test-name":"GotAnIdeaPopup",style:{padding:0,maxWidth:600},header:(0,m.jsxs)(d.PopupHeader,{style:{background:"#CCFFE8",height:80},children:[(0,m.jsx)(d.Col,{xs:!0,md:10,style:{alignSelf:"center"},children:(0,m.jsx)(d.Text,{as:"p",style:{color:"#123952",fontSize:"18px",lineHeight:"25px",paddingLeft:"32px"},children:"Have a suggestion? We'd love to hear from you!"})}),(0,m.jsx)(d.Col,{xs:!0,md:2,style:{textAlign:"right",alignSelf:"center"},children:(0,m.jsx)("span",{style:{color:d.colors.primary,fontSize:"2rem",paddingRight:30,cursor:"pointer"},onClick:r,children:"â"})})]}),children:(0,m.jsx)(B,{dashboardType:t,formUUID:a.current,onClose:r})})};function Y(e){let{maxHeight:t=170,...r}=e;const[a,s]=(0,o.useState)(!1);return(0,m.jsxs)(m.Fragment,{children:[a&&(0,m.jsx)(M,{onClose:()=>s(!1)}),(0,m.jsxs)(y.D4,{style:{textAlign:"center",color:"#16344E",overflowY:"auto",height:t,overflow:"hidden"},children:[(0,m.jsx)("span",{style:{display:"block",marginBlockStart:"0.8em",marginBlockEnd:"0.8em",fontFamily:d.themeOptions.fontFamilies.regular,fontSize:16,fontWeight:600},children:"Welcome to the new dashboard!"}),(0,m.jsx)("span",{style:{margin:0,display:"block",fontFamily:d.themeOptions.fontFamilies.regular,fontSize:14,cursor:"pointer",color:d.colors.primary},onClick:()=>{s&&s(!0)},children:"Have ideas for more tiles to make your work easier?"})]})]})}const H=170,J=function(e){let{salesReports:t={},marketingTile:r={},onClickTile:a}=e;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(y.IA,{style:{height:H},title:"Pre-sales Total",prevTotalCount:t.presales.prevTotalCount,prevTotalCurrency:t.presales.prevTotalCurrency,totalCount:t.presales.totalCount,totalCurrency:t.presales.totalCurrency,onClick:()=>{a&&a({report_type:"SALES_TOTALS",report_sub_type:"PRE-SALES",title:"Pre-sales"})}})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(y.IA,{style:{height:H},title:"In Production Total",prevTotalCount:t.inProduction.prevTotalCount,prevTotalCurrency:t.inProduction.prevTotalCurrency,totalCount:t.inProduction.totalCount,totalCurrency:t.inProduction.totalCurrency,onClick:()=>{a&&a({report_type:"SALES_TOTALS",report_sub_type:"IN-PRODUCTION",title:"In Production"})}})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(y.IA,{style:{height:H},title:"Invoice Total",prevTotalCount:t.invoices.prevTotalCount,prevTotalCurrency:t.invoices.prevTotalCurrency,totalCount:t.invoices.totalCount,totalCurrency:t.invoices.totalCurrency,onClick:()=>{a&&a({report_type:"SALES_TOTALS",report_sub_type:"INVOICE",title:"Invoice"})}})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(Y,{maxHeight:H})}),(0,m.jsx)(d.Col,{xs:!0,md:8,lg:4,style:{paddingTop:"0.5rem",paddingLeft:"0.5rem",alignSelf:"center"},children:(0,m.jsx)(y.DE,{link:r.link,title:r.title,imgSrc:r.imgSrc,maxHeight:H})})]})};var z=r(97836),q=r(46676),K=r(56366),X=r(51405),Q=r(38718);const Z="client_id";function ee(e){let{row:t,style:r={}}=e;return(0,m.jsx)("div",{"data-test-name":"ClientRepPic",style:{...r,overflowWrap:"break-word"},children:(0,m.jsx)(X.Al,{children:(0,m.jsx)(X.Ay,{backgroundColor:d.colors.primary,name:t.original.sales_rep_full_name||"Sales Rep","data-tip":t.original.sales_rep_full_name||"Sales Rep","data-for":"sales-rep-avatar",...t.original.sales_rep_image&&s().isObject(t.original.sales_rep_image)?{src:(0,u.AE)(t.original.sales_rep_image)}:{}})})})}function te(e){let{row:t,style:r={}}=e;return(0,m.jsx)("div",{"data-test-name":"ClientName",style:{...r,overflowWrap:"break-word"},children:(0,m.jsx)(d.Link,{as:"a",href:`/client.php?id=${t.original.client_id}`,target:"_blank",style:{display:"block",color:d.colors.primary,fontWeight:"bold",textDecoration:"none"},children:t.original.client_name})})}function re(e){let{row:t,value:r,style:a={}}=e;const s=t.original.sales_target,o=s&&!isNaN(s)&&0!==parseInt(s)?parseFloat(s).toFixed(0):0;return(0,m.jsx)("div",{"data-test-name":"ClientSalesTarget",style:{...a,overflowWrap:"break-word"},children:(0,m.jsx)("span",{style:{display:"block",fontWeight:"bold",color:d.colors.green.main},children:(0,u.Y6)(o)})})}function ae(e){let{row:t,style:r={}}=e;return(0,m.jsxs)("div",{"data-test-name":"ClientContact",style:{...r,overflowWrap:"break-word"},children:[(0,m.jsx)("span",{style:{display:"block",fontWeight:"bold"},children:t.original.contact_full_name||""}),(0,m.jsx)("span",{children:t.original.contact_email||""})]})}function se(e){let{row:t,style:r={}}=e;const a=n().useMemo(()=>{const e=t.original.last_activity;if(!e)return null;const r=e.activity_date&&-1===e.activity_date.indexOf("0000-00-00")?new Date(1e3*e.activity_ts):"",a=K.S4[e.activity_type],s={date:(0,u.yw)(r)||"",activity_type:a,val:"",link:!1};return a?"none"===a.href?(s.val=a.val||"",s.link=!1):a.val&&(s.val=a.val+(e.activity_details?" #"+e.activity_details:""),s.link=e.activity_type.replace(" ","_").toLowerCase()+".php?id="+e.activity_id):(s.val="",s.link=""),s},[t.original.last_activity]);return a?(0,m.jsxs)("div",{"data-test-name":"ClientActivity",style:{...r,overflowWrap:"break-word"},children:[(0,m.jsx)("span",{style:{display:"block",fontWeight:"bold"},children:a.date||""}),a.link?(0,m.jsx)(d.Link,{as:"a",href:a.link,target:"_blank",rel:"noopener noreferrer",style:{display:"block",color:d.colors.primary,fontWeight:"bold",textDecoration:"none"},children:a.val}):(0,m.jsx)("span",{children:a.val})]}):null}const oe=e=>{let{data:t=[],loading:r,handleUpdateRow:a,showLastActivity:l=!0,defaultSort:i={id:"date_created",desc:!0}}=e;const p=(0,Q.A)(),[_,c]=(0,o.useState)(!1),[u,g]=(0,o.useState)(!1);(0,o.useEffect)(()=>{(0,y.W1)(),g(!1)},[t]);const S=n().useCallback(e=>c(e),[]),h=n().useMemo(()=>[{Header:()=>(0,m.jsx)("div",{children:"Client"}),accessor:e=>`${e.client_name}`,Cell:te,sticky:"left",noDrag:!0,minWidth:250,maxWidth:500,id:Z},{Header:()=>(0,m.jsx)("div",{children:"Rep"}),accessor:e=>`${e.sales_rep_full_name}`,sticky:"left",Cell:ee,noDrag:!0,minWidth:130,maxWidth:500,id:"sales_rep_id"},{Header:()=>(0,m.jsx)("div",{children:"Sales Target"}),accessor:e=>`${e.sales_target}`,Cell:re,sticky:"left",noDrag:!0,minWidth:230,maxWidth:500,id:"sales_target"},{Header:()=>(0,m.jsx)("div",{children:"Contact"}),accessor:e=>`${e.contact_full_name}`,Cell:ae,sticky:"left",noDrag:!0,minWidth:280,maxWidth:500,id:"primary_contact_id"},...l?[{Header:()=>(0,m.jsx)("div",{children:"Last Activity"}),accessor:e=>`${s().get(e,["last_activity","activity_details"],"")}`,Cell:se,sticky:"left",noDrag:!0,minWidth:160,maxWidth:500,id:"last_activity"}]:[]],[l]),T=(0,o.useCallback)(e=>_&&_[Z]===e[Z]?c(!1):c(e),[_]);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.SimpleWindowedTableStyles,{rowClickable:!0,style:r?{display:"none"}:{},children:[(0,m.jsx)(d.SimpleWindowedTable,{columns:h,data:t,defaultSort:i,onClickRow:T,onScroll:y.W1,onUpdateData:a,useTableProps:{autoResetPage:!u,autoResetGroupBy:!u,autoResetSortBy:!u,autoResetFilters:!u,autoResetRowState:!u,onClickProject:S},height:(O=p[1],O<251?100:O<351?150:O<540?O-280:O<700?O-350>450?450:O-350:O<850?O-300>450?450:O-300:500)}),(0,m.jsx)(q.default,{id:"sales-rep-avatar"})]}
1),r?(0,m.jsx)(d.Row,{children:(0,m.jsx)(d.Col,{xs:!0,style:{alignSelf:"100%",textAlign:"center"},children:(0,m.jsx)(d.Loading,{})})}):null]});var O};var ne=r(30596),le=r(31238),ie=r(93664);const de=new Date,pe=["SALES_TOTALS","PROJECTION_TOTALS","STUCK_IN_STAGE_TOTALS","POTENTIAL_REPEAT_ORDERS","CLIENTS_WITH_NO_RECENT_ACTIVITY","SALES_ORDERS_PENDING_CLIENT_APPROVAL","PRESALES_PENDING_CLIENT_APPROVAL","OVERDUE_IN_HANDS_DATE_PROJECTS","PROJECTS_WITH_NO_BUDGET","OPEN_ORDER_STATUS_TOTALS"],_e="SALES_DASHBOARD_ORDER_REP_TYPE",ce="SALES_DASHBOARD_CLIENT_REP_TYPE",ue=function(e){let{...t}=e;const r=(0,l.wA)(),a=(0,g.Us)(),n=(0,g.u7)(["HAS-SALES-TARGETS"]),i=(0,l.d4)(e=>(0,ne.I6)(e).map(e=>({label:e.value,value:e.key}))),_=(0,l.d4)(e=>e.entities.statuses),c=(0,l.d4)(C.Tp.loading),S=(0,l.d4)(C.Tp.reports),h=(0,l.d4)(e=>{const t=C.Tp.loading(e);return pe.filter(e=>s().get(t,e,!1)).length>0}),{hasUserFlag:T,onDeleteAddFlag:O}=(0,g.B7)(a),E=T(_e),[b,A]=(0,o.useState)({rep_type:E?"ORDER":"CLIENT",rep_id:a.user_id}),[x,P]=(0,o.useState)(!1),[R,v]=(0,o.useState)(null),[I,f]=(0,o.useState)(!0),[k,F]=(0,o.useState)(!1),[W,G]=(0,o.useState)("OPEN_SALES_ORDERS"),[V,B]=(0,o.useState)({imgSrc:"",title:"",text:"",link:"",dashboard:""});(0,o.useEffect)(()=>{const e="ORDER"===b.rep_type?ce:_e,t="ORDER"===b.rep_type?_e:ce;O(e,t)},[b.rep_type,O]),(0,o.useEffect)(()=>{(0,u.oD)("GET","marketing-setting/dashboard-marketing",{dashboard_type:"SALES"},null,null,null,!1).then(e=>{const{json:t}=e;B(t.marketing)}).catch(e=>{console.error(e)})},[r,a]),(0,o.useEffect)(()=>{if((0,y.W1)(),"GROUP"===b.rep_id&&!b.team_id)return;f(!0);const e=Object.values(C.mG).filter(e=>pe.includes(e.type)).reduce((e,t)=>{const r=(0,C.FN)(t.type,b);return r?[...e,r]:e},[]);(async()=>{await Promise.all(e.map(e=>r(e.cb(e.route,e.type,e.params))))})()},[r,b]);const M=e=>{if(!s().get(e,"order_type",""))return;f(!1);const t=e.order_type,a=C.mG.STUCK_IN_STAGE_TOTALS,o=e.title,n=(0,C.FN)("STUCK_IN_STAGE_TOTALS",b);n&&(r(n.cb(n.route,n.type,{...n.params,report_type:"STUCK_IN_STAGE_TOTALS",get_data:1,days:30,order_type:t})),v({type:"projects-list",title:"Stuck in Stage - "+o,report_type:a.type,order_type:t,loading:c[a.type]}))},Y=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!s().get(e,"month_name",""))return;f(!1);const a=C.mG.PROJECTION_TOTALS,o=e.month_name,n=new Date(parseInt(e.year),parseInt(e.month),1);n.setDate(n.getDate()-1);const l=(0,C.FN)("PROJECTION_TOTALS",b);l&&(r(l.cb(l.route,l.type,{...l.params,report_type:"PROJECTION_TOTALS",get_data:1,start_stamp:(0,u.yw)(new Date(parseInt(e.year),parseInt(e.month)-1,1)),end_stamp:(0,u.yw)(n),order_type:t||""})),v({type:"projects-list",title:"Projection - "+o,report_type:a.type,loading:c[a.type],order_type:t}))},H=e=>{if(!s().get(e,"order_type",""))return;f(!1);const t=e.order_type,a=e.title,o=e.status_name,n=(0,C.FN)("OPEN_ORDER_STATUS_TOTALS",b);n&&(r(n.cb(n.route,n.type,{...n.params,report_type:"OPEN_ORDER_STATUS_TOTALS",get_data:1,order_type:t,status_name:o})),v({type:"projects-list",report_type:"OPEN_ORDER_STATUS_TOTALS",loading:c.OPEN_ORDER_STATUS_TOTALS,title:"Open Orders - "+a,order_type:t}))};function q(e){return W!==e?{opacity:0,height:0,display:"none"}:{opacity:1,transition:"300ms opacity ease-out"}}return(0,m.jsx)(d.Row,{"data-test-name":"Dashboard",children:(0,m.jsxs)(d.Col,{xs:!0,padded:!0,children:[(0,m.jsx)(D.iM,{noteId:x,clearnoteId:()=>P(!1),onUpdateNote:e=>{f(!1),r((0,j.w3)(e.note_id,e))}}),function(){if(!R)return null;if("add_task"===R.action)return(0,m.jsx)(D.VV,{"data-test-name":"Dashboard.renderPopup",onClose:()=>v(!1),message:{details_type:"NOTE",note_type:"NOTE"}});if(!["projects-list","clients-list"].includes(R.type))return null;let e=null;return e="projects-list"===R.type?(0,m.jsx)(N.A,{...R,onSave:()=>v(!1),loadReportTotal:e=>F(e)}):(0,m.jsx)(oe,{...R,onSave:()=>v(!1)}),(0,m.jsxs)(d.Popup,{"data-test-name":"Dashboard.renderPopup",title:R.title,onClose:()=>{if(v(!1),k){const e=(0,C.FN)(k,b);if(!e)return e;r(e.cb(e.route,e.type,e.params))}},className:`popup ${R.type}-popup csku-styles`,children:[e,(0,m.jsx)("br",{})]})}(),(0,m.jsxs)(d.Row,{style:{marginTop:0,marginBottom:20}
1,children:[(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,children:(0,m.jsx)(z.A,{title:"Sales Dashboard"})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,end:1,children:(0,m.jsx)(le.m,{})})]}),(0,m.jsxs)(d.Row,{"data-test-name":"Dashboard.renderFilters",style:{marginTop:0,marginBottom:20},children:[(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"dashboard-rep-type",options:p.Y9,value:b.rep_type,onChange:e=>A(t=>({...t,rep_type:e.value})),label:"Rep Type",className:"csku-select-v3"})}),(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"dashboard-rep",options:i,value:b.rep_id,onChange:e=>A(t=>({...t,rep_id:e.value})),label:"Rep",className:"csku-select-v3",isDisabled:!0})})]}),h&&I?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Loading,{}),(0,m.jsx)("p",{style:{padding:0,margin:0,textAlign:"center",color:"#00A0B6",fontSize:"1.3rem"},children:"Loading..."})]}):function(){const e=(0,p.jk)(S),t=parseFloat((s().find(s().get(S,"PROJECTION_TOTALS.sales_target",[]),e=>e.year==de.getFullYear()&&e.month==de.getMonth()+1)||{target:"0.0000"}).target||0),o=parseFloat((s().find(s().get(S,"PROJECTION_TOTALS.orders",[]),e=>e.year==de.getFullYear()&&e.month==de.getMonth()+1&&"INVOICE"==e.order_type)||{total:"0.0000"}).total||0),l=parseFloat((s().find(s().get(S,"PROJECTION_TOTALS.sales_target",[]),e=>e.year==de.getFullYear()&&e.month==de.getMonth()+1)||{sales_orders_target:"0.0000"}).sales_orders_target||0),i=parseFloat((s().find(s().get(S,"PROJECTION_TOTALS.sales_orders_in_production_analytics",[]),e=>e.next_year==de.getFullYear()&&e.month==ie.yz[de.getMonth()].substring(0,3))||{total_next_year:"0.0000"}).total_next_year||0);return(0,m.jsxs)(d.Row,{"data-test-name":"Dashboard.renderContent",children:[n&&(0,m.jsx)(m.Fragment,{children:"CLIENT"===b.rep_type?(0,m.jsxs)(d.Col,{xs:!0,padded:!0,children:[1==a.show_invoice_targets?(0,m.jsx)(d.Thermometer,{value:o,valueLabel:"Invoices this month:",target:t,style:{marginBottom:1==a.show_sales_order_targets?"1rem":""}}):null,1==a.show_sales_order_targets?(0,m.jsx)(d.Thermometer,{value:i,valueLabel:"Sales orders in production:",target:l,barColor:"#FFD302",labelTextColor:"#C69B00",isSecondary:!0}):null]}):null}),(0,m.jsx)(J,{salesReports:e,marketingTile:V,onClickTile:e=>{if(f(!1),e){const t=(0,C.FN)("SALES_TOTALS",b);if(!t)return;return r(t.cb(t.route,t.type,{...t.params,report_type:"SALES_TOTALS",report_sub_type:e.report_sub_type,get_data:1})),void v({type:"projects-list",report_type:"SALES_TOTALS",loading:c.SALES_TOTALS,...e})}v(e)}}),(0,m.jsx)(d.Col,{padded:!0,xs:!0,lg:6,children:(0,m.jsxs)(y.D4,{style:{paddingBottom:40},children:[(0,m.jsxs)(d.TabBar,{style:{marginBottom:10,borderBottomColor:d.colors.errors.main,fontSize:16},children:[(0,m.jsx)(d.Tab,{selected:"OPEN_SALES_ORDERS"===W,onClick:()=>{G("OPEN_SALES_ORDERS")},children:"Open Sales Orders"}),(0,m.jsx)(d.Tab,{selected:"OPEN_PRE_SALES"===W,onClick:()=>{G("OPEN_PRE_SALES")},children:"Open Pre-sales"}),(0,m.jsx)(d.Tab,{selected:"STUCK_IN_STAGE"===W,onClick:()=>{G("STUCK_IN_STAGE")},children:"Stuck In Stage"})]}),(0,m.jsx)("div",{style:{...q("STUCK_IN_STAGE")},children:(0,m.jsx)(w,{statuses:_,data:s().get(S,"STUCK_IN_STAGE_TOTALS.summary",{}),onClickColumn:M})}),(0,m.jsx)("div",{style:{...q("OPEN_SALES_ORDERS")},children:(0,m.jsx)(L,{statuses:_,data:s().get(S,"OPEN_ORDER_STATUS_TOTALS.summary",{}),order_type:"SALES ORDER",onClickColumn:H})}),(0,m.jsx)("div",{style:{...q("OPEN_PRE_SALES")},children:(0,m.jsx)(L,{statuses:_,data:s().get(S,"OPEN_ORDER_STATUS_TOTALS.summary",{}),order_type:"PRE-SALES",onClickColumn:H})})]})}),(0,m.jsx)(d.Col,{padded:!0,xs:!0,lg:6,children:(0,m.jsxs)(y.D4,{children:[(0,m.jsx)(d.Text,{as:"p",style:{marginTop:0,fontSize:16,fontWeight:"bold",padding:16},children:"Projection"}),(0,m.jsx)(U,{salesTargets:s().get(S,"PROJECTION_TOTALS.sales_target",[]),orders:s().get(S,"PROJECTION_TOTALS.orders",[]),onClickColumn:Y,height:"380px"})]})}),(0,m.jsx)(d.Col,{xs:!0,children:(0,m.jsx)($,{salesReports:e,salesRepId:b.rep_id,salesRepType:b.rep_type,onClickTile:e=>{f(!1),v(e)},marketingTile:V})}),(0,m.jsx)(d.Col,{xs:!0,padded:!0,children:(0,m.jsx)(y.D4,{padded:!0,children:(0,m.jsx)(D.Ag,{noteId:x,onClickNote:P,noteUserId:b.rep_id,onAddTask:e=>{f(!1),v({action:"add_task"})},onChangeWeek:()=>f(!1)})})})]})}()]})})};var ye=r(38123),ge=r.n(ye);function Se(e){return"SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")?{...e,date_field:"date_inhandsdate",start_stamp:ge()().startOf("month").format("YYYY-MM-DD"),end_stamp:ge()().endOf("month").format("YYYY-MM-DD")}:e}const me=n().memo(e=>{const{onClickNumberTile:t,isLoading:r=!1,filters:a={}}=e,n=(0,o.useCallback)(function(){return Se(a,arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")},[a]),i=(0,g.Us)(),_=(0,l.d4)(C.Tp.reports),c=(0,p.jk)(_),u=(0,o.useMemo)(()=>{const e=c.invoiceOpenStatusTotals,t=c.soReadyToBeInvoicedTotals,r=c.soInProductionTotals,a=parseInt(s().get(c.depositInvoicesNotPaidUnInvoiced,["totals"],"")||0),o=parseInt(s().get(c.depositInvoicesPaidSOInProduction,["totals"],"")||0),l=parseInt(s().get(c.clientsOnCreditHold,["totals"],"")||0);return[{clickable:e>0,checked:0===e,showWarning:e>0,total:e,type:"projects-list",title:"Invoices",text:"Open",report_type:C.mG.INVOICE_OPEN_STATUS_TOTALS.type,order_type:C.mG.INVOICE_OPEN_STATUS_TOTALS.params.order_type,status_id:C.mG.INVOICE_OPEN_STATUS_TOTALS.params.status_id,params:{report_type:C.mG.INVOICE_OPEN_STATUS_TOTALS.type,...n(C.mG.INVOICE_OPEN_STATUS_TOTALS.type)},totalStyle:{color:0===e?"#DADADA":"#000000"}},{clickable:t>0,showWarning:t>0,total:t,type:"projects-list",title:"Sales Orders",text:"Ready to be invoiced",report_type:C.mG.SALES_ORDER_READY_INVOICING_STATUS_TOTALS.type,order_type:C.mG.SALES_ORDER_READY_INVOICING_STATUS_TOTALS.params.order_type,status_id:C.mG.SALES_ORDER_READY_INVOICING_STATUS_TOTALS.params.status_id,params:{report_type:C.mG.SALES_ORDER_READY_INVOICING_STATUS_TOTALS.type,...n(C.mG.SALES_ORDER_READY_INVOICING_STATUS_TOTALS.type)},totalStyle:{color:0===t?"#DADADA":"#000000"}},{clickable:r>0,showWarning:r>0,total:r,type:"projects-list",title:"Sales Orders",text:"In production",report_type:C.mG.SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS.type,order_type:C.mG.SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS.params.order_type,status_id:C.mG.SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS.params.status_id,params:{report_type:C.mG.SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS.type,...n(C.mG.SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS.type)},totalStyle:{color:0===r?"#DADADA":"#000000"}},{clickable:a>0,showWarning:a>0,total:a,type:"deposit-invoices-list",title:"Deposit Invoices",text:"Not paid for uninvoiced orders",report_type:C.mG.DEPOSIT_INVOICES_NOT_PAID_UNINVOICED.type,params:{report_type:C.mG.DEPOSIT_INVOICES_NOT_PAID_UNINVOICED.type,...n(C.mG.DEPOSIT_INVOICES_NOT_PAID_UNINVOICED.type)},totalStyle:{color:0===a?"#DADADA":"#000000"}},{clickable:o>0,showWarning:o>0,total:o,type:"deposit-invoices-list",title:"Deposit Invoices",text:"Paid and not in production",report_type:C.mG.DEPOSIT_INVOICES_PAID_
1SO_NOT_IN_PRODUCTION.type,params:{report_type:C.mG.DEPOSIT_INVOICES_PAID_SO_NOT_IN_PRODUCTION.type,...n(C.mG.DEPOSIT_INVOICES_PAID_SO_NOT_IN_PRODUCTION.type)},totalStyle:{color:0===o?"#DADADA":"#000000"}},{clickable:l>0,showWarning:l>0,total:l,type:"clients-list",title:"Clients",text:"On credit hold",report_type:C.mG.CLIENTS_ON_CREDIT_HOLD.type,data:c.clientsOnCreditHold.data||[],params:{report_type:C.mG.CLIENTS_ON_CREDIT_HOLD.type,...n(C.mG.CLIENTS_ON_CREDIT_HOLD.type)},totalStyle:{color:0===l?"#DADADA":"#000000"}}]},[c,n]);return r?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Loading,{}),(0,m.jsx)("p",{style:{padding:0,margin:0,textAlign:"center",color:"#00A0B6",fontSize:"1.3rem"},children:"Loading..."})]}):(0,m.jsx)(d.Row,{children:(0,m.jsx)(d.Col,{xs:!0,children:(0,m.jsx)(W.L,{deps:[u,i],children:u.map(e=>(0,m.jsx)(d.Col,{xs:!0,sm:4,lg:3,padded:!0,style:{textAlign:"center",height:185},children:(0,m.jsx)(F,{style:{height:170,minWidth:160},...e,...e.clickable?{onClick:t(e)}:{}})},e.report_type+e.report_sub_type))})})})}),he=me;var Te=r(82654);const Oe=[{label:"Client Rep",value:"CLIENT"},{label:"Order Rep",value:"ORDER"}],Ee=n().memo(e=>{const{identity:t,filters:r,setFilters:a}=e,o=(0,l.d4)(Te.Lk),{isAdmin:n}=(0,u.el)(t);return(0,m.jsxs)(d.Row,{style:{marginTop:0},children:[(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"user-rep_type",options:Oe,value:r.rep_type,onChange:e=>{const t=s().get(e,"value","");a(e=>({...e,rep_type:t}))},label:"Rep Type",className:"csku-select-v3"})}),(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"user-rep-id",options:o,value:r.rep_id,onChange:e=>{const t=s().get(e,"value","");a(e=>({...e,rep_id:t}))},label:"Rep",className:"csku-select-v3",isClearable:n&&r.rep_id})})]})});var be=r(75206),Ae=r.n(be),xe=r(67564),Pe=r(60794);function Re(e){return"object"==typeof e&&s().keys(e).length>0}const ve=e=>{let{row:t,style:r={}}=e;const a=t.original.sales_rep_id||t.original.user_id,s=((t.original.sales_rep_first_name||"")+" "+(t.original.sales_rep_last_name||"")).trim(),o=n().useMemo(()=>{const e=t.original.order_rep_file,r=t.original.order_rep_user_image_paths;return Re(e)?{src:(0,u.AE)(e)}:Re(r)?{user_image_paths:r}:{}},[t.original.order_rep_file,t.original.order_rep_user_image_paths]);return(0,m.jsx)("div",{"data-test-name":"SalesRepPic",style:r,children:(0,m.jsx)(X.Al,{children:(0,m.jsx)(X.Ay,{backgroundColor:d.colors.primary200,name:s,"data-tip":s,"data-for":"sales-rep-avatar",...o,style:a?{}:{display:"none"},onClick:()=>{a&&window.open(`/user.php?id=${a}`,"_blank")}})})})},Ie=e=>{let{row:t,style:r={}}=e;const a=t.original.job_name||"",s=a.length>50;return(0,m.jsx)("div",{"data-test-name":"ProjectName",style:r,children:(0,m.jsxs)(d.Link,{as:"a",href:`/project/${t.original.job_number}`,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),children:[t.original.job_number," - ",a.slice(0,51),s?"...":""]})})},fe=e=>{let{row:t,style:r={}}=e;return(0,m.jsx)("div",{"data-test-name":"SalesOrderNumber",style:r,children:(0,m.jsx)(d.Link,{as:"a",href:`/order.php?id=${t.original.order_id}`,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),children:t.original.order_form_number})})},Ce=e=>{let{row:t,style:r={}}=e;return(0,m.jsx)("div",{"data-test-name":"DepositNumber",style:r,children:(0,m.jsx)("span",{children:t.original.form_number})})},je=e=>{let{row:t,style:r={}}=e;const a=t.original.client_name||"",s=a.length>25;return(0,m.jsx)("div",{"data-test-name":"ClientName",style:r,children:(0,m.jsxs)(d.Link,{as:"a",href:`/client.php?id=${t.original.client_id}`,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),children:[a.slice(0,26),s]})})},De=e=>{let{row:t,style:r={}}=e;return(0,m.jsx)("div",{style:r,children:(0,m.jsx)("span",{children:t.original.date_orderdate?ge()(t.original.date_orderdate).format("YYYY-MM-DD"):""})})},Ne=e=>{let{row:t,style:r={}}=e;return(0,m.jsx)("div",{style:r,children:(0,m.jsx)("span",{style:{color:d.colors.green.main,fontWeight:"bold"},children:t.original.deposit_amount?(0,u.Y6)(t.original.deposit_amount):""})})},Le=xe.Al.getElementById("root")||xe.Al.getElementById("resku"),ke=e=>{let{data:t=[],loading:r=!1,handleUpdateRow:a,defaultSort:l={id:"date_orderdate",desc:!0}}=e;const i=(0,Q.A)(),[p,_]=(0,o.useState)(!1),[c,u]=(0,o.useState)(!1);(0,o.useEffect)(()=>{(0,y.W1)(),u(!1)},[t]);const g=n().useCallback(e=>_(e),[]),S=n().useMemo(()=>[{Header:()=>(0,m.jsx)("div",{children:"Order Rep"}),accessor:e=>`${e.sales_rep_first_name} ${e.sales_rep_last_name}`,sticky:"left",Cell:ve,noDrag:!0,minWidth:140,maxWidth:500,id:"user_id"},{Header:()=>(0,m.jsx)("div",{children:"Sales Order #"}),accessor:e=>`${e.order_form_number}`,Cell:fe,sticky:"left",noDrag:!0,minWidth:150,maxWidth:500,id:"order_form_number"},{Header:()=>(0,m.jsx)("div",{children:"Deposit #"}),accessor:e=>`${e.form_number}`,Cell:Ce,sticky:"left",noDrag:!0,minWidth:150,maxWidth:500,id:"form_number"},{Header:()=>(0,m.jsx)("div",{children:"Client"}),accessor:e=>`${e.client_name}`,Cell:je,sticky:"left",noDrag:!0,minWidth:140,maxWidth:500,id:"client_id"},{Header:()=>(0,m.jsx)("div",{children:"Job"}),accessor:e=>`${e.job_name}`,Cell:Ie,sticky:"left",noDrag:!0,minWidth:210,maxWidth:500,id:"job_id"},{Header:()=>(0,m.jsx)("div",{children:"Sales Order Date"}),accessor:e=>`${e.date_orderdate}`,Cell:De,sticky:"left",noDrag:!0,minWidth:175,maxWidth:500,id:"date_orderdate"},{Header:()=>(0,m.jsx)("div",{children:"Deposit Amount"}),accessor:e=>`${e.deposit_amount}`,Cell:Ne,sticky:"left",noDrag:!0,minWidth:150,maxWidth:500,id:"deposit_amount"}],[]),h=(0,o.useCallback)(e=>p&&p.job_id===e.job_id&&p.order_id===e.order_id?_(!1):_(e),[p]),T=n().useMemo(()=>i[1]<251?100:i[1]<351?150:i[1]<540?i[1]-280:i[1]<700?i[1]-350>450?450:i[1]-350:i[1]<850?i[1]-300>450?450:i[1]-300:500,[i]),O=n().useCallback(()=>_(!1),[]),E=n().useMemo(()=>s().get(p,["job_id"],null),[p]),b=n().useMemo(()=>"INVOICE"!==s().get(p,["order_type"],null)?"":s().get(p,["order_id"],null),[p]);return(0,m.jsxs)(m.Fragment,{children:[Ae().createPortal((0,m.jsx)(Pe.A,{onClose:O,onUpdate:a,projectId:E,orderId:b,loading:r}),Le),(0,m.jsxs)(d.SimpleWindowedTableStyles,{rowClickable:!0,style:r?{display:"none"}:{},children:[(0,m.jsx)(d.SimpleWindowedTable,{columns:S,data:t,defaultSort:l,onClickRow:h,onScroll:y.W1,onUpdateData:a,useTableProps:{autoResetPage:!c,autoResetGroupBy:!c,autoResetSortBy:!c,autoResetFilters:!c,autoResetRowState:!c,onClick:g},height:T}),(0,m.jsx)(q.default,{id:"sales-rep-avatar"})]}
1),r?(0,m.jsx)(d.Row,{children:(0,m.jsx)(d.Col,{xs:!0,style:{alignSelf:"100%",textAlign:"center"},children:(0,m.jsx)(d.Loading,{})})}):null]})},Ue=n().memo(e=>{const{identity:t,showPopup:r,setShowPopup:a}=e,o=(0,l.d4)(C.Tp.reports),n=(0,l.d4)(C.Tp.loading);if(!r)return null;if("add_task"===r.action)return(0,m.jsx)(D.VV,{onClose:()=>a(!1),message:{reminder_user:t.user_id,details_type:"NOTE",note_type:"NOTE"}});if(!["projects-list","clients-list","deposit-invoices-list"].includes(r.type))return null;let i=null;return"projects-list"===r.type?i=(0,m.jsx)(N.A,{...r,onSave:()=>a(!1)}):"clients-list"===r.type?i=(0,m.jsx)(oe,{...r,showLastActivity:!1,data:s().get(o,[r.report_type,"data"],[]),loading:s().get(n,[r.report_type],!1),onSave:()=>a(!1)}):"deposit-invoices-list"===r.type&&(i=(0,m.jsx)(ke,{...r,data:s().get(o,[r.report_type,"data"],[]),loading:s().get(n,[r.report_type],!1),onSave:()=>a(!1)})),(0,m.jsxs)(d.Popup,{title:r.title,onClose:()=>{a(!1)},className:`popup ${r.type}-popup csku-styles`,children:[i,(0,m.jsx)("br",{})]})}),we=["INVOICE_OPEN_STATUS_TOTALS","SALES_ORDER_READY_INVOICING_STATUS_TOTALS","SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS","CLIENTS_ON_CREDIT_HOLD","DEPOSIT_INVOICES_NOT_PAID_UNINVOICED","DEPOSIT_INVOICES_PAID_SO_NOT_IN_PRODUCTION"],Fe=function(e){const t=(0,l.wA)(),r=(0,g.Us)(),{isAdmin:a}=(0,u.el)(r),i=(0,l.d4)(C.Tp.loading),p=(0,l.d4)(e=>{const t=C.Tp.loading(e);return e.display.loading.fetch_pos_for_production||we.filter(e=>s().get(t,e,!1)).length>0}),[_,c]=(0,o.useState)(!1),[S,h]=(0,o.useState)(!0),[T,O]=(0,o.useState)(null),[E,b]=(0,o.useState)({rep_type:"CLIENT",rep_id:a?"":r.user_id,team_id:""}),A=n().useCallback(function(){return Se(E,arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")},[E]);(0,o.useEffect)(()=>{const e=A();if((0,y.W1)(),"GROUP"===e.rep_id&&!e.team_id)return;h(!0);const r=Object.values(C.mG).filter(e=>we.includes(e.type)).reduce((e,t)=>{const r=A(t.type),a=(0,C.FN)(t.type,{...r,"max-results":1});return a?[...e,a]:e},[]);(async()=>{await Promise.all(r.map(e=>t(e.cb(e.route,e.type,e.params))))})()},[t,A]);const x=n().useCallback(e=>()=>{const r=e.report_type||"",a=e.params.order_type,o=e.params.status_id,n=A(r),l=(0,C.FN)(r,n);if(!l)return;h(!1),t(l.cb(l.route,l.type,{...l.params,report_type:r,get_data:1,...e.params}));const d=`${e.title} - ${e.text||""}`,p=e.type;O({type:p,title:d,report_type:e.report_type,order_type:a,status_id:o,loading:e.loading||s().get(i,[e.report_type],!1),storeLoadingKeys:["reports","loading",e.report_type],filters:n})},[t,A,i]);return(0,m.jsx)(d.Row,{"data-test-name":"Dashboard",children:(0,m.jsxs)(d.Col,{xs:!0,padded:!0,children:[(0,m.jsx)(D.iM,{noteId:_,clearnoteId:()=>c(!1),onUpdateNote:e=>{t((0,j.w3)(e.note_id,e))}}),(0,m.jsx)(Ue,{identity:r,showPopup:T,setShowPopup:O}),(0,m.jsxs)(d.Row,{style:{marginTop:0,marginBottom:20},children:[(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,children:(0,m.jsx)(z.A,{title:"Finance Dashboard"})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,end:1,children:(0,m.jsx)(le.m,{})})]}),(0,m.jsx)(Ee,{identity:r,filters:E,setFilters:b}),(0,m.jsx)(he,{onClickNumberTile:x,isLoading:p&&S,filters:E}),(0,m.jsx)(d.Row,{style:{...p&&S?{display:"none"}:{}},children:(0,m.jsx)(d.Col,{xs:!0,padded:!0,children:(0,m.jsx)(y.D4,{padded:!0,children:(0,m.jsx)(D.Ag,{noteId:_,onClickNote:c,noteUserId:E.rep_id,onAddTask:e=>{O({action:"add_task"})}})})})})]})})},We=new Date,Ge=["SALES_TOTALS","PROJECTION_TOTALS","STUCK_IN_STAGE_TOTALS","POTENTIAL_REPEAT_ORDERS","CLIENTS_WITH_NO_RECENT_ACTIVITY","SALES_ORDERS_PENDING_CLIENT_APPROVAL","PRESALES_PENDING_CLIENT_APPROVAL","OVER
1DUE_IN_HANDS_DATE_PROJECTS","PROJECTS_WITH_NO_BUDGET","OPEN_ORDER_STATUS_TOTALS"],Ve="MANAGEMENT_DASHBOARD_ORDER_REP_TYPE",$e="MANAGEMENT_DASHBOARD_CLIENT_REP_TYPE",Be=function(e){let{...t}=e;const r=(0,l.wA)(),a=(0,g.Us)(),n=(0,l.d4)(e=>{const t=(0,ne.I6)(e).map(e=>({value:e.key,label:e.value}));return[{label:"All",value:""},{label:"Group",value:"GROUP"}].concat(t)}),i=(0,l.d4)(e=>e.entities.statuses),_=(0,l.d4)(e=>Object.values(e.entities.teams).map(e=>({value:e.team_id,label:e.team_name}))),c=(0,l.d4)(e=>{const t=C.Tp.loading(e);return Ge.filter(e=>s().get(t,e,!1)).length>0}),S=(0,l.d4)(C.Tp.loading),h=(0,l.d4)(C.Tp.reports),{hasUserFlag:T,onDeleteAddFlag:O}=(0,g.B7)(a),E=T(Ve),[b,A]=(0,o.useState)({rep_type:E?"ORDER":"CLIENT",rep_id:"",team_id:""}),[x,P]=(0,o.useState)(!1),[R,v]=(0,o.useState)(null),[I,f]=(0,o.useState)(!0),[k,F]=(0,o.useState)(!1),[W,G]=(0,o.useState)("OPEN_SALES_ORDERS"),[V,B]=(0,o.useState)({imgSrc:"",title:"",text:"",link:"",dashboard:""});(0,o.useEffect)(()=>{(0,u.oD)("GET","marketing-setting/dashboard-marketing",{dashboard_type:"MANAGEMENT"},null,null,null,!1).then(e=>{const{json:t}=e;B(t.marketing)}).catch(e=>{console.error(e)})},[r,a]),(0,o.useEffect)(()=>{if((0,y.W1)(),"GROUP"===b.rep_id&&!b.team_id)return;f(!0);const e=Object.values(C.mG).filter(e=>Ge.includes(e.type)).reduce((e,t)=>{const r=(0,C.FN)(t.type,b);return r?[...e,r]:e},[]);(async()=>{await Promise.all(e.map(e=>r(e.cb(e.route,e.type,e.params))))})()},[r,b]),(0,o.useEffect)(()=>{const e="ORDER"===b.rep_type?$e:Ve,t="ORDER"===b.rep_type?Ve:$e;O(e,t)},[b.rep_type,O]);const M=e=>{if(!s().get(e,"order_type",""))return;f(!1);const t=e.order_type,a=C.mG.STUCK_IN_STAGE_TOTALS,o=e.title,n=(0,C.FN)("STUCK_IN_STAGE_TOTALS",b);n&&(r(n.cb(n.route,n.type,{...n.params,report_type:"STUCK_IN_STAGE_TOTALS",get_data:1,days:30,order_type:t})),v({type:"projects-list",title:"Stuck in Stage - "+o,report_type:a.type,order_type:t,loading:S[a.type]}))},Y=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!s().get(e,"month_name",""))return;f(!1);const a=C.mG.PROJECTION_TOTALS,o=e.month_name,n=new Date(parseInt(e.year),parseInt(e.month),1);n.setDate(n.getDate()-1);const l=(0,C.FN)("PROJECTION_TOTALS",b);l&&(r(l.cb(l.route,l.type,{...l.params,report_type:"PROJECTION_TOTALS",get_data:1,start_stamp:(0,u.yw)(new Date(parseInt(e.year),parseInt(e.month)-1,1)),end_stamp:(0,u.yw)(n),order_type:t||""})),v({type:"projects-list",title:"Projection - "+o,report_type:a.type,loading:S[a.type],order_type:t}))},H=e=>{if(!s().get(e,"order_type",""))return;f(!1);const t=e.order_type,a=e.title,o=e.status_name,n=(0,C.FN)("OPEN_ORDER_STATUS_TOTALS",b);n&&(r(n.cb(n.route,n.type,{...n.params,report_type:"OPEN_ORDER_STATUS_TOTALS",get_data:1,order_type:t,status_name:o})),v({type:"projects-list",report_type:"OPEN_ORDER_STATUS_TOTALS",loading:S.OPEN_ORDER_STATUS_TOTALS,title:"Open Orders - "+a,order_type:t}))};function q(e){return W!==e?{opacity:0,height:0,display:"none"}:{opacity:1,transition:"300ms opacity ease-out"}}return(0,m.jsx)(d.Row,{"data-test-name":"Dashboard",children:(0,m.jsxs)(d.Col,{xs:!0,padded:!0,children:[(0,m.jsx)(D.iM,{noteId:x,clearnoteId:()=>P(!1),onUpdateNote:e=>{f(!1),r((0,j.w3)(e.note_id,e))}}),function(){if(!R)return null;if("add_task"===R.action)return(0,m.jsx)(D.VV,{"data-test-name":"Dashboard.renderPopup",onClose:()=>v(!1),message:{details_type:"NOTE",note_type:"NOTE"}});if("new-project"===R.action)return(0,m.jsx)(le.A,{"data-test-name":"Dashboard.renderPopup",onClose:()=>v(!1)});if(!["projects-list","clients-list"].includes(R.type))return null;let e=null;return"projects-list"===R.type?e=(0,m.jsx)(N.A,{...R,onSave:()=>v(!1),loadReportTotal:e=>F(e)}):"clients-list"===R.type&&(e=(0,m.jsx)(oe,{...R,onSave:()=>v(!1)})),(0,m.jsxs)(d.Popup,{"data-test-name":"Dashboard.renderPopup",title:R.title,onClose:()=>{if(v(!1),k){const e=(0,C.FN)(k,b);if(!e)return e;r(e.cb(e.route,e.type,e.params))}},className:`popup ${R.type}-popup csku-styles`,children:[e,(0,m.jsx)("br",{})]})}(),(0,m.jsxs)(d.Row,{style:{marginTop:0,marginBottom:20}
1,children:[(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,children:(0,m.jsx)(z.A,{title:"Management Dashboard"})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,end:1,children:(0,m.jsx)(le.m,{})})]}),(0,m.jsxs)(d.Row,{"data-test-name":"Dashboard.renderFilters",style:{marginTop:0,marginBottom:0},children:[(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"dashboard-rep-type",options:p.Y9,value:b.rep_type,onChange:e=>{A(t=>({...t,rep_type:e?e.value:""}))},label:"Rep Type",className:"csku-select-v3"})}),(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"dashboard-rep",options:n,value:b.rep_id,onChange:e=>{const t=s().get(e,"value","");A("GROUP"!==t?e=>({...e,rep_id:t,team_id:""}):e=>({...e,rep_id:t}))},label:"Rep",className:"csku-select-v3",isClearable:b.rep_id})}),"GROUP"===b.rep_id?(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"dashboard-team_id",options:_,value:b.team_id,onChange:e=>A(t=>({...t,team_id:e?e.value:""})),label:"Group",className:"csku-select-v3",isClearable:b.team_id})}):null]}),c&&I?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Loading,{}),(0,m.jsx)("p",{style:{padding:0,margin:0,textAlign:"center",color:"#00A0B6",fontSize:"1.3rem"},children:"Loading..."})]}):function(){const e=(0,p.jk)(h),t=parseFloat((s().find(s().get(h,"PROJECTION_TOTALS.sales_target",[]),e=>e.year==We.getFullYear()&&e.month==We.getMonth()+1)||{target:"0.0000"}).target||0),o=parseFloat((s().find(s().get(h,"PROJECTION_TOTALS.orders",[]),e=>e.year==We.getFullYear()&&e.month==We.getMonth()+1&&"INVOICE"==e.order_type)||{total:"0.0000"}).total||0),n=parseFloat((s().find(s().get(h,"PROJECTION_TOTALS.sales_target",[]),e=>e.year==We.getFullYear()&&e.month==We.getMonth()+1)||{sales_orders_target:"0.0000"}).sales_orders_target||0),l=parseFloat((s().find(s().get(h,"PROJECTION_TOTALS.sales_orders_in_production_analytics",[]),e=>e.next_year==We.getFullYear()&&e.month==ie.yz[We.getMonth()].substring(0,3))||{total_next_year:"0.0000"}).total_next_year||0);return(0,m.jsxs)(d.Row,{"data-test-name":"Dashboard.renderContent",children:["CLIENT"===b.rep_type?(0,m.jsxs)(d.Col,{xs:!0,padded:!0,children:[1==a.show_invoice_targets?(0,m.jsx)(d.Thermometer,{value:o,valueLabel:"Invoices this month:",target:t,style:{marginBottom:1==a.show_sales_order_targets?"1rem":""}}):null,1==a.show_sales_order_targets?(0,m.jsx)(d.Thermometer,{value:l,valueLabel:"Sales orders in production:",target:n,barColor:"#FFD302",labelTextColor:"#C69B00",isSecondary:!0}):null]}):null,(0,m.jsx)(J,{salesReports:e,marketingTile:V,onClickTile:e=>{if(f(!1),e){const t=(0,C.FN)("SALES_TOTALS",b);if(!t)return;return r(t.cb(t.route,t.type,{...t.params,report_type:"SALES_TOTALS",report_sub_type:e.report_sub_type,get_data:1})),void v({type:"projects-list",report_type:"SALES_TOTALS",loading:S.SALES_TOTALS,...e})}v(e)}}),(0,m.jsx)(d.Col,{padded:!0,xs:!0,lg:6,children:(0,m.jsxs)(y.D4,{style:{paddingBottom:40},children:[(0,m.jsxs)(d.TabBar,{style:{marginBottom:10,borderBottomColor:d.colors.errors.main,fontSize:16},children:[(0,m.jsx)(d.Tab,{selected:"OPEN_SALES_ORDERS"===W,onClick:()=>{G("OPEN_SALES_ORDERS")},children:"Open Sales Orders"}),(0,m.jsx)(d.Tab,{selected:"OPEN_PRE_SALES"===W,onClick:()=>{G("OPEN_PRE_SALES")},children:"Open Pre-sales"}),(0,m.jsx)(d.Tab,{selected:"STUCK_IN_STAGE"===W,onClick:()=>{G("STUCK_IN_STAGE")},children:"Stuck In Stage"})]}),(0,m.jsx)("div",{style:{...q("STUCK_IN_STAGE")},children:(0,m.jsx)(w,{statuses:i,data:s().get(h,"STUCK_IN_STAGE_TOTALS.summary",{}),onClickColumn:M})}),(0,m.jsx)("div",{style:{...q("OPEN_SALES_ORDERS")},children:(0,m.jsx)(L,{statuses:i,data:s().get(h,"OPEN_ORDER_STATUS_TOTALS.summary",{}),order_type:"SALES ORDER",onClickColumn:H})}),(0,m.jsx)("div",{style:{...q("OPEN_PRE_SALES")},children:(0,m.jsx)(L,{statuses:i,data:s().get(h,"OPEN_ORDER_STATUS_TOTALS.summary",{}),order_type:"PRE-SALES",onClickColumn:H})})]})}),(0,m.jsx)(d.Col,{padded:!0,xs:!0,lg:6,children:(0,m.jsxs)(y.D4,{children:[(0,m.jsx)(d.Text,{as:"p",style:{marginTop:0,fontSize:16,fontWeight:"bold",padding:16},children:"Projection"}),(0,m.jsx)(U,{salesTargets:s().get(h,"PROJECTION_TOTALS.sales_target",[]),orders:s().get(h,"PROJECTION_TOTALS.orders",[]),onClickColumn:Y,he
1ight:"380px"})]})}),(0,m.jsx)(d.Col,{xs:!0,children:(0,m.jsx)($,{salesReports:e,salesRepId:b.rep_id,salesTeamId:b.team_id,salesRepType:b.rep_type,onClickTile:e=>{f(!1),v(e)},marketingTile:V})}),(0,m.jsx)(d.Col,{xs:!0,padded:!0,children:(0,m.jsx)(y.D4,{padded:!0,children:(0,m.jsx)(D.Ag,{noteId:x,onClickNote:P,repType:b.rep_type,noteUserId:b.rep_id,noteUserTeamId:b.team_id,onAddTask:e=>{f(!1),v({action:"add_task"})},onChangeWeek:()=>f(!1)})})})]})}()]})})};var Me=r(40585),Ye=r(93807),He=r(26926),Je=r(57191);function ze(e,t){switch(e){case"NA_DATE":return t.date_nextaction;case"IH_DATE":return t.po_or_so_in_hands_date;case"PS_DATE":return t.date_shipdatecurrent;default:return null}}const qe="SHOW_CALENDAR_WEEKEND",Ke="TASK",Xe="PO",Qe=new Date,Ze=function(e){let{itemId:t=null,onClickItem:r=null,onAddTask:a=null,onChangeWeek:i=null,onUpdate:p=null,repType:_=null,userId:c=null,teamId:S=null,...h}=e;const T=(0,g.Us)(),{onAddFlag:O,onDeleteFlag:E,hasUserFlag:b}=(0,g.B7)(T),[A,x]=(0,o.useState)("ALL"),[P,R]=(0,o.useState)(Ke),v=n().useMemo(()=>[{title:"Tasks",type:Ke,selected:!1,showFooterTasks:!0,Icon:d.TaskIcon,calendarTabs:[{content:"",label:"All Tasks",key:"ALL",onClick:()=>{x("ALL")}},{content:"",label:"Client Tasks",key:"CLIENT",onClick:()=>{x("CLIENT")}},{content:"",label:"Project Tasks",key:"JOB",onClick:()=>{x("JOB")}},{content:"",label:"PO Tasks",key:"PURCHASE ORDER",onClick:()=>{x("PURCHASE ORDER")}}]},{title:"POs",type:Xe,selected:!1,showFooterTasks:!1,Icon:d.ReceiptLongIcon,calendarTabs:[{content:"",label:"Next Action Date",key:"NA_DATE",onClick:()=>{x("NA_DATE")}},{content:"",label:"In Hands Date",key:"IH_DATE",onClick:()=>{x("IH_DATE")}},{content:"",label:"Projected Ship Date",key:"PS_DATE",onClick:()=>{x("PS_DATE")}}]}],[]),I=n().useMemo(()=>v.find(e=>e.type===P),[v,P]),f=function(e){let{identity:t,teamId:r=null,userId:a=null}=e;const o=(0,l.wA)(),i=(0,l.d4)(e=>j.Tp.loading(e).notes),d=(0,l.d4)(e=>{const t=(0,Je.A)(e,r,a),o=j.Tp.calendarNotesByReminderUsers(e,t);return!a||r?o.map(e=>({...e,title:(0,m.jsxs)("span",{children:[(0,m.jsx)(X.Ay,{name:s().get(e,"reminder_user_full_name",e.title),style:{display:"inline-flex",fontSize:"0.85rem",height:28,width:28},"data-tip":s().get(e,"reminder_user_full_name",e.title)||"","data-for":"note-rep-avatar"}),(0,m.jsx)("span",{children:e.title})]})})):o}),p=(0,l.d4)(e=>{const t=(0,Je.A)(e,r,a),o=j.Tp.overdueCalendarNotesByReminderUsers(e,t);return!a||r?o.map(e=>({...e,title:!a||r?(0,m.jsxs)("span",{children:[(0,m.jsx)(X.Ay,{name:s().get(e,"reminder_user_full_name",e.title),style:{display:"inline-flex",fontSize:"0.85rem",height:28,width:28},"data-tip":s().get(e,"reminder_user_full_name",e.title)||"","data-for":"note-rep-avatar"}),(0,m.jsx)("span",{children:e.title})]}):e.title})):o}),_=n().useCallback(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};("GROUP"!==a||r)&&o((0,j.GW)({start_stamp_reminder:(0,u.yw)((0,u.ny)(new Date)),end_stamp_reminder:(0,u.yw)((0,u.OX)(new Date)),include_complete:!0,note_type:"ALL REMINDERS",reminder_user_id:a,reminder_user_team_id:r,tenant_id:t.company_id,max_results:1e3,with_po:!0,with_parent_data:!0,...e}))},[o,a,r,t]);return{loading:i,tasks:d,overdueTasks:p,getNotes:_,onUpdate:e=>{o((0,j.w3)(e.note_id,e))}}}({identity:T,userId:c,teamId:S,repType:_,selectedTab:A,isSelected:I.type===Ke}),C=function(e){let{identity:t,teamId:r=null,userId:a=null,repType:o=null,selectedTab:i="NA_DATE"}=e;const p=(0,l.wA)(),_=(0,l.d4)(e=>s().get(e,["display","loading","fetch_pos_for_production"],!1)),c=(0,l.d4)(e=>e.entities.next_action_types),y=(0,l.d4)(He.LH),g=(0,l.d4)(e=>{const t=(0,Je.A)(e,r,a);return(0,He.qK)(e).filter(e=>{const r=ze(i,e);return("ALL"===t||t.includes(e.production_rep_id))&&r&&"0000-00-00 00:00:00"!==r&&"0"!==r}).map(e=>{const t=`PO #${e.form_number}`,o=ze(i,e);return{hideCheckbox:!0,id:e.purchase_order_id,purchase_order_id:e.purchase_order_id,date_nextaction:e.date_nextaction,draggable:["NA_DATE","PS_DATE"].includes(i),description:(0,m.jsxs)(d.Text,{style:{color:"#000",fontFamily:d.themeOptions.fontFamilies.regular},children:[(0,m.jsx)("span",{style:{display:"block",paddingTop:10,paddingBottom:5},children:e.supplier_name}),(0,m.jsxs)("span",{style:{display:"block",paddingBottom:5},children:["Project #",e.job_number]}),(0,m.jsx)("span",{style:{display:"block",paddingBottom:5},children:s().get(c,[e.next_action_type_id,"label"],"")})]}),title:!a||r?(0,m.jsxs)("span",{style:{color:"#000"},children:[(0,m.jsx)(X.Ay,{name:s().get(e,"purchase_order_rep_full_name",t),style:{display:"inline-flex",fontSize:"0.85rem",height:28,width:28},"data-tip":s().get(e,"purchase_order_rep_full_name",t)||"","data-for":"po-rep-avatar"}),(0,m.jsxs)(d.Text,{style:{fontWeight:"bold"},children:["#",e.form_number]})]}):(0,m.jsxs)(d.Text,{style:{fontWeight:"bold",color:"#000"},children:["#",e.form_number]}),Icon:(0,m.jsx)(d.ReceiptLongIcon,{}),date:new Date((0,u._U)(o)),colorType:"light-green",isDescriptionHtml:!0}})}),S=n().useCallback(e=>s().get(y,[e]),[y]),h=n().useCallback(e=>p((0,Ye.cB)(e,{production_po:!0})),[p]),T=n().useCallback(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};("GROUP"!==a||r)&&p((0,Ye.G7)({start_stamp:(0,u.yw)((0,u.ny)(new Date)),end_stamp:(0,u.yw)((0,u.OX)(new Date)),date_filter:"",rep_type:o,production_rep_id:a||"",rep_team_id:r||"",tenant_id:t.company_id,"max-results":1e3,calendar_view:!0,...e}))},[p,a,r,o,t]);return{loading:_,tasks:g,overdueTasks:[],getPOs:T,onUpdate:(e,t,r,a)=>{p((0,Ye.Dz)(e,t,r,a))},findPO:S,fetchPO:h}}({identity:T,userId:c,teamId:S,repType:_,selectedTab:A,isSelected:I.type===Xe}),D=n().useMemo(()=>I.type===Ke?f.loading:I.type===Xe?C.loading:(I.type,!1),[I,f.loading,C.loading]),N=n().useMemo(()=>I.type===Ke?A===Me.D.ALL.value?f.tasks:s().filter(f.tasks,e=>e.parent_type===A):I.type===Xe?C.tasks:(I.type,[]),[f.tasks,C.tasks,A,I]),L=n().useMemo(()=>I.type===Ke?A===Me.D.ALL.value?f.overdueTasks:s().filter(f.overdueTasks,e=>e.parent_type===A):[],[f.overdueTasks,A,I]);(0,o.useEffect)(()=>{I.type===Ke&&f.getNotes({start_stamp_reminder:(0,u.yw)((0,u.W9)(30,Qe)),end_stamp_reminder:(0,u.yw)((0,u.W9)(1,(0,u.ny)(Qe))),include_complete:!1})},[T]),(0,o.useEffect)(()=>{x(I.calendarTabs&&I.calendarTabs.length?I.calendarTabs[0].key:"ALL")},[I]),(0,o.useEffect)(()=>{I.type===Ke?f.getNotes():I.type===Xe?C.getPOs({start_stamp:(0,u.yw)((0,u.ny)(Qe)),end_stamp:(0,u.yw)((0,u.OX)(Qe)),date_filter:""}):I.type,(0,y.W1)()},[I,f.getNotes,C.getPOs]),(0,o.useEffect)(()=>{r&&r(!1)},[A,r,I]),(0,o.useEffect)(()=>{(0,y.W1)()},[D]);const k=n().useCallback(e=>{void 0===t||t!==e.id?"PO"!==I.type?r&&r(I.type,e.id,e):Promise.resolve(C.fetchPO(e.id)).then(t=>{r&&r(I.type,e.id,C.findPO(e.id)||e)}):r&&r(!1)},[t,r,I,C.findPO,C.fetchPO]),U=n().useCallback(e=>{let{date:t}=e;if(I.type===Ke){const e={start_stamp_reminder:(0,u.yw)((0,u.ny)(t)),end_stamp_reminder:(0,u.yw)((0,u.OX)(t))};f.getNotes(e),(0,y.W1)()}else I.type===Xe?C.getPOs({start_stamp:(0,u.yw)((0,u.ny)(t)),end_stamp:(0,u.yw)((0,u.OX)(t)),date_filter:""}):I.type;i&&i({date:t,start_stamp:(0,u.yw)((0,u.ny)(t)),end_stamp:(0,u.yw)((0,u.OX)(t))})},[i,I,f.getNotes,C.getPOs]),w=b(qe);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.DraggableTasksCalendar,{tasks:N,views:s().map(v,e=>({...e,selected:P===e.type}
1)),onUpdateTask:(e,t)=>{if(I.type===Ke)"DROP"===t.action?f.onUpdate({note_id:e.note_id,date_reminder:s().isDate(e.date)?(0,u.yw)(e.date):e.date}):"TOGGLE_CHECKBOX"===t.action&&f.onUpdate({note_id:e.note_id,reminder_complete:e.completed?1:0}),(0,y.W1)();else if(I.type===Xe&&"DROP"===t.action){let t=null;switch(A){case"NA_DATE":t="date_nextaction";break;case"PS_DATE":t="date_shipdatecurrent";break;default:return}if(!t)return;const r=s().isDate(e.date)?(0,u.yw)(e.date):e.date;C.onUpdate(e.purchase_order_id,t,e[t],r)}p&&p(e,t,I)},footerTasks:L,headerTabs:s().get(I,"calendarTabs",[]),onClickTask:k,onChangeWeek:U,onClickAddTask:a,loading:D,weekend:w,onToggleWeekend:e=>{e?O(qe):E(qe),(0,y.W1)()},onClickView:R,showFooterTasks:s().get(I,"showFooterTasks",!1),showAddTaskBtn:I.type===Ke}),(0,m.jsx)(q.default,{id:"po-rep-avatar"})]})};var et=r(26955),tt=r(23329);const rt=["PO_STATUS_TOTALS","OPEN_ORDER_STATUS_TOTALS"],at={PO_BY_STAGE:"PO_BY_STAGE",PO_BY_PROOF_STATUS:"PO_BY_PROOF_STATUS",PO_OVERDUE_NEXT_ACTION_DATE:"PO_OVERDUE_NEXT_ACTION_DATE",PO_OVERDUE_IN_HANDS_DATE:"PO_OVERDUE_IN_HANDS_DATE",PO_OVERDUE_PROJ_SHIP_DATE:"PO_OVERDUE_PROJ_SHIP_DATE",PO_PROBLEM_STATUS:"PO_PROBLEM_STATUS",PO_FOLLOW_UP_STATUS:"PO_FOLLOW_UP_STATUS"},st=function(e){let{...t}=e;const r=(0,l.wA)(),a=(0,g.Us)(),i=(0,l.d4)(C.Tp.loading),_=(0,l.d4)(e=>{const t=C.Tp.loading(e);return e.display.loading.fetch_pos_for_production||rt.filter(e=>s().get(t,e,!1)).length>0}),c=(0,l.d4)(e=>e.entities.statuses),S=(0,l.d4)(C.Tp.reports),h=(0,l.d4)(He.LH),T=(0,l.d4)(Te.Lk),[O,E]=(0,o.useState)(!1),[b,A]=(0,o.useState)(!0),[x,P]=(0,o.useState)(null),[R,v]=(0,o.useState)(!1),[I,f]=(0,o.useState)("details"),[L,U]=(0,o.useState)(a.user_id),[w,G]=(0,o.useState)({imgSrc:"",title:"",text:"",link:"",dashboard:""}),V=s().get(h,[R],!1),$=(0,l.d4)(e=>(0,Je.A)(e,null,L));(0,o.useEffect)(()=>{(0,u.oD)("GET","marketing-setting/dashboard-marketing",{dashboard_type:"PRODUCTION"},null,null,null,!1).then(e=>{const{json:t}=e;G(t.marketing)}).catch(e=>{console.error(e)})},[r,a]),(0,o.useEffect)(()=>{A(!0),(0,y.W1)();const e=Object.values(C.mG).filter(e=>"OPEN_ORDER_STATUS_TOTALS"===e.type).reduce((e,t)=>{const r=(0,C.FN)(t.type,{});return r?[...e,r]:e},[]);(async()=>{await Promise.all(e.map(e=>r(e.cb(e.route,e.type,{...e.params,..."OPEN_ORDER_STATUS_TOTALS"===e.type?{order_type:"SALES ORDER",rep_type:"ORDER",rep_id:"",production_rep_id:"",status_name:"Client Approved"}:{}})))),A(!1)})()},[r]),(0,o.useEffect)(()=>{A(!0),(0,y.W1)();const e=Object.values(C.mG).filter(e=>rt.includes(e.type)&&"OPEN_ORDER_STATUS_TOTALS"!==e.type).reduce((e,t)=>{if("PO_STATUS_TOTALS"===t.type)return[...e,...Object.keys(at).filter(e=>!["PO_PROBLEM_STATUS","PO_FOLLOW_UP_STATUS"].includes(e)).map(e=>(0,C.FN)(t.type,{rep_id:L,report_sub_type:e}))];const r=(0,C.FN)(t.type,{rep_id:L});return r?[...e,r]:e},[]);(async()=>{await Promise.all(e.map(e=>r(e.cb(e.route,e.type,e.params)))),A(!1)})()},[r,L]);const B=n().useCallback(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e&&s().get(s().find(s().values(c),r=>{const a=r.status_name===e;return t?a&&["PROOF","PURCHASE ORDER"].includes(r.parent_type):a}),["status_id"],"")||""},[c]),M=n().useCallback((e,t)=>{const r={production_rep_ids:$};return e===at.PO_BY_STAGE?r.status_id=t:e===at.PO_BY_PROOF_STATUS?r.proof_status_id=t:e===at.PO_PROBLEM_STATUS?r.standing="PROBLEM":e===at.PO_FOLLOW_UP_STATUS?r.standing="FOLLOWUP":e===at.PO_OVERDUE_NEXT_ACTION_DATE?r.next_action_date_overdue=!0:e===at.PO_OVERDUE_IN_HANDS_DATE?r.inhands_date_overdue=!0:e===at.PO_OVERDUE_PROJ_SHIP_DATE&&(r.proj_ship_date_overdue=!0),r},[$]),H=n().useCallback(e=>()=>{const t=e.report_sub_type||"",a=(0,C.FN)(e.report_type,{rep_id:L,production_rep_id:L});if(!a)return;A(!1),r(a.cb(a.route,a.type,{...a.params,report_type:e.report_type,report_sub_type:t,get_data:1,...e.params}));let o="";e.report_sub_type===at.PO_FOLLOW_UP_STATUS?o="Follow Up":e.report_sub_type===at.PO_PROBLEM_STATUS&&(o="Problem");const n=B(o,"production-list"===e.type),l=`${"project-list"===e.type?"Sales Orders":"POs"} - ${e.text}`,d=e.type||"production-list";P({type:d,title:l,report_type:e.report_type,report_sub_type:t,loading:e.loading||s().get(i,[e.report_type],!1),storeLoadingKeys:["reports","loading",e.report_type],posFilters:"production-list"===d?M(t,n):void 0})},[r,L,i,M,B]),J=n().useCallback(e=>{if(!s().get(e,"order_type","")&&!s().get(e,"status_name",""))return;A(!1);const t=e.order_type,a=e.status_name,o=e.report_type||"",n=B(a,!0),l=`POs - ${a}`,i=(0,C.FN)("PO_STATUS_TOTALS",{rep_id:L,production_rep_id:L});i&&(r(i.cb(i.route,i.type,{...i.params,report_type:"PO_STATUS_TOTALS",report_sub_type:o,get_data:1,order_type:t,status_name:a,status_id:n})),P({type:"production-list",title:l,report_type:"PO_STATUS_TOTALS",report_sub_type:o,order_type:t,storeLoadingKeys:["reports","loading","PO_STATUS_TOTALS"],posFilters:M(o,n)}))},[r,L,M,B]),q=(0,p.jk)(S),K=n().useMemo(()=>{const e=parseInt(s().get(q.poStatusReport,["totals",at.PO_OVERDUE_NEXT_ACTION_DATE],0)||0),t=parseInt(s().get(q.poStatusReport,["totals",at.PO_OVERDUE_IN_HANDS_DATE],0)||0),r=parseInt(s().get(q.poStatusReport,["totals",at.PO_OVERDUE_PROJ_SHIP_DATE],0)||0),a=parseInt(s().get(q.poStatusReport,["totals","num_problem"],0)||0),o=parseInt(s().get(q.poStatusReport,["totals","num_follow_up"],0)||0),n=parseInt(s().get(q.openOrderStatusTotals,["sales_order_num_client_approved"])||0);return[{clickable:e>0,checked:0===e,showWarning:e>0,total:e,type:"production-list",title:"POs",text:0===e?"No overdue next actions":"Next action overdue",report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_OVERDUE_NEXT_ACTION_DATE,params:{report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_OVERDUE_NEXT_ACTION_DATE,rep_id:L,production_rep_id:L},totalStyle:{color:0===e?"#DADADA":"#000000"}},{clickable:t>0,checked:0===t,showWarning:t>0,total:t,type:"production-list",title:"POs",text:0===t?"No overdue in-hands dates":"In-hands overdue",report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_OVERDUE_IN_HANDS_DATE,params:{report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_OVERDUE_IN_HANDS_DATE,rep_id:L,production_rep_id:L},totalStyle:{color:0===t?"#DADADA":"#000000"}},{clickable:r>0,checked:0===r,showWarning:r>0,total:r,type:"production-list",title:"POs",text:0===r?"No overdue projected ship dates":"Projected ship date overdue",report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_OVERDUE_PROJ_SHIP_DATE,params:{report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_OVERDUE_PROJ_SHIP_DATE,rep_id:L,production_rep_id:L},totalStyle:{color:0===r?"#DADADA":"#000000"}},{clickable:a>0,showWarning:a>0,total:a,type:"production-list",title:"POs",text:"Problem status",report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_PROBLEM_STATUS,params:{report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_PROBLEM_STATUS,rep_id:L,production_rep_id:L},totalStyle:{color:0===a?"#DADADA":"#000000"}},{clickable:o>0,showWarning:o>0,total:o,type:"production-list",title:"POs",text:"Followup status",report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_FOLLOW_UP_STATUS,params:{report_type:C.mG.PO_STATUS_TOTALS.type,report_sub_type:at.PO_FOLLOW_UP_STATUS,rep_id:L,production_rep_id:L},totalStyle:{color:0===o?"#DADADA":"#000000"}},{clickable:!0,showWarning:n>0,total:n,title:"Sales Orders",text:"Client approved",type:"projects-list",report_type:C.mG.OPEN_ORDER_STATUS_TOTALS.type,params:{order_type:"SALES ORDER",status_name:"Client Approved",rep_type:"",rep_id:"",production_rep_id:""},totalStyle:{color:0===n?"#DADADA":"#000000"}}]},[q,L,i]),X=n().useCallback(()=>(0,m.jsxs)(d.Row,{"data-test-name":"Dashboard",children:[(0,m.jsx)(d.
1Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(F,{showPS:!0,style:{height:170,minWidth:160},text:"With PS order status updated",title:"POs",total:"Coming Soon",totalStyle:{fontSize:18}})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(F,{showPS:!0,style:{height:170,minWidth:160},text:"With PS shipping update",title:"POs",total:"Coming Soon",totalStyle:{fontSize:18}})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(F,{showPS:!0,style:{height:170,minWidth:160},text:"TBD",title:"POs",total:"Coming Soon",totalStyle:{fontSize:18}})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,md:4,lg:2,padded:!0,children:(0,m.jsx)(Y,{})}),(0,m.jsx)(d.Col,{xs:!0,sm:!0,md:8,lg:4,style:{paddingTop:"0.5rem",paddingLeft:"0.5rem",alignSelf:"center"},children:(0,m.jsx)(y.DE,{link:w.link,title:w.title,imgSrc:w.imgSrc,boxShadow:"",maxHeight:170})}),(0,m.jsx)(d.Col,{padded:!0,xs:!0,lg:6,children:(0,m.jsxs)(y.D4,{children:[(0,m.jsx)(d.Text,{as:"p",style:{marginTop:0,fontSize:16,fontWeight:"bold",padding:16},children:"Purchase Orders by Stage"}),(0,m.jsx)(k,{totals:s().get(q,["poStatusReport","totals"],{}),order_type:"PURCHASE ORDER",report_type:at.PO_BY_STAGE,onClickColumn:J,height:"380px"})]})}),(0,m.jsx)(d.Col,{padded:!0,xs:!0,lg:6,children:(0,m.jsxs)(y.D4,{children:[(0,m.jsx)(d.Text,{as:"p",style:{marginTop:0,fontSize:16,fontWeight:"bold",padding:16},children:"Purchase Orders by Proof Status"}),(0,m.jsx)(k,{totals:s().get(q,["poStatusReport","totals"],{}),order_type:"PROOF",report_type:at.PO_BY_PROOF_STATUS,onClickColumn:J,height:"380px"})]})}),(0,m.jsx)(d.Col,{xs:!0,children:(0,m.jsx)(W.A,{deps:[K,a],children:K.map(e=>(0,m.jsx)(d.Col,{"data-test-name":"Dashboard",xs:!0,sm:4,lg:3,padded:!0,style:{textAlign:"center",height:185},children:(0,m.jsx)(F,{style:{height:170,minWidth:160},...e,...e.clickable?{onClick:H(e)}:{}})},e.report_type+e.report_sub_type))})})]}),[a,w,H,J,q,K]);return(0,m.jsx)(d.Row,{"data-test-name":"Dashboard",children:(0,m.jsxs)(d.Col,{xs:!0,padded:!0,children:[(0,m.jsx)(D.iM,{noteId:O,clearnoteId:()=>E(!1),onUpdateNote:e=>{r((0,j.w3)(e.note_id,e))}}),(0,m.jsx)(et.A,{sidePanelRow:V,setSidePanelRow:v,selectedTab:I,setSelectedTab:f,sidepanelZIndex:1005}),function(){if(!x)return null;if("add_task"===x.action)return(0,m.jsx)(D.VV,{"data-test-name":"Dashboard.renderPopup",onClose:()=>P(!1),message:{reminder_user:L,details_type:"NOTE",note_type:"NOTE"}});if(!["production-list","projects-list"].includes(x.type))return null;let e=null;return"production-list"===x.type?e=(0,m.jsx)(tt.A,{...x,sidePanelRow:V,setSidePanelRow:e=>{e&&s().get(e,["purchase_order_id"],!1)?v(e.purchase_order_id):v(!1)},setSelectedSidePanelTab:f,showPopupTable:!0,onSave:()=>P(!1)}):"projects-list"===x.type&&(e=(0,m.jsx)(N.A,{...x,onSave:()=>P(!1)})),(0,m.jsxs)(d.Popup,{"data-test-name":"Dashboard.renderPopup",title:x.title,onClose:()=>{P(!1)},className:`popup ${x.type}-popup csku-styles`,popupContentStyle:{height:"calc(100% - 60px)"},children:[e,(0,m.jsx)("br",{})]})}(),(0,m.jsxs)(d.Row,{style:{marginTop:0,marginBottom:20},children:[(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,children:(0,m.jsx)(z.A,{title:"Production Dashboard"})}),(0,m.jsx)(d.Col,{xs:!0,sm:6,padded:!0,end:1,children:(0,m.jsx)(le.m,{})})]}),(0,m.jsx)(d.Row,{"data-test-name":"Dashboard.renderFilters",style:{marginTop:0},children:(0,m.jsx)(d.Col,{xs:!0,md:4,padded:!0,children:(0,m.jsx)(y.AF,{name:"production-rep",options:T,value:L,onChange:e=>{const t=s().get(e,"value","");U(t)},label:"Production Rep",className:"csku-select-v3",isClearable:L})})}),_&&b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Loading,{}),(0,m.jsx)("p",{style:{padding:0,margin:0,textAlign:"center",color:"#00A0B6",fontSize:"1.3rem"},children:"Loading..."})]}):X(),(0,m.jsx)(d.Row,{style:{..._&&b?{display:"none"}:{}},children:(0,m.jsx)(d.Col,{xs:!0,padded:!0,children:(0,m.jsx)(y.D4,{padded:!0,children:(0,m.jsx)(Ze,{itemId:O,userId:L,repType:"ORDER",onClickItem:(e,t,r)=>{e===Ke?E(t):e===Xe&&v(t)},onAddTask:e=>{P({action:"add_task"})}})})})})]})})},ot=function(e){return"SUPPLIER"===(0,g.Us)().company_type?(0,m.jsx)(f,{"data-test-name":"DashboardContainer"}):"SALES_DASHBOARD"===e.dashboard_type?(0,m.jsx)(ue,{"data-test-name":"DashboardContainer"}):"FINANCE_DASHBOARD"===e.dashboard_type?(0,m.jsx)(Fe,{"data-test-name":"DashboardContainer"}):"MANAGEMENT_DASHBOARD"===e.dashboard_type?(0,m.jsx)(Be,{"data-test-name":"DashboardContainer"}):"PRODUCTION_DASHBOARD"===e.dashboard_type?(0,m.jsx)(st,{"data-test-name":"DashboardContainer"}):(0,m.jsx)("div",{"data-test-name":"DashboardContainer",children:"Dashboard"})};r(13404)},23637(e,t,r){r.d(t,{H$:()=>_,NE:()=>l,Qi:()=>y,RJ:()=>u,S8:()=>d,Sk:()=>p,eX:()=>c,oo:()=>i,wW:()=>g});var a=r(22224),s=r.n(a),o=r(77777),n=r(22078);const l=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue}).dashboard.loading},i=e=>function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue};return s().get(t.dashboard.entities.products,e,{})},d=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue}).dashboard.entities.billing_periods},p=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue}).dashboard.entities.reports.supplierEvents},_=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue}).dashboard.entities.reports.supplierPOs},c=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue}).dashboard.entities.reports.supplierProducts},u=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue}).dashboard.entities.reports.supplierPresales},y=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dashboard:o.ue}).dashboard.entities.supplierEvents},g=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dropdowns:{tenants:{}}};return(0,n.Dp)(Object.values(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dropdowns:{tenants:{}}};return s().get(e,"dropdowns.tenants",{})}(e)),"tenant_id","tenant_name",null)}},88007(e,t,r){r.d(t,{Ec:()=>a,Ej:()=>o,GM:()=>y,I:()=>g,II:()=>S,JO:()=>l,Rw:()=>h,US:()=>d,Vl:()=>c,Y_:()=>u,_Y:()=>T,hZ:()=>p,nm:()=>i,qc:()=>O,uH:()=>E,vW:()=>s}),Date.prototype.toStr=function(){return`${this.getFullYear()}-${(this.getMonth()+1+"").padStart(2,"0")}-${(this.getDate()+"").padStart(2,"0")}`};const a=new Date,s=a.getFullYear(),o=a.getMonth(),n=a.getDate(),l=e=>{let{y:t=s,m:r=o,d:a=n,toStr:l=!1}=e;return l?new Date(t,r,a).toStr():new Date(t,r,a)},i={Jan:"January",Feb:"February",Mar:"March",Apr:"April",May:"May",Jun:"June",Jul:"July",Aug:"August",Sep:"September",Oct:"October",Nov:"November",Dec:"December"},d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],p=["January","February","March","April","May","June","July","August","September","October","November","December"],_=d.filter((e,t)=>
1t<=o),c=d.filter((e,t)=>t>o).concat(_),u=d.filter((e,t)=>t>o),y=["Q1","Q2","Q3","Q4"],g=e=>parseInt(e/3)+1,S=g(o),m=y.filter((e,t)=>t<=S-1),h=y.filter((e,t)=>t>S).concat(m),T=y.filter((e,t)=>t>S-1),O=1==S?4:S-1,E=0==o?11:o-1},28363(e,t,r){r.d(t,{fz:()=>g,Y$:()=>y,Y9:()=>u,xj:()=>_,Ej:()=>o.Ej,II:()=>o.II,vW:()=>o.vW,hZ:()=>o.hZ,I:()=>o.I,US:()=>o.US,Vl:()=>o.Vl,Y_:()=>o.Y_,nm:()=>o.nm,jk:()=>i,Ux:()=>p,uH:()=>o.uH,qc:()=>o.qc,GM:()=>o.GM,Rw:()=>o.Rw,_Y:()=>o._Y,i9:()=>d,Ec:()=>o.Ec,pl:()=>c});var a=r(22224),s=r.n(a),o=r(88007),n=r(22078),l=r(20001);function i(e){const t=s().get(e,["SALES_TOTALS","current_week"],{}),r=s().get(e,["SALES_TOTALS","past_week"],{}),a=s().get(e,["POTENTIAL_REPEAT_ORDERS"],{}),o=s().get(e,["CLIENTS_WITH_NO_RECENT_ACTIVITY"],{}),n=s().get(e,["INVOICE_OPEN_STATUS_TOTALS"],{}),i=s().get(e,["SALES_ORDER_READY_INVOICING_STATUS_TOTALS"],{}),d=s().get(e,["COMMISSION_UNPAID_TOTALS"],{}),p=s().get(e,["CLIENTS_ON_CREDIT_HOLD"],{}),_=s().get(e,["DEPOSIT_INVOICES_NOT_PAID"],{}),c=s().get(e,["DEPOSIT_INVOICES_NOT_PAID_UNINVOICED"],{}),u=s().get(e,["DEPOSIT_INVOICES_PAID_SO_NOT_IN_PRODUCTION"],{}),y=s().get(e,["SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS"],{}),g=parseInt(t.num_estimates||0)+parseInt(t.num_opportunities||0)+parseInt(t.num_presentations||0),S=parseFloat(t.total_estimate_budget||0)+parseFloat(t.total_opportunity_budget||0)+parseFloat(t.total_presentation_budget||0),m=parseInt(r.num_estimates||0)+parseInt(r.num_opportunities||0)+parseInt(r.num_presentations||0),h=parseFloat(r.total_estimate_budget||0)+parseFloat(r.total_opportunity_budget||0)+parseFloat(r.total_presentation_budget||0),T=l.mG.OPEN_ORDER_STATUS_TOTALS.type,O=s().get(e,[T,"summary"],{}),E=s().get(e,l.mG.PRESALES_PENDING_CLIENT_APPROVAL.type,{}),b=s().get(e,l.mG.SALES_ORDERS_PENDING_CLIENT_APPROVAL.type,{}),A=s().get(e,l.mG.PROJECTS_WITH_NO_BUDGET.type,{}),x=s().get(e,l.mG.OVERDUE_IN_HANDS_DATE_PROJECTS.type,{}),P=s().get(e,["PO_STATUS_TOTALS"],{});return{presales:{prevTotalCount:m,prevTotalCurrency:h,totalCount:g,totalCurrency:S},inProduction:{prevTotalCount:parseInt(r.num_in_production||0),prevTotalCurrency:parseFloat(r.total_in_production||0),totalCount:parseInt(t.num_in_production||0),totalCurrency:parseFloat(t.total_in_production||0)},invoices:{prevTotalCount:parseInt(r.num_invoices||0),prevTotalCurrency:parseFloat(r.total_invoices||0),totalCount:parseInt(t.num_invoices||0),totalCurrency:parseFloat(t.total_invoices||0)},presalesPendingClientApproval:{totals:parseInt(E.totals||0),data:E.data},soPendingClientApproval:{totals:parseInt(b.totals||0),data:b.data},projectsWithNoBudget:{totals:parseInt(A.totals||0),data:A.data},projectsWithNoInhandsDate:{totals:parseInt(x.totals||0),data:x.data},openOrderStatusTotals:O,potentialRepeatOrders:a,clientWithNoRecentActivity:o,clientsOnCreditHold:p,poStatusReport:P,commissionUnpaidTotals:d,depositInvoicesNotPaid:_,depositInvoicesNotPaidUnInvoiced:c,depositInvoicesPaidSOInProduction:u,invoiceOpenStatusTotals:parseInt(s().get(n,["summary","num_open"],0)||0),soReadyToBeInvoicedTotals:parseInt(s().get(i,["summary","num_ready_to_be_invoiced"],0)||0),soInProductionTotals:parseInt(s().get(y,["summary","num_in_production"],0)||0),soInProduction:y}}(0,o.JO)({d:1,toStr:!0}),(0,o.JO)({d:1,m:o.Ej-1,toStr:!0}),(0,o.JO)({d:1,m:o.Ej-2,toStr:!0}),(0,o.JO)({d:1,m:1,toStr:!0}),(0,o.JO)({d:1,y:o.vW-10,toStr:!0});const d=[{value:"month",label:"Monthly"},{value:"quarter",label:"Quarterly"},{value:"year",label:"Yearly"}],p=[{label:"Monthly",value:"MONTH"},{label:"Yearly",value:"YEAR"}];function _(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e/t>(arguments.length>3&&void 0!==arguments[3]?arguments[3]:8)?arguments.length>2&&void 0!==arguments[2]?arguments[2]:550:70*(e||1)/(t||1)}const c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"number";return"currency"==t?e.toString().includes("$")?e:(0,n.Y6)(parseFloat(e.toString())).replace(" ",""):"number"===t?e.toString().includes(",")?e:s().parseInt(e.toString()).toLocaleString():"percentage"===t?e.toString().includes("%")?e:(0,a.round)(100*parseFloat(e.toString()))+"%":"roundedCurrency"===t?e.toString().includes("$")?e:"$"+Math.round(parseFloat(e.toString()),0):e},u=[{label:"Client Rep",value:"CLIENT"},{label:"Order Rep",value:"ORDER"}],y={OPPORTUNITY:{title:"Opportunities",type:"OPPORTUNITY",order:1},PRESENTATION:{title:"Presentations",type:"PRESENTATION",order:2},ESTIMATE:{title:"Estimates",type:"ESTIMATE",order:3},"SALES ORDER":{title:"Sales Orders",type:"SALES ORDER",order:4},INVOICE:{title:"Invoice",type:"INVOICE",order:5}},g={OPPORTUNITY:"Op",PRESENTATION:"P",ESTIMATE:"E",SALES_ORDER:"SO","SALES ORDER":"SO",INVOICE:"In"}},83751(e,t,r){r.d(t,{Jm:()=>_,vb:()=>p});var a=r(22224),s=r.n(a),o=(r(3602),r(76189)),n=r(88007),l=r(67564);const i=(0,n.JO)({m:0,d:1,y:n.vW-2,toStr:!0}),d=(0,n.JO)({m:11,d:31,y:n.vW,toStr:!0});function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const r={date_from:"",date_to:"",quarter:"",year:"",prev_date_from:"",prev_date_to:"",prev_quarter:"",prev_year:""};return["totals","tags","tenants_count"].includes(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")?{date_from:i,date_to:d}:("quarter"==e?(r.quarter=n.II,r.year=n.vW,t&&(r.prev_quarter=n.qc,r.prev_year=1==n.II?n.vW-1:n.vW)):"month"==e?(r.month=n.Ej+1,r.year=n.vW,t&&(r.prev_month=n.uH+1,r.prev_year=0==n.Ej?n.vW-1:n.vW)):"year"==e&&(r.year=n.vW,t&&(r.prev_year=n.vW-1)),r)}const _=e=>{let{cardId:t,totals_by:r,group_by:a,formatNumberType:i,onlyValTransform:d,fileName:p}=e;return(e,_,c)=>{if(e.openPopup("Exporting"),function(e){let t=e.exporting.getFormatOptions("png");t.quality=1,t.multiplier=2,t.scale=4,e.exporting.setFormatOptions("png",t),t=e.exporting.getFormatOptions("jpg"),t.quality=1,t.multiplier=2,t.scale=4,e.exporting.setFormatOptions("jpg",t),t=e.exporting.getFormatOptions("svg"),t.quality=1,t.multiplier=2,t.scale=4,e.exporting.setFormatOptions("svg",t),t=e.exporting.getFormatOptions("pdf"),t.multiplier=2,t.scale=4,e.exporting.setFormatOptions("pdf",t)}(e),p&&(p=p.replaceAll(" ","_"),e.exporting.filePrefix=p),l.Al.getElementById("export_menu_"+t).hasChildNodes()||(e.exporting.menu.container=l.Al.getElementById("export_menu_"+t)),e.exporting.events.hasListenersByType("exportstarted")){const t=e.exporting.events;t._listeners&&t._listeners.length>
10&&t._listeners.forEach(e=>{e.disposer._dispose()})}e.exporting.events.on("exportstarted",function(t){e.exporting.adapter.add("data",function(e){return e=["totals","tags","tenants_count"].includes(r)?function(e){let{data:t,totals_by:r,group_by:a,formatNumberType:l,onlyValTransform:i}=e;if(!t||t&&0==t.length)return t;t=t.data?t.data:t;let d=[];var p="tags"===r||"tenants_count"===r?"Total Percenatge":"Total";return t.forEach((e,t)=>{d[t]={[p]:"tags"===r||"tenants_count"===r?(0,o.pl)(e.totals_percentage,l):(0,o.pl)(e.totals,l),year:s().parseInt(e.year),group_by:e.group_by.split(" ")[0]}}),d.sort((e,t)=>{const r="month"==a?n.US.indexOf(e.group_by):"quarter"==a?n.GM.indexOf(e.group_by):s().parseInt(e.group_by),o="month"==a?n.US.indexOf(t.group_by):"quarter"==a?n.GM.indexOf(t.group_by):s().parseInt(t.group_by);return r>o?1:r<o?-1:0}).sort((e,t)=>e.year>t.year?-1:e.year<t.year?1:0),d}({data:e,totals_by:r,group_by:a,formatNumberType:i,onlyValTransform:d}):function(e){let{data:t,totals_by:r,group_by:a,formatNumberType:l,onlyValTransform:i}=e;if(!t||t&&0==t.length)return t;t=t.data?t.data:t;let d=[],p=-1;return t.forEach((e,n)=>{if(e&&(!e.group_by||"tenant"===r||"industry"===r||"events"===r)){const _=void 0!==e.gr1?1:void 0!==e.gr2?2:"";e[`gr${_}_subData`]&&e[`gr${_}_subData`].length>0&&(p=n,d=d.concat(e[`gr${_}_subData`].map(e=>({year:"year"==a?e.group_by.split(" ")[1]:e.group_by.split(" ")[2],group_by:e.group_by.split(" ")[1],totals:(0,o.pl)(e.totals,l),[`${r}_name`]:e[`${r}_name`]})))),i?(t[n].totals=(0,o.pl)(e.totals,l),delete t[n][`${r}_id`]):t[n]={year:"year"==a?e[`gr${_}`]:e[`gr${_}_group_by`].split(" ")[2],group_by:e[`gr${_}`],totals:"roundedCurrency"===l?(0,o.pl)(parseFloat(e[`gr${_}_totals`]),l):(0,o.pl)(s().parseInt(e[`gr${_}_totals`]),l),[`${r}_name`]:e[`gr${_}_${r}_name`]}}}),t=t.concat(d),p>-1&&t.splice(p,1),t=s().orderBy(t,["year",e=>e?"month"==a?n.US.indexOf(e.group_by):"quarter"==a?n.GM.indexOf(e.group_by):s().parseInt(e.group_by):e,function(e){if(!e)return e;let t=e.totals;return t=(t+"").replace(",","").replace("$","").trim(),t=parseFloat(t),t}],["desc","year"==a?"desc":"asc","desc"]),t}({data:e,totals_by:r,group_by:a,formatNumberType:i,onlyValTransform:d}),{...e,data:e}})},void 0),e.closeAllPopups()}}},60794(e,t,r){r.d(t,{A:()=>f});var a=r(22224),s=r.n(a),o=r(41594),n=r.n(o),l=r(73640),i=r(98483),d=r(3602),p=r(84685),_=r(83075),c=r(22078),u=r(83176),y=r(90100),g=r(28989),S=r(30596),m=r(82654),h=r(64490),T=r(93664);Object.values(T.eo.MARGIN_BY_CLIENT.type);const O=(e,t)=>t?t.date_inhandsdate:e.order_date_inhandsdate||e.date_inhandsdate||"",E=(e,t)=>t?t.date_created:e.order_date_created||e.date_created||"";var b=r(76189),A=r(53787),x=r(63988);const P=(0,l.Mz)([e=>e.entities.projects,(e,t)=>t],(e,t)=>s().get(e,[t,"latest_order"],{})),R=(0,l.Mz)([e=>e.entities.projects,(e,t)=>t],(e,t)=>s().get(e,[t],{}));function v(e){let{projectId:t}=e;const r=(0,i.wA)(),a=(0,i.d4)(e=>_.Tp.remindersByParent(e,t,"JOB")),s=n().useCallback(e=>{r((0,_.w3)(e.note_id,e))},[r]);return t?a.map((e,t)=>{const r=(0,_.ex)(e),a=(e.message_text||"").replace(/(href=['"])(?!https?:)/,"$1/").replace(/<a /,'<a target="_blank" ');return(0,x.jsxs)("div",{"data-test-name":"ProjectNotes",style:{marginBottom:"0.2rem",width:"100%"},children:[(0,x.jsxs)("span",{style:{display:"inline-block",verticalAlign:"top"},children:[(0,x.jsx)(d.Radio,{type:"checkbox",name:"note-checkbox",checked:r}),(0,x.jsx)(d.CheckMark,{checked:r,style:{top:"auto",right:"auto",bottom:"auto",left:"auto"},onClick:t=>{s({note_id:e.note_id,reminder_complete:r?0:1,date_complete:r?"":(0,c.yw)(new Date)})}})]}),(0,x.jsxs)("span",{style:{display:"inline-block",paddingLeft:35},children:[(0,x.jsx)("p",{style:{margin:0},dangerouslySetInnerHTML:{__html:a}}),(0,x.jsxs)("p",{style:{margin:0,paddingTop:10,color:"#B7B7B7",fontSize:12},children:["Due ",(0,c.l8)(Date.parse(e.date_reminder))]})]})]},`${t}_${e.message_id}`)}):null}function I(e){let{projectId:t,showNewTask:r,setShowNewTask:a}=e;const s=(0,i.wA)(),n=(0,i.d4)(m.bb),l=(0,i.d4)(m.BL),[_,c]=(0,o.useState)({message_text:"",date_reminder:"",reminder_user:""});return t&&r?(0,x.jsx)(d.Col,{"data-test-name":"NewTaskForm",xs:!0,style:{borderBottom:"1px solid #e0e7eb",padding:10,marginBottom:16,background:"#edf2f4",borderRadius:4,boxShadow:"0 2px 4px rgb(0 0 0 / 7%)"},children:(0,x.jsxs)(d.Row,{children:[(0,x.jsx)(d.Col,{padded:!0,xs:!0,className:"resku",children:(0,x.jsx)(g.A,{mention_users:n,value:_.message_text,onChange:e=>c(t=>({...t,message_text:e}))})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,md:6,children:(0,x.jsx)(u.Ay,{portalId:"root-portal",customInput:(0,x.jsx)(u.Q7,{date:_.date_reminder,label:"Task Date"}),showMonthDropdown:!0,showYearDropdown:!0,value:_.date_reminder,onCh
1ange:e=>c(t=>({...t,date_reminder:e}))})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,md:6,children:(0,x.jsx)(p.AF,{name:"project_new_task_assign_to",label:"Assign To",options:l,value:_.reminder_user,onChange:e=>c(t=>({...t,reminder_user:e.value}))})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,style:{textAlign:"right"},children:(0,x.jsx)(d.Button,{onClick:()=>{Promise.resolve(s((0,y.oH)({date_reminder:_.date_reminder,details_parent_id:t,details_parent_type:"JOB",details_type:"NOTE",job_id:t,message_text:_.message_text,reminder_user:_.reminder_user,tagged_users:""}))).then(e=>{a(!1),c({message_text:"",date_reminder:"",reminder_user:""})})},children:"Create Task"})})]})}):null}const f=e=>{let{projectId:t,orderId:r="",onClose:a,onUpdate:l=null}=e;const c=(0,i.wA)(),y=(0,i.d4)(e=>R(e,t)),g=(0,i.d4)(m.BL),T=(0,i.d4)(e=>{const r=P(e,t);return r&&r.order_type?s().map((0,S.s3)(e,{order_type:r.order_type}),e=>({label:e.status_name,value:e.status_id})):[]}),[f,C]=(0,o.useState)(y),[j,D]=(0,o.useState)({}),[N,L]=(0,o.useState)(!0),[k,U]=(0,o.useState)(!1);(0,o.useEffect)(()=>{t&&(L(!0),Promise.resolve(c((0,h.eg)(t,{with_latest_order:1,order_id:r}))).then(e=>{const r=e.payload.project;r.latest_order&&r.latest_order.order_id&&D(r.latest_order),r.notes&&r.notes.length&&c((0,_.GW)({parent_id:t,parent_type:"JOB",note_type:"ALL REMINDERS"})),L(!1)}))},[c,t,r]),(0,o.useEffect)(()=>{const e=s().get(y,["latest_order"],{});C({...y,date_inhandsdate:O(y,e),date_created:E(y,e),total_budget:s().get(y,["total_budget"],s().get(e,["total_budget"],0))}),D(e)},[y]);const w=n().useCallback((e,r,a)=>{j.order_id&&t&&Promise.resolve(c(["date_inhandsdate","status_id"].includes(e)?(0,A.iY)(j.order_id,e,a,r):(0,h.vr)(t,e,a,r))).then(r=>{D(a=>({...a,job_id:t,order_id:j.order_id,order_type:j.order_type,[e]:r.payload.data[e]})),l&&l({job_id:t,order_id:j.order_id,field:e,previous_value:a,value:r.payload.data[e],shouldRemoteUpdate:!1,order_type:j.order_type})})},[j.order_id,j.order_type,t,l,c]),F=n().useMemo(()=>{const e=s().get(j,["order_type"],!1);return["SALES ORDER","INVOICE"].includes(e)&&!isNaN(j.total_subtotal)?parseFloat(j.total_subtotal).toFixed(2):""},[j]),W=n().useMemo(()=>{const e=[{onClick:()=>window.open(`/project/${y.job_number}/`,"_blank"),content:"View Project"}];return s().get(j,"client_id",null)&&e.push({onClick:()=>window.open(`/client.php?id=${j.client_id}`,"_blank"),content:"View Client"}),e},[y,j]);return(0,x.jsx)(d.SidePanel,{"data-test-name":"ProjectSidepanel",visible:t,style:{zIndex:9999,padding:"1em"},header:(0,x.jsx)(x.Fragment,{children:(0,x.jsxs)(d.Row,{children:[(0,x.jsx)(d.Col,{xs:!0,md:6,children:(0,x.jsx)(d.Text,{as:"a",href:`/project/${y.job_number}`,target:"_blank",style:{fontSize:"24px",lineHeight:"40px",fontWeight:"bold",textDecoration:"none",fontFamily:d.themeOptions.fontFamilies.bold},children:"Project"})}),(0,x.jsxs)(d.Col,{xs:!0,md:6,style:{textAlign:"right"},children:[(0,x.jsx)(d.Dropdown,{sm:"width: 100%; margin-top: 10px;",style:{marginRight:"10px",zIndex:105},items:W}),(0,x.jsx)(d.Button,{onClick:e=>{a&&a(e)},children:"Close"})]}),(0,x.jsx)(d.Col,{xs:!0,style:{paddingTop:5,paddingBottom:10},children:(0,x.jsxs)(d.Text,{as:"span",style:{fontSize:"16px",lineHeight:"24px",fontWeight:"bold",display:"block",fontFamily:d.themeOptions.fontFamilies.bold},children:[s().get(j,"client_name")," - Project #",s().get(y,"job_number")," - ",s().get(y,"job_name")]})})]})}),children:(0,x.jsx)(d.Row,{children:N?(0,x.jsx)(d.Col,{xs:!0,children:(0,x.jsx)(d.Loading,{})}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Col,{padded:!0,xs:!0,md:6,children:[(0,x.jsx)("span",{style:{display:"inline-block"},children:(0,x.jsx)(d.CircleProgressIcon,{percentage:s().get(b.Y$,[j.order_type,"order"],0)/5*100,text:b.fz[j.order_type]})}),(0,x.jsx)("span",{style:{display:"inline-block",paddingLeft:"10px",verticalAlign:"top",paddingTop:10},children:(0,x.jsx)(d.Text,{style:{display:"block"},children:j.order_type})})]}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,md:6,children:(0,x.jsx)(p.l6,{options:T,value:j.status_id,onChange:e=>w("status_id",e.value,j.status_id)})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,children:(0,x.jsx)(u.Ay,{customInput:(0,x.jsx)(u.Q7,{date:f.date_inhandsdate,label:"In-Hands Date"}),showMonthDropdown:!0,showYearDropdown:!0,value:f.date_inhandsdate,onChange:e=>w("date_inhandsdate",e,f.date_inhandsdate),portalId:"root-portal",style:{width:"100%"}})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,md:6,children:(0,x.jsx)(d.LabeledInput,{label:"Budget",value:f.total_budget||"",onChange:e=>C(t=>({...t,total_budget:e.target.value})),onBlur:e=>w("total_budget",e.target.value,f.total_budget)})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,md:6,children:(0,x.jsx)(d.LabeledInput,{label:"Value",defaultValue:F,disabled:!0,readOnly:!0,style:{border:"none",boxShadow:"none"}})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,md:6,children:(0,x.jsx)(p.AF,{name:"project_client_rep",label:"Client Rep",options:g,value:f.client_rep_id,onChange:e=>w("client_rep_id",e.value,f.client_rep_id)})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,md:6,children:(0,x.jsx)(p.AF,{name:"project_order_rep",label:"Order Rep",options:g,value:f.sales_rep_id,onChange:e=>w("sales_rep_id",e.value,f.sales_rep_id)})}),(0,x.jsx)(d.Col,{padded:!0,xs:!0,style:{paddingBottom:20},children:(0,x.jsx)(d.Button,{style:{width:"100%",background:"#EEFDFF",color:d.colors.primary,boxShadow:"0px 2px 4px rgba(22, 112, 125, 0.12)",border:"none"},onClick:e=>U(e=>!e),children:"New Task"})}),(0,x.jsx)(I,{projectId:t,showNewTask:k,setShowNewTask:U}),(0,x.jsx)(v,{projectId:t})]})})})}},20001(e,t,r){r.d(t,{Ay:()=>f,FN:()=>I,Tp:()=>m,_Q:()=>y,mG:()=>p,sg:()=>u,xb:()=>x});var a=r(22224),s=r.n(a),o=r(23204),n=r(75174),l=r(22078),i=r(93807),d=r(45191);const p={SALES_TOTALS:{route:"sales-totals",type:"SALES_TOTALS"},STUCK_IN_STAGE_TOTALS:{route:"stuck-in-stage-totals",type:"STUCK_IN_STAGE_TOTALS"},PROJECTION_TOTALS:{route:"projection-totals",type:"PROJECTION_TOTALS"},SALES_ORDERS_PENDING_CLIENT_APPROVAL:{route:"dashboard-reports",type:"SALES_ORDERS_PENDING_CLIENT_APPROVAL"},PRESALES_PENDING_CLIENT_APPROVAL:{route:"dashboard-reports",type:"PRESALES_PENDING_CLIENT_APPROVAL"},PRESALES_CLIENT_REVIEW:{route:"dashboard-reports",type:"PRESALES_CLIENT_REVIEW"},OVERDUE_IN_HANDS_DATE_PROJECTS:{route:"dashboard-reports",type:"OVERDUE_IN_HANDS_DATE_PROJECTS"},PROJECTS_WITH_NO_BUDGET:{route:"dashboard-reports",type:"PROJECTS_WITH_NO_BUDGET"},OPEN_ORDER_STATUS_TOTALS:{route:"open-order-status-totals",type:"OPEN_ORDER_STATUS_TOTALS"},POTENTIAL_REPEAT_ORDERS:{route:"potential-repeat-orders",type:"POTENTIAL_REPEAT_ORDERS"},CLIENTS_WITH_NO_RECENT_ACTIVITY:{route:"clients-with-no-recent-activity",type:"CLIENTS_WITH_NO_RECENT_ACTIVITY"},PO_STATUS_TOTALS:{route:"po-status-totals",type:"PO_STATUS_TOTALS"},ORDER_STATUS_TOTALS:{route:"order-status-totals",type:"ORDER_STATUS_TOTALS"},INVOICE_OPEN_STATUS_TOTALS:{route:"order-status-totals",type:"INVOICE_OPEN_STATUS_TOTALS",params:{order_type:"INVOICE",status_name:"Open",status_id:d.A.INVOICE_OPEN}},SALES_ORDER_READY_INVOICING_STATUS_TOTALS:{route:"order-status-totals",type:"SALES_ORDER_READY_INVOICING_STATUS_TOTALS",params:{order_type:"SALES ORDER",status_name:"Ready To Be Invoiced",status_id:d.A.SALES_ORDER_READY_TO_BE_INVOICED,report_sub_type:"SALES_ORDER_READY_TO_BE_INVOICED"}},SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS:{route:"order-status-totals",type:"SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS",params:{order_type:"SALES ORDER",status_name:"In Production",status_id:d.A.SALES_ORDER_IN_PRODUCTION,report_sub_type:"SALES_ORDER_IN_PRODUCTION"}},COMMISSION_TOTALS:{route:"commission",type:"COMMISSION_TOTALS",params:{}},COMMISSION_UNPAID_TOTALS:{route:"commission",type:"COMMISSION_UNPAID_TOTALS",params:{commission_paid:"unpaid"}},INVOICE_UNPAID_TOTALS:{route:"commission",type:"INVOICE_UNPAID_TOTALS",params:{invoice_paid:"unpaid"}},CLIENTS_ON_CREDIT_HOLD:{route:"clients-on-credit-hold",type:"CLIENTS_ON_CREDIT_HOLD"},DEPOSIT_INVOICES_NOT_PAID:{route:"unpaid-deposits",type:"DEPOSIT_INVOICES_NOT_PAID"},DEPOSIT_INVOICES_NOT_PAID_UNINVOICED:{route:"deposit-invoices",type:"DEPOSIT_INVOICES_NOT_PAID_UNINVOICED",params:{report_sub_type:"UNINVOICED_ORDERS",paid:0}
1},DEPOSIT_INVOICES_PAID_SO_NOT_IN_PRODUCTION:{route:"deposit-invoices",type:"DEPOSIT_INVOICES_PAID_SO_NOT_IN_PRODUCTION",params:{report_sub_type:"SO_NOT_IN_PRODUCTION",paid:1}}},_=(0,o.Z0)({name:"reports",initialState:{data:{},current_types:[],loading:{},errors:{}},reducers:{setReports(e,t){e.data=t.payload},fetchReportsSuccess(e,t){e.data={...e.data,...t.payload.reduce((e,t)=>({...e,[t.report_type]:t}),{})},e.current_types=t.payload.map(e=>e.report_type)},fetchReportSuccess(e,t){e.data={...e.data,[t.payload.report_type]:{...e.data[t.payload.report_type]||{},...t.payload}}},fetchPOReportSuccess(e,t){e.data={...e.data,[t.payload.report_type]:{...e.data[t.payload.report_type]||{},totals:{...s().get(e.data,[t.payload.report_type,"totals"],{}),...s().get(t.payload,["totals"],{})},data:t.payload.data||[]}}},updateReportProjectData(e,t){const r=t.payload.report_type,a=s().get(e.data,[r,"data"],[])||[],o=!isNaN(t.index)&&t.payload.index>-1?t.index:s().findIndex(a,e=>e.job_id===t.payload.job_id);if(-1===o)return;const n=e.data[r].data[o];e.data[r].data[o]={...n,...t.payload.data,latest_order:{...n.latest_order||{},...t.payload.data.latest_order||{}}}},reportsFailure(e,t){e.errors=t.payload},setLoading(e,t){e.loading=t.payload},updateLoading(e,t){e.loading={...e.loading,...t.payload}}}}),c=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return async(a,o)=>{a(A({[t]:!0}));try{const{json:o}=await(0,l.oD)("GET",`report/${e}`,r,null,null,null,!1);if(o&&!o.error){const e=s().get(o,"report",s().get(o,"data",null)),r=s().get(o,"totals",null),n={report_type:t};null!=r&&(n.totals=r),null!=e&&(n.data=e),a(O(n))}else a(E(S(o.error,"Cannot get reports.")))}catch(e){console.error("ERROR|fetchReport| ",e),a(E(S(e,"Cannot get reports.")))}a(A({[t]:!1}))}},u=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return async(a,o)=>{a(A({[t]:!0}));try{const{json:o}=await(0,l.oD)("GET",`report/${e}`,r,null,null,null,!1);if(o&&!o.error){const e=s().get(o,"totals",{});a(O({...e,report_type:t}))}else a(E(S(o.error,"Cannot get reports.")))}catch(e){console.error("ERROR|fetchReportTotals| ",e),a(E(S(e,"Cannot get reports.")))}a(A({[t]:!1}))}},y=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return async(a,o)=>{a(A({[t]:!0}));try{const{json:o}=await(0,l.oD)("GET",`report/${e}`,r,null,null,null,!1);if(o&&!o.error){const e=s().get(o,"report",{});a(O({...e,report_type:t}))}else a(E(S(o.error,"Cannot get reports.")))}catch(e){console.error("ERROR|fetchDashboardReports| ",e),a(E(S(e,"Cannot get reports.")))}a(A({[t]:!1}))}},g=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return async(a,o)=>{a(A({[t]:!0}));try{const{json:o}=await(0,l.oD)("GET",`report/${e}`,r,null,null,null,!1);if(o&&!o.error){const e=s().get(o,"report",{});a(P({...e,report_type:t})),s().get(e,["data"],[]).length>0&&a((0,i.yG)(s().get(e,["data"],[])))}else a(E(S(o.error,"Cannot get reports.")))}catch(e){console.error("ERROR|fetchPOReport| ",e),a(E(S(e,"Cannot get reports.")))}a(A({[t]:!1}))}};function S(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Unable to perform this action";return"string"==typeof e?e:s().get(e,"message",!1)?s().get(e,"message",!1):s().get(e,"detail",!1)?s().get(e,"detail",!1):t}const m={reports:(0,n.Mz)(e=>e.reports.data,e=>e),loading:(0,n.Mz)(e=>e.reports.loading,e=>e),errors:(0,n.Mz)(e=>e.reports.errors,e=>e)},{setReports:h,fetchReportsSuccess:T,fetchReportSuccess:O,reportsFailure:E,setLoading:b,updateLoading:A,updateReportProjectData:x,fetchPOReportSuccess:P}=_.actions,R=new Date,v=e=>"GROUP"===s().get(e,["rep_id"],"")?"":s().get(e,["rep_id"],"");function I(e,t){const r=p[e];switch(e){case"SALES_TOTALS":return{route:r.route,type:r.type,params:{...t,rep_id:v(t)},cb:u};case"PROJECTION_TOTALS":return{route:r.route,type:r.type,params:{start_stamp:(0,l.yw)(new Date(R.getFullYear(),R.getMonth(),1)),end_stamp:(0,l.yw)(new Date(R.getFullYear(),R.getMonth()+3,1)),report_type:r.type,...t,rep_id:v(t)},cb:u};case"ORDER_STATUS_TOTALS":case"OPEN_ORDER_STATUS_TOTALS":case"INVOICE_OPEN_STATUS_TOTALS":case"SALES_ORDER_READY_INVOICING_STATUS_TOTALS":case"SALES_ORDER_IN_PRODUCTION_STATUS_TOTALS":return{route:r.route,type:r.type,params:{...r.params||{},report_type:r.type,...t,rep_id:v(t)},cb:u};case"POTENTIAL_REPEAT_ORDERS":return{route:r.route,type:r.type,params:{report_type:r.type,last_year_orders:90,...t,rep_id:v(t)},cb:u};case"CLIENTS_WITH_NO_RECENT_ACTIVITY":return{route:r.route,type:r.type,params:{report_type:r.type,no_action_days:60,...t,rep_id:v(t)},cb:u};case"STUCK_IN_STAGE_TOTALS":return{route:r.route,type:r.type,params:{report_type:r.type,days:30,...t,rep_id:v(t)},cb:u};case"SALES_ORDERS_PENDING_CLIENT_APPROVAL":case"PRESALES_PENDING_CLIENT_APPROVAL":case"OVER
1DUE_IN_HANDS_DATE_PROJECTS":case"PROJECTS_WITH_NO_BUDGET":return{route:r.route,type:r.type,params:{report_type:r.type,...t,rep_id:v(t)},cb:y};case"PO_STATUS_TOTALS":return{route:r.route,type:r.type,params:{report_type:r.type,new_production:!0,...t,rep_id:v(t),production_rep_id:v(t)},cb:g};case"COMMISSION_TOTALS":case"COMMISSION_UNPAID_TOTALS":case"INVOICE_UNPAID_TOTALS":case"DEPOSIT_INVOICES_NOT_PAID":case"DEPOSIT_INVOICES_NOT_PAID_UNINVOICED":case"DEPOSIT_INVOICES_PAID_SO_NOT_IN_PRODUCTION":return{route:r.route,type:r.type,params:{date_category:"custom",paid_date_category:"custom","max-results":1e6,...r.params||{},report_type:r.type,sales_rep_type:t.rep_type||"",sales_rep_id:v(t),...t,rep_id:v(t)},cb:c};case"CLIENTS_ON_CREDIT_HOLD":return{route:r.route,type:r.type,params:{...r.params||{},report_type:r.type,...t,rep_id:v(t)},cb:c};default:return null}}const f=_.reducer},77962(e,t,r){r.d(t,{Ay:()=>g,Tp:()=>_,ug:()=>d});var a=r(22224),s=r.n(a),o=r(23204),n=r(75174),l=r(22078);const i=(0,o.Z0)({name:"status",initialState:{data:{},current_ids:[],errors:{}},reducers:{setStatus(e,t){e.data=t.payload},fetchStatusSuccess(e,t){e.data={...e.data,...t.payload.reduce((e,t)=>({...e,[t.status_id]:t}),{})},e.current_ids=t.payload.map(e=>e.status_id)},statusFailure(e,t){e.errors=t.payload}}}),d=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return async(t,r)=>{try{const{json:r}=await(0,l.oD)("GET","status/all-status",e),a=s().get(r,"status",[]);return t(u(a)),a}catch(e){console.error("ERROR|fetchStatus| ",e),t(y("Cannot get status."))}return null}},p=e=>s().get(e,"status.data",{}),_={status:(0,n.Mz)(p,e=>e),byId:(0,n.Mz)([p,(e,t)=>t],(e,t)=>e[t]),options:(0,n.Mz)(p,e=>Object.values(e).map(e=>({label:e.status_name,value:e.status_id}))),optionsOrderedByType:(0,n.Mz)([e=>(e=>Object.values(e.status.data))(e),(e,t)=>t],(e,t)=>(e=>s().orderBy(e,[e=>parseInt(e.flow_order)],["asc"]))(e).filter(e=>e.parent_type===t).map(e=>({label:e.status_name,value:e.status_id})))},{setStatus:c,fetchStatusSuccess:u,statusFailure:y}=i.actions,g=i.reducer}}]); 2//# sourceMappingURL=6438.63a15b4a.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.