mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 10:16:15 +00:00
3a3a830d93
- add ShouldSkipSPAFallback() deny prefixes: /api, /admin/api, /payments, /pay - apply StaticWithConfig Skipper in both main http server and install server - add unit tests for fallback skip matching behavior
1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
import{$a as e,Aa as t,Ba as n,Ca as r,Da as i,Do as a,Ea as o,Fa as s,Fs as c,Ga as l,Ha as u,Ia as d,Ja as f,Ka as p,La as m,Ma as h,Na as g,Oa as _,Oo as v,Pa as y,Qa as b,Ra as x,Sa as S,So as C,Ta as ee,Ua as w,Va as T,Wa as E,Xa as D,Ya as O,Yt as te,Za as k,Zl as ne,_a as re,_o as ie,ao as ae,ba as oe,bo as se,co as ce,do as A,eo as le,fo as j,ga as ue,go as de,ha as fe,ho as pe,io as me,ja as he,ka as ge,ko as _e,lo as ve,ma as ye,mo as be,no as xe,nu as M,oo as Se,ou as Ce,po as we,qa as N,ro as Te,ru as Ee,so as De,to as Oe,uo as ke,va as Ae,vo as je,wa as Me,xa as Ne,xo as P,ya as Pe,yo as Fe,za as F}from"./messages-BovT1T-w.js";import{a as I,s as Ie}from"./auth-store-ramu4Ja7.js";import{i as Le,t as Re}from"./router-I0SVmQhl.js";import{r as ze}from"./route-BxpeArPd.js";import{G as Be,m as Ve,o as L,s as R}from"./search-provider-Ddt37OW6.js";import{i as He,t as z}from"./button-DJA4fnJ8.js";import{a as B,l as Ue,r as We,t as Ge}from"./dropdown-menu-CUea1X0A.js";import{d as V,f as Ke,l as H,m as U,p as W,u as G}from"./command-BwVY_kli.js";import{t as qe}from"./label-CsevXZTG.js";import{o as Je,s as Ye}from"./select-u60_CGVx.js";import{t as Xe}from"./cookies-BNZcTwGc.js";import{t as K}from"./createLucideIcon-D28ivbfF.js";import{_ as Ze,d as q,f as Qe,g as $e,h as et,m as tt,n as nt,p as rt,r as it,t as at,v as ot,y as st}from"./data-table-CpxorDbP.js";import{t as ct}from"./chevron-down-CdmvZsfI.js";import{t as lt}from"./download-CN4vU01G.js";import{t as ut}from"./ellipsis-Y4gZr59G.js";import{t as dt}from"./eye-CDavQcLN.js";import{r as ft}from"./empty-state-Cam-sX8U.js";import{n as J}from"./dist-DvAgZMq72.js";import{t as pt}from"./input-DiRPHDd8.js";import{t as mt}from"./page-header-BBJ9dE3-.js";import{t as ht}from"./badge-BAmRBT3U.js";import{t as gt}from"./use-table-url-state-C7-IMA3_.js";import{t as Y}from"./long-text-BXQXVuRh.js";import{t as _t}from"./coming-soon-dialog-DMmjLgiX.js";var X=K(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),vt=K(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Z=Ce(Ee(),1),Q=M();function yt({open:e,onOpenChange:t,order:n,isLoading:a}){let s=[[`Trade ID`,n?.trade_id??`-`],[_(),n?.order_id??`-`],[i(),n?.name??`-`],[o(),`${R(n?.amount)} ${n?.currency??``}`.trim()||`-`],[ee(),`${R(n?.actual_amount,6)} ${n?.token??``}`.trim()||`-`],[Me(),n?.network??`-`],[r(),n?.receive_address??`-`],[S(),n?.notify_url??`-`],[Ne(),n?.redirect_url??`-`],[oe(),n?.block_transaction_id??`-`],[Pe(),n?.parent_trade_id??`-`],[Ae(),L(n?.created_at)||`-`],[re(),L(n?.updated_at)||`-`]];return(0,Q.jsx)(H,{onOpenChange:t,open:e,children:(0,Q.jsxs)(G,{className:`sm:max-w-3xl`,children:[(0,Q.jsxs)(W,{children:[(0,Q.jsx)(U,{children:ue()}),(0,Q.jsx)(V,{children:fe()})]}),a?(0,Q.jsx)(`div`,{className:`py-8 text-center text-muted-foreground text-sm`,children:ye()}):(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:s.map(([e,t])=>(0,Q.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-muted-foreground text-xs`,children:e}),(0,Q.jsx)(`div`,{className:`break-all text-sm`,children:t})]},e))})]})})}var bt={1:`bg-amber-500/10 text-amber-600`,2:`bg-emerald-500/10 text-emerald-600`,3:`bg-rose-500/10 text-rose-600`},xt={1:_e(),2:v(),3:a()};function St(e){return[{id:`expander`,enableHiding:!1,meta:{label:``,skeleton:`action`,sticky:`left`},header:()=>null,cell:({row:e})=>{let t=(e.original.sub_orders?.length??0)>0,n=e.depth*1.5;return(0,Q.jsx)(`div`,{style:{paddingLeft:n?`${n}rem`:void 0},children:t?(0,Q.jsx)(z,{className:`h-6 w-6 p-0`,onClick:()=>e.toggleExpanded(),variant:`ghost`,children:e.getIsExpanded()?(0,Q.jsx)(ct,{className:`h-4 w-4`}):(0,Q.jsx)(Be,{className:`h-4 w-4`})}):null})}},{accessorKey:`status`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:b()}),cell:({row:e})=>{let t=e.original.status??1;return(0,Q.jsx)(ht,{className:bt[t],children:xt[t]??t})},filterFn:(e,t,n)=>n.includes(e.getValue(t)),meta:{label:b(),skeleton:`badge`}},{accessorKey:`trade_id`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:`Trade ID`}),cell:({row:e})=>(0,Q.jsx)(Y,{className:`font-medium`,children:e.original.trade_id}),enableHiding:!1,meta:{label:`Trade ID`,skeleton:`id`}},{accessorKey:`order_id`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:k()}),cell:({row:e})=>(0,Q.jsx)(Y,{className:`min-w-40`,children:e.original.order_id}),meta:{label:k(),skeleton:`id`}},{accessorKey:`name`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:D()}),cell:({row:e})=>e.original.name??`-`,meta:{label:D(),skeleton:`short`}},{accessorKey:`amount`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:O()}),cell:({row:e})=>`${R(e.original.amount)} ${e.original.currency||``}`,meta:{label:O(),skeleton:`amount`}},{accessorKey:`actual_amount`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:f()}),cell:({row:e})=>`${R(e.original.actual_amount,6)} ${e.original.token||``}`,meta:{label:f(),skeleton:`amount`}},{accessorKey:`network`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:N()}),id:`chain`,meta:{label:N(),skeleton:`short`}},{accessorKey:`receive_address`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:p()}),cell:({row:e})=>(0,Q.jsx)(Y,{className:`min-w-36`,children:e.original.receive_address}),meta:{label:p(),skeleton:`long`}},{accessorKey:`created_at`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:l()}),cell:({row:e})=>(0,Q.jsx)(`div`,{className:`min-w-32`,children:L(e.original.created_at)}),meta:{label:l(),skeleton:`date`}},{accessorKey:`updated_at`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:E()}),cell:({row:e})=>L(e.original.updated_at),meta:{label:E(),skeleton:`date`}},{accessorKey:`block_transaction_id`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:w()}),cell:({row:e})=>(0,Q.jsx)(Y,{className:`min-w-40`,children:e.original.block_transaction_id??`-`}),meta:{label:w(),skeleton:`id`}},{accessorKey:`pay_by_sub_id`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:c()}),cell:({row:e})=>{let t=e.original.pay_by_sub_id;return t===0||t==null?`-`:t},meta:{label:c(),skeleton:`id`}},{accessorKey:`payment_type`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:u()}),meta:{label:u(),skeleton:`short`}},{accessorKey:`is_selected`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:T()}),cell:({row:e})=>e.original.is_selected?s():y(),meta:{label:T(),skeleton:`badge`}},{accessorKey:`callback_confirm`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:n()}),cell:({row:e})=>e.original.callback_confirm===1?g():h(),meta:{label:n(),skeleton:`badge`}},{accessorKey:`callback_num`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:F()}),cell:({row:e})=>e.original.callback_num??0,meta:{label:F(),skeleton:`id`}},{accessorKey:`notify_url`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:x()}),cell:({row:e})=>(0,Q.jsx)(Y,{className:`min-w-48`,children:e.original.notify_url??`-`}),meta:{label:x(),skeleton:`long`}},{accessorKey:`redirect_url`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:m()}),cell:({row:e})=>(0,Q.jsx)(Y,{className:`min-w-48`,children:e.original.redirect_url??`-`}),meta:{label:m(),skeleton:`long`}},{accessorKey:`api_key_id`,header:({column:e})=>(0,Q.jsx)(q,{column:e,title:`API Key ID`}),cell:({row:e})=>e.original.api_key_id??`-`,meta:{label:`API Key ID`,skeleton:`id`}},{id:`actions`,enableHiding:!1,meta:{label:d(),skeleton:`action`,sticky:`right`,className:He(`w-12`)},cell:({row:n})=>(0,Q.jsxs)(Ge,{modal:!1,children:[(0,Q.jsx)(Ue,{asChild:!0,children:(0,Q.jsxs)(z,{className:`flex h-8 w-8 p-0 data-[state=open]:bg-muted`,variant:`ghost`,children:[(0,Q.jsx)(ut,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:ge()})]})}),(0,Q.jsxs)(We,{align:`end`,className:`w-44`,children:[(0,Q.jsxs)(B,{onClick:()=>e(j(),n.original),children:[he(),(0,Q.jsx)(dt,{className:`ml-auto h-4 w-4`})]}),(0,Q.jsxs)(B,{onClick:()=>e(A(),n.original),children:[t(),(0,Q.jsx)(vt,{className:`ml-auto h-4 w-4`})]}),(0,Q.jsxs)(B,{onClick:()=>e(C(),n.original),children:[C(),(0,Q.jsx)(X,{className:`ml-auto h-4 w-4`})]}),n.original.status===2&&!!n.original.notify_url&&(0,Q.jsxs)(B,{onClick:()=>e(P(),n.original),children:[P(),(0,Q.jsx)(ft,{className:`ml-auto h-4 w-4`})]})]})]})}]}var $=ze(`/_authenticated/orders/`);function Ct({data:t,isLoading:n,onAction:r,onRefresh:i}){let[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)({}),{globalFilter:l,onGlobalFilterChange:u,columnFilters:d,onColumnFiltersChange:f,pagination:p,onPaginationChange:m,ensurePageInRange:h}=gt({search:$.useSearch(),navigate:$.useNavigate(),pagination:{defaultPage:1,defaultPageSize:10},globalFilter:{enabled:!0,key:`orderNo`},columnFilters:[{columnId:`status`,searchKey:`status`,type:`array`},{columnId:`chain`,searchKey:`chain`,type:`array`}]}),g=Qe({data:t,columns:(0,Z.useMemo)(()=>St(r),[r]),state:{sorting:a,columnVisibility:s,columnFilters:d,globalFilter:l,pagination:p},onSortingChange:o,onColumnVisibilityChange:c,onColumnFiltersChange:f,onGlobalFilterChange:u,onPaginationChange:m,getSubRows:e=>e.sub_orders,paginateExpandedRows:!1,globalFilterFn:(e,t,n)=>{let r=String(n).toLowerCase();return String(e.original.id??``).toLowerCase().includes(r)||String(e.original.order_id??``).toLowerCase().includes(r)},getCoreRowModel:rt(),getExpandedRowModel:tt(),getFilteredRowModel:Ze(),getPaginationRowModel:ot(),getSortedRowModel:st(),getFacetedRowModel:et(),getFacetedUniqueValues:$e()});(0,Z.useEffect)(()=>{h(g.getPageCount())},[g,h]);let _=[...new Set(t.map(e=>e.network).filter(Boolean))].map(e=>({label:e,value:e}));return(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4`,children:[(0,Q.jsx)(at,{filters:[{columnId:`status`,title:xe(),options:[...Le]},{columnId:`chain`,title:Oe(),options:_}],onRefresh:i,searchPlaceholder:le(),table:g}),(0,Q.jsx)(it,{className:`min-w-[1200px]`,emptyText:e(),loading:n,table:g}),(0,Q.jsx)(nt,{className:`mt-auto`,table:g})]})}var wt={[C()]:C(),[P()]:P()};function Tt(){return window.location.origin}function Et(){let e=I.useQuery(`get`,`/admin/api/v1/orders/list-with-sub`),t=I.useMutation(`post`,`/admin/api/v1/orders/{trade_id}/close`),n=I.useMutation(`post`,`/admin/api/v1/orders/{trade_id}/mark-paid`),r=I.useMutation(`post`,`/admin/api/v1/orders/{trade_id}/resend-callback`),i=I.useMutation(`get`,`/admin/api/v1/orders/{trade_id}`),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1);async function y(){await Re.invalidateQueries({queryKey:[`get`,`/admin/api/v1/orders/list-with-sub`]})}async function b(){if(!a?.row.trade_id)return;let e={params:{path:{trade_id:a.row.trade_id}}};a.action===C()?await t.mutateAsync(e):a.action===P()&&await r.mutateAsync(e),J.success(te({action:wt[a.action]})),await y(),o(null)}async function x(){if(!(s?.trade_id&&h.trim())){J.error(se());return}await n.mutateAsync({params:{path:{trade_id:s.trade_id}},body:{block_transaction_id:h.trim()}}),J.success(Fe()),c(null),g(``),await y()}async function S(){v(!0);try{let e=Xe(Ie),t=e?JSON.parse(e):``,n=await fetch(`${Tt()}/admin/api/v1/orders/export`,{headers:t?{Authorization:`Bearer ${t}`}:{}});if(!n.ok)throw Error(`Export failed`);let r=await n.blob(),i=window.URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`orders-${Date.now()}.csv`,a.click(),window.URL.revokeObjectURL(i),J.success(ie())}catch{J.error(je())}finally{v(!1)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ye,{fixed:!0}),(0,Q.jsxs)(Je,{className:`flex flex-1 flex-col gap-4 sm:gap-6`,children:[(0,Q.jsx)(mt,{actions:(0,Q.jsxs)(z,{disabled:_,onClick:S,variant:`outline`,children:[(0,Q.jsx)(lt,{className:`mr-2 h-4 w-4`}),_?de():pe()]}),description:be(),title:we()}),(0,Q.jsx)(Ct,{data:e.data?.data?.list??[],isLoading:e.isLoading,onAction:async(e,t)=>{if(e===j()){m(!0),f((await i.mutateAsync({params:{path:{trade_id:t.trade_id}}})).data??t);return}if(e===A()||e===C()||e===P()){u(!0);return}o({action:e,row:t})},onRefresh:()=>e.refetch()})]}),a&&(0,Q.jsx)(Ve,{confirmText:ke(),desc:(0,Q.jsx)(`span`,{children:ve({action:a.action,id:String(a.row.trade_id??a.row.id??``)})}),handleConfirm:b,onOpenChange:()=>o(null),open:!0,title:ce({action:a.action})}),(0,Q.jsx)(yt,{isLoading:i.isPending,onOpenChange:e=>{m(e),e||f(null)},open:p,order:d}),(0,Q.jsx)(H,{onOpenChange:e=>{e||(c(null),g(``))},open:!!s,children:(0,Q.jsxs)(G,{children:[(0,Q.jsxs)(W,{children:[(0,Q.jsx)(U,{children:De()}),(0,Q.jsx)(V,{children:Se({id:String(s?.trade_id??s?.id??``)})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(qe,{htmlFor:`blockTransactionId`,children:ae()}),(0,Q.jsx)(pt,{id:`blockTransactionId`,onChange:e=>g(e.target.value),placeholder:`0x... / transaction hash`,value:h})]}),(0,Q.jsxs)(Ke,{children:[(0,Q.jsx)(z,{onClick:()=>c(null),variant:`outline`,children:ne()}),(0,Q.jsx)(z,{disabled:n.isPending,onClick:x,children:n.isPending?me():Te()})]})]})}),(0,Q.jsx)(_t,{onOpenChange:u,open:l})]})}var Dt=Et;export{Dt as component}; |