1import{c as A,U as u,j as e,m as I,r as o,u as F,n as R,ax as k,ad as L,az as r,aA as U,B as y,s as C,aB as T,F as O,Z as P,C as B,$,a as q}from"./index-CDfdkqy7.js";import{R as W}from"./refresh-cw-DhrJWKKO.js";import{S as z}from"./shield-alert-B8Wmf8O1.js";import{U as _}from"./user-plus-CUDpLU3E.js";import{T as H,a as V,b as j,c as w}from"./tabs-CbeQQkSI.js";import{B as Q}from"./briefcase-DeHEkZ-5.js";import{S as X}from"./scale-BJag28iO.js";import{C as J}from"./calendar-BTQNo8Aw.js";import{S as Y}from"./search-ChaG_NGT.js";import{B as Z}from"./badge-eAcNZjve.js";import{A as G}from"./ActivityLog-BTpWw8SD.js";import"./index-BE7vp0iw.js";import"./square-pen-CX1tP_hy.js";import"./trash-2-cOTpNmyP.js";/** 2 * @license lucide-react v0.469.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const S=A("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** 7 * @license lucide-react v0.469.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const K=A("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]),ee=({title:a,value:t,icon:l,color:d,loading:c,delay:i})=>e.jsxs(I.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.35,delay:i},className:"rounded-2xl border border-gray-100 bg-white p-6 shadow-sm",children:[e.jsx("div",{className:`mb-4 inline-flex rounded-xl p-3 ${d}`,children:e.jsx(l,{className:"h-6 w-6 text-white"})}),e.jsx("h3",{className:"mb-1 text-sm font-medium text-gray-500",children:a}),c?e.jsx("div",{className:"mt-2 h-9 w-20 animate-pulse rounded bg-gray-200","aria-label":`Loading ${a}`}):e.jsx("p",{className:"text-3xl font-bold text-gray-900",children:Number(t||0).toLocaleString()})]}),se=({stats:a,loading:t=!1})=>{const l=a||{totalUsers:0,members:0,professionals:0,staff:0,active:0,inactive:0},d=[{title:"User records",value:l.totalUsers,icon:u,color:"bg-blue-600"},{title:"Active members",value:l.members,icon:S,color:"bg-emerald-500"},{title:"Active professionals",value:l.professionals,icon:X,color:"bg-purple-500"},{title:"Internal staff & admins",value:l.staff,icon:Q,color:"bg-orange-500"},{title:"Active accounts",value:l.active,icon:S,color:"bg-[#001F3F]"},{title:"Inactive accounts",value:l.inactive,icon:K,color:"bg-gray-400"}];return e.jsx("div",{className:"mb-8 grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3",children:d.map((c,i)=>e.jsx(ee,{...c,loading:t,delay:i*.04},c.title))})},ae=new Set(["member","free_member","paid_member","lifetime_member"]),te=({members:a=[],loading:t=!1,error:l=""})=>{const[d,c]=o.useState(""),i=o.useMemo(()=>a.filter(s=>ae.has(s.role)),[a]),x=o.useMemo(()=>{const s=d.trim().toLowerCase();return s?i.filter(n=>[n.full_name,n.name,n.email,n.member_code,n.member_number,n.phone].some(h=>String(h||"").toLowerCase().includes(s))):i},[i,d]),p=o.useMemo(()=>{const s=Date.now(),n=s-10080*60*1e3,h=s-720*60*60*1e3;return{total:i.length,newThisMonth:i.filter(g=>new Date(g.created_at).getTime()>=h).length,newThisWeek:i.filter(g=>new Date(g.created_at).getTime()>=n).length}},[i]);return l?e.jsx("div",{className:"rounded-xl border border-red-200 bg-red-50 p-6 text-sm text-red-800",children:"Member records are unavailable. No local demonstration records are being used."}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-3",children:[{label:"Member records",value:p.total,icon:u,color:"bg-blue-100 text-[#001F3F]"},{label:"Created in last 30 days",value:p.newThisMonth,icon:J,color:"bg-green-100 text-green-700"},{label:"Created in last 7 days",value:p.newThisWeek,icon:_,color:"bg-purple-100 text-purple-700"}].map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-gray-100 bg-white p-6 shadow-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-500",children:s.label}),t?e.jsx("div",{className:"mt-2 h-9 w-16 animate-pulse rounded bg-gray-200"}):e.jsx("h3",{className:"mt-1 text-3xl font-bold",children:s.value})]}),e.jsx("div",{className:`rounded-full p-3 ${s.color}`,children:e.jsx(s.icon,{className:"h-6 w-6"})})]},s.label))}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-gray-100 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex flex-col items-center justify-between gap-4 border-b border-gray-100 p-6 sm:flex-row",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-[#001F3F]",children:"Member records"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Loaded from the authenticated Supabase users table."})]}),e.jsxs("div",{className:"relative w-full sm:w-80",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"search",placeholder:"Search name, email, ID, or phone...",value:d,onChange:s=>c(s.target.value),className:"w-full rounded-lg border py-2 pl-9 pr-4 text-sm focus:border-[#001F3F] focu
11s:outline-none"})]})]}),t?e.jsx("div",{className:"p-10 text-center text-sm text-gray-500",children:"Loading live member records..."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100 bg-gray-50 text-left font-medium text-gray-500",children:[e.jsx("th",{className:"px-6 py-4",children:"Name / ID"}),e.jsx("th",{className:"px-6 py-4",children:"Contact"}),e.jsx("th",{className:"px-6 py-4",children:"Location"}),e.jsx("th",{className:"px-6 py-4",children:"Joined"}),e.jsx("th",{className:"px-6 py-4",children:"Status"})]})}),e.jsxs("tbody",{className:"divide-y divide-gray-100",children:[x.slice(0,50).map(s=>e.jsxs("tr",{className:"hover:bg-gray-50/50",children:[e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"font-semibold text-gray-900",children:s.full_name||s.name||"-"}),e.jsx("div",{className:"font-mono text-xs text-gray-500",children:s.member_code||s.member_number||"-"})]}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{children:s.email||"-"}),e.jsx("div",{className:"text-xs text-gray-500",children:s.phone||"-"})]}),e.jsx("td",{className:"px-6 py-4 text-gray-600",children:[s.city,s.state].filter(Boolean).join(", ")||"-"}),e.jsx("td",{className:"px-6 py-4 text-gray-600",children:s.created_at?new Date(s.created_at).toLocaleDateString():"-"}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(Z,{className:s.is_active!==!1?"bg-green-100 text-green-700 hover:bg-green-200":"bg-gray-100 text-gray-700",children:s.is_active!==!1?"Active":"Inactive"})})]},s.id)),x.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-6 py-10 text-center text-gray-500",children:"No matching live member records."})})]})]})}),e.jsxs("div",{className:"border-t border-gray-100 p-4 text-center text-xs text-gray-400",children:["Showing up to 50 of ",x.length," matching records"]})]})]})},re=new Set(["member","free_member","paid_member","lifetime_member"]),ie=new Set(["professional","lawyer"]),le=new Set(["staff","info_admin","admin","super_admin"]),ne=a=>({totalUsers:a.length,members:a.filter(t=>re.has(t.role)&&t.is_active!==!1).length,professionals:a.filter(t=>ie.has(t.role)&&t.is_active!==!1).length,staff:a.filter(t=>le.has(t.role)&&t.is_active!==!1).length,active:a.filter(t=>t.is_active!==!1).length,inactive:a.filter(t=>t.is_active===!1).length}),oe=a=>[a===r.SUPER_ADMIN&&{label:"Preview account portals",description:"Inspect Member, Volunteer, Staff, and Professional layouts without changing identity.",path:"/admin/portal-preview",icon:T},a===r.SUPER_ADMIN&&{label:"Manage users",description:"Create accounts and assign access roles.",path:"/admin/users",icon:u},[r.SUPER_ADMIN,r.ADMIN,r.INFO_ADMIN].includes(a)&&{label:"Content studio",description:"Edit visual content, images, events, and photos.",path:"/admin/content",icon:O},[r.SUPER_ADMIN,r.ADMIN,r.INFO_ADMIN].includes(a)&&{label:"Applications & cards",de
11scription:"Review applications and prepare approved Evolis cards.",path:"/admin/applications",icon:P},[r.SUPER_ADMIN,r.ADMIN,r.INFO_ADMIN].includes(a)&&{label:"Events & photos",description:"Publish events and manage approved event photos.",path:"/admin/career-events",icon:B},[r.SUPER_ADMIN,r.ADMIN].includes(a)&&{label:"AI call center",description:"Review the live call-center workflow.",path:"/admin/ai-call-center",icon:$},[r.SUPER_ADMIN,r.ADMIN,r.INFO_ADMIN].includes(a)&&{label:"Email routing",description:"Review routing recipients and delivery rules.",path:"/admin/email-routing",icon:q}].filter(Boolean),we=()=>{const a=F(),t=R(),{admin:l}=k(),{user:d}=L(),c=l||d,i=c?.role||r.STAFF,[x,p]=o.useState([]),[s,n]=o.useState(!0),[h,g]=o.useState(""),[b,M]=o.useState(null),f=async()=>{n(!0),g("");try{const{data:m,error:N}=await C.from("users").select("*").order("created_at",{ascending:!1});if(N)throw N;p(m||[]),M(new Date)}catch(m){p([]),g(`Live account data could not be loaded: ${m.message}`)}finally{n(!1)}};o.useEffect(()=>{f()},[]);const D=o.useMemo(()=>ne(x),[x]),v=o.useMemo(()=>oe(i),[i]),E=[r.SUPER_ADMIN,r.ADMIN].includes(i);return e.jsxs("div",{className:"min-h-screen bg-gray-50 p-4 md:p-6",children:[e.jsxs("div",{className:"mb-8 flex flex-col justify-between gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold uppercase tracking-wider text-[#C41E3A]",children:U[i]||i}),e.jsx("h1",{className:"mt-1 text-3xl font-bold text-[#001F3F]",children:"Dashboard Overview"}),e.jsxs("p",{className:"mt-1 text-gray-500",children:["Welcome back",c?.name?`, ${c.name}`:"",". Every number below comes from the live database."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(y,{variant:"outline",className:"gap-2",onClick:f,disabled:s,children:[e.jsx(W,{className:`h-4 w-4 ${s?"animate-spin":""}`})," Refresh live data"]}),i===r.SUPER_ADMIN&&e.jsxs(y,{onClick:()=>a("/admin/users"),className:"gap-2 bg-[#001F3F] text-white hover:bg-[#C41E3A]",children:[e.jsx(_,{className:"h-4 w-4"})," Add User"]})]})]}),t.state?.accessDenied&&e.jsxs("div",{className:"mb-6 flex items-start gap-3 rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-950",children:[e.jsx(z,{className:"mt-0.5 h-5 w-5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold",children:"That page is outside this account's assigned role."}),e.jsx("p",{className:"mt-1",children:t.state.accessDenied})]})]}),h&&e.jsxs("div",{className:"mb-6 rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-800",children:[e.jsx("strong",{children:"Live data unavailable."})," ",h," No demonstration values are being shown."]}),e.jsxs(H,{defaultValue:"overview",className:"w-full",children:[e.jsxs(V,{className:"mb-6",children:[e.jsx(j,{value:"overview",children:"Overview"}),e.jsx(j,{value:"members",children:"Member records"})]}),e.jsxs(w,{value:"overview",children:[e.jsx(se,{stats:D,loading:s}),e.jsxs("section",{className:"mb-8 rounded-2xl border border-gray-100 bg-white p-6 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col justify-between gap-2 sm:flex-row sm:items-end",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-[#001F3F]",children:"Your assigned workspace"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Available actions are different for each account role."})]}),e.jsx("p",{className:"text-xs text-gray-400",children:b?`Live data refreshed ${b.toLocaleTimeString()}`:"Waiting for live data"})]}),v.length>0?e.jsx("div",{className:"mt-5 grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:v.map(m=>e.jsxs("button",{type:"button",onClick:()=>a(m.path),className:"flex items-start gap-3 rounded-xl border border-gray-200 p-4 text-left transition hover:border-[#003b68] hover:bg-sky-50",children:[e.jsx("span",{className:"rounded-lg bg-[#001F3F] p-2 text-white",children:e.jsx(m.icon,{className:"h-5 w-5"})}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-bold text-[#001F3F]",children:m.label}),e.jsx("span",{className:"mt-1 block text-sm text-gray-500",children:m.description})]})]},m.path))}):e.jsx("p",{className:"mt-5 rounded-xl bg-gray-50 p-4 text-sm text-gray-600",children:"This staff account has dashboard and member-record visibility only. A Super Administrator must assign a higher role before management tools appear."})]}),E&&e.jsx(G,{limit:8})]}),e.jsx(w,{value:"members",children:e.jsx(te,{members:x,loading:s,error:h})})]})]})};export{we 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.