1import{dW as h,a as b,cT as N,k as x,r as i,j as e,B as n,a3 as v,a4 as D,a5 as P,a6 as k,a7 as o,aB as B,aS as S,aT as w,aU as E,aV as T,aW as Q,aX as R,c as I,cC as M}from"./main-To_L_1y0.js";import{r as O}from"./responsive-dialog-DmvfOf_v.js";import{m as V}from"./payouts-D-QEdbTL.js";import{u as A,p as F,P as L}from"./use-create-payout-batch-CfnnsxhE.js";import{P as z}from"./plus-Dmm6tEsW.js";import{C as W}from"./circle-alert-FW1OSRXz.js";import"./copyable-cell-DmLta7Ig.js";import"./status-badge-3MuKKbXq.js";import"./useMutation-B7FocJ-g.js";import"./card-C3vrXP0B.js";import"./label-DhPWvjid.js";import"./switch-Cs1R8cqt.js";import"./merchant-detail-utils-bX_jeLIZ.js";import"./square-pen-CkugJq_h.js";function re(){const{merchantId:r}=h.useParams(),{status:d,create:p}=h.useSearch(),t=b(),j=N("admin-payouts:create"),g=x(M(r)).data?.brand_name,l=x(V(r,d)),m=l.data??[],C=i.useCallback(()=>{t({to:".",search:a=>({...a,create:!0}),replace:!0})},[t]),c=i.useCallback(()=>{t({to:".",search:a=>({...a,create:void 0}),replace:!0})},[t]),s=A(r,{onDone:c}),u=i.useCallback(()=>{s.reset(),c()},[s,c]),f=i.useMemo(()=>F(),[]);return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Payouts"}),j?e.jsxs(n,{onClick:C,size:"sm",children:[e.jsx(z,{className:"h-4 w-4"}),"Create Batch"]}):null]}),e.jsx(L,{merchantId:r}),e.jsx("div",{className:"mb-4",children:e.jsxs(v,{value:d??"all",onValueChange:a=>t({to:".",search:y=>({...y,status:a==="all"?void 0:a})}),children:[e.jsx(D,{className:"w-[160px]",children:e.jsx(P,{placeholder:"All statuses"})}),e.jsxs(k,{children:[e.jsx(o,{value:"all",children:"All statuses"}),e.jsx(o,{value:"pending",children:"Pending"}),e.jsx(o,{value:"processing",children:"Processing"}),e.jsx(o,{value:"completed",children:"Completed"}),e.jsx(o,{value:"failed",children:"Failed"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:l.isError?e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 gap-3 text-muted-foreground",children:[e.jsx(W,{className:"h-8 w-8 text-destructive"}),e.jsx("p",{children:l.error?.message??"Failed to load payout batches."}),e.jsx(n,{variant:"outline",size:"sm",onClick:()=>l.refetch(),children:"Retry"})]}):e.jsx(B,{columns:f,data:m,isLoading:l.isLoading,totalCount:m.length,emptyState:e.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground",children:"No payout batches found."}),onRowClick:a=>t({to:"/payouts/$payoutBatchId",params:{payoutBatchId:a.original.id},search:{merchant_id:r}}),className:"h-full"})}),e.jsx(S,{open:!!p,onOpenChange:a=>!a&&u(),children:e.jsxs(w,{className:O,children:[e.jsxs(E,{children:[e.jsx(T,{children:"Create Payout Batch"}),e.jsxs(Q,{children:["Create a new payout batch for"," ",e.jsx("span",{className:"font-medium text-foreground",children:g??"this merchant"}),"? This will bundle all eligible CONVERTED cross-border transactions."]})]}),s.isError&&e.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800 dark:border-red-800 dark:bg-red-950 dark:text-red-200",children:[e.jsx("p",{className:"font-medium",children:"Error:"}),e.jsx("p",{className:"mt-1",children:s.error.message})]}),e.jsxs(R,{children:[e.jsx(n,{variant:"outline",onClick:u,disabled:s.isPending,children:"Cancel"}),e.jsxs(n,{onClick:()=>s.mutate(),disabled:s.isPending,children:[s.isPending&&e.jsx(I,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Batch"]})]})]})})]})}export{re as component};
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.