1import{j as e}from"./vendor-query-DXQz-G-n.js";import{u as P,r as g}from"./vendor-react-UDtOjBVY.js";import{I as D}from"./IconDownload-BI5_73u3.js";import{u as f}from"./vendor-ui-GdHffJNH.js";import{c as I,s as _,g as E,e as k}from"./swap-hooks-C4b_wW_T.js";import{u as z}from"./usePersistedTableFilters-C1Q5Rtsf.js";import{P as S}from"./PageHeader-CDex3Fjd.js";import{t as F,a as q}from"./statusBadgeVariant-Cnk71OSd.js";import{K,bE as T,c5 as B,bF as L,u as R,c6 as V}from"./index-UEZkOO2I.js";import{B as A}from"./badge-CRnoYkek.js";import{N as H}from"./NationalSwapCreateAction-CxhQaFW7.js";import{u as M}from"./use-table-state-CuVM3Qyx.js";import{u as Q}from"./use-server-paginated-query-CjNpbYyj.js";import{B as $}from"./button-CNe8f_9i.js";import{S as l}from"./select-DPuFNQOi.js";import{D as O}from"./data-table-DGa0Yf7J.js";import"./contracts-yz9VotRY.js";import"./download-CBSMuAGV.js";import"./IconPlus-Ch4g8rF6.js";import"./hooks-8nfbzETC.js";import"./hooks-D-Y4g-WP.js";import"./hooks-B5aqQiNO.js";import"./form-modal-0EDf5Pjp.js";import"./IconCheck-C4yarnKh.js";import"./input-xyAn92SA.js";import"./IconCalendar-BkKdedXD.js";import"./combobox-BJdPdv2l.js";import"./index-BnQOV3pI.js";import"./confirm-modal-dLNyTExr.js";import"./index-i5a15ItW.js";import"./IconSearch-DNXPliZk.js";import"./IconChevronLeft-CKebVIDy.js";import"./IconChevronRight-CUgA3LJg.js";function y(t,m){const i=(a,s)=>(t==null?void 0:t(a,{params:s}))??T(L,B,a,{params:s});return[{key:"player_name",header:i("swaps.table.player"),sortable:!0,render:a=>{var s,c;return e.jsxs("span",{className:"text-sm font-semibold text-primary-900",children:[(s=a.player)==null?void 0:s.firstname," ",(c=a.player)==null?void 0:c.lastname]})}},{key:"from_club",header:i("swaps.table.originClub"),sortable:!0,render:a=>{var s;return e.jsx("span",{className:"text-sm text-primary-700",children:((s=a.from_club)==null?void 0:s.name)??i("common.empty")})}},{key:"club",header:i("swaps.table.destinationClub"),sortable:!0,render:a=>{var s;return e.jsx("span",{className:"text-sm text-primary-700",children:((s=a.club)==null?void 0:s.name)??i("common.empty")})}},{key:"union",header:i("swaps.table.union",{union:m??i("terminology.union.singular")}),sortable:!0,render:a=>{var s;return e.jsx("span",{className:"text-sm text-primary-700",children:((s=a.union)==null?void 0:s.name)??i("common.empty")})}},{key:"requestdate",header:i("swaps.table.requestDate"),sortable:!0,className:"w-32",render:a=>e.jsx("span",{className:"text-xs text-primary-600",children:K(a.requestdate)})},{key:"status_id",header:i("swaps.table.status"),sortable:!0,className:"w-28",render:a=>e.jsx(A,{variant:q(a.status_id),children:a.status_name??F(a.status_id,t)})}]}y();function Pe(){var h;const t=R(),{terminology:m}=V(),i=P(),{filters:a,setFilter:s}=z({activeStatusId:""}),c=a.activeStatusId?Number(a.activeStatusId):null,r=M({initialSortKey:"requestdate",initialSortDir:"desc"}),{data:p}=I(),b=(p==null?void 0:p.data)??[],u={...c!=null?{status_id:c}:void 0},{data:n,isLoading:w,isError:j}=Q({queryKey:[..._.list(u)],queryFn:o=>E(o,u),tableState:r}),[v,d]=g.useState(!1),x=((h=m==null?void 0:m.union)==null?void 0:h.singular)??t("terminology.union.singular"),C=g.useMemo(()=>y(t,x),[t,x]);if(j)return e.jsxs("div",{children:[e.jsx(S,{title:t("swaps.title")}),e.jsx("div",{className:"rounded-lg bg-error-50 p-4 text-center text-error-600",children:t("common.error.loadData")})]});const N=async()=>{d(!0);try{await k(),f.success(t("common.success.exportDownloaded"))}catch{f.error(t("common.error.export"))}finally{d(!1)}};return e.jsxs("div",{children:[e.jsx(S,{title:t("swaps.title"),actions:e.jsxs(e.Fragment,{children:[e.jsxs($,{variant:"outline",size:"sm",onClick:N,loading:v,children:[e.jsx(D,{size:16}),t("swaps.list.export")]}),e.jsx(H,{})]})}),e.jsx("div",{className:"mb-5 flex flex-wrap gap-3",children:e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1",children:[e.jsx("span",{className:"text-xs font-medium text-primary-600",children:t("swaps.list.filter.status")}),e.jsxs(l.Root,{value:a.activeStatusId||"all",onValueChange:o=>{s("activeStatusId",o!=="all"?o:""),r.onPageChange(1)},children:[e.jsx(l.Trigger,{size:"sm",children:e.jsx(l.Value,{placeholder:t("swaps.list.filter.allStatuses")})}),e.jsxs(l.Content,{children:[e.jsx(l.Item,{value:"all",children:t("swaps.list.filter.allStatuses")}),b.map(o=>e.jsx(l.Item,{value:String(o.id),children:o.name},o.id))]})]})]})}),e.jsx(O,{columns:C,data:(n==null?void 0:n.items)??[],loading:w,emptyMessage:r.search?t("swaps.list.emptySearch",{params:{search:r.search}}):t("swaps.list.empty"),sortKey:r.sortKey,sortDir:r.sortDir,onSort:r.onSort,page:r.page,pageSize:r.pageSize,total:(n==null?void 0:n.total)??0,onPageChange:r.onPageChange,onPageSizeChange:r.onPageSizeChange,searchValue:r.search,onSearchChange:r.onSearchChange,searchPlaceholder:t("swaps.list.searchPlaceholder"),onRowClick:o=>i(`/pases-nacionales/${o.id}`),getRowHref:o=>`/pases-nacionales/${o.id}`})]})}
1export{Pe 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.