PageSourceSearch

https://eliteos.ai/assets/Dashboard-BMM6vEWU.js

js eliteos.ai collected 2026-10-05 15:00:30 UTC 11,680 bytes, 13 lines download raw bytes

1import{u as F,a as E,r as B,b as S,s as N,j as e,c as p,B as k,C as K,X as O,S as z,T as U,d as Q,e as V,f as o,g as b,h as j,F as I,i as c,k as f,U as D,l as X}from"./index-DhnUWhec.js";import{B as W}from"./badge-BkgD4F58.js";import{u as $}from"./useMutation-BZxAUnPF.js";import{I as M,L as H,S as G}from"./shield-alert-Bep3SUpR.js";import{E as J}from"./external-link-GLc8jcYz.js";import{C as Y}from"./chevron-left-DeaBFp77.js";import{W as Z,O as ee,P as se}from"./wrench-Bj-7Sh_U.js";import{C as T}from"./circle-check-D83E9THT.js";import{C as te}from"./circle-x-LEoPgWHT.js";import{M as re}from"./megaphone-Ch9pVlE6.js";import{B as ae}from"./bell-i-7UlxjH.js";import{C as ne}from"./clock-BIx7ucpZ.js";import{A as ie}from"./arrow-right-VSi66ibK.js";import{C as le}from"./circle-alert-CVUwbBI5.js";const de={Info:M,Sparkles:z,Wrench:Z,AlertTriangle:U,AlertOctagon:ee,CheckCircle2:T,XCircle:te,Megaphone:re,Lightbulb:H,PartyPopper:se,ShieldAlert:G,Bell:ae},L={info:{bg:"bg-blue-50 dark:bg-blue-950/30",border:"border-blue-200 dark:border-blue-800",text:"text-blue-800 dark:text-blue-200",icon:"text-blue-600 dark:text-blue-400"},success:{bg:"bg-green-50 dark:bg-green-950/30",border:"border-green-200 dark:border-green-800",text:"text-green-800 dark:text-green-200",icon:"text-green-600 dark:text-green-400"},warning:{bg:"bg-amber-50 dark:bg-amber-950/30",border:"border-amber-200 dark:border-amber-800",text:"text-amber-800 dark:text-amber-200",icon:"text-amber-600 dark:text-amber-400"},error:{bg:"bg-red-50 dark:bg-red-950/30",border:"border-red-200 dark:border-red-800",text:"text-red-800 dark:text-red-200",icon:"text-red-600 dark:text-red-400"},announcement:{bg:"bg-purple-50 dark:bg-purple-950/30",border:"border-purple-200 dark:border-purple-800",text:"text-purple-800 dark:text-purple-200",icon:"text-purple-600 dark:text-purple-400"},maintenance:{bg:"bg-slate-50 dark:bg-slate-950/30",border:"border-slate-200 dark:border-slate-700",text:"text-slate-800 dark:text-slate-200",icon:"text-slate-600 dark:text-slate-400"},feature:{bg:"bg-indigo-50 dark:bg-indigo-950/30",border:"border-indigo-200 dark:border-indigo-800",text:"text-indigo-800 dark:text-indigo-200",icon:"text-indigo-600 dark:text-indigo-400"},tip:{bg:"bg-yellow-50 dark:bg-yellow-950/30",border:"border-yellow-200 dark:border-yellow-800",text:"text-yellow-800 dark:text-yellow-200",icon:"text-yellow-600 dark:text-yellow-400"},urgent:{bg:"bg-rose-50 dark:bg-rose-950/30",border:"border-rose-300 dark:border-rose-800",text:"text-rose-800 dark:text-rose-200",icon:"text-rose-600 dar
1k:text-rose-400"},celebration:{bg:"bg-pink-50 dark:bg-pink-950/30",border:"border-pink-200 dark:border-pink-800",text:"text-pink-800 dark:text-pink-200",icon:"text-pink-600 dark:text-pink-400"}};function oe(){var d,P;const{user:r}=F(),w=E(),[x,u]=B.useState(0),{data:a=[],isLoading:l}=S({queryKey:["dashboard-alerts",r==null?void 0:r.id],queryFn:async()=>{if(!(r!=null&&r.id))return[];const{data:n}=await N.from("user_dismissed_alerts").select("alert_id").eq("user_id",r.id),g=(n==null?void 0:n.map(y=>y.alert_id))||[];let A=N.from("alerts").select(`
2          id,
3          title,
4          message,
5          link_url,
6          link_label,
7          is_dismissible,
8          alert_types (
9            name,
10            theme,
11            icon
12          )
13        `).eq("is_active",!0).lte("starts_at",new Date().toISOString()).order("created_at",{ascending:!1});g.length>0&&(A=A.not("id","in",`(${g.join(",")})`));const{data:R,error:q}=await A;if(q)throw q;return(R||[]).filter(y=>!y.expires_at||new Date(y.expires_at)>new Date)},enabled:!!(r!=null&&r.id)}),m=$({mutationFn:async n=>{if(!(r!=null&&r.id))throw new Error("Not authenticated");const{error:g}=await N.from("user_dismissed_alerts").insert({user_id:r.id,alert_id:n});if(g)throw g},onSuccess:()=>{w.invalidateQueries({queryKey:["dashboard-alerts"]}),x>=a.length-1&&u(0)}}),v=n=>{m.mutate(n)},C=()=>{u(n=>n===0?a.length-1:n-1)},h=()=>{u(n=>n===a.length-1?0:n+1)};if(l||a.length===0)return null;const i=a[x],s=((d=i.alert_types)==null?void 0:d.theme)||"info",t=L[s]||L.info,_=de[((P=i.alert_types)==null?void 0:P.icon)||"Info"]||M;return e.jsxs("div",{className:p("relative rounded-lg border px-4 py-3 mb-6 flex items-center gap-3",t.bg,t.border),children:[e.jsx(_,{className:p("h-5 w-5 flex-shrink-0",t.icon)}),e.jsx("div",{className:p("flex-1 min-w-0",t.text),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:i.title}),i.message&&e.jsxs("span",{className:"hidden sm:inline text-sm opacity-80 truncate",children:["— ",i.message]})]})}),i.link_url&&e.jsxs("a",{href:i.link_url,target:"_blank",rel:"noopener noreferrer",className:p("hidden sm:flex items-center gap-1 text-sm font-medium hover:underline",t.text),children:[i.link_label||"Learn more",e.jsx(J,{className:"h-3 w-3"})]}),a.length>1&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(k,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:C,children:e.jsx(Y,{className:"h-4 w-4"})}),e.jsxs("span",{className:p("text-xs tabular-nums",t.text),children:[x+1,"/",a.length]}),e.jsx(k,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:h,children:e.jsx(K,{className:"h-4 w-4"})})]}),i.is_dismissible&&e.jsx(k,{variant:"ghost",size:"icon",className:"h-7 w-7 flex-shrink-0",onClick:()=>v(i.id),disabled:m.isPending,children:e.jsx(O,{className:"h-4 w-4"})})]})}function ve(){F();const{role:r,canAccess:w,isSuperAdmin:x,isAdmin:u}=Q(),a=V(),{data:l=[],isLoading:m}=S({queryKey:["dashboard-projects"],queryFn:async()=>{const{data:s,error:t}=await N.from("projects").select("*").order("updated_at",{ascending:!1}).limit(10);if(t)throw t;return s||[]}}),{data:v=0,isLoading:C}=S({queryKey:["dashboard-user-count"],enabled:u,queryFn:async()=>{const{count:s,error:t}=await N.from("profiles").select("*",{count:"exact",head:!0});if(t)throw t;return s||0}}),h=B.useMemo(()=>{const s=l.filter(d=>!["Complete","Cancelled"].includes(d.stage)).length,t=l.filter(d=>d.stage==="Complete").length,_=l.filter(d=>["Installation","Inspection","PTO"].includes(d.stage)).length;return{active:s,completed:t,inProgress:_,total:l.length}},[l]),i=s=>{switch(s){case"Complete":return"default";case"Cancelled":return"destructive";case"Installation":return"secondary";default:return"outline"}};return e.jsxs("div",{className:"container mx-auto px-4 py-6 space-y-6",children:[e.jsx(oe,{}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(o,{children:[e.jsxs(b,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(j,{className:"text-sm font-medium",children:"Active Projects"}),e.jsx(I,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(c,{children:m?e.jsx(f,{className:"h-8 w-16"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h.active}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Projects in progress"})]})})]}),e.jsxs(o,{children:[e.jsxs(b,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(j,{className:"text-sm font-medium",children:"In Installation"}),e.jsx(ne,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(c,{children:m?e.jsx(f,{className:"h-8 w-16"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h.inProgress}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting completion"})]})})]}),e.jsxs(o,{children:[e.jsxs(b,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(j,{className:"text-sm font-medium",children:"Completed"}),e.jsx(T,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(c,{children:m?e.jsx(f,{className:"h-8 w-16"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-2xl font-bold",children:h.completed}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Successfully finished"})]})})]}),w("users","view")&&e.jsxs(o,{children:[e.jsxs(b,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(j,{className:"text-sm font-medium",children:"Team Members"}),e.jsx(D,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(c,{children:C?e.jsx(f,{className:"h-8 w-16"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-2xl font-bold",children:v}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active users"})]})})]})]}),e.jsxs(o,{children:[e.jsxs(b,{className:"flex flex-row items-center justify-between",children:[e.jsx(j,{children:"Recent Projects"}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>a("/projects"),children:["View All",e.jsx(ie,{className:"h-4 w-4 ml-1"})]})]}),e.jsx(c,{children:m?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((s,t)=>e.jsx(f,{className:"h-14 w-full"},t))}):l.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(I,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No projects yet"}),w("projects","create")&&e.jsx(k,{variant:"outline",className:"mt-4",onClick:()=>a("/projects"),children:"Create your first project"})]}):e.jsx("div",{className:"space-y-2",children:l.slice(0,5).map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>a(`/projects/${s.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(I,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.property_type," • Updated ",new Date(s.updated_at).toLocaleDateString()]})]})]}),e.jsx(W,{variant:i(s.stage),children:s.stage})]},s.id))})})]}),(x||u)&&e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(o,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>a("/csv-import"),children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-lg bg-blue-100 dar
13k:bg-blue-900/20 flex items-center justify-center",children:e.jsx(X,{className:"h-6 w-6 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Import Data"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"CSV Import Tool"})]})]})})}),e.jsx(o,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>a("/users"),children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-lg bg-green-100 dark:bg-green-900/20 flex items-center justify-center",children:e.jsx(D,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Manage Users"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Team & Roles"})]})]})})}),x&&e.jsx(o,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>a("/data-browser"),children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-lg bg-purple-100 dark:bg-purple-900/20 flex items-center justify-center",children:e.jsx(le,{className:"h-6 w-6 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Data Browser"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Direct DB Access"})]})]})})})]})]})}export{ve 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.