95879e33d4
- keep install-mode root redirect to /install and add tests covering install root redirect and install page serving
- change root backend handler from Any("/") to POST("/") so GET / can consistently serve the SPA after install
Co-authored-by: Copilot <copilot@github.com>
1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
import{$a as e,$o as t,$u as n,Ao as r,Ba as i,Bo as a,Co as o,Do as s,Eo as c,Fo as l,Ga as u,Go as d,Ha as f,Ho as ee,Io as p,Ja as m,Ka as h,Ko as g,Lo as te,Mo as ne,No as re,Oo as ie,Po as ae,Qa as _,Qo as v,Qu as y,Ra as oe,Ro as se,So as b,To as x,Ua as S,Uo as ce,Va as C,Vo as le,Wa as w,Wo as ue,Xa as T,Ya as E,Za as D,Zo as O,_o as k,ao as de,bo as A,co as j,dn as fe,do as M,eo as pe,fo as N,go as P,ho as F,io as me,jo as he,ko as ge,lo as I,mo as L,nd as _e,no as ve,oo as ye,po as R,qa as be,qu as xe,ro as Se,sc as z,so as B,to as Ce,uo as V,vo as H,wo as we,xo as U,yo as Te,za as Ee,zo as De}from"./messages-BOl-zx8S.js";import{a as W,s as Oe}from"./auth-store-D_jr_Pei.js";import{i as ke,t as Ae}from"./router-D0lu_-Oq.js";import{r as je}from"./route-C5Xnq6N2.js";import{o as G,s as K}from"./search-provider-D-fTfilE.js";import{i as Me,t as q}from"./button-D-oR8d6w.js";import{t as Ne}from"./confirm-dialog-DyK21C4Z.js";import{a as J,l as Pe,r as Fe,t as Ie}from"./dropdown-menu-HbmfecEg.js";import{t as Le}from"./label-B2Q8_O-h.js";import{n as Re}from"./skeleton-gJOqI-7w.js";import{t as ze}from"./cookies-D0aVbsDr.js";import{t as Be}from"./createLucideIcon-DMX28cCu.js";import{_ as Ve,d as Y,f as He,g as Ue,h as We,m as Ge,n as Ke,p as qe,r as Je,t as Ye,v as Xe,y as Ze}from"./data-table-C3uNvchK.js";import{t as Qe}from"./chevron-down-uSXLUPEl.js";import{t as $e}from"./download-BhpqmSj0.js";import{t as et}from"./ellipsis-DvvxWQuy.js";import{t as tt}from"./eye-CJkHHosh.js";import{r as nt}from"./empty-state-BelJgFUf.js";import{n as rt,t as it}from"./main-DvsnNI3V.js";import{d as at,f as ot,l as st,m as ct,p as lt,u as ut}from"./command-yFHhtFiR.js";import{n as X}from"./dist-BNiRpK39.js";import{t as dt}from"./input-CZHXycLK.js";import{t as ft}from"./page-header-BRM1dngJ.js";import{t as pt}from"./badge-D-FAREMY.js";import{t as mt}from"./use-table-url-state-BYcGNz1q.js";import{t as Z}from"./long-text-XqSY0a1g.js";import{t as ht}from"./coming-soon-dialog-DIE5FD4U.js";var gt=Be(`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`}]]),_t=Be(`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`}]]),Q=_e(n(),1),$=y();function vt({open:e,onOpenChange:t,order:n,isLoading:r}){let a=[[`Trade ID`,n?.trade_id??`-`],[_(),n?.order_id??`-`],[D(),n?.name??`-`],[T(),`${K(n?.amount)} ${n?.currency??``}`.trim()||`-`],[E(),`${K(n?.actual_amount,6)} ${n?.token??``}`.trim()||`-`],[m(),n?.network??`-`],[be(),n?.receive_address??`-`],[h(),n?.notify_url??`-`],[u(),n?.redirect_url??`-`],[w(),n?.block_transaction_id??`-`],[S(),n?.parent_trade_id??`-`],[f(),G(n?.created_at)||`-`],[C(),G(n?.updated_at)||`-`]];return(0,$.jsx)(st,{onOpenChange:t,open:e,children:(0,$.jsxs)(ut,{className:`sm:max-w-3xl`,children:[(0,$.jsxs)(lt,{children:[(0,$.jsx)(ct,{children:i()}),(0,$.jsx)(at,{children:Ee()})]}),r?(0,$.jsx)(`div`,{className:`py-8 text-center text-muted-foreground text-sm`,children:oe()}):(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:a.map(([e,t])=>(0,$.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,$.jsx)(`div`,{className:`mb-1 text-muted-foreground text-xs`,children:e}),(0,$.jsx)(`div`,{className:`break-all text-sm`,children:t})]},e))})]})})}var yt={1:`bg-amber-500/10 text-amber-600`,2:`bg-emerald-500/10 text-emerald-600`,3:`bg-rose-500/10 text-rose-600`},bt={1:t(),2:v(),3:O()};function xt(t){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,$.jsx)(`div`,{style:{paddingLeft:n?`${n}rem`:void 0},children:t?(0,$.jsx)(q,{className:`h-6 w-6 p-0`,onClick:()=>e.toggleExpanded(),variant:`ghost`,children:e.getIsExpanded()?(0,$.jsx)(Qe,{className:`h-4 w-4`}):(0,$.jsx)(Re,{className:`h-4 w-4`})}):null})}},{accessorKey:`status`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:b()}),cell:({row:e})=>{let t=e.original.status??1;return(0,$.jsx)(pt,{className:yt[t],children:bt[t]??t})},filterFn:(e,t,n)=>n.includes(e.getValue(t)),meta:{label:b(),skeleton:`badge`}},{accessorKey:`trade_id`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:`Trade ID`}),cell:({row:e})=>(0,$.jsx)(Z,{className:`font-medium`,children:e.original.trade_id}),enableHiding:!1,meta:{label:`Trade ID`,skeleton:`id`}},{accessorKey:`order_id`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:U()}),cell:({row:e})=>(0,$.jsx)(Z,{className:`min-w-40`,children:e.original.order_id}),meta:{label:U(),skeleton:`id`}},{accessorKey:`name`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:A()}),cell:({row:e})=>e.original.name??`-`,meta:{label:A(),skeleton:`short`}},{accessorKey:`amount`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:Te()}),cell:({row:e})=>`${K(e.original.amount)} ${e.original.currency||``}`,meta:{label:Te(),skeleton:`amount`}},{accessorKey:`actual_amount`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:H()}),cell:({row:e})=>`${K(e.original.actual_amount,6)} ${e.original.token||``}`,meta:{label:H(),skeleton:`amount`}},{accessorKey:`network`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:k()}),id:`chain`,meta:{label:k(),skeleton:`short`}},{accessorKey:`receive_address`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:P()}),cell:({row:e})=>(0,$.jsx)(Z,{className:`min-w-36`,children:e.original.receive_address}),meta:{label:P(),skeleton:`long`}},{accessorKey:`created_at`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:F()}),cell:({row:e})=>(0,$.jsx)(`div`,{className:`min-w-32`,children:G(e.original.created_at)}),meta:{label:F(),skeleton:`date`}},{accessorKey:`updated_at`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:L()}),cell:({row:e})=>G(e.original.updated_at),meta:{label:L(),skeleton:`date`}},{accessorKey:`block_transaction_id`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:R()}),cell:({row:e})=>(0,$.jsx)(Z,{className:`min-w-40`,children:e.original.block_transaction_id??`-`}),meta:{label:R(),skeleton:`id`}},{accessorKey:`pay_by_sub_id`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:z()}),cell:({row:e})=>{let t=e.original.pay_by_sub_id;return t===0||t==null?`-`:t},meta:{label:z(),skeleton:`id`}},{accessorKey:`payment_type`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:N()}),meta:{label:N(),skeleton:`short`}},{accessorKey:`is_selected`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:M()}),cell:({row:e})=>e.original.is_selected?de():me(),meta:{label:M(),skeleton:`badge`}},{accessorKey:`callback_confirm`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:V()}),cell:({row:e})=>e.original.callback_confirm===1?Se():ve(),meta:{label:V(),skeleton:`badge`}},{accessorKey:`callback_num`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:I()}),cell:({row:e})=>e.original.callback_num??0,meta:{label:I(),skeleton:`id`}},{accessorKey:`notify_url`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:j()}),cell:({row:e})=>(0,$.jsx)(Z,{className:`min-w-48`,children:e.original.notify_url??`-`}),meta:{label:j(),skeleton:`long`}},{accessorKey:`redirect_url`,header:({column:e})=>(0,$.jsx)(Y,{column:e,title:B()}),cell:({row:e})=>(0,$.jsx)(Z,{className:`min-w-48`,children:e.original.redirect_url??`-`}),meta:{label:B(),skeleton:`long`}},{accessorKey:`api_key_id`,header:({column:e})=>(0,$.jsx)(Y,{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:ye(),skeleton:`action`,sticky:`right`,className:Me(`w-12`)},cell:({row:n})=>(0,$.jsxs)(Ie,{modal:!1,children:[(0,$.jsx)(Pe,{asChild:!0,children:(0,$.jsxs)(q,{className:`flex h-8 w-8 p-0 data-[state=open]:bg-muted`,variant:`ghost`,children:[(0,$.jsx)(et,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:e()})]})}),(0,$.jsxs)(Fe,{align:`end`,className:`w-44`,children:[(0,$.jsxs)(J,{onClick:()=>t(p(),n.original),children:[Ce(),(0,$.jsx)(tt,{className:`ml-auto h-4 w-4`})]}),(0,$.jsxs)(J,{onClick:()=>t(l(),n.original),children:[pe(),(0,$.jsx)(_t,{className:`ml-auto h-4 w-4`})]}),(0,$.jsxs)(J,{onClick:()=>t(g(),n.original),children:[g(),(0,$.jsx)(gt,{className:`ml-auto h-4 w-4`})]}),n.original.status===2&&!!n.original.notify_url&&(0,$.jsxs)(J,{onClick:()=>t(d(),n.original),children:[d(),(0,$.jsx)(nt,{className:`ml-auto h-4 w-4`})]})]})]})}]}var St=je(`/_authenticated/orders/`);function Ct({data:e,isLoading:t,onAction:n,onRefresh:r}){let[i,a]=(0,Q.useState)([]),[s,l]=(0,Q.useState)({}),{globalFilter:u,onGlobalFilterChange:d,columnFilters:f,onColumnFiltersChange:ee,pagination:p,onPaginationChange:m,ensurePageInRange:h}=mt({search:St.useSearch(),navigate:St.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=He({data:e,columns:(0,Q.useMemo)(()=>xt(n),[n]),state:{sorting:i,columnVisibility:s,columnFilters:f,globalFilter:u,pagination:p},onSortingChange:a,onColumnVisibilityChange:l,onColumnFiltersChange:ee,onGlobalFilterChange:d,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:qe(),getExpandedRowModel:Ge(),getFilteredRowModel:Ve(),getPaginationRowModel:Xe(),getSortedRowModel:Ze(),getFacetedRowModel:We(),getFacetedUniqueValues:Ue()});(0,Q.useEffect)(()=>{h(g.getPageCount())},[g,h]);let te=[...new Set(e.map(e=>e.network).filter(Boolean))].map(e=>({label:e,value:e}));return(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4`,children:[(0,$.jsx)(Ye,{filters:[{columnId:`status`,title:c(),options:[...ke]},{columnId:`chain`,title:x(),options:te}],onRefresh:r,searchPlaceholder:we(),table:g}),(0,$.jsx)(Je,{className:`min-w-[1200px]`,emptyText:o(),loading:t,table:g}),(0,$.jsx)(Ke,{className:`mt-auto`,table:g})]})}var wt={[g()]:g(),[d()]:d()};function Tt(){return window.location.origin}function Et(){let e=W.useQuery(`get`,`/admin/api/v1/orders/list-with-sub`),t=W.useMutation(`post`,`/admin/api/v1/orders/{trade_id}/close`),n=W.useMutation(`post`,`/admin/api/v1/orders/{trade_id}/mark-paid`),i=W.useMutation(`post`,`/admin/api/v1/orders/{trade_id}/resend-callback`),o=W.useMutation(`get`,`/admin/api/v1/orders/{trade_id}`),[c,u]=(0,Q.useState)(null),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),[oe,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(!1);async function T(){await Ae.invalidateQueries({queryKey:[`get`,`/admin/api/v1/orders/list-with-sub`]})}async function E(){if(!c?.row.trade_id)return;let e={params:{path:{trade_id:c.row.trade_id}}};c.action===g()?await t.mutateAsync(e):c.action===d()&&await i.mutateAsync(e),X.success(fe({action:wt[c.action]})),await T(),u(null)}async function D(){if(!(f?.trade_id&&x.trim())){X.error(ue());return}await n.mutateAsync({params:{path:{trade_id:f.trade_id}},body:{block_transaction_id:x.trim()}}),X.success(ce()),m(null),S(``),await T()}async function O(){w(!0);try{let e=ze(Oe),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),X.success(le())}catch{X.error(ee())}finally{w(!1)}}return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rt,{fixed:!0}),(0,$.jsxs)(it,{className:`flex flex-1 flex-col gap-4 sm:gap-6`,children:[(0,$.jsx)(ft,{actions:(0,$.jsxs)(q,{disabled:C,onClick:O,variant:`outline`,children:[(0,$.jsx)($e,{className:`mr-2 h-4 w-4`}),C?a():De()]}),description:se(),title:te()}),(0,$.jsx)(Ct,{data:e.data?.data?.list??[],isLoading:e.isLoading,onAction:async(e,t)=>{if(e===p()){b(!0),y((await o.mutateAsync({params:{path:{trade_id:t.trade_id}}})).data??t);return}if(e===l()||e===g()||e===d()){_(!0);return}u({action:e,row:t})},onRefresh:()=>e.refetch()})]}),c&&(0,$.jsx)(Ne,{confirmText:ae(),desc:(0,$.jsx)(`span`,{children:re({action:c.action,id:String(c.row.trade_id??c.row.id??``)})}),handleConfirm:E,onOpenChange:()=>u(null),open:!0,title:ne({action:c.action})}),(0,$.jsx)(vt,{isLoading:o.isPending,onOpenChange:e=>{b(e),e||y(null)},open:oe,order:v}),(0,$.jsx)(st,{onOpenChange:e=>{e||(m(null),S(``))},open:!!f,children:(0,$.jsxs)(ut,{children:[(0,$.jsxs)(lt,{children:[(0,$.jsx)(ct,{children:he()}),(0,$.jsx)(at,{children:r({id:String(f?.trade_id??f?.id??``)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Le,{htmlFor:`blockTransactionId`,children:ge()}),(0,$.jsx)(dt,{id:`blockTransactionId`,onChange:e=>S(e.target.value),placeholder:`0x... / transaction hash`,value:x})]}),(0,$.jsxs)(ot,{children:[(0,$.jsx)(q,{onClick:()=>m(null),variant:`outline`,children:xe()}),(0,$.jsx)(q,{disabled:n.isPending,onClick:D,children:n.isPending?ie():s()})]})]})}),(0,$.jsx)(ht,{onOpenChange:_,open:h})]})}var Dt=Et;export{Dt as component}; |