1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[2604],{82599(e,s,n){n.r(s),n.d(s,{component:()=>k});var a=n(72361),i=n(68413),t=n(96962),d=n(53540),r=n(55667),l=n(6702),c=n(20598),o=n(63742),x=n(46775),u=n(1755),m=n(54023),h=n(61309),p=n(18434),j=n(32999),g=n(34151),v=n(67267),f=n(64577);async function N(e,s){let n=new URLSearchParams({p:String(e),page_size:"20"});s&&n.set("status",s);let a=await f.FH.get(`/api/invoice/request?${n.toString()}`);if(!a.data?.success)throw Error(a.data?.message??"load failed");return a.data.data}async function b(e,s,n){let a=await f.FH.post("/api/invoice/request/handle",{id:e,action:s,admin_remark:n});if(!a.data?.success)throw Error(a.data?.message??"handle failed")}async function y(e,s){let n=new FormData;n.append("id",String(e)),n.append("file",s);let a=await f.FH.post("/api/invoice/request/file",n,{headers:{"Content-Type":"multipart/form-data"}});if(!a.data?.success)throw Error(a.data?.message??"upload failed")}async function w(e){let s=(await f.FH.get(`/api/invoice/request/${e}/file/admin`,{responseType:"blob"})).data;if(s.type.includes("application/json")){let e=JSON.parse(await s.text());throw Error(e?.message??"load file failed")}let n=URL.createObjectURL(s);window.open(n,"_blank"),setTimeout(()=>URL.revokeObjectURL(n),6e4)}let _={pending:{label:"Pending",variant:"secondary"},issued:{label:"Issued",variant:"default"},rejected:{label:"Rejected",variant:"destructive"}},k=function(){let{t:e}=(0,l.Bd)(),s=(0,t.jE)(),[n,f]=(0,i.useState)("pending"),[k,A]=(0,i.useState)(1),[R,C]=(0,i.useState)(null),[S,E]=(0,i.useState)(""),{data:F,isLoading:q}=(0,d.I)({queryKey:["invoice-admin",n,k],queryFn:()=>N(k,n)}),I=(0,r.n)({mutationFn:e=>{let{id:s,action:n}=e;return b(s,n,S)},onSuccess:()=>{c.oR.success(e("Processed")),C(null),E(""),s.invalidateQueries({queryKey:["invoice-admin"]})},onError:e=>c.oR.error(e.message)}),U=(0,r.n)({mutationFn:e=>{let{id:s,file:n}=e;return y(s,n)},onSuccess:()=>{c.oR.success(e("Invoice file uploaded")),C(null),s.invalidateQueries({queryKey:["invoice-admin"]})},onError:e=>c.oR.error(e.message)}),L=F?.items??[],$=Math.max(1,Math.ceil((F?.total??0)/20));return(0,a.jsxs)(v.Ni,{children:[(0,a.jsx)(v.Ni.Title,{children:e("Invoice Management")}),(0,a.jsx)(v.Ni.Description,{children:e("Review and process user invoice requests")}),(0,a.jsxs)(v.Ni.Content,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(g.tU,{value:n,onValueChange:e=>{f(e),A(1)},children:(0,a.jsxs)(g.j7,{children:[(0,a.jsx)(g.Xi,{value:"pending",children:e("Pending")}),(0,a.jsx)(g.Xi,{value:"issued",children:e("Issued")}),(0,a.jsx)(g.Xi,{value:"rejected",children:e("Rejected")}),(0,a.jsx)(g.Xi,{value:"",children:e("All")})]})}),q?(0,a.jsx)(p.E,{className:"h-48 w-full"}):(0,a.jsxs)(j.XI,{children:[(0,a.jsx)(j.A0,{children:(0,a.jsxs)(j.Hj,{children:[(0,a.jsx)(j.nd,{children:"ID"}),(0,a.jsx)(j.nd,{children:e("User")}),(0,a.jsx)(j.nd,{children:e("Amount")}),(0,a.jsx)(j.nd,{children:e("Company")}),(0,a.jsx)(j.nd,{children:e("Tax Number")}),(0,a.jsx)(j.nd,{children:e("XML needed")}),(0,a.jsx)(j.nd,{children:e("Applied At")}),(0,a.jsx)(j.nd,{children:e("Status")}),(0,a.jsx)(j.nd,{})]})}),(0,a.jsxs)(j.BF,{children:[L.map(s=>{let n=_[s.status]??{label:s.status,variant:"secondary"};return(0,a.jsxs)(j.Hj,{children:[(0,a.jsx)(j.nA,{children:s.id}),(0,a.jsx)(j.nA,{children:s.username??s.user_id}),(0,a.jsxs)(j.nA,{className:"font-medium",children:["Â¥",s.amount_yuan.toFixed(2)]}),(0,a.jsx)(j.nA,{className:"max-w-[180px] truncate",children:s.company_name}),(0,a.jsx)(j.nA,{className:"text-muted-foreground text-xs",children:s.tax_number}),(0,a.jsx)(j.nA,{children:s.need_xml?(0,a.jsx)(o.E,{variant:"secondary",children:"XML"}):(0,a.jsx)("span",{className:"text-muted-foreground text-xs",children:e("No")})}),(0,a.jsx)(j.nA,{className:"text-muted-foreground text-xs",children:new Date(1e3*s.create_time).toLocaleString("zh-CN",{hour12:!1})}),(0,a.jsx)(j.nA,{children:(0,a.jsx)(o.E,{variant:n.variant,children:e(n.label)})}),(0,a.jsx)(j.nA,{children:(0,a.jsx)(x.$,{variant:"outline",size:"sm",onClick:()=>{C(s),E(s.admin_remark??"")},children:"pending"===s.status?e("Review"):e("View")})})]},s.id)}),0===L.length&&(0,a.jsx)(j.Hj,{children:(0,a.jsx)(j.nA,{colSpan:8,className:"text-muted-foreground py-10 text-center text-sm",children:e("No invoice requests")})})]})]}),$>1&&(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,a.jsx)(x.$,{variant:"outline",size:"sm",disabled:k<=1,onClick:()=>A(e=>e-1),children:e("Previous")}),(0,a.jsxs)("span",{className:"text-muted-foreground text-xs",children:[k," / ",$]}),(0,a.jsx)(x.$,{variant:"outline",size:"sm",disabled:k>=$,onClick:()=>A(e=>e+1),children:e("Next")})]})]}),(0,a.jsx)(u.lG,{open:!!R,onOpenChange:e=>{e||C(null)},children:(0,a.jsxs)(u.Cf,{className:"max-w-lg",children:[(0,a.jsx)(u.c7,{children:(0,a.jsxs)(u.L3,{children:[e("Invoice Request")," #",R?.id]})}),R&&(0,a.jsxs)("div",{className:"flex flex-col gap-3 text-sm",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("User"),": "]}),R.username??R.user_id]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("Amount"),":"," "]}),(0,a.jsxs)("strong",{children:["Â¥",R.amount_yuan.toFixed(2)]})]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("Company"),":"," "]}),R.company_name]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("Tax Number"),":"," "]}),R.tax_number]}),R.bank_name&&(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("Bank"),":"," "]}),R.bank_name," ",R.bank_account]}),R.address&&(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("Address"),":"," "]}),R.address," ",R.phone]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("Receiving Email"),":"," "]}),R.email]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("TopUp Orders"),":"," "]}),"month"===R.mode?`${e("Monthly bill")} ${R.bill_month}
1`:R.topup_ids.join(", ")]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("Invoice type"),":"," "]}),"special"===R.invoice_type?e("Special VAT invoice (3% fee)"):e("Standard invoice (1% fee)")]}),(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground",children:[e("XML needed"),":"," "]}),R.need_xml?e("Yes"):e("No")]})]}),(0,a.jsxs)("div",{className:"border-border/60 flex flex-wrap items-center gap-2 rounded-md border px-3 py-2",children:[(0,a.jsxs)("span",{className:"text-muted-foreground text-xs",children:[e("Invoice file"),":"]}),R.has_file?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"max-w-[180px] truncate text-xs",children:R.file_name}),(0,a.jsx)(x.$,{variant:"outline",size:"sm",onClick:()=>w(R.id).catch(e=>c.oR.error(e.message)),children:e("View")})]}):(0,a.jsx)("span",{className:"text-muted-foreground text-xs",children:e("Not uploaded")}),"rejected"!==R.status&&(0,a.jsxs)("label",{className:"inline-flex cursor-pointer",children:[(0,a.jsx)("input",{type:"file",accept:".pdf,.ofd,.png,.jpg,.jpeg",className:"hidden",onChange:e=>{let s=e.target.files?.[0];s&&U.mutate({id:R.id,file:s}),e.target.value=""}}),(0,a.jsx)("span",{className:"border-input bg-background hover:bg-accent inline-flex h-8 items-center rounded-md border px-3 text-xs font-medium",children:U.isPending?e("Uploading..."):R.has_file?e("Replace file"):e("Upload invoice")})]})]}),(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)(h.J,{className:"text-xs",children:e("Admin Remark")}),(0,a.jsx)(m.p,{value:S,onChange:e=>E(e.target.value),placeholder:e("Optional, visible to user"),disabled:"pending"!==R.status})]})]}),R?.status==="pending"&&(0,a.jsxs)(u.Es,{children:[(0,a.jsx)(x.$,{variant:"destructive",disabled:I.isPending,onClick:()=>I.mutate({id:R.id,action:"rejected"}),children:e("Reject")}),(0,a.jsx)(x.$,{disabled:I.isPending,onClick:()=>I.mutate({id:R.id,action:"issued"}),children:e("Mark as Issued")})]})]})})]})]})}}}]);
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.