1import{u as L,r as m,d as D,j as e,L as T,B as j,a as f,b as _,q as R,t as w}from"./index-CudHG6B4.js";import{u as P}from"./useMutation-CBAYgnG2.js";import{A as k}from"./AdminLayout-BZuCIv3f.js";import{C as I,a as z}from"./card-5b9UOcPu.js";import{B}from"./badge-CMf0SrHQ.js";import{I as $}from"./input-kx1YXBs7.js";import{T as q,a as E,b as n}from"./tabs-CZVTTJLT.js";import{T as F,a as M,b,c as l,d as O,e as o}from"./table-Hzp9xhRa.js";import{S as H}from"./skeleton-BegiI0pz.js";import{A as U,a as K,b as Q,c as G,d as V,e as W,f as J,g as X}from"./alert-dialog-BT3erKQG.js";import{S as Y}from"./TransparencyPage-Ylxz21fu.js";import{A as Z}from"./arrow-right-B1UlrPw0.js";import{T as ee}from"./trash-2-B1etNceJ.js";import"./InstitutionRegister-CdUSyHyq.js";import"./alert-kp6gCZ70.js";import"./label-B2onvOiF.js";import"./index-C1iJF-SR.js";import"./chevron-up-qSRaMRim.js";import"./check-D8BjNWtW.js";import"./building-2-CMfa6c9V.js";import"./shield-check-ic92rXB7.js";import"./users-DX1W4CCh.js";import"./AuthenticatedApplication-C2-e6xTS.js";import"./connectors-BciFpN0c.js";import"./circle-alert-CRUc3mQk.js";import"./textarea-C9FUOvKW.js";import"./circle-C1ccQMbh.js";import"./chevron-right-Dr8cwl4J.js";import"./user-DCnI1kiW.js";import"./arrow-left-lxn-dpfG.js";import"./clock-DzjvzExH.js";import"./triangle-alert-BA2tGhup.js";import"./file-text-76AiIfll.js";import"./circle-check-CTosiqnS.js";import"./AboutPage-CamkJ7cK.js";import"./PrivacyPage-Beavwhs0.js";import"./TermsPage-SeBMfIpe.js";import"./BackingDashboard-CVY4Rsg2.js";import"./shield-Hr0aqzVI.js";import"./layers-Ca3pv70P.js";import"./dollar-sign-BcfyEtLy.js";import"./LandVerifyPage-NEwI3vUf.js";import"./award-BusU1ju6.js";import"./hash-DyzAXdJv.js";import"./globe-NLl4Wr5a.js";import"./scale-DM0tAT-O.js";import"./calendar-BTBtzozc.js";import"./trending-up-C66B21n6.js";import"./landmark-BA_0Cnnl.js";import"./LandCertificate-Du_3NAH9.js";import"./printer-C2HCk7DD.js";import"./OnchainDocsPage-DDA6342p.js";import"./book-open-DvSukaGG.js";import"./code-CMLileHq.js";import"./sprout-z_rucUaP.js";import"./ProtocolPage-UaH8jgc9.js";import"./LandProtocolDevRef-_yp8P5Ot.js";import"./InstitutionInvitePage-CIc8kA4i.js";import"./FlowOfFundsPage-BjbpHgzo.js";import"./CapitalProviderChoice-C78InrEx.js";import"./IndividualProviderRegister-DyWPKEYx.js";const te={pending:{label:"In Review",variant:"secondary"},in_review:{label:"In Review",variant:"secondary"},needs_action:{label:"Needs Action",variant:"destructive"},rejected:{label:"Rejected",variant:"destructive"},approved:{label:"Active",variant:"default"},tokenized:{label:"Active",variant:"default"},deactivating:{label:"Deactivating",variant:"outline"},deactivated:{label:"Deactivated",variant:"outline"}};function ae(c){switch(c.status){case"pending":case"in_review":return"Review documents";case"needs_action":return"Waiting for owner";case"approved":return c.tokenized?"Active":"Mint tokens";case"tokenized":return"Active";case"deactivating":return"Complete deactivation";default:return"-"}}function mt(){const[c]=L(),N=new URLSearchParams(c.split("?")[1]||"").get("filter")||"all",[u,y]=m.useState(N),[d,A]=m.useState(""),[s,p]=m.useState(null),[C,h]=m.useState(null),{data:x=[],isLoading:S}=D({queryKey:["/api/admin/lands"]}),i=P({mutationFn:t=>_("POST",`/api/admin/lands/${t.id}/purge`,{confirm:`PURGE_LAND_${t.id}`}),onMutate:t=>{h(t.id)},onSuccess:(t,a)=>{R.invalidateQueries({queryKey:["/api/admin/lands"]}),w.success(`"${a.name}" deleted`)},onError:(t,a)=>{w.error(`Could not delete "${a.name}". Please try again.`)},onSettled:()=>{h(null)}}),v=x.filter(t=>{var r,g;if(!(t.name.toLowerCase().includes(d.toLowerCase())||(((r=t.ownerName)==null?void 0:r.toLowerCase())||"").includes(d.toLowerCase())||(((g=t.location)==null?void 0:g.toLowerCase())||"").includes(d.toLowerCase())))return!1;switch(u){case"in_review":return t.status==="pending"||t.status==="in_review";case"needs_action":return t.status==="needs_action"||t.status==="rejected";case"active":return t.status==="approved"||t.status==="tokenized";case"deactivating":return t.status==="deactivating"||t.status==="deactivated";default:return!0}});return e.jsxs(k,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900",children:"Land Management"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Review and manage all land parcels on the platform"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-between",children:[e.jsx(q,{value:u,onValueChange:y,children:e.jsxs(E,{children:[e.jsxs(n,{value:"all",children:["All (",x.length,")"]}),e.jsx(n,{value:"in_review",children:"In Review"}),e.jsx(n,{value:"needs_action",children:"Needs Action"}),e.jsx(n,{value:"active",children:"Active"}),e.jsx(n,{value:"deactivating",children:"Deactivating"})]})}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx($,{placeholder:"Search lands...",value:d,onChange:t=>A(t.target.value),className:"pl-9"})]})]}),e.jsx(I,{children:e.jsx(z,{className:"p-0",children:S?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3,4,5].map(t=>e.jsx(H,{className:"h-12 w-full"},t))}):v.length===0?e.jsx("div",{className:"p-8 text-center text-gray-500",children:"No lands found matching your criteria"}):e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(b,{children:[e.jsx(l,{children:"Parcel Name"}),e.jsx(l,{children:"Owner"}),e.jsx(l,{children:"Status"}),e.jsx(l,{children:"Next Step"}),e.jsx(l,{className:"w-[120px]"})]})}),e.jsx(O,{children:v.map(t=>{const a=te[t.status]||{label:t.status,variant:"secondary"},r=C===t.id;return e.jsxs(b,{children:[e.jsx(o,{className:"font-medium",children:t.name}),e.jsx(o,{className:"text-gray-600",children:t.ownerName||"-"}),e.jsx(o,{children:e.jsx(B,{variant:a.variant,children:a.label})}),e.jsx(o,{className:"text-gray-600 text-sm",children:ae(t)}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(T,{href:`/admin/land/${t.id}`,children:e.jsxs(j,{variant:"ghost",size:"sm",children:["Open ",e.jsx(Z,{className:"h-4 w-4 ml-1"})]})}),e.jsx(j,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>p(t),disabled:r,"aria-label":`Delete ${t.name}`,children:r?e.jsx(f,{className:"h-4 w-4 animate-spin"}):e.jsx(ee,{className:"h-4 w-4"})})]})})]},t.id)})})]})})})]}),e.jsx(U,{open:s!==null,onOpenChange:t=>{!t&&!i.isPending&&p(null)},children:e.jsxs(K,{children:[e.jsxs(Q,{children:[e.jsx(G,{children:"Delete land parcel?"}),e.jsxs(V,{children:["This will permanently delete ",e.jsx("strong",{children:s==null?void 0:s.name})," and all associated records, including documents, loan history, and on-chain data. This action cannot be undone."]})]}),e.jsxs(W,{children:[e.jsx(J,{disabled:i.isPending,children:"Cancel"}),e.jsx(X,{className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",disabled:i.isPending,onClick:t=>{t.preventDefault(),s&&i.mutate(s,{onSettled:()=>p(null)})},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"h-4 w-4 mr-2 animate-spin"})," Deleting..."]}):"Delete permanently"})]})]})})]})}export{mt 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.