1import{r as n,j as t,B as u}from"./index-BKqgh2-a.js";import{N as y,D as A}from"./DrawerHeader-DRtOVHRN.js";import{a as R}from"./authAxios-DczOoM4i.js";import{u as S,P as L}from"./axios-DDo_axc3.js";import{u as j}from"./AccountCircle-DEt4SNiY.js";import{T as _}from"./Typography-DmmAfZLK.js";import{L as p}from"./LoadingButton-C0wRnXP_.js";import{br as b}from"./DataGrid-yAV68Ctb.js";import"./useTranslation-v9TXqKRV.js";import"./MenuItem-CLahpyZd.js";import"./Button-Ct1D3401.js";import"./useThemeProps-hbIU_Ugg.js";import"./index-BtoY9wl6.js";import"./Select-CHZqkeMK.js";import"./FormHelperText-WzQAaEgZ.js";import"./ListSubheader-BXsiKwpA.js";import"./Stack-CqSJL9v8.js";import"./FormControlLabel-DcwpPw15.js";import"./TextField-Dz2UG-sb.js";import"./LinearProgress-4xsuNCVp.js";var C={VITE_BASEURL_development:"http://api.gender.io:5007",VITE_BASEURL_production:"https://api.genderapi.io",VITE_SOCKETURL_development:"ws://socket.gender.io:5050",VITE_SOCKETURL_production:"wss://socket.genderapi.io",VITE_ACTIVATE_REQUIRED:"yes",VITE_PAYPAL_CLIENT_ID:"AdDX7cP9DTvTJBMCsycsfjVtOiSLJaBFGWBmf7OTPweeRg7u6pxaMPvDoYpo3OC_HIcP-qk4RiBMr3Ak",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const l=C.VITE_BASEURL_production,m=R;function x(c){if(!c)return"";const a=String(c);return a.length>8?`${a.slice(0,8)}â¦`:a}function X(){const c=S(),a=j(c.breakpoints.up("md")),[v,g]=n.useState(!a),[w,f]=n.useState([]),[E,h]=n.useState(!0),[I,T]=n.useState({}),s=n.useCallback(async()=>{h(!0);const i=await m({url:`${l}/admin/invoicesList`});i.status&&Array.isArray(i.invoices)?f(i.invoices.map(e=>({...e,id:e._id}))):f([]),h(!1)},[]);n.useEffect(()=>{s()},[s]),n.useEffect(()=>{g(!a)},[a]);const o=(i,e,d)=>{T(r=>({...r,[i]:{...r[i],[e]:d}}))};return t.jsxs(u,{sx:{display:"flex"},children:[t.jsx(y,{}),t.jsxs(u,{component:"main",sx:{flexGrow:1,p:3,ml:v?"50px":"unset"},children:[t.jsx(A,{}),t.jsxs(u,{sx:{maxWidth:"1600px",margin:"auto"},children:[t.jsx(_,{variant:"h5",component:"h2",sx:{mb:2},children:"Invoices"}),t.jsx(_,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Pending invoices (not canceled, not refunded, not printed). Actions call the admin API: print, cancel, or refund."}),t.jsx(L,{sx:{p:2,height:560},elevation:3,children:t.jsx(b,{density:"compact",loading:E,rows:w,columns:[{field:"invoice_no",headerName:"Invoice No",width:110},{field:"name",headerName:"Name",minWidth:160,flex:.8},{field:"total",headerName:"Amount",width:140,valueGetter:(i,e)=>e.total!=null?`${Number(e.total).toFixed(2)} ${e.currency||""}`.trim():""},{field:"created_at",headerName:"Created",width:180,type:"dateTime",valueGetter:(i,e)=>e.created_at?new Date(e.created_at):null},{field:"product_id",headerName:"Product",width:120,valueGetter:(i,e)=>x(e.product_id)},{field:"ip_id",headerName:"IP / Key",width:120,valueGetter:(i,e)=>x(e.ip_id)},{field:"actions",headerName:"Actions",sortable:!1,width:340,renderCell:i=>{const e=i.row._id,d=I[e]||{};return t.jsxs(t.Fragment,{children:[t.jsx(p,{size:"small",variant:"contained",loading:!!d.print,sx:{mr:1},onClick:async()=>{o(e,"print",!0);const r=await m({url:`${l}/admin/printInvoice?_id=${e}`});o(e,"print",!1),!r.status&&r.message&&window.alert(r.message),await s()},children:"Print"}),t.jsx(p,{size:"small",variant:"contained",color:"warning",loading:!!d.cancel,sx:{mr:1},disabled:i.row.canceled,onClick:async()=>{window.confirm("Cancel this invoice?")&&(o(e,"cancel",!0),await m({url:`${l}/admin/cancelInvoice?_id=${e}`}),o(e,"cancel",!1),await s())},children:"Cancel"}),t.jsx(p,{size:"small",variant:"contained",color:"error",loading:!!d.refund,disabled:i.row.refund,onClick:async()=>{window.confirm("Mark invoice as refunded?")&&(o(e,"refund",!0),await m({url:`${l}/admin/refundInvoice?_id=${e}`}),o(e,"refund",!1),await s())},children:"Refund"})]})}}],pageSizeOptions:[25,50,100],initialState:{pagination:{paginationModel:{pageSize:25}}},disableRowSelectionOnClick:!0})})]})]})]})}export{X as default};
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.