1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8ae5fc6c-9460-4ce3-85d4-c917552d1b01",e._sentryDebugIdIdentifier="sentry-dbid-8ae5fc6c-9460-4ce3-85d4-c917552d1b01")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5173],{41850:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/sales",function(){return a(89166)}])},23014:function(e,t,a){"use strict";var l=a(85893),s=a(45528),n=a(59335),r=a(65603),o=a(7550);let i=e=>{var t,a,i,c,d,u,m,x,h,p,g,b,y,f,v;let{setSelectedJobIds:j,selectedJobIds:w,variant:N="sales",origin:S,filter:C,jobs:T,handleRequestPaymentJobBatch:A,handleRequestPaymentBatchForSuperAdmin:D,handleRejectRequestPaymentBatch:E}=e,{language:R}=(0,r.E)(),k=0,P=0,q=0,Z=0,I=0,O=0;for(let e of w){let t=T.find(t=>{var a;return"admin-crew"!==N&&("crew"!==S||"admin"!==N)?t.id===e:(null==t?void 0:null===(a=t.paymentRequest)||void 0===a?void 0:a.id)===e});t&&(k+=Number(t.totalPaid),P+=Number(t.paymentsReceived),q+=Number(t.commission),Z+=Number(t.contractAmount),((null==t?void 0:null===(b=t.paymentRequest)||void 0===b?void 0:b.status)==="REQUESTED"||(null===(y=t.paymentRequest)||void 0===y?void 0:y.status)==="PRE_APPROVED")&&(O+=Number(t.paymentRequest.amount)),I+=Number(t.totalToBePaid))}k=(0,s.formatCurrency)(k),P=(0,s.formatCurrency)(P),q=(0,s.formatCurrency)(q),Z=(0,s.formatCurrency)(Z),I=(0,s.formatCurrency)(I),O=(0,s.formatCurrency)(O);let F=w.length>1&&"sales"==N?null==R?void 0:null===(t=R.selectedJobsSummary)||void 0===t?void 0:t.projects:null==R?void 0:null===(a=R.selectedJobsSummary)||void 0===a?void 0:a.project;return("admin"==N||"super-admin"===N)&&(F=w.length>1?null==R?void 0:null===(f=R.selectedJobsSummary)||void 0===f?void 0:f.paymentRequests:null==R?void 0:null===(v=R.selectedJobsSummary)||void 0===v?void 0:v.paymentRequest),F="".concat(F||""," ").concat((null==R?void 0:null===(i=R.selectedJobsSummary)||void 0===i?void 0:i.selected)||"").trim(),(0,l.jsx)(l.Fragment,{children:w.length>0&&(0,l.jsx)(n.Card,{className:"text-center",children:(0,l.jsxs)(n.CardBody,{className:"mt-auto fixed bottom-4 left-1/2 transform -translate-x-1/2 sm:-translate-x-0 sm:bottom-20 sm:left-12 w-full sm:w-11/12 bg-white shadow-lg sm:p-4 h-auto flex flex-col sm:flex-row items-center justify-between rounded-2xl shadow-2xl",children:[(0,l.jsxs)("span",{className:"text-xs md:text-lg font-medium",children:[w.length," ",F]}),(0,l.jsx)(o.Z,{className:"text-xs text-primaryViolet",variant:"text",onClick:()=>j([]),children:null==R?void 0:null===(c=R.selectedJobsSummary)||void 0===c?void 0:c.unselectAll}),("sales"===N||!S&&"admin"===N)&&(0,l.jsxs)("div",{className:"bg-neutral100 rounded-full flex flex-col md:flex-row px-4 py-2 mb-2 md:mb-0",children:[(0,l.jsxs)("span",{className:"mr-4 text-sm md:text-lg",children:[null==R?void 0:null===(d=R.selectedJobsSummary)||void 0===d?void 0:d.totalPaid,": ",k]}),(0,l.jsxs)("span",{className:"mr-4 text-sm sm:text-lg",children:[null==R?void 0:null===(u=R.selectedJobsSummary)||void 0===u?void 0:u.totalCommissionAmount,":"," ",I]}),(0,l.jsxs)("span",{className:"text-sm sm:text-lg",children:[null==R?void 0:null===(m=R.selectedJobsSummary)||void 0===m?void 0:m.comissionPending,": ",q]})]}),("admin-crew"===N||"super-admin"===N||"crew"===S&&"admin"===N)&&(0,l.jsxs)("div",{className:"bg-neutral100 rounded-full px-4 py-2 flex flex-col md:flex-row mb-2 md:mb-0",children:[(0,l.jsx)("span",{className:"mr-4 text-xs sm:text-lg",children:"Total amount:"}),(0,l.jsx)("span",{className:"mr-4 text-sm sm:text-lg",children:O})]}),(0,l.jsxs)("div",{children:["sales"===N||"admin-crew"===N&&"PRE_APPROVED"===C||"crew"===S&&"admin"===N&&"PRE_APPROVED"===C?null:(0,l.jsx)(o.Z,{onClick:()=>"super-admin"===N?D("REJECTED"):E(),className:"bg-primaryViolet rounded-xl mr-5",children:"sales"===N?null==R?void 0:null===(x=R.selectedJobsSummary)||void 0===x?void 0:x.reject:null==R?void 0:null===(h=R.selectedJobsSummary)||void 0===h?void 0:h.reject}),"admin-crew"===N&&"PRE_APPROVED"===C||"crew"===S&&"admin"===N&&"PRE_APPROVED"===C?null:(0,l.jsx)(o.Z,{onClick:()=>"super-admin"===N?D("APPROVED"):A(),className:"bg-primaryViolet text-white rounded-xl border-primaryViolet",variant:"outlined",children:"sales"===N?null==R?void 0:null===(p=R.selectedJobsSummary)||void 0===p?void 0:p.requestPayment:null==R?void 0:null===(g=R.selectedJobsSummary)||void 0===g?void 0:g.approve})]})]})})})};t.Z=i},86843:function(e,t,a){"use strict";var l=a(85893),s=a(59335),n=a(67294),r=a(31481),o=a(65603),i=a(85518);let c=e=>{let{status:t,className:a=""}
1=e,[c,d]=(0,n.useState)(!1),{language:u}=(0,o.E)(),m="green",x="Admin Approved",h="bg-[#DFF7E4]",p=null;switch(t){case"CONNECTED":m="green",x="Connected",h="bg-transparent";break;case"ERROR":m="red",x="Error",h="bg-transparent";break;case"NOT-MATCHED":m="red",x=u.integrations.notMatched,h="bg-[#FFE2E2]";break;case"UPDATED":m="blue",x="Updated",h="bg-[#b1dbf7]";break;case"PENDING":case"AVAILABLE":m="amber",x=u.statusChip.pending,h="bg-yellowInProcess";break;case"REQUESTED":m="gray",x=u.statusChip.requested,h="bg-[#F5F5F5]";break;case"PRE_APPROVED":m="amber",x=u.statusChip.preApproved,h="bg-yellowInProcess";break;case"PAID":m="green",x=u.statusChip.paid,h="bg-greenRequested";break;case"IN_PROCESS":m="amber",x=u.statusChip.inProcess,h="bg-yellowInProcess";break;case"APPROVED":m="green",x=u.statusChip.approved,h="bg-greenRequested";break;case"REJECTED":m="red",x=u.statusChip.rejected,h="bg-[#FFE2E2]";break;case"CANCELLED":m="red",x=u.statusChip.cancelled,h="bg-[#FFE2E2]";break;case"NOT-PAID":m="amber",x=u.salesAdminPage.index.filterBonusStatus.notPaid,h="bg-[#FFF4E2]";break;case"CREATED":m="blue",x=u.projectsContainer.statusCreated,h="bg-[#b1dbf7]";break;case"TO_BE_ASSIGNED":m="blue",x=u.statusChip.toBeAssigned,h="bg-[#b1dbf7]";break;case"STARTED":m="brown",x=u.projectsContainer.statusStarted,h="bg-[#F5DFCC]";break;case"IN_ROUTE":m="purple",x=u.projectsContainer.statusInRoute,h="bg-[#E6DEED]";break;case"CHECK_IN":m="gray",x=u.projectsContainer.statusCheckIn,h="bg-[#DADADA]";break;case"CHECK_OUT":m="gray",x=u.projectsContainer.statusCheckOut,h="bg-[#DADADA]";break;case"WORKING":m="amber",x=u.projectsContainer.statusInProcess,h="bg-[#FFF4E2]";break;case"FINISHED":m="green",p=(0,l.jsx)(r.Z,{className:"".concat(i.tq&&"mt-1"),style:{fontSize:"10px"}}),x=u.projectsContainer.statusFinished,h="bg-greenRequested"}return(0,l.jsx)(s.Chip,{color:m,icon:p,variant:"outlined",className:"text-xs ".concat(i.tq?"w-full text-[9px]":"w-4/5"," text-center md:text-xs mx-0 capitalize whitespace-normal ").concat(h," ").concat(a," rounded-full"),value:x})};t.Z=c},53952:function(e,t,a){"use strict";a.d(t,{Z:function(){return j}});var l=a(85893),s=a(67294),n=a(81916),r=a(41352),o=a(8971),i=a(63938),c=a(72913);let d={startDate:null,endDate:null},u=e=>String(e).padStart(2,"0"),m=(e,t,a)=>"".concat(e,"-").concat(u(t+1),"-").concat(u(a)),x=(e,t)=>new Date(Date.UTC(e,t+1,0)).getUTCDate(),h=(e,t)=>({startDate:m(e,t,1),endDate:m(e,t,x(e,t))}),p=e=>{let t=new Date,a=t.getUTCFullYear(),l=t.getUTCMonth();return"this-month"===e?h(a,l):"last-month"===e?h(0===l?a-1:a,0===l?11:l-1):"this-year"===e?{startDate:m(a,0,1),endDate:m(a,11,31)}:d},g=[{key:"all",label:"All dates"},{key:"this-month",label:"This month"},{key:"last-month",label:"Last month"},{key:"this-year",label:"This year"}],b=e=>{let[t,a,l]=e.split("-").map(Number);return t&&a&&l?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}).format(new Date(Date.UTC(t,a-1,l))):e},y=e=>{let{startDate:t,endDate:a}=e;return t&&a?"".concat(b(t)," - ").concat(b(a)):"All dates"},f=(e,t)=>e.startDate===t.startDate&&e.endDate===t.endDate,v=(e,t)=>"all"===e?!t.startDate&&!t.endDate:f(p(e),t);function j(e){let{value:t,onChange:a,className:u,label:m="Date range",tooltipContent:x="Dates use UTC day boundaries, 00:00 - 23:59 UTC."}=e,[h,b]=(0,s.useState)(!1),[f,j]=(0,s.useState)(t.startDate||""),[w,N]=(0,s.useState)(t.endDate||""),[S,C]=(0,s.useState)("");(0,s.useEffect)(()=>{j(t.startDate||""),N(t.endDate||""),C("")},[t.startDate,t.endDate]);let T=!!(t.startDate&&t.endDate),A=(0,s.useMemo)(()=>y(t),[t]),D=T?"".concat(m,": ").concat(A,". ").concat(x):"".concat(m,". ").concat(x),E=e=>{b(e),e&&(j(t.startDate||""),N(t.endDate||""),C(""))},R=e=>{let t=p(e);j(t.startDate||""),N(t.endDate||""),C(""),a(t),b(!1)},k=()=>{if(!f&&!w){C(""),a(d),b(!1);return}if(!f||!w){C("Select both start and end dates.");return}if(f>w){C("Start date must be before end date.");return}C(""),a({startDate:f,endDate:w}),b(!1)},P=()=>{j(""),N(""),C(""),a(d),b(!1)},q=e=>{e.preventDefault(),e.stopPropagation(),P()};return(0,l.jsx)("div",{className:(0,i.cn)("inline-flex w-full sm:w-56",u),children:(0,l.jsxs)(c.J2,{open:h,onOpenChange:E,children:[(0,l.jsx)(c.xo,{asChild:!0,children:(0,l.jsxs)("button",{type:"button","aria-label":T?"".concat(m," date filter: ").concat(A):"Open ".concat(m," date filter"),title:D,className:(0,i.cn)("group inline-flex h-9 w-full items-center gap-2 rounded-md border bg-white px-3 text-sm outline-none transition-colors focus-visible:ring-1 focus-visible:ring-primaryViolet/60",T||h?"border-primaryViolet":"border-border hover:border-primaryViolet/60"),children:[(0,l.jsx)(n.Z,{className:(0,i.cn)("h-4 w-4 flex-none",T||h?"text-primaryViolet":"text-textGray")}),(0,l.jsx)("span",{className:(0,i.cn)("min-w-0 flex-1 truncate text-left font-medium",T?"text-neutral800":"text-neutral600"),
1children:T?A:m}),T?(0,l.jsx)("span",{role:"button",tabIndex:-1,"aria-label":"Clear date filter",onClick:q,className:"flex h-5 w-5 flex-none items-center justify-center rounded text-textGray transition-colors hover:bg-gray-100 hover:text-neutral800",children:(0,l.jsx)(r.Z,{className:"h-3.5 w-3.5"})}):(0,l.jsx)(o.Z,{className:(0,i.cn)("h-4 w-4 flex-none text-textGray transition-transform",h&&"rotate-180")})]})}),(0,l.jsxs)(c.yk,{align:"start",sideOffset:6,className:"w-[calc(100vw-2rem)] overflow-hidden rounded-xl border-gray-200 bg-white p-0 shadow-lg sm:w-[360px]",children:[(0,l.jsxs)("div",{className:"space-y-4 p-4",children:[(0,l.jsx)("div",{className:"grid grid-cols-2 gap-2",children:g.map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>R(e.key),className:(0,i.cn)("h-9 rounded-lg border px-3 text-xs font-medium transition-colors",v(e.key,t)?"border-primaryViolet bg-bgViolet text-primaryViolet":"border-gray-200 bg-white text-neutral600 hover:border-primaryViolet/60 hover:text-primaryViolet"),children:e.label},e.key))}),(0,l.jsxs)("div",{className:"relative flex items-center",children:[(0,l.jsx)("span",{className:"h-px flex-1 bg-gray-100"}),(0,l.jsx)("span",{className:"px-2 text-[10px] font-medium uppercase tracking-wide text-textGray",children:"Custom range"}),(0,l.jsx)("span",{className:"h-px flex-1 bg-gray-100"})]}),(0,l.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,l.jsxs)("label",{className:"flex flex-col gap-1 text-xs font-medium text-neutral600",children:["Start",(0,l.jsx)("input",{type:"date",value:f,max:w||void 0,onChange:e=>j(e.target.value),className:"h-10 rounded-lg border border-gray-200 bg-white px-3 text-sm text-neutral800 outline-none transition-colors focus:border-primaryViolet focus:ring-1 focus:ring-primaryViolet"})]}),(0,l.jsxs)("label",{className:"flex flex-col gap-1 text-xs font-medium text-neutral600",children:["End",(0,l.jsx)("input",{type:"date",value:w,min:f||void 0,onChange:e=>N(e.target.value),className:"h-10 rounded-lg border border-gray-200 bg-white px-3 text-sm text-neutral800 outline-none transition-colors focus:border-primaryViolet focus:ring-1 focus:ring-primaryViolet"})]})]}),S&&(0,l.jsx)("p",{className:"text-xs text-errorRed",children:S})]}),(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-gray-100 bg-gray-50/60 px-4 py-3",children:[(0,l.jsx)("span",{className:"text-[11px] leading-tight text-textGray",children:x}),(0,l.jsxs)("div",{className:"flex flex-none items-center gap-2",children:[T&&(0,l.jsxs)("button",{type:"button",onClick:P,className:"inline-flex h-9 items-center gap-1.5 rounded-lg px-3 text-sm font-medium text-neutral600 transition-colors hover:text-primaryViolet",children:[(0,l.jsx)(r.Z,{className:"h-4 w-4"}),"Clear"]}),(0,l.jsx)("button",{type:"button",onClick:k,className:"h-9 rounded-lg bg-primaryViolet px-4 text-sm font-medium text-white transition-colors hover:bg-hoverViolet",children:"Apply"})]})]})]})]})})}},72913:function(e,t,a){"use strict";a.d(t,{J2:function(){return o},xo:function(){return i},yk:function(){return c}});var l=a(85893),s=a(67294),n=a(66529),r=a(63938);let o=n.fC,i=n.xz;n.ee;let c=s.forwardRef((e,t)=>{let{className:a,align:s="center",sideOffset:o=4,...i}=e;return(0,l.jsx)(n.h_,{children:(0,l.jsx)(n.VY,{ref:t,align:s,sideOffset:o,className:(0,r.cn)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",a),...i})})});c.displayName=n.VY.displayName},89166:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return ef}});var l=a(85893),s=a(67294),n=a(65603),r=a(59335),o=a(9473),i=a(85518),c=a(38614),d=a(8193),u=a(45528),m=a(29009),x=a(28935),h=a(14195),p=a(3023),g=a(75358),b=a(26050),y=a(18242);let f=e=>{let{data:t}=e;return t&&t.salesTime?(0,l.jsx)("div",{style:{width:"100%",height:120},children:(0,l.jsx)(m.h,{children:(0,l.jsxs)(x.v,{data:(e=>{let t=Object.keys(null==e?void 0:e.salesTime).map(t=>"0"===e.salesTime[t]?null:{name:t,sales:e.salesTime[t]});return t})(t),children:[(0,l.jsx)(h.q,{strokeDasharray:"3 3"}),(0,l.jsx)(p.K,{dataKey:"name"}),(0,l.jsx)(g.B,{}),(0,l.jsx)(b.u,{}),(0,l.jsx)(y.$,{dataKey:"sales",fill:"#4f50f6"})]})})}):null};var v=a(84908);let j=e=>{let{month:t,handleChangeMonth:a}=e;return(0,l.jsx)(v.L,{className:"w-full",value:t,options:[{name:"January",value:0},{name:"February",value:1},{name:"March",value:2},{name:"April",value:3},{name:"May",value:4},{name:"June",value:5},{name:"July",value:6},{name:"August",value:7},{name:"September",value:8},{name:"October",value:9},{name:"November",value:10},{name:"December",value:11}],onChange:e=>a(e.value),optionLabel:"name",placeholder:"Select a Month"})},w=e=>{let{year:t,handleChangeYear:a}=e,s=new Date().getFullYear(),n=Array.from({length:6},(e,t)=>{let a=s-t;return{name:"".concat(a),value:a}}).reverse();return(0,l.jsx)(v.L,{className:"w-full",value:t,options:n,onChange:e=>a(e.value),optionLabel:"name",placeholder:"Select a Year"})},N=e=>{let{totalPaid:t,toBePaid:a,pendingPaymentRequestToBePaid:s,language:n}=e;return(0,l.jsxs)(l.Fragment,{children:[" ",(0,l.jsx)("div",{className:"flex flex-col md:flex-row w-full p-2 rounded-md ",children:(0,l.jsxs)("div",{className:"flex flex-col md:flex-row w-full justify-between",children:[(0,l.jsxs)("div",{className:"flex flex-col w-full md:w-1/2 mb-2 md:mb-0",children:[(0,l.jsxs)("span",{className:"text-sm text-[#16181d]",children:[n.salesPage.dashboard.totalCommissionAmount,":"]}),(0,l.jsx)("span",{className:"mr-2 text-xl text-[#16181d] font-bold",children:(0,u.formatCurrency)(a)})]}),(0,l.jsxs)("div",{className:"flex flex-col w-full md:w-1/2",children:[(0,l.jsxs)("span",{className:"text-sm text-[#16181d]",children:[n.salesPage.dashboard.totalComissionPaid,":"]}),(0,l.jsx)("span",{className:"mr-2 text-xl text-[#16181d] font-bold",children:(0,u.formatCurrency)(t)})]})]})}),(0,l.jsx)("div",{className:"flex flex-col md:flex-row w-full p-2 rounded-md ",children:(0,l.jsxs)("div",{className:"flex flex-col md:flex-row w-full justify-between",children:[(0,l.jsxs)("div",{className:"flex flex-col w-full md:w-1/2 mb-2 md:mb-0",children:[(0,l.jsxs)("span",{className:"text-sm text-[#16181d]",children:[n.salesPage.dashboard.totalCommissionToBeReq,":"]}
1),(0,l.jsx)("span",{className:"mr-2 text-xl text-[#16181d] font-bold",children:(0,u.formatCurrency)(a)})]}),(0,l.jsxs)("div",{className:"flex flex-col w-full md:w-1/2 mb-2 md:mb-0",children:[(0,l.jsxs)("span",{className:"text-sm text-[#16181d]",children:[n.salesPage.dashboard.commissionRequested,":"]}),(0,l.jsx)("span",{className:"mr-2 text-xl text-[#16181d] font-bold",children:(0,u.formatCurrency)(t)})]})]})})]})},S=e=>{let{title:t,sales:a,salesDifference:s,IconComponent:n}=e;return(0,l.jsxs)("div",{className:"flex flex-col rounded-xl",children:[(0,l.jsxs)("div",{className:"flex items-center mb-1",children:[(0,l.jsx)(n,{className:"text-primaryViolet mr-2 text-[#b4cbe3]"}),(0,l.jsx)("span",{className:"text-sm text-[#16181d]",children:t})]}),(0,l.jsxs)("div",{className:"flex items-baseline",children:[(0,l.jsx)("span",{className:"mr-2 text-3xl text-black ",children:(0,u.formatCurrency)(a)}),s>0?(0,l.jsxs)("span",{className:"flex items-center text-xs text-green-500",children:[(0,l.jsx)(d.Vs3,{}),s,"%"]}):(0,l.jsxs)("span",{children:[(0,l.jsx)(d.i0B,{className:"text-red-500"})," ",s]})]})]})},C=e=>{let{data:t,period:a,month:s,year:o,handleChangeMonth:i,handleChangeYear:c}=e,{language:u}=(0,n.E)(),m=new Date(o,s,1).toLocaleString("en-US",{month:"long"});return t&&(0,l.jsx)(r.Card,{className:"mb-2 h-full",children:(0,l.jsxs)(r.CardBody,{className:"flex flex-col justify-between py-12 px-16",children:[(0,l.jsxs)("div",{className:"flex flex-col md:flex-row w-full justify-between mb-5",children:[(0,l.jsx)("div",{className:"mb-2 md:mb-0 md:w-28",children:(0,l.jsx)(r.Typography,{variant:"h6",children:"month"===a?m+" "+o:o})}),(0,l.jsxs)("div",{className:"md:w-2/6",children:["month"===a&&(0,l.jsx)(j,{month:s,handleChangeMonth:i}),"year"===a&&(0,l.jsx)(w,{year:o,handleChangeYear:c})]})]}),(0,l.jsxs)("div",{className:"flex flex-col md:flex-row w-full items-center mt-6 justify-between gap-3",children:[(0,l.jsx)("div",{className:"w-full md:w-[calc(50%-1rem)]",children:(0,l.jsx)(S,{title:u.salesPage.dashboard.totalSales,sales:t.totalSales,salesDifference:1,IconComponent:d.Io8})}),(0,l.jsx)("div",{className:"w-full md:w-[calc(50%-1rem)] mt-4 md:mt-0",children:(0,l.jsx)(f,{data:t})})]}),(0,l.jsx)("div",{className:"w-full flex justify-center my-4 border-b border-[#d1d8e0] w-3/4"}),(0,l.jsx)("div",{className:"w-full",children:(0,l.jsx)(N,{totalPaid:t.totalPaid,toBePaid:t.totalToBePaid,language:u,pendingPaymentRequestToBePaid:t.pendingPaymentRequestToBePaid})})]})})},T=e=>{var t,a,s,n;let{summary:o={},labels:i={}}=e,c=null!==(t=null==o?void 0:o.totalEarned)&&void 0!==t?t:0,d=null!==(a=null==o?void 0:o.totalPaid)&&void 0!==a?a:0,m=null!==(n=null!==(s=null==o?void 0:o.totalUnpaid)&&void 0!==s?s:null==o?void 0:o.totalToBePaid)&&void 0!==n?n:0,x=[{label:i.totalPaid,amount:d,count:null==o?void 0:o.paidCount,accent:"text-green-600"},{label:i.pending,amount:m,count:null==o?void 0:o.notPaidCount,accent:"text-primaryViolet"}];return(0,l.jsx)(r.Card,{className:"h-full",children:(0,l.jsxs)(r.CardBody,{className:"flex flex-col gap-5 p-6",children:[(0,l.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(r.Typography,{className:"text-sm text-gray-500",children:i.totalEarned}),(0,l.jsx)(r.Typography,{variant:"h4",className:"text-[#16181d]",children:(0,u.formatCurrency)(c)})]}),(null==o?void 0:o.totalCount)!=null&&(0,l.jsxs)("span",{className:"rounded-md bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600",children:[o.totalCount," ",i.bonuses]})]}),(0,l.jsx)("div",{className:"grid grid-cols-2 gap-3 border-t border-gray-100 pt-4",children:x.map(e=>(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)("span",{className:"text-xs text-gray-500",children:e.label}),(0,l.jsx)("span",{className:"text-xl font-bold ".concat(e.accent),children:(0,u.formatCurrency)(e.amount)}),null!=e.count&&(0,l.jsxs)("span",{className:"text-[11px] text-gray-400",children:[e.count," ",i.bonuses]})]},e.label))})]})})};var A=a(4570),D=a(34972),E=a(80926),R=a(90744),k=a(89693);let P=e=>{var t,a,i,c;
1let{setLoader:d}=e,{language:u,selectedLang:m}=(0,n.E)(),{user:x}=(0,o.v9)(e=>e.auth),{activeSalesTab:h}=(0,s.useContext)(k.f),[p,g]=(0,s.useState)({}),[b,y]=(0,s.useState)({}),[f,v]=(0,s.useState)(null),[j,w]=(0,s.useState)([]),[N,S]=(0,s.useState)(!0),[P,q]=(0,s.useState)(new Date().getFullYear()),[Z,I]=(0,s.useState)(new Date().getMonth()),O=e=>{I(e)},F=e=>{q(e)},V="en-US";"es"==m&&(V="es-ES");let L=new Date,_=L.toLocaleString(V,{month:"long"}),M=(0,l.jsxs)("span",{className:"text-black",children:[u.salesPage.dashboard.thisMonth," ",(0,l.jsxs)("span",{className:"text-gray-500 ml-2",children:["(",_," ",P,")"]})]}),B="".concat(u.salesPage.dashboard.thisYear," (").concat(P,")"),U=(null==u?void 0:null===(t=u.salesPage)||void 0===t?void 0:t.bonusSummary)||{},z=(null==u?void 0:null===(a=u.salesPage)||void 0===a?void 0:a.bonusProgress)||{},J=(0,s.useCallback)(async()=>{d(!0);let e=new Date(P,Z,1).toISOString().split("T")[0],t=new Date(P,Z+1,0).toISOString().split("T")[0],a=await (0,E.Re)(e,t);a&&g(a),d(!1)},[Z]),Y=(0,s.useCallback)(async()=>{d(!0);let e=new Date(P,0,1).toISOString().split("T")[0],t=new Date(P,11,31).toISOString().split("T")[0],a=await (0,E.Re)(e,t,P);a&&y(a),d(!1)},[P]),W=(0,s.useCallback)(async()=>{S(!0);try{try{var e;let t=await (0,R.f_)({startDate:"".concat(P,"-01-01"),endDate:"".concat(P,"-12-31"),bonusFilter:null});v(null!==(e=null==t?void 0:t.data)&&void 0!==e?e:null)}catch(e){console.log(e)}try{let e=await (0,R.aN)({year:P});w(Array.isArray(e)?e:[])}catch(e){console.log(e)}}finally{S(!1)}},[P]);(0,s.useEffect)(()=>{J(),Y(),W()},[J,Y,W]),(0,s.useEffect)(()=>{"overview"===h&&(J(),Y(),W())},[h,J,Y,W]);let G=null!==(i=null==x?void 0:x.id)&&void 0!==i?i:null==x?void 0:x.userId,Q=(j||[]).map(e=>{var t,a;let l=null!==(t=null==e?void 0:e.reps)&&void 0!==t?t:[],s=null!==(a=l.find(e=>(null==e?void 0:e.userId)===G))&&void 0!==a?a:1===l.length?l[0]:null;return s?{rule:e,rep:s}:null}).filter(Boolean);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"w-full pb-2 lg:w-[calc(50%-1rem)]",children:(0,l.jsx)(C,{title:M,month:Z,year:P,data:p,period:"month",handleChangeMonth:O})}),(0,l.jsx)("div",{className:"w-full pb-2 lg:w-[calc(50%-1rem)] ",children:(0,l.jsx)(C,{title:B,year:P,data:b,period:"year",handleChangeYear:F})}),(N||f||Q.length>0)&&(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",className:"mb-3",children:"".concat(U.title||"Bonuses"," (").concat(P,")")}),(0,l.jsx)("div",{className:"flex w-full flex-col gap-4 lg:flex-row lg:flex-wrap",children:N?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"w-full lg:w-[calc(50%-0.5rem)]",children:(0,l.jsx)(D.Z,{})}),(0,l.jsx)("div",{className:"w-full lg:w-[calc(50%-0.5rem)]",children:(0,l.jsx)(D.Z,{})})]}):(0,l.jsxs)(l.Fragment,{children:[f&&(0,l.jsx)("div",{className:"w-full lg:w-[calc(50%-0.5rem)]",children:(0,l.jsx)(T,{summary:f,labels:U})}),Q.map((e,t)=>{let{rule:a,rep:s}=e;return(0,l.jsxs)("div",{className:"w-full lg:w-[calc(50%-0.5rem)]",children:[(null==a?void 0:a.ruleName)&&(0,l.jsx)(r.Typography,{className:"mb-1 text-xs font-medium text-gray-500",children:a.ruleName}),(0,l.jsx)(A.Z,{rep:s,rule:a,labels:z,showName:!1})]},null!==(c=null==a?void 0:a.ruleId)&&void 0!==c?c:t)})]})})]})]})};var q=a(33289),Z=a(88804),I=a(53854),O=a(7550),F=a(86843);let{formatCurrency:V}=a(45528),L=e=>{var t;let{manualAmountMode:a,manualAmount:s,setManualAmount:n,handleDialogOpen:o,toggleManualAmountMode:i,openReopenDialog:c,job:d,disabled:u=!1}=e;return(0,l.jsxs)("div",{className:"w-full flex flex-col justify-between items-center px-6 py-4 shadow-md rounded-2xl border-t border-slate-800 mb-10",children:[(0,l.jsx)("div",{className:"w-full bg-[#EFF2F5] shadow-lg rounded-2xl px-4 py-2 mb-4 flex justify-between items-center mt-2",children:a?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(r.Typography,{color:"blue-gray",className:"text-sm",children:"Total to be paid:"}),(0,l.jsxs)(r.Typography,{variant:"h4",color:"blue-gray",className:"flex items-baseline gap-1 w-40",children:["$",(0,l.jsx)(r.Input,{variant:"standard",type:"number",min:1,id:"manual-amount",value:s,onChange:e=>n(e.target.value),style:{fontSize:"24px",fontWeight:"600",color:"black",padding:"0"},size:"lg",className:"border-none w-full",placeholder:"Enter Amount",disabled:u})]})]}),(0,l.jsx)(O.Z,{size:"sm",className:"bg-primaryViolet rounded-2xl",disabled:u||null==s,onClick:o,children:"Approve with manual amount"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(r.Typography,{color:"blue-gray",className:"text-sm",children:"Total Paid:"}),(0,l.jsx)(r.Typography,{variant:"h4",color:"blue-gray",children:null!==(t=V(d.commission))&&void 0!==t?t:"$0"})]}),(0,l.jsx)(O.Z,{size:"sm",className:"bg-primaryViolet rounded-2xl",onClick:o,disabled:u,children:"Approve"})]})}),a?(0,l.jsx)("div",{className:"w-full flex justify-end items-center",children:(0,l.jsx)(O.Z,{size:"sm",variant:"outlined",onClick:()=>i(!a),disabled:u,children:"Approve with amount to be paid"})}):(0,l.jsxs)("div",{className:"w-full flex justify-between items-center",children:[(0,l.jsx)("button",{type:"button",className:"text-primaryViolet text-sm underline ".concat(u?"cursor-not-allowed opacity-50":"cursor-pointer"),onClick:()=>{u||i(!a)},disabled:u,children:"Approve with manual amount"}),(0,l.jsx)(O.Z,{size:"sm",variant:"outlined",className:"rounded-2xl border border-primaryViolet text-primaryViolet",onClick:()=>
1c(!0),disabled:u,children:"Reopen"})]})]})};var _=a(4431),M=a(73079),B=a(51226),U=a(92373);function z(e){let{open:t,commissionId:a,detail:s}=e,n=null==s?void 0:s.parentJobId;return t&&a&&(null==s?void 0:s.id)===a&&"number"==typeof n&&Number.isSafeInteger(n)&&!(n<=0)?(0,l.jsx)(U.Z,{jobId:n},n):null}var J=a(13043),Y=a(61830),W=a(3659);let G=e=>{var t,a,i;let{projectDetail:c,jobDetail:d,closeDrawer:m,job:x,comissions:h=[],handleSuperAdminApproveRejectSingle:p,handleJobPaymentRequest:g,handleJobApproval:b,handleReopenJob:y,isMember:f=!1,handleManualJobApproval:v,handleRequestAndApprove:j,fetchJobs:w,galleryOpen:N=!1,handleRejectRequestPaymentSingle:S,variant:C="sales"}=e,{language:T}=(0,n.E)(),{user:A}=(0,o.v9)(e=>e.auth),[D,E]=(0,s.useState)(!1),[R,k]=(0,s.useState)(!1),[P,Z]=(0,s.useState)(),[V,U]=(0,s.useState)(""),[G,Q]=(0,s.useState)(!1),[H,K]=(0,s.useState)("Are you sure you want to approve this payment?"),[$,X]=(0,s.useState)("alert"),[ee,et]=(0,s.useState)(!1),[ea,el]=(0,s.useState)([]),es=null!==(i=(0,W.eR)(d))&&void 0!==i?i:(0,W.eR)(x),en=(0,W.qb)(es),er=(0,W.Gg)(es),eo=["REQUESTED","PRE_APPROVED"].includes(null==d?void 0:d.internalStatus)?"resolve":(null==d?void 0:d.internalStatus)==="AVAILABLE"?"create":null;(0,s.useEffect)(()=>{c&&c.details&&el(c.details)},[c]);let ei=()=>{k(!1),Z(0),U(""),et(!1),m()},ec=()=>{if(!er)return;let e=""===P||null==P||(null==P?void 0:P.trim())===""?null:Number(P);R?v(x.id,{manualAmount:e}):b(x.id),ei()},ed=e=>{en&&(j(e),ei())},eu=async()=>{er&&(y(x.id,{reason:V}),ex(),ei())},em=()=>{et(!ee),K("Are you sure you want to approve this payment?"),X("alert")},ex=()=>{U(""),Q(!G)};return x.status,(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(q.Z,{dialogOpen:ee,handleDialogOpen:em,status:$,mainMessage:H,buttons:"alert"===$?[{text:"YES",action:ec},{text:"NO",variant:"outlined",action:em}]:[{text:"success"===$?"Go back to Jobs":"Close",action:em}]}),(0,l.jsx)(q.Z,{dialogOpen:G,handleDialogOpen:ex,showAlertIcon:!1,buttons:[{text:"Save",action:eu}],children:(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)("div",{className:"text-black",children:"Reasons to be open:"}),(0,l.jsx)(r.Textarea,{rows:8,value:V,onChange:e=>U(e.target.value),size:"lg",className:"bg-[eff2f5] text-xl"})]})}),(0,l.jsx)(s.Fragment,{children:(0,l.jsx)("div",{className:"flex flex-col h-full bg-gray-50",children:(0,l.jsxs)("div",{className:"flex-grow overflow-y-auto",children:[(0,l.jsx)("div",{className:"bg-white border-b border-gray-200 px-6 py-4",children:(0,l.jsxs)("div",{className:"flex justify-between items-center",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)(r.Typography,{variant:"h4",color:"blue-gray",className:"font-bold text-2xl",children:x.jobName||x.name}),x.externalReference&&(0,l.jsxs)(r.Typography,{variant:"small",className:"text-gray-600",children:["Reference: #",x.externalReference]})]}),(0,l.jsx)(r.IconButton,{variant:"text",onClick:ei,className:"hover:bg-gray-100 rounded-lg p-2",children:(0,l.jsx)(I.fMW,{className:"h-6 w-6"})})]})}),(0,l.jsxs)("div",{className:"p-6 space-y-6",children:[(0,l.jsx)(Y.NX,{reconciliation:es,kind:"commission",showShadow:"sales"!==C}),(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[(0,l.jsxs)(r.Typography,{variant:"h6",className:"text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2",children:[(0,l.jsx)("svg",{className:"w-5 h-5 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Job Summary"]}),(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)(r.Typography,{variant:"small",className:"text-gray-500 text-xs uppercase tracking-wider font-medium",children:"Status"}),(0,l.jsx)(F.Z,{status:null==d?void 0:d.internalStatus})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)(r.Typography,{variant:"small",className:"text-gray-500 text-xs uppercase tracking-wider font-medium",children:"Contract Amou
1nt"}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(null==x?void 0:x.contractAmount)})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)(r.Typography,{variant:"small",className:"text-gray-500 text-xs uppercase tracking-wider font-medium",children:"Total Commission"}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(null==d?void 0:d.totalComission)})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)(r.Typography,{variant:"small",className:"text-gray-500 text-xs uppercase tracking-wider font-medium",children:"Lead Source"}),(0,l.jsx)(r.Typography,{className:"text-base font-medium text-gray-700",children:x.leadSourceFixed||(null==d?void 0:d.leadSourceFixed)||x.leadSource||x.leadType||(null==d?void 0:d.leadType)||"General"})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)(r.Typography,{variant:"small",className:"text-gray-500 text-xs uppercase tracking-wider font-medium",children:"Total Paid to Company"}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-green-600",children:(0,u.formatCurrency)(null==d?void 0:d.paymentsReceived)})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsx)(r.Typography,{variant:"small",className:"text-gray-500 text-xs uppercase tracking-wider font-medium",children:"Project Type"}),(0,l.jsx)(r.Typography,{className:"text-base font-medium text-gray-700",children:(null==d?void 0:d.tradeType)||(null==x?void 0:x.tradeType)||(null==x?void 0:x.projectType)||"N/A"})]})]})]}),(x.description||x.notes)&&(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[x.description&&(0,l.jsxs)("div",{className:"mb-4",children:[(0,l.jsxs)(r.Typography,{variant:"h6",className:"text-lg font-semibold text-gray-900 mb-2 flex items-center gap-2",children:[(0,l.jsx)("svg",{className:"w-5 h-5 text-purple-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}),"Description"]}),(0,l.jsx)(r.Typography,{className:"text-gray-700 leading-relaxed",children:x.description||T.salesPage.dashboard.noDescription})]}),x.notes&&(0,l.jsxs)("div",{children:[(0,l.jsxs)(r.Typography,{variant:"h6",className:"text-lg font-semibold text-gray-900 mb-2 flex items-center gap-2",children:[(0,l.jsx)("svg",{className:"w-5 h-5 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Notes"]}),(0,l.jsx)(r.Typography,{className:"text-gray-700 leading-relaxed",children:x.notes||T.salesPage.dashboard.emptyNotes})]})]}),(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[(0,l.jsxs)(r.Typography,{variant:"h6",className:"text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2",children:[(0,l.jsx)("svg",{className:"w-5 h-5 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Financial Details"]}),(0,l.jsx)("div",{className:"space-y-3",children:"sales"===C||"admin"===C?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex justify-between items-center py-2 border-b border-gray-100",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(_.Z,{className:"text-gray-500",style:{fontSize:"1.2rem"}}),(0,l.jsx)(r.Typography,{className:"text-gray-700 font-medium",children:"Total Supplements"})]}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(null==d?void 0:d.supplements)})]}),(0,l.jsxs)("div",{className:"flex justify-between items-center py-2 border-b border-gray-100",children:[(0,l.jsx)(r.Typography,{className:"text-gray-700 font-medium ml-7",children:"Total Commission"}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(null==d?void 0:d.totalComission)})]}),(0,l.jsxs)("div",{className:"flex justify-between items-center py-2 bg-purple-50 px-3 rounded-lg",children:[(0,l.jsx)(r.Typography,{className:"text-purple-800 font-semibold",children:"Total to be paid based on HO payments"}),(0,l.jsx)(r.Typography,{className:"text-xl font-bold text-purple-600",children:(0,u.formatCurrency)(null==d?void 0:d.totalToBePaid)})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex justify-between items-center py-2 border-b border-gray-100",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(_.Z,{className:"text-gray-500",style:{fontSize:"1.2rem"}}),(0,l.jsx)(r.Typography,{className:"text-gray-700 font-medium",children:T.salesPage.dashboard.totalSupplements})]}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(null==d?void 0:d.supplements)})]}),(0,l.jsxs)("div",{className:"flex justify-between items-center py-2 border-b border-gray-100",children:[(0,l.jsx)(r.Typography,{className:"text-gray-700 font-medium ml-7",children:T.salesPage.dashboard.totalCommisionWSupplements}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(null==d?void 0:d.totalComissionWithSupplements)})]}),(0,l.jsxs)("div",{className:"flex justify-between items-center py-2 border-b border-gray-100",children:[(0,l.jsx)(r.Typography,{className:"text-gray-700 font-medium ml-7",children:T.salesPage.dashboard.totalCommisionWOSupplements}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(null==d?void 0:d.totalComissionWithoutSupplements)})]}),(0,l.jsxs)("div",{className:"flex justify-between items-center py-2 bg-green-50 px-3 rounded-lg",children:[(0,l.jsx)(r.Typography,{className:"text-green-800 font-semibold",children:T.salesPage.dashboard.totalPaidUnitedToDate}),(0,l.jsx)(r.Typography,{className:"text-xl font-bold text-green-600",children:(0,u.formatCurrency)(null==d?void 0:d.paymentsReceived)})]})]})})]}),h&&h.length>0&&(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[(0,l.jsxs)(r.Typography,{variant:"h6",className:"text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2",children:[(0,l.jsx)("svg",{className:"w-5 h-5 text-indigo-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Payment History"]}),(0,l.jsx)("div",{className:"space-y-2",children:h.map((e,t)=>(0,l.jsxs)("div",{className:"flex justify-between items-center py-3 px-3 hover:bg-gray-50 rounded-lg transition-colors",children:[(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)(r.Typography,{className:"text-gray-900 font-medium",children:e.jobName}),(0,l.jsx)(r.Typography,{variant:"small",className:"text-gray-500",children:(0,u.formatDate)(e.dateOfApproval)})]}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900",children:(0,u.formatCurrency)(e.amount)})]},t))})]}),(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[(0,l.jsxs)(r.Typography,{variant:"h6",className:"text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2",children:[(0,l.jsx)(M.Z,{className:"text-blue-600",style:{fontSize:"1.3rem"}}),"Sales Information"]}),(0,l.jsxs)("div",{className:"flex items-start gap-4",children:[(0,l.jsx)("div",{className:"rounded-full text-white bg-gradient-to-br from-blue-600 to-purple-600 w-14 h-14 flex items-center justify-center text-lg font-semibold shadow-lg",children:(0,u.getShort)(null==x?void 0:null===(t=x.salesUser)||void 0===t?void 0:t.name)}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)(r.Typography,{className:"text-sm text-gray-500 uppercase tracking-wider font-medium",children:T.salesAdminPage.bonusContainer.salesPerson}),(0,l.jsx)(r.Typography,{className:"text-lg font-semibold text-gray-900 mb-2",children:null==x?void 0:null===(a=x.salesUser)||void 0===a?void 0:a.name}),(0,l.jsxs)("div",{className:"flex items-center gap-2 bg-purple-50 rounded-lg px-3 py-2 inline-flex",children:[(0,l.jsxs)(r.Typography,{className:"text-purple-700 font-medium",children:[T.salesPage.dashboard.commissionToBeRequested,":"]}),(0,l.jsx)(r.Typography,{className:"text-lg font-bold text-purple-900",children:(0,u.formatCurrency)(null==d?void 0:d.commission)})]})]})]})]}),(0,l.jsx)(z,{open:N,commissionId:null==x?void 0:x.id,detail:d}),(0,l.jsxs)("div",{className:"bg-white rounded-xl border border-gray-200 p-6",children:[(0,l.jsxs)(r.Typography,{variant:"h6",className:"text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2",children:[(0,l.jsx)("svg",{className:"w-5 h-5 text-purple-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),"Actions"]}),eo&&(0,l.jsx)("div",{className:"mb-4",children:(0,l.jsx)(Y.Fb,{reconciliation:es,action:eo})}),(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:["admin"===C&&(0,l.jsxs)(l.Fragment,{children:[(null==d?void 0:d.internalStatus)==="REQUESTED"&&(0,l.jsx)(O.Z,{size:"lg",variant:"outlined",className:"border-2 rounded-xl border-red-500 text-red-500 hover:bg-red-50 transition-colors",onClick:()=>S(x),disabled:!er,children:T.selectedJobsSummary.reject}),(null==d?void 0:d.internalStatus)=="REQUESTED"?(0,l.jsx)(L,{manualAmountMode:R,manualAmount:P,setManualAmount:Z,handleDialogOpen:em,toggleManualAmountMode:k,openReopenDialog:Q,job:x,disabled:!er}):(0,l.jsx)("div",{className:"w-full text-center text-gray-500 py-3",children:"No actions available"})]}),"super-admin"===C&&(0,l.jsx)(l.Fragment,{children:(null==d?void 0:d.internalStatus)=="REQUESTED"||(null==d?void 0:d.internalStatus)==="PRE_APPROVED"?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(O.Z,{size:"lg",variant:"outlined",className:"border-2 rounded-xl border-red-500 text-red-500 hover:bg-red-50 transition-colors",onClick:()=>{p(x,"REJECTED")},disabled:!er,children:T.selectedJobsSummary.reject}),(0,l.jsx)(L,{manualAmountMode:R,manualAmount:P,setManualAmount:Z,handleDialogOpen:em,toggleManualAmountMode:k,openReopenDialog:Q,job:x,disabled:!er})]}):(null==d?void 0:d.internalStatus)=="AVAILABLE"?(0,l.jsx)(O.Z,{size:"lg",className:"bg-primaryViolet hover:bg-purple-700 rounded-xl transition-colors",onClick:()=>{ed(x.id)},disabled:!en,children:T.selectedJobsSummary.requestAndApprove}):(0,l.jsx)("div",{className:"w-full text-center text-gray-500 py-3",children:"No actions available"})}),"sales"===C&&!f&&(0,l.jsxs)(l.Fragment,{children:[(null==x?void 0:x.externalReference)&&(0,l.jsxs)(O.Z,{size:"lg",className:"".concat((null==d?void 0:d.internalStatus)==="PAID"?"bg-green-600 hover:bg-green-700":"bg-blue-600 hover:bg-blue-700"," text-white rounded-xl flex items-center justify-center gap-2 transition-colors"),onClick:()=>{E(!0)},children:[(0,l.jsx)(J.Z,{className:"h-5 w-5"}),"View Commission Details"]}
1),(0,l.jsx)(O.Z,{size:"lg",className:"bg-primaryViolet hover:bg-purple-700 rounded-xl transition-colors disabled:bg-gray-300 disabled:cursor-not-allowed",disabled:(null==d?void 0:d.internalStatus)!="AVAILABLE"||!en,onClick:()=>{en&&g(x.id)},children:T.selectedJobsSummary.requestPayment})]}),("admin"===C||"super-admin"===C||"sales"===C)&&!(null==h?void 0:h.length)&&(null==d?void 0:d.internalStatus)!="REQUESTED"&&(null==d?void 0:d.internalStatus)!="PRE_APPROVED"&&(null==d?void 0:d.internalStatus)!="AVAILABLE"&&!(null==x?void 0:x.externalReference)&&(0,l.jsx)("div",{className:"w-full text-center text-gray-500 py-3",children:"No actions available"})]})]})]})]})})}),(0,l.jsx)(B.Z,{open:D,onClose:()=>E(!1),externalReference:null==x?void 0:x.externalReference,userId:null==A?void 0:A.id,userName:null==A?void 0:A.name})]})};var Q=a(23014),H=a(47),K=a(53952),$=a(74478),X=a(44099),ee=a(50215);let et=e=>{let{setLoader:t,setJobDrawerContent:a,setOpenJobDrawer:c,openJobDrawer:d}=e,{language:m}=(0,n.E)(),{user:x}=(0,o.v9)(e=>e.auth),{activeSalesTab:h}=(0,s.useContext)(k.f),[p,g]=(0,s.useState)("payment-not-requested"),[b,y]=(0,s.useState)({startDate:null,endDate:null}),[f,v]=(0,s.useState)([]),[j,w]=(0,s.useState)([]),[N,S]=(0,s.useState)({}),[C,T]=(0,s.useState)({}
1),[A,D]=(0,s.useState)([]),R=(0,s.useCallback)(()=>c(!1),[c]),[P,I]=(0,s.useState)(""),[V,L]=(0,s.useState)(!1),[_,M]=(0,s.useState)(!1),[U,z]=(0,s.useState)(null),et=(0,H.ac)({minWidth:768,maxWidth:1027}),ea=[{label:"Project Name",columnAlign:"w-1/6 mt-2 ml-0",itemAlign:"mt-2 w-full md:w-1/6 ".concat(et?"ml-2":i.tq?"ml-6 mr-5":"ml-6"),render:e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex w-full ".concat(i.tq?"justify-between":""),children:[i.tq&&(0,l.jsx)("p",{className:"".concat(i.tq?"mt-1 mb-3":""),style:{fontSize:i.tq?"10px":null},children:m.salesAdminPage.jobContainer.cardList.jobName}),(0,l.jsx)("p",{style:{fontSize:i.tq?"14px":""},children:e.name||"-"})]}),i.tq&&(0,l.jsx)("hr",{})]})},{label:"Date of Request",columnAlign:"w-1/6 mt-2 ml-10",itemAlign:"mt-2 w-full md:w-1/6 ".concat(et?"ml-2":i.tq?"ml-6 mr-5":"ml-7"),render:e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex w-full ".concat(i.tq?"justify-between":""),children:[i.tq&&(0,l.jsx)("p",{className:"".concat(i.tq?"mt-1 mb-3":""),style:{fontSize:i.tq?"10px":null},children:m.salesAdminPage.jobContainer.cardList.dateOfRequest}),(0,l.jsx)("p",{style:{fontSize:i.tq?"14px":""},children:(0,u.formatDate)(e.paymentRequestDate,"Not requested")})]}),i.tq&&(0,l.jsx)("hr",{})]})},{label:"Contract Amount",columnAlign:"w-1/6 mt-2 ml-4",itemAlign:"mt-2 w-full md:w-1/6 ".concat(et?"ml-2":i.tq?"ml-6 mr-5":"ml-8"),render:e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex w-full ".concat(i.tq?"justify-between":""),children:[i.tq&&(0,l.jsx)("p",{className:"".concat(i.tq?"mt-1 mb-3":""),style:{fontSize:i.tq?"10px":null},children:m.salesPage.dashboard.contractAmount}),(0,l.jsx)("p",{style:{fontSize:i.tq?"14px":""},children:(0,u.formatCurrency)(e.contractAmount)})]}),i.tq&&(0,l.jsx)("hr",{})]})},{label:"Total Paid to Company",columnAlign:"w-1/6 mt-2 ml-4",itemAlign:"mt-2 w-full md:w-1/6 ".concat(et?"ml-2":i.tq?"ml-6 mr-5":"ml-8"),render:e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex w-full ".concat(i.tq?"justify-between":""),children:[i.tq&&(0,l.jsx)("p",{className:"".concat(i.tq?"mt-1 mb-3":""),style:{fontSize:i.tq?"10px":null},children:m.totalPaidToUnited}),(0,l.jsx)("p",{style:{fontSize:i.tq?"14px":""},children:(0,u.formatCurrency)(e.paymentsReceived)})]}),i.tq&&(0,l.jsx)("hr",{})]})},{label:"Request Status",columnAlign:"w-1/6 mt-2 ml-10",itemAlign:"mt-2 w-full md:w-1/6 ".concat(et?"ml-2":i.tq?"ml-6 mr-5":"-ml-2"),render:e=>(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex w-full ".concat(i.tq?"justify-between":""),children:[i.tq&&(0,l.jsx)("p",{className:"".concat(i.tq?"mt-1 mb-3":""),style:{fontSize:i.tq?"10px":null},children:m.salesAdminPage.jobContainer.cardList.status}),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-1",children:[(0,l.jsx)(F.Z,{status:e.internalStatus}),(0,l.jsx)(Y.zg,{reconciliation:(0,W.eR)(e),showShadow:!1})]})]}),i.tq&&(0,l.jsx)("hr",{})]})},{label:"",columnAlign:"w-1/6 mt-2 ml-4",itemAlign:"mt-2 w-full md:w-1/6 ".concat(et?"ml-2":i.tq?"ml-6 mr-5":"ml-6"),render:e=>(0,l.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,l.jsx)(O.Z,{className:"border border-primaryViolet text-primaryViolet bg-white hover:bg-primaryViolet hover:text-white rounded-lg px-4 py-2",variant:"outlined",size:i.tq?"sm":"md",onClick:()=>{ei(e)},children:m.salesAdminPage.bonusContainer.view}),e.externalReference&&(0,l.jsx)(O.Z,{className:"".concat("PAID"===e.internalStatus?"bg-green-600 hover:bg-green-700":"AVAILABLE"===e.internalStatus?"bg-blue-600 hover:bg-blue-700":"REQUESTED"===e.internalStatus||"IN_PROCESS"===e.internalStatus?"bg-yellow-600 hover:bg-yellow-700":"bg-gray-600 hover:bg-gray-700"," text-white rounded-lg px-3 py-2 flex items-center"),size:i.tq?"sm":"md",onClick:()=>{z(e),M(!0)},title:"View Commission Details",children:(0,l.jsx)(J.Z,{className:i.tq?"h-4 w-4":"h-5 w-5"})})]})}],el=(0,s.useCallback)(async()=>{let e=await (0,E.Ly)({status:p,startDate:b.startDate,endDate:b.endDate});if(200===e.status){var t;v((null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.data)||[])}},[p,b.startDate,b.endDate]);(0,s.useEffect)(()=>{el()},[el]),(0,s.useEffect)(()=>{let e=new Set(f.filter(e=>(0,W.qb)((0,W.eR)(e))).map(e=>e.id));w(t=>{let a=t.filter(t=>e.has(t));return a.length===t.length?t:a})},[f]),(0,s.useEffect)(()=>{"jobs"===h&&el()},[h,el]);let es=async()=>{let e=j.filter(e=>{let t=f.find(t=>
1t.id===e);return t&&(0,W.qb)((0,W.eR)(t))});if(e.length!==j.length){w(e),(0,$.WI)((0,X.Eo)(W.CT)),await el();return}if(0!==e.length)try{t(!0);let a=await (0,E.CR)(e);if((0,W.Y3)(a)){(0,$.WI)((0,X.Eo)(W.CT)),await el(),w([]),t(!1);return}if((null==a?void 0:a.status)!==200){t(!1);return}L(!0);let l=e.length;1===l?I("Success, you requested a payment for 1 job"):I("Success, you requested a payment for ".concat(l," jobs")),el(),w([]),t(!1),(0,ee.EM)("sales_payment_request_batch_created",{job_ids:e,job_count:e.length,user_id:null==x?void 0:x.id})}catch(e){t(!1),console.error(e)}},en=(0,s.useCallback)(async e=>{let a=f.find(t=>t.id===e);if(!a||!(0,W.qb)((0,W.eR)(a))){(0,$.WI)((0,X.Eo)(W.CT)),await el();return}t(!0),(0,ee.EM)("sales_payment_request_started",{job_id:e,user_id:null==x?void 0:x.id});let l=await (0,E.CR)([e]);if((0,W.Y3)(l)){(0,$.WI)((0,X.Eo)(W.CT)),await el(),S({}),t(!1);return}200===l.status&&(R(),L(!0),I("Success, you requested a payment for 1 job"),S({}),el()),t(!1)},[t,x,R,L,I,S,el,f]),er=()=>{L(!V)},eo=e=>{y(e),w([])},ei=async e=>{try{let[t,a]=await Promise.all([(0,E.iK)(e.id),(0,E.kZ)(e.id)]);(0,ee.EM)("sales_job_detail_viewed",{job_id:e.id,user_id:null==x?void 0:x.id}),D(a),T(t),c(!0),S(e)}catch(e){console.log(e)}};return(0,s.useEffect)(()=>{a((0,l.jsx)(G,{galleryOpen:d,job:N,jobDetail:C,comissions:A,closeDrawer:R,handleJobPaymentRequest:en}))},[N,C,d,A,R,en,a]),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"w-full mb-10",children:[(0,l.jsx)(q.Z,{dialogOpen:V,handleDialogOpen:er,status:"success",mainMessage:P,subMessage:"You will receive an email once the request is approved",buttons:[{text:"Go back to payments",action:er}]}),(0,l.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-end gap-2 w-full mt-2",children:[(0,l.jsx)("div",{className:"w-full sm:w-56",children:(0,l.jsxs)(r.Select,{size:"lg",className:"bg-white rounded-tl-lg",label:m.filters,value:p,onChange:e=>g(e),children:[(0,l.jsx)(r.Option,{value:"all",children:"All"}),(0,l.jsx)(r.Option,{value:"payment-not-requested",children:m.salesAdminPage.index.filterJobStatus.paymentNotRequested}),(0,l.jsx)(r.Option,{value:"payment-requested",children:m.salesAdminPage.index.filterJobStatus.paymentRequested}),(0,l.jsx)(r.Option,{value:"in-process",children:m.salesAdminPage.index.filterJobStatus.paymentInProcess}),(0,l.jsx)(r.Option,{value:"paid",children:m.salesAdminPage.index.filterJobStatus.paid})]})}),(0,l.jsx)(K.Z,{value:b,onChange:eo,label:"Hibe Approved Date",tooltipContent:"Filters Sales Jobs by parent Hibe Approved Date using UTC time, 00:00 - 23:59 UTC."})]}),(0,l.jsx)("div",{className:"w-full mt-4",children:(0,l.jsx)(Z.Z,{data:f,checkbox:!0,setSelectedIds:w,selectedIds:j,setDrawerOpen:c,setDrawerItem:S,renderCheckboxRule:e=>(0,W.qb)((0,W.eR)(e)),columns:ea})}),(0,l.jsx)(Q.Z,{jobs:f,selectedJobIds:j,setSelectedJobIds:w,handleRequestPaymentJobBatch:es})]}),(0,l.jsx)(B.Z,{open:_,onClose:()=>{M(!1),z(null)},externalReference:null==U?void 0:U.externalReference,userId:null==x?void 0:x.id,userName:null==x?void 0:x.name})]})},ea=()=>{let{selectedLang:e}
1=(0,n.E)(),[t,a]=(0,s.useState)({}),o=new Date,i=o.toLocaleString("en-US",{month:"long"}),c=o.getFullYear(),d="This Month (".concat(i," ").concat(c,")"),m=(0,s.useCallback)(async()=>{let e=await (0,E.Re)();e&&a(e)},[e]);return(0,s.useEffect)(()=>{m()},[m,e]),(0,l.jsx)("div",{children:(0,l.jsxs)("div",{className:"flex flex-wrap gap-3 p-0 pt-5",children:[(0,l.jsx)("div",{className:"w-full sm:w-[calc(50%-1rem)]",children:(0,l.jsx)(C,{title:d,data:null==t?void 0:t.month,period:"month"})}),(0,l.jsx)("div",{className:"w-full sm:w-[calc(50%-1rem)] ",children:(0,l.jsx)(C,{title:"This Year (".concat(c,")"),data:null==t?void 0:t.year,period:"year"})}),(0,l.jsxs)("div",{className:"flex justify-between w-6/12 text-black bg-white rounded-lg items-center shadow-sm px-10 py-4 mt-4",children:[(0,l.jsx)(r.Typography,{children:"Total to be paid on Override Payments:"}),(0,l.jsx)(r.Typography,{variant:"h5",className:"text-2xl",children:(0,u.formatCurrency)(0)})]})]})})},el=e=>{let{memberList:t,setSelectedMember:a}=e,{selectedLang:s}=(0,n.E)();return(0,l.jsx)("div",{className:"w-full mt-4",children:(0,l.jsx)(Z.Z,{checkbox:!1,data:t,columns:[{label:"Name",columnAlign:"w-1/5 flex items-center",itemAlign:"flex items-center w-full sm:w-1/5",render:e=>(0,l.jsx)("span",{className:"text-black text-bold cursor-pointer",onClick:()=>a(e),children:"".concat(e.firstName)})},{label:"Role",columnAlign:"w-1/5 text-center",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 text-center",render:e=>e.salesRole},{label:"Contract Amount",columnAlign:"w-1/5 text-right",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 text-right",render:e=>(0,u.formatCurrency)(e.contractAmount)},{label:"Commission Paid",columnAlign:"w-1/5 text-right",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 text-right",render:e=>(0,u.formatCurrency)(e.comissionPaid)},{label:"Commission To Be Paid",columnAlign:"w-1/5 text-right",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 text-right",render:e=>(0,u.formatCurrency)(e.comissionToBePaid)}]})})},es=[{label:"Team Overview",value:"overview"},{label:"Team Member",value:"member"}],en=e=>{let{setLoader:t,setSelectedMember:a,memberList:s,activeSubTab:r,handleActiveSubTab:o}=e,{selectedLang:i}=(0,n.E)();return(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)("div",{className:"w-2/6",children:es.map(e=>{let{label:t,value:a}=e;return(0,l.jsx)(O.Z,{onClick:()=>o(a),variant:"text",className:(r===a?"text-black-50 border-b-2 border-primaryViolet":"text-gray-500")+" rounded-none hover:bg-white focus:outline-none active:bg-white active:text-black-50 active:outline-none ",children:t},a)})}),(0,l.jsx)("div",{className:"flex-grow",children:"overview"===r?(0,l.jsx)(ea,{}):(0,l.jsx)(el,{setSelectedMember:a,memberList:s})})]})};var er=a(48740),eo=a(63750);let ei=e=>{let{setLoader:t}=e,{selectedLang:a}=(0,n.E)(),[o,i]=(0,s.useState)({}),c=new Date,d=c.toLocaleString("en-US",{month:"long"}),m=c.getFullYear(),x="This Month (".concat(d," ").concat(m,")"),h=(0,s.useCallback)(async()=>{t(!0);let e=await (0,E.Re)();e&&i(e),t(!1)},[a]);return(0,s.useEffect)(()=>{h()},[h,a]),(0,l.jsx)("div",{children:(0,l.jsxs)("div",{className:"flex flex-wrap gap-3 p-0 pt-5",children:[(0,l.jsx)("div",{className:"w-full sm:w-[calc(50%-1rem)]",children:(0,l.jsx)(C,{title:x,data:null==o?void 0:o.month,period:"month"})}),(0,l.jsx)("div",{className:"w-full sm:w-[calc(50%-1rem)] ",children:(0,l.jsx)(C,{title:"This Year (".concat(m,")"),data:null==o?void 0:o.year,period:"year"})}),(0,l.jsxs)("div",{className:"flex justify-between w-6/12 text-black bg-white rounded-lg items-center shadow-sm px-10 py-4 mt-4",children:[(0,l.jsx)(r.Typography,{children:"Total to be paid on Override Payments:"}),(0,l.jsx)(r.Typography,{variant:"h5",className:"text-2xl",children:(0,u.formatCurrency)(0)})]})]})})};var ec=a(19791);let ed=e=>{var t,a,n,o,i,c,d,m,x,h,p;let{job:g,openState:b,closeDrawer:y,handleJobPaymentRequest:f,handleJobApproval:v,handleManualJobApproval:j,isPaymentRequested:w,isMember:N,jobFilter:S="",handleReopenJob:C,variant:T="sales"}
1=e,[A,D]=(0,s.useState)(!1),[E,R]=(0,s.useState)(),[k,P]=(0,s.useState)(!1),[Z,F]=(0,s.useState)(""),[V,_]=(0,s.useState)(!1),[B,U]=(0,s.useState)("Are you sure you want to approve this payment?"),[z,J]=(0,s.useState)("alert"),Y=()=>{D(!1),R(0),F(""),_(!1),y()},W=()=>{let e=""===E||null==E||(null==E?void 0:E.trim())===""?null:Number(E);A?j(g.id,{manualAmount:e}):v(g.id),Y()},G=async()=>{C(g.id,{reason:Z}),H(),Y()},Q=()=>{_(!V),U("Are you sure you want to approve this payment?"),J("alert")},H=()=>{F(""),P(!k)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(q.Z,{dialogOpen:V,handleDialogOpen:Q,status:z,mainMessage:B,buttons:"alert"===z?[{text:"YES",action:W},{text:"NO",variant:"outlined",action:Q}]:[{text:"success"===z?"Go back to Jobs":"Close",action:Q}]}),(0,l.jsx)(q.Z,{dialogOpen:k,handleDialogOpen:H,showAlertIcon:!1,buttons:[{text:"Save",action:G}],children:(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)("div",{className:"text-black",children:"Reasons to be open:"}),(0,l.jsx)(r.Textarea,{rows:8,value:Z,onChange:e=>F(e.target.value),size:"lg",className:"bg-[eff2f5] text-xl"})]})}),(0,l.jsx)(r.Drawer,{placement:"right",open:b,className:"px-8 pt-9 mt-0",size:600,overlay:!0,style:{margin:0},children:(0,l.jsxs)("div",{className:"relative h-full",children:[(0,l.jsxs)("div",{className:"overflow-y-auto mb-6 flex flex-col justify-between gap-4",children:[(0,l.jsx)(I.fMW,{onClick:Y,strokeWidth:2,className:"h-5 w-5 cursor-pointer"}),(0,l.jsxs)("div",{className:"flex justify-between items-start",children:[(0,l.jsx)(r.Typography,{variant:"h4",color:"blue-gray",className:"mb-6",children:g.name}),w&&(0,l.jsx)(r.Chip,{size:"lg",variant:"ghost",color:"green",value:"Requested"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(r.Typography,{variant:"h5",color:"blue-gray",className:"mb-2",children:"Description"}),(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",children:null!==(a=g.description)&&void 0!==a?a:""})]}),(0,l.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-blue-50 rounded-lg mb-4",children:[(0,l.jsx)(M.Z,{style:{fontSize:"1.3rem",color:"#6b7280"}}),(0,l.jsxs)("div",{className:"flex flex-col",children:[(0,l.jsx)(r.Typography,{variant:"small",color:"gray",className:"font-medium",children:"Sales Person:"}),(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",className:"font-bold",children:null!==(n=null===(t=g.salesUser)||void 0===t?void 0:t.name)&&void 0!==n?n:"Not assigned"})]})]}),(0,l.jsxs)("div",{className:"space-y-6 mb-6",children:[(0,l.jsxs)("div",{className:"p-4 bg-gray-50 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-center mb-2",children:[(0,l.jsx)(ec.Z,{className:"mr-2",style:{fontSize:"1.3rem",color:"#6b7280"}}),(0,l.jsx)(r.Typography,{variant:"small",color:"gray",className:"font-medium",children:"Contract Amount:"})]}),(0,l.jsx)(r.Typography,{variant:"h5",color:"blue-gray",className:"font-bold",children:null!==(o=(0,u.formatCurrency)(g.contractAmount))&&void 0!==o?o:"$0"})]}),(0,l.jsxs)("div",{className:"p-4 bg-gray-50 rounded-lg",children:[(0,l.jsxs)("div",{className:"flex items-center mb-2",children:[(0,l.jsx)(ec.Z,{className:"mr-2",style:{fontSize:"1.3rem",color:"#6b7280"}}),(0,l.jsx)(r.Typography,{variant:"small",color:"gray",className:"font-medium",children:"Total Commission for the Job:"})]}),(0,l.jsx)(r.Typography,{variant:"h5",color:"blue-gray",className:"font-bold",children:null!==(i=(0,u.formatCurrency)(g.commission))&&void 0!==i?i:"$0"})]}),(0,l.jsx)("div",{className:"p-4 bg-blue-50 rounded-lg",children:(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)(r.Typography,{variant:"small",color:"gray",className:"font-medium",children:"Total paid to date:"}),(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",className:"font-bold",children:null!==(c=(0,u.formatCurrency)(g.totalPaid))&&void 0!==c?c:"$0"})]})})]}),"sales"===T?(0,l.jsxs)("div",{className:"flex justify-start space-x-3",children:[(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",className:"w-1/3",children:"Supplements:"}),(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",children:null!==(d=g.supplements)&&void 0!==d?d:"None"})]}):(0,l.jsxs)("div",{className:"flex justify-start space-x-3",children:[(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",className:"w-1/3",children:"Address:"}),(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",children:null!==(m=g.supplements)&&void 0!==m?m:"None"})]}),(0,l.jsxs)("div",{className:"flex justify-start space-x-3",children:[(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",className:"w-1/3",children:"Lead Type:"}),(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",children:null!==(h=null!==(x=g.leadSourceFixed)&&void 0!==x?x:g.leadType)&&void 0!==h?h:""})]}),(0,l.jsxs)("div",{className:"",children:[(0,l.jsx)(r.Typography,{variant:"h5",color:"blue-gray",className:"w-full",children:"Notes"}),(0,l.jsx)(r.Typography,{variant:"h6",color:"blue-gray",children:null!==(p=g.notes)&&void 0!==p?p:""})]})]}),(0,l.jsx)("div",{className:"absolute bottom-4 w-full flex items-center justify-between bg-white p-3",children:(0,l.jsxs)(s.Fragment,{children:["sales"===T&&!N&&(0,l.jsx)(O.Z,{size:"lg",className:"bg-primaryViolet",disabled:w,onClick:()=>{f(g.id)},children:"Request Payment"}),"admin"===T&&(0,l.jsx)(l.Fragment,{children:"payment-requested"===S?(0,l.jsx)(L,{manualAmountMode:A,manualAmount:E,setManualAmount:R,handleDialogOpen:Q,toggleManualAmountMode:D,openReopenDialog:P,job:g}):(0,l.jsx)("div",{className:"w-full flex justify-center text-lg items-center px-6 py-4 shadow-md rounded-md border-t border-slate-800",children:"No Actions"})}),"super-admin"===T&&(0,l.jsx)(l.Fragment,{children:"payment-requested"===S?(0,l.jsx)(L,{manualAmountMode:A,manualAmount:E,setManualAmount:R,handleDialogOpen:Q,toggleManualAmountMode:D,openReopenDialog:P,job:g}):(0,l.jsx)("div",{className:"w-full flex justify-center text-lg items-center px-6 py-4 shadow-md rounded-md border-t border-slate-800",children:"No Actions"})})]})})]})})]})},eu=e=>
1{let{setLoader:t,jobList:a,isRequested:r}=e,{selectedLang:i}=(0,n.E)(),{user:c}=(0,o.v9)(e=>e.auth),[d,m]=(0,s.useState)({}),[x,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)(!1),[b,y]=(0,s.useState)(null),f=()=>h(!1);return(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsx)("div",{className:"w-full mt-4",children:(0,l.jsx)(Z.Z,{data:a,checkbox:!1,columns:[{label:"Project Name",columnAlign:"w-1/5 flex items-center",itemAlign:"flex items-center w-full sm:w-1/5",render:e=>e.name},{label:"Date of Request",columnAlign:"w-1/5 text-right",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 text-right",render:e=>(0,u.formatDate)(e.paymentRequestDate,"Not requested")},{label:"Contract Amount",columnAlign:"w-1/5 text-right",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 text-right",render:e=>(0,u.formatCurrency)(e.contractAmount)},{label:"Total Paid To Company",columnAlign:"w-1/5 text-right",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 text-right",render:e=>(0,u.formatCurrency)(e.paymentsReceived)},{label:"",columnAlign:"w-1/5",itemAlign:"mt-2 w-full sm:w-1/5 sm:mt-0 text-right",render:e=>(0,l.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,l.jsx)(O.Z,{className:"bg-primaryViolet",onClick:()=>{h(!0),m(e)},children:"View"}),e.externalReference&&(0,l.jsx)(O.Z,{className:"".concat("PAID"===e.internalStatus?"bg-green-600 hover:bg-green-700":"AVAILABLE"===e.internalStatus?"bg-blue-600 hover:bg-blue-700":"REQUESTED"===e.internalStatus||"IN_PROCESS"===e.internalStatus?"bg-yellow-600 hover:bg-yellow-700":"bg-gray-600 hover:bg-gray-700"," text-white rounded-lg px-3 py-2 flex items-center"),onClick:()=>{y(e),g(!0)},title:"View Commission Details",children:(0,l.jsx)(J.Z,{className:"h-4 w-4"})})]})}]})}),(0,l.jsx)(ed,{job:d,openState:x,closeDrawer:f,isMember:!0,isPaymentRequested:r}),(0,l.jsx)(B.Z,{open:p,onClose:()=>{g(!1),y(null)},externalReference:null==b?void 0:b.externalReference,userId:null==c?void 0:c.id,userName:null==c?void 0:c.name})]})},em=e=>{let{selectedMember:t,setSelectedMember:a,setLoader:r,handleActiveTab:o,handleActiveSubTab:i}=e,{language:c}
1=(0,n.E)(),[d,u]=(0,s.useState)("overview"),[m,x]=(0,s.useState)([]),h=(0,s.useCallback)(async()=>{r(!0);let e=await (0,E.Zy)(t.id,{status:"request"===d?"payment-not-requested":"payment-requested"});if(200===e.status){var a;x((null==e?void 0:null===(a=e.data)||void 0===a?void 0:a.data)||[])}r(!1)},[d,t]);return(0,s.useEffect)(()=>{("request"===d||"requested"===d)&&t&&h()},[h,d,t]),(0,l.jsxs)("div",{className:"w-full",children:[(0,l.jsxs)("h1",{className:"text-2xl sm:text-3xl font-medium text-black mt-10 mb-1 flex gap-4 cursor-pointer",onClick:()=>{a(),o("team"),i("member")},children:[(0,l.jsx)(eo.And,{})," ",t.firstName]}),(0,l.jsx)("div",{className:"w-2/6 mt-8",children:[{label:"Overview",value:"overview"},{label:"To Request",value:"request"},{label:"Already Requested",value:"requested"}].map(e=>{let{label:t,value:a}=e;return(0,l.jsx)(O.Z,{onClick:()=>u(a),variant:"text",className:(d===a?"text-black-50 border-b-2 border-blue-500":"text-gray-500")+" rounded-none hover:bg-white focus:outline-none active:bg-white active:text-black-50 active:outline-none ",children:t},a)})}),(0,l.jsx)("div",{className:"flex-grow",children:(()=>{switch(d){case"overview":return(0,l.jsx)(ei,{setLoader:r,handleActiveSubTab:!0});case"request":return(0,l.jsx)(eu,{jobList:m});default:return(0,l.jsx)(eu,{jobList:m,isRequested:!0})}})()})]})};var ex=a(49116),eh=a(4254),ep=a(68080);let eg=e=>{let{setBonusDrawerContent:t,setOpenBonusDrawer:a}=e,{language:o}=(0,n.E)(),{activeSalesTab:c}
1=(0,s.useContext)(k.f),[m,x]=(0,s.useState)("not-paid"),[h,p]=(0,s.useState)(""),[g,b]=(0,s.useState)({startDate:null,endDate:null}),[y,f]=(0,s.useState)([]),[v,j]=(0,s.useState)(0),[w,N]=(0,s.useState)(0),[S,C]=(0,s.useState)([]),[T,A]=(0,s.useState)({}),D=e=>{p(e)},E=e=>{a(e)},P=(0,s.useCallback)(async()=>{let e=await (0,R.jg)({status:m,search:h,startDate:g.startDate,endDate:g.endDate});(null==e?void 0:e.data)&&f(e.data)},[m,h,g.startDate,g.endDate]),q=(0,s.useCallback)(async()=>{let e=await (0,R.f_)({startDate:g.startDate,endDate:g.endDate,bonusFilter:m});(null==e?void 0:e.data)&&j(e.data.totalToBePaid)},[m,g.startDate,g.endDate]),I=async e=>{try{let t=await (0,R.FC)(e.id),a=t.reduce((e,t)=>e+Number(t.contractAmount),0);N(a),C(t),A(e),E(!0)}catch(e){console.log(e)}};(0,s.useEffect)(()=>{P(),q()},[P,q]),(0,s.useEffect)(()=>{"bonuses"===c&&(P(),q())},[c,P,q]),(0,s.useEffect)(()=>{t((0,l.jsx)(ex.Z,{closeDrawer:()=>E(!1),totalBonusThisMonth:v,setOpen:E,variant:"sales",totalContractAmount:w,bonus:T,jobsForBonus:S}))},[T,v,w,S]);let O=o.salesAdminPage.bonusContainer;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-10 items-baseline",children:(0,l.jsxs)("div",{className:"flex flex-col justify-between ".concat(i.tq?"w-screen":"w-full"," text-black bg-white rounded-lg items-center shadow-sm px-10 py-4 sm:mt-4"),children:[(0,l.jsx)(r.Typography,{className:"text-xs sm:text-lg ",children:"Total bonuses:"}),(0,l.jsx)(r.Typography,{variant:"h5",className:"text-md sm:text-2xl text-primaryViolet",children:(0,u.formatCurrency)(v)})]})}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between w-full mt-4",children:[(0,l.jsx)("div",{className:"".concat(i.tq?"w-full":"w-full lg:w-72"),children:(0,l.jsx)(r.Input,{className:"rounded-lg bg-white",onChange:e=>D(e.target.value),label:O.search,icon:(0,l.jsx)(d.RB5,{})})}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-end",children:[(0,l.jsx)("div",{className:"w-full sm:w-56",children:(0,l.jsxs)(ep.Ph,{value:m,onValueChange:x,children:[(0,l.jsx)(ep.i4,{className:"bg-white",children:(0,l.jsx)(ep.ki,{placeholder:o.filters})}),(0,l.jsxs)(ep.Bw,{children:[(0,l.jsx)(ep.Ql,{value:"paid",children:o.salesAdminPage.index.filterBonusStatus.paid}),(0,l.jsx)(ep.Ql,{value:"not-paid",children:o.salesAdminPage.index.filterBonusStatus.notPaid})]})]})}),(0,l.jsx)(K.Z,{className:"w-full sm:w-56",value:g,onChange:b,label:"Bonus date",tooltipContent:"Filters Bonuses by bonus date using UTC time, 00:00 - 23:59 UTC."})]})]}),(0,l.jsx)("div",{className:"w-full mt-4",children:(0,l.jsx)(Z.Z,{data:y,checkbox:!1,columns:[{label:"Amount",columnAlign:"w-2/5",itemAlign:"mt-2 sm:mt-0 w-full sm:w-2/5 sm:pr-4",render:e=>(0,l.jsx)(eh.Z,{bonus:e,isMobile:i.tq,showShadow:!1})},{label:O.date,columnAlign:"w-1/5",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5",render:e=>(0,u.formatDate)(e.date,"N/A")},{label:O.status,columnAlign:"w-1/5",itemAlign:"mt-2 sm:mt-0 w-full sm:w-1/5 t",render:e=>e.status},{label:"",columnAlign:"w-1/5",itemAlign:"mt-2 w-full sm:w-1/5 sm:mt-0 text-right",render:e=>(0,l.jsx)(r.Button,{className:"bg-primaryViolet rounded-full",onClick:()=>{I(e)},children:O.view})}]})})]})};var eb=a(34572);let ey=()=>{let{user:e}=(0,o.v9)(e=>e.auth),{isAuthenticated:t,language:a}=(0,n.E)(),{activeSalesTab:d,setActiveSalesTab:m}
1=(0,s.useContext)(k.f),[x,h]=(0,s.useState)(!1),[p,g]=(0,s.useState)(),[b,y]=(0,s.useState)(["overview","jobs","bonuses"]),[f,v]=(0,s.useState)("overview"),[j,w]=(0,s.useState)("overview"),[N,S]=(0,s.useState)(null),[C,T]=(0,s.useState)(!1),[A,D]=(0,s.useState)(!1),[R,q]=(0,s.useState)([]);(0,s.useEffect)(()=>{t()},[]),(0,s.useEffect)(()=>{(0,E.ox)().then(e=>{if(200===e.status){var t,a;(null==e?void 0:null===(t=e.data)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.length)>0&&y(["overview","jobs","bonuses","team"]),q(e.data.data)}})},[]);let Z=e=>{m(e)};return(0,l.jsxs)("div",{children:[(0,l.jsxs)("main",{className:"mx-4 mb-20 sm:mx-10 flex flex-col items-center space-y-3",children:[x&&(0,l.jsx)(er.Z,{}),p?(0,l.jsx)("div",{className:"w-3/4 mx-auto",children:(0,l.jsx)(em,{selectedMember:p,setSelectedMember:g,setLoader:h,handleActiveTab:v,handleActiveSubTab:w})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"".concat(i.tq?"w-full":"w-3/4"," mx-auto"),children:[(0,l.jsx)("h1",{className:"text-2xl sm:text-3xl font-medium text-black mt-10 mb-1 ",children:a.dashboard}),(0,l.jsxs)(r.Typography,{className:"text-textGray",children:[" ",a.hi+" "+(null==e?void 0:e.name)+", "+a.dashMessage]})]}),(0,l.jsx)("div",{className:"".concat(i.tq?"w-full":"w-3/4"," mx-auto"),children:(0,l.jsxs)(r.Tabs,{value:d,className:"flex flex-col ",children:[(0,l.jsx)(r.TabsHeader,{className:"flex md:justify-between justify-start items-start w-full bg-transparent p-0 ",children:(0,l.jsx)("div",{className:"flex space-x-2 md:space-x-0 bg-[#d1d8e0] rounded-xl p-1.5",children:b.map((e,t)=>{var s,n;return(0,l.jsx)(r.Tab,{value:e,className:"w-full md:w-fit z-0 py-2 px-4 md:px-10 rounded-xl capitalize active:bg-primaryViolet",onClick:()=>Z(e),children:null===(s=a.salesPage)||void 0===s?void 0:null===(n=s.index)||void 0===n?void 0:n.tabs[e]},t)})})}),(0,l.jsx)("div",{className:"flex-grow",children:(0,l.jsxs)(r.TabsBody,{children:[(0,l.jsx)(r.TabPanel,{value:"overview",className:"flex flex-wrap gap-3 p-0 pt-5 ",children:(0,l.jsx)(P,{setLoader:h})},"overview"),(0,l.jsx)(r.TabPanel,{value:"jobs",className:"flex flex-wrap gap-3 p-0 pt-5",children:(0,l.jsx)(et,{openJobDrawer:C,setLoader:h,setJobDrawerContent:S,setOpenJobDrawer:T,closeJobDrawer:A})},"jobs"),(0,l.jsx)(r.TabPanel,{value:"bonuses",className:"flex flex-wrap gap-3 p-0 pt-5",children:(0,l.jsx)(eg,{setBonusDrawerContent:S,setOpenBonusDrawer:T})},"bonuses"),(0,l.jsx)(r.TabPanel,{value:"team",className:"flex flex-wrap gap-3 p-0 pt-5",children:(0,l.jsx)(en,{setLoader:h,setSelectedMember:g,memberList:R,activeSubTab:j,handleActiveSubTab:w})},"team")]})})]})})]}),(null==e?void 0:e.jobLastUpdateDate)&&(0,l.jsx)("div",{className:"w-3/4 text-right mr-12",children:(0,l.jsxs)(r.Typography,{className:"pr-12 text-textGray",children:[a.lastUpdated,":"," ",(0,u.formatDate)(null==e?void 0:e.jobLastUpdateDate,a.none)]})})]}),"jobs"===d&&(0,l.jsx)(eb.Z,{}),(0,l.jsx)(c.Z,{openState:C,closeDrawer:A,children:N})]})};var ef=ey},6206:function(e,t,a){"use strict";a.d(t,{$U:function(){return c},CV:function(){return p},Cq:function(){return b},EB:function(){return g},Hl:function(){return T},I:function(){return D},J2:function(){return N},Kq:function(){return y},N_:function(){return f},QD:function(){return j},RN:function(){return u},Zi:function(){return h},cb:function(){return E},dj:function(){return A},fh:function(){return d},kY:function(){return m},ly:function(){return w},oN:function(){return C},oP:function(){return x},s6:function(){return k},st:function(){return o},uB:function(){return S},yl:function(){return R},z9:function(){return v}});var l=a(56674),s=a(63763),n=a(14204);let r=(n.T||"").replace("/v1","/v2"),o="REVIEW_REQUIRED",i=(e,t,a)=>{t&&a&&(e.startDate=t,e.endDate=a)},c=async e=>{let{limit:t=100,page:a=0,search:l="",userIds:n=null,userStatus:r="all",status:o="ALL",reconciliationStatus:c=null,crmFlagged:d=!1,crmFlagRuleId:u,startDate:m=null,endDate:x=null}=e;try{let e={limit:t,page:a};d&&(e.crmFlagged="true"),u&&(e.crmFlagRuleId=u),l&&(e.search=l),n&&(e.userIds=n),"all"!==r&&(e.userStatus=r),"ALL"!==o&&(e.status=o),c&&(e.reconciliationStatus=c),i(e,m,x);let h=await s.Z.get("/job/parent",{params:e});return h}catch(e){throw console.error("Error fetching parent jobs:",e),e}},d=async e=>{try{let t=await s.Z.get("/job/parent/".concat(e));return t.data}catch(e){throw e}},u=async e=>{try{var t,a;let l={};(null==e?void 0:e.crmFlagged)&&(l.crmFlagged="true"),(null==e?void 0:e.crmFlagRuleId)&&(l.crmFlagRuleId=e.crmFlagRuleId),(null==e?void 0:e.jobIds)&&e.jobIds.length>0&&(l.jobIds=e.jobIds.join(",")),(null==e?void 0:e.search)&&(l.search=e.search),(null==e?void 0:e.status)&&"ALL"!==e.status&&""!==e.status&&(l.status=e.status),(null==e?void 0:e.userStatus)&&"all"!==e.userStatus&&(l.userStatus=e.userStatus),(null==e?void 0:e.userIds)&&e.userIds.length>0&&(l.userIds=e.userIds.join(",")),(null==e?void 0:e.limit)&&(l.limit=e.limit),(null==e?void 0:e.page)!==void 0&&(l.page=e.page),(null==e?void 0:e.reconciliationStatus)&&(l.reconciliationStatus=e.reconciliationStatus),i(l,null==e?void 0:e.startDate,null==e?void 0:e.endDate);let n=await s.Z.get((null==e?void 0:e.crmFlagged)||(null==e?void 0:e.crmFlagRuleId)?"/job/parent/crm-flags/csv"
1:"/job/csv",{params:l,responseType:"blob"}),r=(null==e?void 0:e.reconciliationStatus)?"review-required-jobs-".concat(new Date().toISOString().split("T")[0],".csv"):"jobs-export-".concat(new Date().toISOString().split("T")[0],".csv"),o=n.headers["content-disposition"],c=null===(t=null==o?void 0:o.match(/filename\*=UTF-8''([^;]+)/i))||void 0===t?void 0:t[1],d=null===(a=null==o?void 0:o.match(/filename\s*=\s*"?([^";]+)"?/i))||void 0===a?void 0:a[1],u=c?decodeURIComponent(c):d||r,m=window.URL.createObjectURL(new Blob([n.data],{type:"text/csv"})),x=document.createElement("a");return x.href=m,x.setAttribute("download",u),document.body.appendChild(x),x.click(),document.body.removeChild(x),window.URL.revokeObjectURL(m),n}catch(e){throw console.error("Error exporting jobs:",e),e}},m=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{var a,l,n,r;let o={expectedAmount:t.expectedAmount,manualAmount:null!==(a=t.manualAmount)&&void 0!==a?a:null,manualApprovalReason:null!==(l=t.manualApprovalReason)&&void 0!==l?l:null,acceptOverpayment:null!==(n=t.acceptOverpayment)&&void 0!==n&&n,overpaymentApprovalReason:null!==(r=t.overpaymentApprovalReason)&&void 0!==r?r:null},i=await s.Z.post("payment-request/sales/approve/".concat(e),o);return i.data}catch(e){throw console.error("Error approving payment request:",e),e}},x=async(e,t)=>{let a=await s.Z.post("/job/commission/".concat(e,"/reconciliation/approvals"),t);return a.data},h=async(e,t,a)=>{let l=await s.Z.post("/job/commission/".concat(e,"/reconciliation/approvals/").concat(t,"/revoke"),{reason:a});return l.data},p=async(e,t)=>{try{let a=await s.Z.post("payment-request/sales/manual-override/".concat(e),t);return a.data}catch(e){throw console.error("Error performing manual override:",e),e}},g=async e=>{try{let t=await s.Z.post("payment-request/sales/reject/".concat(e));return t.data}catch(e){throw console.error("Error rejecting payment request:",e),e}},b=async(e,t)=>{try{let a=await s.Z.post("job/re-open/".concat(e),{reason:t});return a.data}catch(e){throw console.error("Error reopening payment request:",e),e}},y=(e,t,a)=>(0,l.YE)(e,"REQUEST_ONLY",t,a),f=(e,t,a)=>(0,l.YE)(e,"REQUEST_AND_APPROVE",t,a),v=async e=>{try{let t=await s.Z.post("payment-request/sales/reject",{jobIds:e});return t.data}catch(e){throw console.error("Error rejecting payment batch (sales admin):",e),e}},j=async function(){let{userIds:e=null,status:t=null,search:a=null,userStatus:l=null,page:n=0,limit:r=1,startDate:o=null,endDate:c=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let d={page:n,limit:r};null!==e&&(d.userIds=e),null!==t&&(d.status=t),null!==a&&(d.search=a),null!==l&&(d.userStatus=l),i(d,o,c);let u=await s.Z.get("sales/summary",{params:d});return u.data}catch(e){throw console.error("Error fetching total to be paid:",e),e}},w=async(e,t,a)=>{try{let l=await s.Z.post("job/".concat(e,"/role"),{userId:t,salesRoleId:a});return l.data}catch(e){throw console.error("Error assigning user to role:",e),e}},N=async(e,t)=>{try{let a=await s.Z.delete("job/".concat(e,"/role/").concat(t));return a.data}catch(e){throw console.error("Error unassigning user from role:",e),e}},S=async e=>{let{jobId:t,assignmentId:a,userId:l,reason:n,idempotencyKey:r}=e,o=await s.Z.post("job/".concat(t,"/role/").concat(a,"/replace"),{userId:l,reason:n,idempotencyKey:r});return o.data},C=async e=>{try{let t=await s.Z.post("/job/check",{code:e});return t.data}catch(e){var t;throw(null==e?void 0:null===(t=e.response)||void 0===t?void 0:t.status)!==404&&console.error("Error checking job:",e),e}},T=async()=>{try{let e=await s.Z.get("/job/sync-metrics");return e.data}catch(e){throw console.error("Error fetching sync metrics:",e),e}},A=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var t,a;let l={page:null!==(t=e.page)&&void 0!==t?t:1,limit:null!==(a=e.limit)&&void 0!==a?a:50};e.status&&(l.status=e.status),e.poNumber&&(l.poNumber=e.poNumber);let n=await s.Z.get("/job/sync-status",{params:l});return n.data}catch(e){throw console.error("Error fetching sync status jobs:",e),e}},D=async(e,t)=>{try{let a=await s.Z.get("/job/receipt/".concat(e,"/").concat(t));return a.data}catch(e){var a;if((null===(a=e.response)||void 0===a?void 0:a.status)===403)throw Error("You do not have permission to view this receipt");throw console.error("Error fetching commission receipt:",e),e}},E=async()=>{try{let e=await s.Z.get("/job/exceptions",{baseURL:r});return e.data}catch(e){throw console.error("Error fetching job exceptions:",e),e}},R=async e=>{try{let t=await s.Z.post("/job/exceptions",{poNumber:e},{baseURL:r});return t.data}catch(e){throw console.error("Error adding job exception:",e),e}},k=async e=>{try{let t=await s.Z.delete("/job/exceptions/".concat(e),{baseURL:r});return t.data}catch(e){throw console.error("Error removing job exception:",e),e}}},56674:function(e,t,a){"use strict";a.d(t,{Y9:function(){return r},YE:function(){return n},iK:function(){return s}});var l=a(63763);async function s(e){let t=[];for(let a=0;a<e.items.length;a+=100){let{data:s}=await l.Z.post("/payment-request/sales/actions",{...e,items:e.items.slice(a,a+100)});t.push(...s.results)}return{results:t}}async function n(e,t,a,l){let n=await s({requestId:a,action:t,items:[{commissionId:e,paymentRequestId:null,expectedAmount:l}]}),r=n.results[0];if(!r)throw Error("The payment action did not return a result. Refresh the job.");if(!r.success)throw Error(r.message);return r}async function r(e,t){let{data:a}=await l.Z.patch("/payment-request/sales/pending-override/".concat(e),t);return a}},80926:function(e,t,a){"use strict";a.d(t,{CR:function(){return i},Ly:function(){return r},Re:function(){return n},Zy:function(){return d},bg:function(){return u},iK:function(){return m},kZ:function(){return x},ox:function(){return c},w8:function(){return o}}),a(74478);var l=a(63763);a(93162),a(44099);let s=(e,t,a)=>
1{t&&a&&(e.startDate=t,e.endDate=a)},n=async function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;try{let s={startDate:e,endDate:t};e||t||(delete s.startDate,delete s.endDate),a&&(s.year=a);let n=await l.Z.get("job/summary",{params:s});return n.data}catch(e){console.log(e)}},r=async function(){let{limit:e=100,status:t="payment-not-requested",page:a=0,search:n="",userIds:r=null,userStatus:o="all",startDate:i=null,endDate:c=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let d={limit:e,page:a,status:t,search:n,userIds:r,userStatus:o};""==t&&delete d.status,r&&""!==r||delete d.userIds,s(d,i,c);let u=await l.Z.get("job",{params:d});return u}catch(e){return e}},o=async function(){let{search:e=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let t={search:e};""==e&&delete t.search;let a=await l.Z.get("job/simplified",{params:t});return a}catch(e){return e}},i=async e=>{try{let t=await l.Z.post("payment-request/sales",{jobIds:e});return t}catch(e){return e}},c=async function(){let{limit:e=1e3,status:t="",page:a=0,search:s=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let n={limit:e,page:a,status:t,search:s};""==t&&delete n.status;let r=await l.Z.get("sales/team/member",{params:n});return r}catch(e){return e}},d=async function(e){let{limit:t=1e3,status:a="payment-not-requested",page:s=0,search:n=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let r={limit:t,page:s,status:a,search:n};""==a&&delete r.status;let o=await l.Z.get("sales/team/member/job/".concat(e),{params:r});return o}catch(e){return e}},u=async e=>{try{let t=await l.Z.put("user/configuration",{autoRequestPayment:e});return t}catch(e){return e}},m=async e=>{try{let t=await l.Z.get("job/detail/".concat(e));return t.data.job}catch(e){return e}},x=async e=>{var t;let a=await l.Z.get("payment-request/sales/job/".concat(e));return{paymentRequests:a.data.paymentRequests,commissionSummary:null!==(t=a.data.commissionSummary)&&void 0!==t?t:null}}}},function(e){e.O(0,[6556,4617,2013,4938,5826,7363,8922,4003,4908,9246,3429,8122,8804,4406,5686,9774,2888,179],function(){return e(e.s=41850)}),_N_E=e.O()}]);
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.