1import{r as n,b as w,a6 as k,u as $,h as j,j as e,a9 as A,ah as N,ag as v,d as L,S as D}from"./index-D43MT5hw.js";const F=({status:i})=>{const m=i==="Open"?"bg-green-100 text-green-700 ring-green-200":i==="Closed"?"bg-amber-100 text-amber-700 ring-amber-200":"bg-gray-100 text-gray-700 ring-gray-200";return e.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium ring-1 ${m}`,children:i})},_=()=>{const[i,m]=n.useState(""),[E,p]=n.useState(!1),[z,h]=n.useState(null),{domain:g}=w(),[b,f]=n.useState([]),[r,P]=n.useState("active"),u=k(i,300),C=$(),S=t=>{C(`/auctions/detail/${t}`)},[o,c]=n.useState({currentPage:1,perPage:20,total:0,lastPage:0}),y=n.useCallback(async()=>{p(!0),h(null);const t=new Date,l=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${t.getDate()}`;try{const a=r==="active"?await j.getAuctions(g,o.currentPage,u):await j.getAuctionsForArchive(g,o.currentPage,u,l);f(a?.data??[]),c(s=>({...s,currentPage:a?.meta?.current_page??s.currentPage,perPage:a?.meta?.per_page??s.perPage,total:a?.meta?.total??s.total,lastPage:a?.meta?.last_page??1}))}catch(a){console.error("Error fetching auctions:",a),h(a),f([]),c(s=>({...s,lastPage:1,total:0}))}finally{p(!1)}},[g,o.currentPage,u,r]);return n.useEffect(()=>{y()},[y]),n.useEffect(()=>{c(t=>({...t,currentPage:1}))},[r]),e.jsx("section",{className:"w-full relative",children:e.jsxs("div",{className:"mx-auto w-[95%] py-4 z-30 relative min-h-[60vh]",children:[e.jsxs("div",{className:"mt-2 md:flex justify-between items-center gap-3",children:[e.jsx(A,{title:"Auctions",description:"Manage and view all auctions"}),e.jsxs("div",{className:"w-full sm:w-80",children:[e.jsx("label",{className:"sr-only",children:"Search auctions"}),e.jsx("input",{value:i,onChange:t=>{m(t.target.value),c(l=>({...l,currentPage:1}))},type:"text",placeholder:"Search by title, auction no , dept...",className:"w-full rounded-lg my-2 border border-gray-200 bg-white px-3 py-2 text-sm outline-none ring-emerald-200 focus:ring-2"})]})]}),e.jsxs("div",{className:"flex justify-end items-center gap-3 p-2",children:[e.jsx("span",{className:`text-sm font-semibold ${r==="active"?"text-slate-900":"text-slate-400"}`,children:"Active"}),e.jsxs("button",{type:"button",role:"switch","aria-checked":r==="archive",onClick:()=>{P(r==="active"?"archive":"active"),c(t=>({...t,currentPage:1}))},className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors 2 ${r==="archive"?"bg-slate-600":"bg-emerald-500"} 3 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2`,children:[e.jsx("span",{className:`inline-block h-5 w-5 transform rounded-full bg-white shadow transition-transform 4 ${r==="archive"?"translate-x-5":"translate-x-1"}`}),e.jsx("span",{className:"sr-only",children:"Toggle active/archive"})]}),e.jsx("span",{className:`text-sm font-semibold ${r==="archive"?"text-slate-900":"text-slate-400"}`,children:"Archive"})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-200 bg-white",children:e.jsxs("table",{className:"min-w-full text-left text-sm",children:[e.jsx("thead",{className:"background-linear text-white",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-6 font-semibold",children:"S.No"}),e.jsx("th",{className:"px-4 py-6 font-semibold",children:"Title"}),e.jsx("th",{className:"px-4 py-6 font-semibold",children:"Closing Date"}),e.jsx("th",{className:"px-4 py-6 font-semibold",children:"Status"}),e.jsx("th",{className:"px-4 py-6 font-semibold",children:"Department"}),e.jsx("th",{className:"px-4 py-6 font-semibold text-right",children:"Auction Notice"}),e.jsx("th",{className:"px-4 py-6 font-semibold text-right",children:"File"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:b.length>0?b.map((t,l)=>{const a=t?.notice_media?.file_path,s=t?.document_media?.file_path,d=!a,x=!s;return e.jsxs("tr",{className:"hover:bg-gray-50/70",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-gray-900",children:(o.currentPage-1)*o.perPage+(l+1)}),e.jsx("td",{className:"px-4 py-3 text-gray-800 hover:underline cursor-pointer",onClick:()=>S(t.uuid),children:t.title}),e.jsx("td",{className:"px-4 py-3 text-gray-700",children:t.deadline_formatted}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(F,{status:t.status=="active"?"Open":"Closed"})}),e.jsx("td",{className:"px-4 py-3 text-gray-800 hover:underline cursor-pointer",children:t.department?.name??""}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{type:"button",disabled:d,onClick:()=>a&&window.open(a,"_blank","noopener,noreferrer"),className:`rounded-lg px-3 py-2 text-xs font-semibold cursor-pointer ${d?"opacity-50 cursor-not-allowed":""}`,children:e.jsxs("span",{className:`${d?"":"text-[#0289CC]"} inline-flex items-center gap-2`,children:[d?e.jsx(N,{size:20}):e.jsx(v,{size:20}),d?"No File":"File"]})})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("button",{type:"button",disabled:x,onClick:()=>s&&window.open(s,"_blank","noopener,noreferrer"),className:`rounded-lg px-3 py-2 text-xs font-semibold cursor-pointer ${x?"opacity-50 cursor-not-allowed":""}`,children:e.jsxs("span",{className:`${x?"":"text-[#0289CC]"} inline-flex items-center gap-2`,children:[x?e.jsx(N,{size:20}):e.jsx(v,{size:20}),x?"No File":"File"]})})})]},`${t.auction_number}-${l}`)}):e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-4 py-8 text-center text-sm text-gray-500",children:"No data found"})})})]})}),e.jsx(L,{forcePage:(o.currentPage??1)-1,pageCount:o.lastPage,onPageChange:t=>{const l=t.selected+1;c(a=>({...a,currentPage:l}))},pageRangeDisplayed:3,marginPagesDisplayed:1,previousLabel:"< Prev",nextLabel:"Next >",breakLabel:"â¦",containerClassName:"flex items-center justify-start gap-2 mt-6",pageClassName:"cursor-pointer",pageLinkClassName:"min-w-[40px] bg-white px-3 py-2 rounded-md text-sm border hover:bg-gray-50",activeLinkClassName:"background-linear border text-white border-emerald-900",previousLinkClassName:"px-3 py-2 rounded-md border text-sm hover:bg-gray-50",nextLinkClassName:"px-3 py-2 rounded-md border text-sm hover:bg-gray-50",disabledLinkClassName:"opacity-50 cursor-not-allowed hover:bg-transparent",breakLinkClassName:"px-2 text-sm text-gray-500"})]})]})})},O=()=>{const{basicInfo:i}=w();return e.jsxs(e.Fragment,{children:[e.jsx(D,{title:`${i?.title.replace(/\r?\n/g," ")}`,titleSuffix:"Auctions",description:"",keywords:"",type:"article"}),e.jsx(_,{})]})};export{O 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.