PageSourceSearch

https://contently.com/tev2/static/js/211.2bff5ef8.chunk.js

js contently.com collected 2026-09-24 08:32:03 UTC 29,761 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkplatform_web=self.webpackChunkplatform_web||[]).push([[211],{94450:function(n,e,t){t.d(e,{cX:function(){return h}});var r,i,o=t(30168),c=t(37762),a=t(93433),d=t(29439),s=t(50390),l=t(96692),u=t(35640),x=t(65700),p=t(97356),f=(t(62559),["MMM d, yyyy 'at' h:mmaaa","yyyy-MM-dd HH:mm:ss","MM/dd/yyyy","yyyy-MM-dd","MMM d, yyyy"]);function h(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{key:"",direction:null},t=(0,s.useState)(e),r=(0,d.Z)(t,2),i=r[0],o=r[1],c=(0,s.useMemo)((function(){return i.key&&i.direction?(0,a.Z)(n).sort((function(n,e){var t=v(n,i.key),r=v(e,i.key);if(null==t&&null==r)return 0;if(null==t)return"asc"===i.direction?-1:1;if(null==r)return"asc"===i.direction?1:-1;if("number"===typeof t&&"number"===typeof r)return"asc"===i.direction?t-r:r-t;if("string"===typeof t&&"string"===typeof r){var o=/^-?\d+(\.\d+)?$/;if(o.test(t.trim())&&o.test(r.trim())){var c=parseFloat(t),a=parseFloat(r);return"asc"===i.direction?c-a:a-c}}if(t instanceof Date&&r instanceof Date)return"asc"===i.direction?t.getTime()-r.getTime():r.getTime()-t.getTime();var d=b(t),s=b(r);if(d&&s)return"asc"===i.direction?d.getTime()-s.getTime():s.getTime()-d.getTime();var l=String(t).toLowerCase(),u=String(r).toLowerCase();return l<u?"asc"===i.direction?-1:1:l>u?"asc"===i.direction?1:-1:0})):n}),[n,i]),l=(0,s.useCallback)((function(n){o((function(e){if(e.key===n){if("asc"===e.direction)return{key:n,direction:"desc"};if("desc"===e.direction)return{key:"",direction:null}}return{key:n,direction:"asc"}}))}),[]),u=(0,s.useCallback)((function(n){return i.key===n?i.direction:null}),[i]);return{sortedData:c,sortConfig:i,requestSort:l,getSortDirection:u}}function v(n,e){return e.split(".").reduce((function(n,e){return null===n||void 0===n?void 0:n[e]}),n)}function b(n){if("string"!==typeof n||!n.trim())return null;var e=(0,u.D)(n);if((0,x.J)(e))return e;var t,r=(0,c.Z)(f);try{for(r.s();!(t=r.n()).done;){var i=t.value;try{var o=(0,p.Qc)(n,i,new Date);if((0,x.J)(o))return o}catch(a){}}}catch(d){r.e(d)}finally{r.f()}return null}l.ZP.th(r||(r=(0,o.Z)(["\n  text-align: left;\n  padding: 12px 16px;\n  background: #f8f9fa;\n  font-size: 11px;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  color: ",";\n  border-bottom: 1px solid #e9ecef;\n  cursor: ",";\n  user-select: none;\n  white-space: nowrap;\n  \n  &:hover {\n    ","\n  }\n"])),(function(n){return n.$sorted?"#00a6c2":"#666"}),(function(n){return n.$sortable?"pointer":"default"}),(function(n){return n.$sortable&&"\n      background: #f0f0f0;\n      color: #00a6c2;\n    "})),l.ZP.span(i||(i=(0,o.Z)(["\n  margin-left: 4px;\n  display: inline-block;\n  \n  &::after {\n    content: '","';\n    font-size: 12px;\n  }\n"])),(function(n){var e=n.$direction;return"asc"===e?"\u2193":"desc"===e?"\u2191":""}))},20211:function(n,e,t){t.r(e),t.d(e,{AdminExternalInvoiceDetailPage:function(){return de},AdminExternalInvoicesPage:function(){return _n},default:function(){return _n}});var r,i,o,c,a,d,s,l,u,x,p,f,h,v,b,g,m,j=t(50390),Z=t(41354),y=t(74165),k=t(15861),I=t(29439),w=t(30168),P=t(96692),C=t(88410),_=t(75400),S=t(69066),D=t(78512),T=t(94450),z=t(62559),E=P.ZP.div(r||(r=(0,w.Z)(["\n  padding: 0;\n"]))),$=P.ZP.div(i||(i=(0,w.Z)(["\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  margin-bottom: 24px;\n"]))),M=P.ZP.div(o||(o=(0,w.Z)(["\n  font-size: 13px;\n  color: #666;\n  margin-bottom: 16px;\n  text-transform: uppercase;\n"]))),N=P.ZP.h2(c||(c=(0,w.Z)(["\n  font-size: 20px;\n  font-weight: 600;\n  color: #333;\n  margin: 0;\n"]))),F=P.ZP.button(a||(a=(0,w.Z)(["\n  padding: 10px 20px;\n  border-radius: 4px;\n  font-size: 14px;\n  font-weight: 500;\n  cursor: pointer;\n  \n  ","\n  \n  &:disabled {\n    opacity: 0.6;\n    cursor: not-allowed;\n  }\n"])),(function(n){return"primary"===n.variant?"\n    background: #00a6c2;\n    color: white;\n    border: none;\n    \n    &:hover {\n      background: #0094ab;\n    }\n  ":"\n    background: white;\n    color: #666;\n    border: 1px solid #ddd;\n    \n    &:hover {\n      background: #f8f9fa;\n    }\n  "})),A=P.ZP.div(d||(d=(0,w.Z)(["\n  padding: 40px;\n  text-align: center;
1\n  color: #666;\n"]))),L=P.ZP.table(s||(s=(0,w.Z)(["\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 13px;\n  background: white;\n  border: 1px solid #e9ecef;\n  border-radius: 6px;\n  overflow: hidden;\n"]))),U=P.ZP.th(l||(l=(0,w.Z)(["\n  text-align: left;\n  padding: 12px 16px;\n  background: #f8f9fa;\n  font-size: 11px;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  color: ",";\n  border-bottom: 1px solid #e9ecef;\n  cursor: ",";\n  user-select: none;\n  white-space: nowrap;\n  \n  &:hover {\n    ","\n  }\n"])),(function(n){return n.$sorted?"#00a6c2":"#666"}),(function(n){return n.$sortable?"pointer":"default"}),(function(n){return n.$sortable&&"\n      background: #f0f0f0;\n      color: #00a6c2;\n    "})),O=P.ZP.td(u||(u=(0,w.Z)(["\n  padding: 12px 16px;\n  border-bottom: 1px solid #e9ecef;\n  color: #333;\n"]))),q=P.ZP.span(x||(x=(0,w.Z)(["\n  display: inline-block;\n  padding: 4px 8px;\n  border-radius: 3px;\n  font-size: 11px;\n  font-weight: 600;\n  ","\n"])),(function(n){return n.isPaid?"\n    background: #e8f5e9;\n    color: #2e7d32;\n  ":"\n    background: #fff3e0;\n    color: #f57c00;\n  "})),G=(0,P.ZP)(_.rU)(p||(p=(0,w.Z)(["\n  color: #00a6c2;\n  text-decoration: none;\n  font-weight: 500;\n  \n  &:hover {\n    text-decoration: underline;\n  }\n"]))),Q=P.ZP.div(f||(f=(0,w.Z)(["\n  padding: 60px;\n  text-align: center;\n  color: #666;\n  background: #f8f9fa;\n  border-radius: 6px;\n"]))),R=P.ZP.div(h||(h=(0,w.Z)(["\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  gap: 8px;\n  margin-top: 24px;\n"]))),H=P.ZP.button(v||(v=(0,w.Z)(["\n  padding: 8px 12px;\n  background: ",";\n  color: ",";\n  border: 1px solid ",";\n  border-radius: 4px;\n  font-size: 14px;\n  cursor: pointer;\n  \n  &:hover:not(:disabled) {\n    background: ",";\n  }\n  \n  &:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n  }\n"])),(function(n){return n.active?"#00a6c2":"#fff"}),(function(n){return n.active?"#fff":"#333"}),(function(n){return n.active?"#00a6c2":"#ddd"}),(function(n){return n.active?"#0094ab":"#f8f9fa"})),J=P.ZP.div(b||(b=(0,w.Z)(["\n  background: #e3f2fd;\n  border: 1px solid #90caf9;\n  border-radius: 6px;\n  padding: 16px;\n  margin-bottom: 24px;\n  display: flex;\n  align-items: center;\n  gap: 12px;\n"]))),X=P.ZP.div(g||(g=(0,w.Z)(["\n  width: 20px;\n  height: 20px;\n  border: 2px solid #e3f2fd;\n  border-top-color: #1976d2;\n  border-radius: 50%;\n  animation: spin 1s linear infinite;\n  \n  @keyframes spin {\n    to {\n      transform: rotate(360deg);\n    }\n  }\n"]))),B=P.ZP.span(m||(m=(0,w.Z)(["\n  font-size: 14px;\n  color: #1565c0;\n"]))),K=function(n){if(!n)return"-";try{var e=new Date(n);return(0,S.Q)(e,{addSuffix:!0})}catch(t){return n}},V=function n(e,t){(0,D.U2)("/api/v1/batches/".concat(e),!0).then((function(r){r.isComplete?t():setTimeout((function(){return n(e,t)}),1e3)})).catch((function(){t()}))},W=function(n){var e=n.direction;return e?(0,z.jsx)("span",{style:{marginLeft:"4px"},children:"asc"===e?"\u2193":"\u2191"}):null},Y=function(){var n=(0,j.useState)(0),e=(0,I.Z)(n,2),t=e[0],r=e[1],i=(0,j.useState)(!0),o=(0,I.Z)(i,2),c=o[0],a=o[1],d=(0,j.useState)(!1),s=(0,I.Z)(d,2),l=s[0],u=s[1],x=(0,j.useState)([]),p=(0,I.Z)(x,2),f=p[0],h=p[1],v=(0,j.useRef)(!0),b=(0,T.cX)(f,{key:"id",direction:"desc"}),g=b.sortedData,m=b.requestSort,Z=b.getSortDirection,w=(0,j.useCallback)((0,k.Z)((0,y.Z)().mark((function n(){var e;return(0,y.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a(!0),n.prev=1,n.next=4,(0,D.U2)("/api/v2/external_invoices",!0);case 4:e=n.sent,v.current&&h(Array.isArray(e)?e:[]),n.next=12;break;case 8:n.prev=8,n.t0=n.catch(1),console.error("Failed to fetch external invoices:",n.t0),v.current&&h([]);case 12:return n.prev=12,v.current&&a(!1),n.finish(12);case 15:case"end":return n.stop()}}),n,null,[[1,8,12,15]])}))),[]);(0,j.useEffect)((function(){return v.current=!0,w(),function(){v.current=!1}}),[w]);var P=(0,j.useCallback)((0,k.Z)((0,y.Z)().mark((function n(){var e,t;return(0,y.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u(!0),n.prev=1,n.next=4,(0,D.v_)("/api/v2/fetch_invoices",null,!1);case 4:null!==(t=n.sent)&&void 0!==t&&null!==(e=t.data)&&void 0!==e&&e.id?(C.Am.info("Fetching invoices from NetSuite..."),V(t.data.id,(function(){v.current&&(w(),u(!1),C.Am.success("Invoices fetched successfully!"))}))):(u(!1),C.Am.error("Failed to start invoice fetch")),n.next=12;break;case 8:n.prev=8,n.t0=n.catch(1),u(!1),C.Am.error((null===n.t0||void 0===n.t0?void 0:n.t0.message)||"Failed to fetch invoices");case 12:case"end":return n.stop()}}),n,null,[[1,8]])}))),[w]),_=Math.ceil(g.length/10),S=g.slice(10*t,10*(t+1)),Y=c||l;return(0,z.jsxs)(E,{children:[(0,z.jsxs)($,{children:[(0,z.jsx)(N,{children:"Exter
1nal Invoices"}),(0,z.jsx)(F,{variant:"primary",onClick:P,disabled:Y,children:l?"Fetching...":"Fetch Invoices"})]}),l&&(0,z.jsxs)(J,{children:[(0,z.jsx)(X,{}),(0,z.jsx)(B,{children:"Fetching invoices from NetSuite..."})]}),c?(0,z.jsx)(A,{children:"Loading invoices..."}):0===f.length?(0,z.jsxs)(Q,{children:[(0,z.jsx)("p",{children:"No external invoices found."}),(0,z.jsx)("p",{children:'Click "Fetch Invoices" to retrieve invoices from NetSuite.'})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(M,{children:[f.length," Total External_Invoices"]}),(0,z.jsxs)(L,{children:[(0,z.jsx)("thead",{children:(0,z.jsxs)("tr",{children:[(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("id"),onClick:function(){return m("id")},children:["ID ",(0,z.jsx)(W,{direction:Z("id")})]}),(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("status"),onClick:function(){return m("status")},children:["Status ",(0,z.jsx)(W,{direction:Z("status")})]}),(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("internalId"),onClick:function(){return m("internalId")},children:["NetSuite ID ",(0,z.jsx)(W,{direction:Z("internalId")})]}),(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("pubId"),onClick:function(){return m("pubId")},children:["Pub ID ",(0,z.jsx)(W,{direction:Z("pubId")})]}),(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("createdDate"),onClick:function(){return m("createdDate")},children:["Created ",(0,z.jsx)(W,{direction:Z("createdDate")})]}),(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("lastModifiedDate"),onClick:function(){return m("lastModifiedDate")},children:["Modified ",(0,z.jsx)(W,{direction:Z("lastModifiedDate")})]}),(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("memo"),onClick:function(){return m("memo")},children:["Memo ",(0,z.jsx)(W,{direction:Z("memo")})]}),(0,z.jsxs)(U,{$sortable:!0,$sorted:null!==Z("total"),onClick:function(){return m("total")},children:["Total ",(0,z.jsx)(W,{direction:Z("total")})]})]})}),(0,z.jsx)("tbody",{children:S.map((function(n){var e,t,r;return(0,z.jsxs)("tr",{children:[(0,z.jsx)(O,{children:(0,z.jsx)(G,{to:"/admin2/external_invoices/".concat(n.id),children:n.id})}),(0,z.jsx)(O,{children:(0,z.jsx)(q,{isPaid:(null===(e=n.status)||void 0===e?void 0:e.includes("Paid"))||!1,children:n.status||"-"})}),(0,z.jsx)(O,{children:n.internalId||"-"}),(0,z.jsx)(O,{children:(r=n.pubId,r?r.includes(",")?r.replace(/,/g,", "):r:"-")}),(0,z.jsx)(O,{children:K(n.createdDate)}),(0,z.jsx)(O,{children:K(n.lastModifiedDate)}),(0,z.jsx)(O,{children:n.memo||"-"}),(0,z.jsx)(O,{children:(t=n.total,null==t?"-":t.toLocaleString("en-US",{style:"currency",currency:"USD"}))})]},n.id)}))})]}),_>1&&(0,z.jsxs)(R,{children:[(0,z.jsx)(H,{onClick:function(){return r((function(n){return n-1}))},disabled:0===t,children:"\u2190 Previous"}),(0,z.jsxs)("span",{children:["Page ",t+1," of ",_]}),(0,z.jsx)(H,{onClick:function(){return r((function(n){return n+1}))},disabled:t>=_-1,children:"Next \u2192"})]})]})]})};var nn,en,tn,rn,on,cn,an,dn,sn,ln,un,xn,pn,fn,hn,vn,bn,gn,mn,jn,Zn,yn,kn,In,wn,Pn,Cn,_n=function(){return(0,z.jsx)(Z.Z,{title:"External Invoices",pageTitle:"External invoices",children:(0,z.jsx)(Y,{})})},Sn=t(4942),Dn=t(1413),Tn=t(15545),zn=t(32804),En=t(91966),$n=P.ZP.div(nn||(nn=(0,w.Z)(["\n  display: flex;\n  justify-content: space-between;\n  align-items: flex-start;\n  margin-bottom: 24px;\n"]))),Mn=P.ZP.h1(en||(en=(0,w.Z)(["\n  font-size: 28px;\n  font-weight: 400;\n  color: #0891b2;\n  margin: 0;\n"]))),Nn=P.ZP.button(tn||(tn=(0,w.Z)(["\n  padding: 10px 20px;\n  background: #6b7280;\n  color: #fff;\n  border: none;\n  border-radius: 4px;\n  font-size: 14px;\n  cursor: pointer;\n  \n  &:hover {\n    background: #4b5563;\n  }\n  \n  &:disabled {\n    opacity: 0.6;\n    cursor: not-allowed;\n  }\n"]))),Fn=P.ZP.h2(rn||(rn=(0,w.Z)(["\n  font-size: 18px;\n  font-weight: 600;\n  color: #333;\n  margin: 0 0 16px 0;\n  padding-bottom: 8px;\n  border-bottom: 1px solid #e5e7eb;\n"]))),An=P.ZP.div(on||(on=(0,w.Z)(["\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 16px 32px;\n  margin-bottom: 32px;\n"]))),Ln=P.ZP.div(cn||(cn=(0,w.Z)(["\n  display: flex;\n  flex-direction: column;\n"]))),Un=P.ZP.span(an||(an=(0,w.Z)(["\n  font-size: 13px;\n  font-weight: 600;\n  color: #374151;\n  margin-bottom: 4px;\n"]))),On=P.ZP.span(dn||(dn=(0,w.Z)(["\n  font-size: 14px;\n  color: #111827;\n"]))),qn=P.ZP.span(sn||(sn=(0,w.Z)(["\n  display: inline-block;\n  padding: 4px 12px;\n  border-radius: 4px;\n  font-size: 12px;\n  font-weight: 600;\n  text-transform: uppercase;\n  \n  ","\n"])),(function(n){var e=n.status,t=(null===e||void 0===e?void 0:e.toLowerCase())||"";return t.includes("paid")?"background: #d1fae5; color: #065f46;":t.includes("open")?"background: #fef3c7; color: #92400e;":t.includes("void")?"background: #fee2e2; color: #991b1b;":"background: #e5e7eb; color: #374151;"})),Gn=P.ZP.select(ln||(ln=(0,w.Z)(["\n  width: 100%;\n  padding: 10px 12px;\n  border: 1px solid #d1d5db;\n  border-radius: 4px;\n  font-size: 14px;\n  background: white;\n  margin-bottom: 24px;\n  \n  &:focus {\n    outline: none;\n    border-color: #0891b2;\n  }\n"]))),Qn=P.ZP.table(un||(un=(0,w.Z)(["\n  width: 100%;\n  border-collapse: collapse;\n  font-size: 13px;\n  background: white;\n  border: 1px solid #e5e7eb;\n  border-radius: 4px;\n  overflow: hidden;\n"]))),Rn=P.ZP.th(xn||(xn=(0,w.Z)(["\n  text-align: left;\n  padding: 12px 16px;\n  background: #f9fafb;\n  font-size: 12px;\n  font-weight: 600;\n  color: #374151;\n  border-bottom: 1px solid #e5e7eb;
1\n"]))),Hn=P.ZP.td(pn||(pn=(0,w.Z)(["\n  padding: 12px 16px;\n  border-bottom: 1px solid #e5e7eb;\n  color: #111827;\n  vertical-align: middle;\n"]))),Jn=P.ZP.select(fn||(fn=(0,w.Z)(["\n  padding: 6px 10px;\n  border: 1px solid #d1d5db;\n  border-radius: 4px;\n  font-size: 13px;\n  background: white;\n  min-width: 120px;\n  \n  &:focus {\n    outline: none;\n    border-color: #0891b2;\n  }\n"]))),Xn=P.ZP.button(hn||(hn=(0,w.Z)(["\n  padding: 6px 16px;\n  background: #0891b2;\n  color: white;\n  border: none;\n  border-radius: 4px;\n  font-size: 13px;\n  cursor: pointer;\n  white-space: nowrap;\n  \n  &:hover {\n    background: #0e7490;\n  }\n  \n  &:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n  }\n"]))),Bn=P.ZP.button(vn||(vn=(0,w.Z)(["\n  padding: 6px 16px;\n  background: #ef4444;\n  color: white;\n  border: none;\n  border-radius: 4px;\n  font-size: 13px;\n  cursor: pointer;\n  white-space: nowrap;\n  \n  &:hover:not(:disabled) {\n    background: #dc2626;\n  }\n  \n  &:disabled {\n    opacity: 0.5;\n    cursor: not-allowed;\n  }\n"]))),Kn=P.ZP.div(bn||(bn=(0,w.Z)(["\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n"]))),Vn=P.ZP.div(gn||(gn=(0,w.Z)(["\n  display: flex;\n  gap: 8px;\n  align-items: center;\n  flex-wrap: wrap;\n"]))),Wn=(0,P.ZP)(_.rU)(mn||(mn=(0,w.Z)(["\n  color: #0891b2;\n  text-decoration: none;\n  font-size: 13px;\n  \n  &:hover {\n    text-decoration: underline;\n  }\n"]))),Yn=P.ZP.span(jn||(jn=(0,w.Z)(["\n  font-size: 13px;\n  color: #374151;\n"]))),ne=P.ZP.div(Zn||(Zn=(0,w.Z)(["\n  padding: 60px;\n  text-align: center;\n  color: #666;\n"]))),ee=P.ZP.div(yn||(yn=(0,w.Z)(["\n  font-size: 14px;\n  margin-bottom: 16px;\n  \n  a {\n    color: #0891b2;\n    text-decoration: none;\n    \n    &:hover {\n      text-decoration: underline;\n    }\n  }\n"]))),te=P.ZP.div(kn||(kn=(0,w.Z)(["\n  position: fixed;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  background: rgba(0, 0, 0, 0.5);\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  z-index: 1000;\n"]))),re=P.ZP.div(In||(In=(0,w.Z)(["\n  background: white;\n  padding: 24px;\n  border-radius: 8px;\n  max-width: 400px;\n  width: 90%;\n"]))),ie=P.ZP.p(wn||(wn=(0,w.Z)(["\n  font-size: 14px;\n  color: #374151;\n  margin: 0 0 20px 0;\n"]))),oe=P.ZP.div(Pn||(Pn=(0,w.Z)(["\n  display: flex;\n  gap: 12px;\n  justify-content: flex-end;\n"]))),ce=P.ZP.button(Cn||(Cn=(0,w.Z)(["\n  padding: 8px 20px;\n  border: none;\n  border-radius: 4px;\n  font-size: 14px;\n  cursor: pointer;\n  \n  ","\n"])),(function(n){return"primary"===n.$variant?"background: #10b981; color: white; &:hover { background: #059669; }":"background: #e5e7eb; color: #374151; &:hover { background: #d1d5db; }"})),ae=function(n){return null==n?"None":n.toLocaleString("en-US",{style:"currency",currency:"USD"})};var de=function(){var n=(0,Tn.UO)().id,e=(0,En.Q)(),t=e.setTimezoneFromResponse,r=e.formatDateTime,i=(0,j.useState)(!0),o=(0,I.Z)(i,2),c=o[0],a=o[1],d=(0,j.useState)(!1),s=(0,I.Z)(d,2),l=s[0],u=s[1],x=(0,j.useState)(null),p=(0,I.Z)(x,2),f=p[0],h=p[1],v=(0,j.useState)([]),b=(0,I.Z)(v,2),g=b[0],m=b[1],w=(0,j.useState)([]),P=(0,I.Z)(w,2),S=P[0],D=P[1],T=(0,j.useState)([]),E=(0,I.Z)(T,2),$=E[0],M=E[1],N=(0,j.useState)(""),F=(0,I.Z)(N,2),A=F[0],L=F[1],U=(0,j.useState)({}),O=(0,I.Z)(U,2),q=O[0],G=O[1],Q=(0,j.useState)({isOpen:!1,lineItemId:null,action:null,message:""}),R=(0,I.Z)(Q,2),H=R[0],J=R[1],X=(0,j.useState)(!1),B=(0,I.Z)(X,2),K=B[0],V=B[1],W=(0,j.useCallback)((0,k.Z)((0,y.Z)().mark((function e(){var r;return(0,y.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:return a(!0),e.prev=3,e.next=6,zn.ZP.get("/admin2/external_invoices/".concat(n,".json"));case 6:r=e.sent,h(r.data.externalInvoice),m(r.data.publications||[]),D(r.data.transactionCategories||[]),M(r.data.accounts||[]),t(r.data),e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),console.error("Failed to fetch invoice:",e.t0),C.Am.error("Failed to load invoice details");case 18:return e.prev=18,a(!1),e.finish(18);case 21:case"end":return e.stop()}}),e,null,[[3,14,18,21]])}))),[n,t]);(0,j.useEffect)((function(){W()}),[W]);var Y,nn=(0,j.useCallback)((function(n,e){zn.ZP.get("/api/v1/batches/".concat(n)).then((function(t){var r,i,o;null!==(r=t.data)&&void 0!==r&&null!==(i=r.data)&&void 0!==i&&null!==(o=i.attributes)&&void 0!==o&&o.isComplete?e():setTimeout((function(){return nn(n,e)}),1e3)}
1)).catch((function(){e()}))}),[]),en=function(){var n=(0,k.Z)((0,y.Z)().mark((function n(){var e,t,r;return(0,y.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null!==f&&void 0!==f&&f.internalId){n.next=3;break}return C.Am.error("No NetSuite invoice ID available"),n.abrupt("return");case 3:return u(!0),n.prev=4,n.next=7,zn.ZP.post("/api/v2/fetch_invoices",{netsuite_invoice_id:f.internalId});case 7:r=n.sent,null!==(e=r.data)&&void 0!==e&&null!==(t=e.data)&&void 0!==t&&t.id?(C.Am.info("Fetching latest invoice info from NetSuite..."),nn(r.data.data.id,(function(){W(),u(!1),C.Am.success("Invoice updated successfully!")}))):(C.Am.error("Failed to start invoice fetch"),u(!1)),n.next=15;break;case 11:n.prev=11,n.t0=n.catch(4),C.Am.error("Failed to fetch invoice from NetSuite"),u(!1);case 15:case"end":return n.stop()}}),n,null,[[4,11]])})));return function(){return n.apply(this,arguments)}}(),tn=function(n,e,t){G((function(r){return(0,Dn.Z)((0,Dn.Z)({},r),{},(0,Sn.Z)({},n,(0,Dn.Z)((0,Dn.Z)({},r[n]),{},(0,Sn.Z)({},e,t))))}))},rn=A?g.filter((function(n){var e;return(null===(e=n.accountId)||void 0===e?void 0:e.toString())===A})):g,on=function(n){return null===f||void 0===f?void 0:f.invoiceListItems.find((function(e){return e.id===n}))},cn=function(){J({isOpen:!1,lineItemId:null,action:null,message:""})},an=function(){var n=(0,k.Z)((0,y.Z)().mark((function n(){return(0,y.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(H.lineItemId&&H.action){n.next=2;break}return n.abrupt("return");case 2:if(V(!0),n.prev=3,"transfer"!==H.action){n.next=9;break}return n.next=7,dn(H.lineItemId);case 7:n.next=12;break;case 9:if("cancelCredit"!==H.action){n.next=12;break}return n.next=12,sn(H.lineItemId);case 12:return n.next=14,W();case 14:C.Am.success("transfer"===H.action?"Transfer completed":"Credit canceled"),n.next=21;break;case 17:n.prev=17,n.t0=n.catch(3),console.error("Operation failed:",n.t0),C.Am.error("Operation failed");case 21:return n.prev=21,V(!1),cn(),n.finish(21);case 25:case"end":return n.stop()}}),n,null,[[3,17,21,25]])})));return function(){return n.apply(this,arguments)}}(),dn=function(){var n=(0,k.Z)((0,y.Z)().mark((function n(e){var t,r,i,o,c,a;return(0,y.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(i=q[e],o=on(e),i&&o){n.next=4;break}throw new Error("Missing selection or line item");case 4:return n.next=6,zn.ZP.post("/api/v2/transactions",{transaction:{type:"Credit",amount_in_dollars_and_cents:o.amount,internal_note:"",public_note:"",brand_profile_id:i.publicationId,category:i.categoryId,internal_invoice_credit_memo_reference:"",completed:!0,completed_at:(new Date).toUTCString()}});case 6:if(c=n.sent,a=null===(t=c.data)||void 0===t||null===(r=t.data)||void 0===r?void 0:r.id){n.next=10;break}throw new Error("Failed to create credit transaction");case 10:return n.next=12,zn.ZP.patch("/api/v2/invoice_list_items/".concat(e),{invoice_list_item:{credit_id:a}});case 12:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),sn=function(){var n=(0,k.Z)((0,y.Z)().mark((function n(e){var t,r,i,o,c,a;return(0,y.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if((i=on(e))&&i.creditId){n.next=3;break}throw new Error("Missing line item or credit");case 3:if(null!==(o=q[e])&&void 0!==o&&o.publicationId&&null!==o&&void 0!==o&&o.categoryId){n.next=6;break}throw new Error("Please select publication and category to cancel the credit");case 6:return n.next=8,zn.ZP.post("/api/v2/transactions",{transaction:{type:"Debit",amount_in_dollars_and_cents:i.amount,internal_note:"",public_note:"",brand_profile_id:o.publicationId,category:o.categoryId,internal_invoice_credit_memo_reference:"",completed:!0,completed_at:(new Date).toUTCString()}});case 8:if(c=n.sent,a=null===(t=c.data)||void 0===t||null===(r=t.data)||void 0===r?void 0:r.id){n.next=12;break}throw new Error("Failed to create debit transaction");case 12:return n.next=14,zn.ZP.patch("/api/v2/invoice_list_items/".concat(e),{invoice_list_item:{debit_id:a}});case 14:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),ln=function(n){var e=q[n.id],t=null!=n.creditId,r=null!=n.debitId,i=(null===e||void 0===e?void 0:e.publicationId)&&(null===e||void 0===e?void 0:e.categoryId);return t&&r?(0,z.jsxs)(Yn,{children:[(0,z.jsxs)(Wn,{to:"/admin2/transactions/".concat(n.creditId),children:["Credit #",n.creditId]})," canceled out with ",(0,z.jsxs)(Wn,{to:"/admin2/transactions/".concat(n.debitId),children:["Debit #",n.debitId]})]}):t?(0,z.jsxs)(Kn,{children:[(0,z.jsxs)(Vn,{children:[(0,z.jsxs)(Wn,{to:"/admin2/transactions/".concat(n.creditId),children:["Credit #",n.creditId]}),(0,z.jsx)(Bn,{onClick:function(){return e=n.id,void J({isOpen:!0,lineItemId:e,action:"cancelCredit",message:"Create debit to cancel out transferred funds? This action can not be undone!"});var e},disabled:!i,title:i?"":"Please select publication and category first",children:"Cancel out credit"})]}),!i&&(0,z.jsxs)(Vn,{children:[(0,z.jsxs)(Jn,{value:(null===e||void 0===e?void 0:e.publicationId)||"",onChange:function(e){return tn(n.id,"publicationId",e.target.value)},children:[(0,z.jsx)("option",{value:"",children:"Publication (required for cancel)"}),rn.map((function(n){return(0,z.jsx)("option",{value:n.id,children:n.name},n.id)}))]}),(0,z.jsxs)(Jn,{value:(null===e||void 0===e?void 0:e.categoryId)||"",onChange:function(e){return tn(n.id,"categoryId",e.target.value)},children:[(0,z.jsx)("option",{value:"",children:"Category (required for cancel)"}),S.map((function(n){return(0,z.jsx)("option",{value:n.id,children:n.name},n.id)}))]})]})]}):(0,z.jsxs)(Vn,{children:[(0,z.jsxs)(Jn,{value:(null===e||void 0===e?void 0:e.publicationId)||"",onChange:function(e){return tn(n.id,"publicationId",e.target.value)},children:[(0,z.jsx)("option",{value:"",children:"Publication"}),rn.map((function(n){return(0,z.jsx)("option",{value:n.id,children:n.name},n.id)}))]}),(0,z.jsxs)(Jn,{value:(null===e||void 0===e?void 0:e.categoryId)||"",onChange:function(e){return tn(n.id,"categoryId",e.target.value)},children:[(0,z.jsx)("option",{value:"",children:"Category"}),S.map((function(n){return(0,z.jsx)("option",{value:n.id,children:n.name},n.id)}))]}),(0,z.jsx)(Xn,{onClick:function(){return function(n){var e=q[n];if(null!==e&&void 0!==e&&e.publicationId&&null!==e&&void 0!==e&&e.categoryId){var t=on(n),r=rn.find((function(n){return n.id.toString()===e.publicationId}));J({isOpen:!0,lineItemId:n,action:"transfer",message:"Transfer ".concat(ae(null===t||void 0===t?void 0:t.amount)," to ").concat(null===r||void 0===r?void 0:r.name,"?")})}else C.Am.warning("Please select both publication and category")}
1(n.id)},disabled:!(null!==e&&void 0!==e&&e.publicationId)||!(null!==e&&void 0!==e&&e.categoryId),children:"Transfer"})]})};return c?(0,z.jsx)(Z.Z,{title:"External Invoice",pageTitle:"External invoices",children:(0,z.jsx)(ne,{children:"Loading invoice details..."})}):f?(0,z.jsxs)(Z.Z,{title:"External Invoice",pageTitle:"External invoices",children:[(0,z.jsx)(ee,{children:(0,z.jsx)(_.rU,{to:"/admin2/external_invoices",children:"External invoices"})}),(0,z.jsxs)($n,{children:[(0,z.jsxs)(Mn,{children:["External Invoice ",f.id]}),(0,z.jsx)(Nn,{onClick:en,disabled:l,children:l?"Fetching...":"Fetch most recent invoice info"})]}),(0,z.jsxs)(Fn,{children:["NetSuite invoice ",f.tranId||f.internalId]}),(0,z.jsxs)(An,{children:[(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Status"}),(0,z.jsx)(On,{children:(0,z.jsx)(qn,{status:f.status||"",children:f.status||"Unknown"})})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Sub Total"}),(0,z.jsx)(On,{children:ae(f.subTotal)})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Created date"}),(0,z.jsx)(On,{children:r(f.createdDate)})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Total Cost Estimate"}),(0,z.jsx)(On,{children:null!=f.totalCostEstimate?ae(f.totalCostEstimate):"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Last modified date"}),(0,z.jsx)(On,{children:r(f.lastModifiedDate)})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Estimated Gross Profit"}),(0,z.jsx)(On,{children:null!=f.estGrossProfit?"".concat(ae(f.estGrossProfit)," (").concat((Y=f.estGrossProfitPercent,null==Y?"None":"".concat(Y.toFixed(0),"%")),")"):"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"NetSuite Transaction ID"}),(0,z.jsx)(On,{children:f.tranId||f.internalId||"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Discount Total"}),(0,z.jsx)(On,{children:null!=f.discountTotal?ae(f.discountTotal):"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Due Date"}),(0,z.jsx)(On,{children:f.dueDate||"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Tax Total"}),(0,z.jsx)(On,{children:null!=f.taxTotal?ae(f.taxTotal):"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Memo"}),(0,z.jsx)(On,{children:f.memo||"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Total"}),(0,z.jsx)(On,{children:ae(f.total)})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Email"}),(0,z.jsx)(On,{children:f.email||"None"})]}),(0,z.jsxs)(Ln,{children:[(0,z.jsx)(Un,{children:"Publication ID"}),(0,z.jsx)(On,{children:f.pubId||"None"})]})]}),(0,z.jsxs)(Gn,{value:A,onChange:function(n){return L(n.target.value)},children:[(0,z.jsx)("option",{value:"",children:"Select Account to limit publication selectors"}),$.map((function(n){return(0,z.jsxs)("option",{value:n.id,children:[n.id," - ",n.name]},n.id)}))]}),f.invoiceListItems&&f.invoiceListItems.length>0&&(0,z.jsxs)(Qn,{children:[(0,z.jsx)("thead",{children:(0,z.jsxs)("tr",{children:[(0,z.jsx)(Rn,{children:"Line"}),(0,z.jsx)(Rn,{children:"Item"}),(0,z.jsx)(Rn,{children:"Description"}),(0,z.jsx)(Rn,{children:"Quantity/Rate"}),(0,z.jsx)(Rn,{children:"Amount"}),(0,z.jsx)(Rn,{children:"Actions"})]})}),(0,z.jsx)("tbody",{children:f.invoiceListItems.map((function(n){return(0,z.jsxs)("tr",{children:[(0,z.jsx)(Hn,{children:n.line}),(0,z.jsx)(Hn,{children:n.externalItemName}),(0,z.jsx)(Hn,{children:n.description||"-"}),(0,z.jsxs)(Hn,{children:[n.quantity," x ",ae(n.rate)]}),(0,z.jsx)(Hn,{children:ae(n.amount)}),(0,z.jsx)(Hn,{children:(0,z.jsx)(Kn,{children:ln(n)})})]},n.id)}))})]}),H.isOpen&&(0,z.jsx)(te,{onClick:cn,children:(0,z.jsxs)(re,{onClick:function(n){return n.stopPropagation()},children:[(0,z.jsx)(ie,{children:H.message}),(0,z.jsxs)(oe,{children:[(0,z.jsx)(ce,{onClick:cn,disabled:K,children:"Cancel"}),(0,z.jsx)("span",{style:{color:"#6b7280"},children:"or"}),(0,z.jsx)(ce,{$variant:"primary",onClick:an,disabled:K,children:K?"Processing...":"Confirm"})]})]})})]}):(0,z.jsx)(Z.Z,{title:"External Invoice",pageTitle:"External invoices",children:(0,z.jsx)(ne,{children:"Invoice not found"})})}}}]);
2//# sourceMappingURL=211.2bff5ef8.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.