1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=(new e.Error).stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="ed5d2a97-f4cc-4bf8-969b-2dc7156f3629",e._sentryDebugIdIdentifier="sentry-dbid-ed5d2a97-f4cc-4bf8-969b-2dc7156f3629")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2319],{62319:function(e,a,t){t.d(a,{Z:function(){return k}});var s=t(85893),r=t(67294),l=t(43484),i=t(73213),n=t(78888),d=t(12587),c=t(68080),o=t(13025),m=t(87764),u=t(88767),f=t(63763);let x="/invoice-verification/returns",h=async e=>{try{let a=await f.Z.get(x,{params:e});return a.data}catch(e){throw console.error("Error fetching return flags:",e),e}},p=async e=>{try{let a={export:"csv"};(null==e?void 0:e.search)&&(a.search=e.search),(null==e?void 0:e.flagType)&&(a.flagType=e.flagType);let t=await f.Z.get(x,{params:a,responseType:"blob"}),s=t.headers["content-disposition"],r="job-nimbus-returns.csv";if(s){let e=s.match(/filename="(.+)"/);e&&e.length>1&&(r=e[1])}let l=new Blob([t.data],{type:"text/csv"}),i=window.URL.createObjectURL(l),n=document.createElement("a");n.href=i,n.download=r,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(i)}catch(e){throw console.error("Error exporting returns CSV:",e),e}},y=[{value:"all",label:"All returns"},{value:"missing_credit_memo",label:"Missing Credit Memo"},{value:"quantity_mismatch",label:"Mismatch"},{value:"ok",label:"Matched"}];var g=function(){var e,a,t,s;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{page:l=0,limit:i=25,search:n,flagType:d}=r,c=(0,u.useQuery)({queryKey:["returns",l,i,n,d],queryFn:()=>h({page:l,limit:i,search:n||void 0,flagType:d&&"all"!==d?d:void 0}),keepPreviousData:!0,refetchOnWindowFocus:!1}),o=null!==(t=null===(e=c.data)||void 0===e?void 0:e.total)&&void 0!==t?t:0;return{returns:null!==(s=null===(a=c.data)||void 0===a?void 0:a.data)&&void 0!==s?s:[],isReturnsLoading:c.isLoading,isReturnsFetching:c.isFetching,refetchReturns:c.refetch,paginationData:{total:o,page:l,limit:i,totalPages:Math.max(1,Math.ceil(o/i))}}},b=t(74478),v=t(44099);let j={missing_credit_memo:{label:"Missing Credit Memo",variant:"destructive"},quantity_mismatch:{label:"Mismatch",variant:"secondary"},ok:{label:"Matched",variant:"default"}},w=e=>{let{initialSearch:a=""}=e,[t,n]=(0,r.useState)(0),[d,u]=(0,r.useState)(a),[f,x]=(0,r.useState)(a),[h,j]=(0,r.useState)("all"),[w,k]=(0,r.useState)(!1);(0,r.useEffect)(()=>{n(0),u(a),x(a)},[a]);let{returns:C,isReturnsLoading:_,isReturnsFetching:R,paginationData:M}=g({page:t,limit:25,search:f,flagType:h}),S=()=>{n(0),x(d.trim())},Z=async()=>{k(!0);try{await p({search:f||void 0,flagType:"all"!==h?h:void 0}),(0,b.WI)((0,v.XA)("The CSV download will start shortly."))}catch(e){(0,b.WI)((0,v.Eo)("Could not export the CSV. Please try again."))}finally{k(!1)}},z=M.totalPages;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold",children:"Returns & Credit Memos"}),(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Returns reported in Job Nimbus vs. supplier credit memos."})]}),(0,s.jsxs)(l.z,{variant:"outline",onClick:Z,disabled:w,title:"Download CSV",children:[(0,s.jsx)(o.Z,{className:"h-4 w-4 mr-2 ".concat(w?"animate-spin":"")}),"Export CSV"]})]}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 mb-4",children:[(0,s.jsxs)("div",{className:"flex-1 flex gap-2",children:[(0,s.jsx)(i.I,{placeholder:"Search by job, PO or credit memo #",value:d,onChange:e=>u(e.target.value),onKeyDown:e=>"Enter"===e.key&&S()}),(0,s.jsx)(l.z,{variant:"outline",size:"icon",onClick:S,children:(0,s.jsx)(m.Z,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{className:"w-full sm:w-56",children:(0,s.jsxs)(c.Ph,{value:h,onValueChange:e=>{n(0),j(e)},children:[(0,s.jsx)(c.i4,{className:"bg-white",children:(0,s.jsx)(c.ki,{placeholder:"Status"})}),(0,s.jsx)(c.Bw,{children:y.map(e=>(0,s.jsx)(c.Ql,{value:e.value,children:e.label},e.value))})]})})]}),_?(0,s.jsx)("p",{className:"text-gray-500 py-10 text-center",children:"Loading returnsâ¦"}):0===C.length?(0,s.jsx)("p",{className:"text-gray-500 py-10 text-center",children:"No returns found for this filter."}):(0,s.jsx)("div",{className:"flex flex-col gap-3",children:C.map(e=>(0,s.jsx)(N,{item:e},e.id))}),(0,s.jsxs)("div",{className:"flex items-center justify-between mt-6",children:[(0,s.jsxs)("span",{className:"text-sm text-gray-500",children:[M.total," returns",R?" \xb7 updatingâ¦":""]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.z,{variant:"outline",size:"sm",disabled:t<=0,onClick:()=>n(e=>Math.max(0,e-1)),children:"Previous"}),(0,s.jsxs)("span",{className:"text-sm self-center",children:[t+1," / ",z]}
1),(0,s.jsx)(l.z,{variant:"outline",size:"sm",disabled:t+1>=z,onClick:()=>n(e=>e+1),children:"Next"})]})]})]})},N=e=>{var a,t;let{item:r}=e,l=j[r.flagType],i=null!==(t=null===(a=r.comparison)||void 0===a?void 0:a.mismatches)&&void 0!==t?t:[];return(0,s.jsx)(d.Zb,{className:"p-4",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)("span",{className:"font-semibold",children:r.jobNimbusJobNumber||r.poNumber||"â"}),(0,s.jsx)(n.C,{variant:l.variant,children:l.label}),r.creditMemoInvoiceNumber&&(0,s.jsxs)("span",{className:"text-xs text-gray-500",children:["CM #",r.creditMemoInvoiceNumber]})]}),r.details&&(0,s.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:r.details}),i.length>0&&(0,s.jsx)("ul",{className:"text-xs text-gray-500 mt-1 list-disc list-inside",children:i.slice(0,5).map((e,a)=>(0,s.jsx)("li",{children:e},a))})]}),(0,s.jsx)("div",{className:"text-right shrink-0",children:r.returnDate&&(0,s.jsx)("span",{className:"text-xs text-gray-400",children:new Date(r.returnDate).toLocaleDateString()})})]})})};var k=w},68080:function(e,a,t){t.d(a,{Bw:function(){return h},Ph:function(){return o},Ql:function(){return y},i4:function(){return u},ki:function(){return m}});var s=t(85893),r=t(67294),l=t(8971),i=t(84979),n=t(13742),d=t(20822),c=t(63938);let o=d.fC;d.ZA;let m=d.B4,u=r.forwardRef((e,a)=>{let{className:t,children:r,...i}=e;return(0,s.jsxs)(d.xz,{ref:a,className:(0,c.cn)("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-border bg-transparent px-3 py-2 text-sm font-normal ring-offset-white placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-primaryViolet/60 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-700 dark:bg-gray-900/80 dark:ring-offset-gray-800 dark:placeholder:text-gray-400 dark:focus:ring-emerald-500 [&>span]:line-clamp-1",t),...i,children:[r,(0,s.jsx)(d.JO,{asChild:!0,children:(0,s.jsx)(l.Z,{className:"h-4 w-4"})})]})});u.displayName=d.xz.displayName;let f=r.forwardRef((e,a)=>{let{className:t,...r}=e;return(0,s.jsx)(d.u_,{ref:a,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",t),...r,children:(0,s.jsx)(i.Z,{})})});f.displayName=d.u_.displayName;let x=r.forwardRef((e,a)=>{let{className:t,...r}=e;return(0,s.jsx)(d.$G,{ref:a,className:(0,c.cn)("flex cursor-default items-center justify-center py-1",t),...r,children:(0,s.jsx)(l.Z,{})})});x.displayName=d.$G.displayName;let h=r.forwardRef((e,a)=>{let{className:t,children:r,position:l="popper",...i}=e;return(0,s.jsx)(d.h_,{children:(0,s.jsxs)(d.VY,{ref:a,className:(0,c.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border border-gray-200 bg-white p-0 text-gray-950 shadow-md 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 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-50","popper"===l&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:l,...i,children:[(0,s.jsx)(f,{}),(0,s.jsx)(d.l_,{className:(0,c.cn)("p-1.5","popper"===l&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),(0,s.jsx)(x,{})]})})});h.displayName=d.VY.displayName;let p=r.forwardRef((e,a)=>{let{className:t,...r}=e;return(0,s.jsx)(d.__,{ref:a,className:(0,c.cn)("px-2 py-1.5 text-sm font-semibold",t),...r})});p.displayName=d.__.displayName;let y=r.forwardRef((e,a)=>{let{className:t,children:r,...l}=e;return(0,s.jsxs)(d.ck,{ref:a,className:(0,c.cn)("relative flex w-full cursor-pointer select-none items-center rounded-md py-1.5 pl-2 pr-8 text-sm outline-none hover:bg-gray-100 focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:dark:bg-gray-800 dark:focus:bg-gray-800 dark:focus:text-gray-50",t),...l,children:[(0,s.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(d.wU,{children:(0,s.jsx)(n.Z,{className:"h-4 w-4"})})}),(0,s.jsx)(d.eT,{children:r})]})});y.displayName=d.ck.displayName;let g=r.forwardRef((e,a)=>{let{className:t,...r}=e;
1return(0,s.jsx)(d.Z0,{ref:a,className:(0,c.cn)("-mx-1 my-1 h-px bg-gray-100 dark:bg-gray-800",t),...r})});g.displayName=d.Z0.displayName}}]);
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.