PageSourceSearch

https://injuryrehabpros.com/assets/AdminApplications-kO_ntozI.js

js injuryrehabpros.com collected 2026-10-08 10:09:27 UTC 19,214 bytes, 11 lines download raw bytes

1import{j as e}from"./vendor-ui-B_ITVS8P.js";import{r as a}from"./vendor-react-MmTTFgKI.js";import{c as q,s as b,X as z}from"./index-9XpualPm.js";import{S as G}from"./search-BvRU3aOz.js";import{C as V}from"./chevron-right-BnZAtUsz.js";import"./vendor-query-Dv61pbTW.js";/**
2 * @license lucide-react v0.462.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 H=q("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
7 * @license lucide-react v0.462.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 W=q("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),Y=()=>{const[l,x]=a.useState({user:null,session:null,isLoading:!0,isAdmin:!1}),h=a.useCallback(async i=>{const{data:c,error:r}=await b.from("user_roles").select("role").eq("user_id",i).eq("role","admin").maybeSingle();return r?(console.error("Error checking admin role:",r),!1):!!c},[]);return a.useEffect(()=>{const{data:{subscription:i}}=b.auth.onAuthStateChange(async(c,r)=>{const o=r?.user??null;let m=!1;o?setTimeout(async()=>{m=await h(o.id),x({user:o,session:r,isLoading:!1,isAdmin:m})},0):x({user:null,session:null,isLoading:!1,isAdmin:!1})});return b.auth.getSession().then(async({data:{session:c}})=>{const r=c?.user??null;let o=!1;r&&(o=await h(r.id)),x({user:r,session:c,isLoading:!1,isAdmin:o})}),()=>{i.unsubscribe()}},[h]),{...l,signUp:async(i,c)=>{const{data:r,error:o}=await b.auth.signUp({email:i,password:c,options:{emailRedirectTo:window.location.origin}});return{data:r,error:o}},signIn:async(i,c)=>{const{data:r,error:o}=await b.auth.signInWithPassword({email:i,password:c});return{data:r,error:o}},signOut:async()=>{const{error:i}=await b.auth.signOut();return{error:i}}}},s={bg:"#0A1628",panel:"#1E293B",border:"#334155",text:"#FFFFFF",muted:"#94A3B8",subtle:"#64748B",primary:"#0D968B",primaryHover:"#0B7E74"},N=25,O=["new","qualified","disqualified","booked","showed","closed"],K={ready:"a",partner:"b",save:"c",beyond_budget:"d"},Q={a:"#10B981",b:"#F59E0B",c:"#F97316",d:"#EF4444"},S={new:{bg:"#334155",text:"#CBD5E1"},qualified:{bg:"#0D968B",text:"#fff"},disqualified:{bg:"#7F1D1D",text:"#FCA5A5"},booked:{bg:"#1E40AF",text:"#BFDBFE"},showed:{bg:"#6B21A8",text:"#E9D5FF"},closed:{bg:"#065F46",text:"#A7F3D0"}};function E(l){return l==null?s.muted:l<=3?"#EF4444":l<=6?"#F59E0B":"#10B981"}function F(l){return new Date(l).toLocaleString("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})}function X(){const[l,x]=a.useState(""),[h,f]=a.useState(""),[u,p]=a.useState(""),[i,c]=a.useState(!1);async function r(o){o.preventDefault(),p(""),c(!0);const{error:m}=await b.auth.signInWithPassword({email:l,password:h});c(!1),m&&p(m.message||"Sign-in failed")}return e.jsx("div",{className:"min-h-screen flex items-center justify-center px-4",style:{backgroundColor:s.bg,fontFamily:"Inter, system-ui, sans-serif"},children:e.jsxs("form",{onSubmit:r,className:"rounded-xl p-8 w-full max-w-sm border",style:{backgroundColor:s.panel,borderColor:s.border},children:[e.jsx("div",{className:"text-center mb-6",children:e.jsxs("span",{className:"text-xl font-black tracking-tight",style:{color:s.text},children:["OMNI",e.jsx("span",{style:{color:s.primary},children:"."})]})}),e.jsx("h2",{className:"text-2xl font-bold text-center mb-6",style:{color:s.text},children:"Admin Access"}),e.jsx("input",{type:"email",value:l,onChange:o=>{x(o.target.value),p("")},placeholder:"Email",autoComplete:"email",className:"w-full rounded-lg px-4 py-3 mb-3 border outline-none",style:{backgroundColor:`${s.panel}cc`,borderColor:s.border,color:s.text},autoFocus:!0,required:!0}),e.jsx("input",{type:"password",value:h,onChange:o=>{f(o.target.value),p("")},placeholder:"Password",autoComplete:"current-password",className:"w-full rounded-lg px-4 py-3 mb-3 border outline-none",style:{backgroundColor:`${s.panel}cc`,borderColor:u?"#EF4444":s.border,color:s.text},required:!0}),u&&e.jsx("p",{className:"text-sm mb-3",style:{color:"#EF4444"},children:u}),e.jsx("button",{type:"submit",disabled:i,className:"w-full rounded-lg py-3 font-semibold transition-colors disabled:opacity-60",style:{backgroundColor:s.primary,color:"#fff"},children:i?"Signing in…":"Sign In"})]})})}function Z({onSignOut:l}){return e.jsx("div",{className:"min-h-screen flex items-center justify-center px-4",style:{backgroundColor:s.bg,fontFamily:"Inter, system-ui, sans-serif"},children:e.jsxs("div",{className:"rounded-xl p-8 w-full max-w-sm border text-center",style:{backgroundColor:s.panel,borderColor:s.border},children:[e.jsx("h2",{className:"text-xl font-bold mb-3",style:{color:s.text},children:"Not authorized"}),e.jsx("p",{className:"text-sm mb-6",style:{color:s.muted},children:"Your account does not have admin access."}),e.jsx("button",{onClick:l,className:"w-full rounded-lg py-3 font-semibold",style:{backgroundColor:s.primary,color:"#fff"},children:"Sign out"})]})})}function J({app:l,onClose:x,onStatusUpdate:h}){const[f,u]=a.useState(l.status),[p,i]=a.useState(!1);async function c(){i(!0),await h(l.id,f),i(!1)}const r=({label:o,value:m})=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide mb-1",style:{color:s.subtle},children:o}),e.jsx("div",{className:"text-sm",style:{color:s.text},children:m||e.jsx("span",{style:{color:s.subtle},children:"—"})})]});return e.jsxs("div",{className:"fixed inset-0 z-50 flex",style:{fontFamily:"Inter, system-ui, sans-serif"},children:[e.jsx("div",{className:"flex-1 bg-black/60",onClick:x}),e.jsxs("div",{className:"w-full max-w-xl h-full overflow-y-auto p-6 sm:p-8 border-l",style:{backgroundColor:s.bg,borderColor:s.border},children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide",style:{color:s.primary},children:"Application"}),e.jsx("h2",{className:"text-2xl font-bold",style:{color:s.text},children:l.full_name}),e.jsx("p",{className:"text-sm",style:{color:s.muted},children:F(l.created_at)})]}),e.jsx("button",{onClick:x,className:"p-2 rounded-lg",style:{color:s.muted},children:e.jsx(z,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-6",children:[e.jsx(r,{label:"Email",value:l.email}),e.jsx(r,{label:"Mobile",value:l.mobile}),e.jsx(r,{label:"Country",value:l.country}),e.jsx(r,{label:"Pain Score",value:l.pain_impact_score??"—"}),e.jsx(r,{label:"Commitment",value:l.commitment_score??"—"}),e.jsx(r,{label:"Invested Before",value:l.invested_before===null?"—":l.invested_before?"Yes":"No"})]}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsx(r,{label:"Primary Issue",value:l.primary_issue}),e.jsx(r,{label:"Duration",value:l.issue_duration}),e.jsx(r,{label:"Treatments Tried",value:l.treatments_tried?.length?e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:l.treatments_tried.map(o=>e.jsx("span",{className:"text-xs px-2 py-1 rounded",style:{backgroundColor:`${s.primary}20`,color:s.primary},children:o},o))}):null}),e.jsx(r,{label:"Investment Readiness",value:l.investment_readiness}),e.jsx(r,{label:"Cost of Inaction",value:l.cost_of_inaction?e.jsx("p",{className:"leading-relaxed whitespace-pre-wrap",children:l.cost_of_inaction}):null}),e.jsx(r,{label:"Outcome Vision",value:l.outcome_vision?e.jsx("p",{className:"leading-relaxed whitespace-pre-wrap",children:l.outcome_vision}):null}),e.jsx(r,{label:"Additional Notes",value:l.additional_notes?e.jsx("p",{className:"leading-relaxed whitespace-pre-wrap",children:l.additional_notes}):null})]}),(l.disqualify_reason||l.referred_program)&&e.jsxs("div",{className:"rounded-lg p-4 mb-6 border",style:{backgroundColor:`${s.panel}80`,borderColor:s.border},children:[e.jsx("div",{className:"text-xs uppercase tracking-wide mb-2",style:{color:s.subtle},children:"Routing"}),l.disqualify_reason&&e.jsxs("div",{className:"text-sm mb-1",style:{color:s.text},children:["Reason: ",e.jsx("span",{style:{color:"#EF4444"},children:l.disqualify_reason})]}),l.referred_program&&e.jsxs("div",{className:"text-sm",style:{color:s.text},children:["Referred to: ",e.jsx("span",{style:{color:s.primary},children:l.referred_program})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-6",children:[e.jsx(r,{label:"UTM Source",value:l.utm_source}),e.jsx(r,{label:"UTM Medium",value:l.utm_medium}),e.jsx(r,{label:"UTM Campaign",value:l.utm_campaign})]}),e.jsxs("div",{className:"rounded-lg p-4 border",style:{backgroundColor:`${s.panel}80`,borderColor:s.border},children:[e.jsx("div",{className:"text-xs uppercase tracking-wide mb-3",style:{color:s.subtle},children:"Update Status"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("select",{value:f,onChange:o=>u(o.target.value),className:"flex-1 rounded-lg px-3 py-2 border outline-none text-sm",style:{backgroundColor:s.bg,borderColor:s.border,color:s.text},children:O.map(o=>e.jsx("option",{value:o,children:o.charAt(0).toUpperCase()+o.slice(1)},o))}),e.jsx("button",{onClick:c,disabled:p||f===l.status,className:"px-4 py-2 rounded-lg font-semibold text-sm disabled:opacity-50",style:{backgroundColor:s.primary,color:"#fff"},children:p?"Saving…":"Save"})]})]})]})]})}function ae(){const{user:l,isAdmin:x,isLoading:h}
11=Y(),f=!!l&&x,[u,p]=a.useState([]),[i,c]=a.useState(!0),[r,o]=a.useState("all"),[m,R]=a.useState(""),[v,P]=a.useState(""),[A,$]=a.useState(""),[w,I]=a.useState(""),[j,D]=a.useState(0),[B,k]=a.useState(null);a.useEffect(()=>{if(!f)return;document.title="Applications Dashboard — OMNI";async function t(){c(!0);const{data:y,error:d}=await b.from("applications").select("*").order("created_at",{ascending:!1});d&&console.error(d),p(y||[]),c(!1)}t();const n=b.channel("applications-realtime").on("postgres_changes",{event:"*",schema:"public",table:"applications"},()=>t()).subscribe();return()=>{b.removeChannel(n)}},[f]);const C=a.useMemo(()=>u.filter(t=>{if(r!=="all"&&t.status!==r||m&&new Date(t.created_at)<new Date(m)||v&&new Date(t.created_at)>new Date(v+"T23:59:59"))return!1;if(w){const n=w.toLowerCase();if(!t.full_name?.toLowerCase().includes(n)&&!t.email?.toLowerCase().includes(n))return!1}return!0}),[u,r,m,v,w]),_=a.useMemo(()=>{const t=u.length,n=u.filter(g=>g.status==="qualified"||g.status==="booked").length,y=u.filter(g=>g.status==="disqualified").length,d=t>0?Math.round(n/t*100):0;return{total:t,qualified:n,disqualified:y,conv:d}},[u]),L=Math.max(1,Math.ceil(C.length/N)),M=C.slice(j*N,j*N+N);a.useEffect(()=>{D(0)},[r,m,v,w]);async function U(t,n){const{error:y}=await b.from("applications").update({status:n}).eq("id",t);if(y){console.error(y);return}p(d=>d.map(g=>g.id===t?{...g,status:n}:g)),k(d=>d&&d.id===t?{...d,status:n}:d)}async function T(){await b.auth.signOut()}return h?e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{backgroundColor:s.bg,color:s.muted},children:"Loading…"}):l?x?e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:s.bg,fontFamily:"Inter, system-ui, sans-serif"},children:[e.jsx("header",{className:"border-b sticky top-0 z-30",style:{backgroundColor:`${s.bg}f5`,borderColor:s.border,backdropFilter:"blur(8px)"},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 py-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-lg font-black tracking-tight",style:{color:s.text},children:["OMNI",e.jsx("span",{style:{color:s.primary},children:"."})]}),e.jsx("h1",{className:"hidden sm:block text-sm font-semibold",style:{color:s.muted},children:"Applications Dashboard"}),e.jsxs("button",{onClick:T,className:"flex items-center gap-2 text-sm px-3 py-1.5 rounded-lg border",style:{color:s.muted,borderColor:s.border},children:[e.jsx(W,{className:"w-4 h-4"})," Logout"]})]})}),e.jsxs("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 py-6 sm:py-8",children:[e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[{label:"Total Applications",value:_.total},{label:"Qualified",value:_.qualified},{label:"Disqualified",value:_.disqualified},{label:"Conversion Rate",value:`${_.conv}%`}].map(t=>e.jsxs("div",{className:"rounded-xl p-6 border",style:{backgroundColor:`${s.panel}80`,borderColor:s.border},children:[e.jsx("div",{className:"text-3xl font-bold",style:{color:s.text},children:t.value}),e.jsx("div",{className:"text-sm mt-1",style:{color:s.muted},children:t.label})]},t.label))}),e.jsxs("div",{className:"rounded-xl p-4 mb-6 border flex flex-wrap items-end gap-3",style:{backgroundColor:`${s.panel}50`,borderColor:s.border},children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{className:"text-xs mb-1",style:{color:s.muted},children:"Status"}),e.jsxs("select",{value:r,onChange:t=>o(t.target.value),className:"rounded-lg px-3 py-2 border text-sm outline-none",style:{backgroundColor:s.bg,borderColor:s.border,color:s.text},children:[e.jsx("option",{value:"all",children:"All"}),O.map(t=>e.jsx("option",{value:t,children:t.charAt(0).toUpperCase()+t.slice(1)},t))]})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{className:"text-xs mb-1",style:{color:s.muted},children:"From"}),e.jsx("input",{type:"date",value:m,onChange:t=>R(t.target.value),className:"rounded-lg px-3 py-2 border text-sm outline-none",style:{backgroundColor:s.bg,borderColor:s.border,color:s.text}})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("label",{className:"text-xs mb-1",style:{color:s.muted},children:"To"}
11),e.jsx("input",{type:"date",value:v,onChange:t=>P(t.target.value),className:"rounded-lg px-3 py-2 border text-sm outline-none",style:{backgroundColor:s.bg,borderColor:s.border,color:s.text}})]}),e.jsxs("div",{className:"flex flex-col flex-1 min-w-[200px]",children:[e.jsx("label",{className:"text-xs mb-1",style:{color:s.muted},children:"Search name or email"}),e.jsxs("div",{className:"relative",children:[e.jsx(G,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2",color:s.muted}),e.jsx("input",{value:A,onChange:t=>$(t.target.value),onKeyDown:t=>t.key==="Enter"&&I(A),placeholder:"Search…",className:"w-full rounded-lg pl-9 pr-3 py-2 border text-sm outline-none",style:{backgroundColor:s.bg,borderColor:s.border,color:s.text}})]})]}),e.jsx("button",{onClick:()=>I(A),className:"rounded-lg px-4 py-2 text-sm font-semibold",style:{backgroundColor:s.primary,color:"#fff"},children:"Apply"})]}),i?e.jsx("div",{className:"text-center py-16",style:{color:s.muted},children:"Loading applications…"}):C.length===0?e.jsx("div",{className:"text-center py-16 rounded-xl border",style:{color:s.muted,backgroundColor:`${s.panel}30`,borderColor:s.border},children:"No applications match your filters."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden lg:block rounded-xl overflow-hidden border",style:{backgroundColor:`${s.panel}30`,borderColor:s.border},children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{style:{backgroundColor:s.panel},children:e.jsx("tr",{children:["Date","Name","Email","Mobile","Issue","Duration","Pain","Commit","Inv.","Status",""].map(t=>e.jsx("th",{className:"text-left px-4 py-3 text-xs uppercase tracking-wide font-semibold",style:{color:s.muted},children:t},t))})}),e.jsx("tbody",{children:M.map(t=>{const n=t.investment_readiness?K[t.investment_readiness]:null,y=S[t.status]||S.new;return e.jsxs("tr",{onClick:()=>k(t),className:"border-b cursor-pointer transition-colors",style:{borderColor:s.border},onMouseEnter:d=>d.currentTarget.style.backgroundColor=`${s.panel}99`,onMouseLeave:d=>d.currentTarget.style.backgroundColor="transparent",children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",style:{color:"#CBD5E1"},children:F(t.created_at)}),e.jsx("td",{className:"px-4 py-3 font-medium",style:{color:s.text},children:t.full_name}),e.jsx("td",{className:"px-4 py-3 max-w-[180px] truncate",style:{color:"#CBD5E1"},children:t.email}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",style:{color:"#CBD5E1"},children:t.mobile}),e.jsx("td",{className:"px-4 py-3 max-w-[180px] truncate",style:{color:"#CBD5E1"},children:t.primary_issue||"—"}),e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",style:{color:"#CBD5E1"},children:t.issue_duration||"—"}),e.jsx("td",{className:"px-4 py-3 font-bold",style:{color:E(t.pain_impact_score)},children:t.pain_impact_score??"—"}),e.jsx("td",{className:"px-4 py-3 font-bold",style:{color:E(t.commitment_score)},children:t.commitment_score??"—"}),e.jsx("td",{className:"px-4 py-3 font-bold uppercase",children:n?e.jsx("span",{style:{color:Q[n]},children:n}):e.jsx("span",{style:{color:s.muted},children:"—"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-xs px-2.5 py-1 rounded-full font-semibold uppercase tracking-wide",style:{backgroundColor:y.bg,color:y.text},children:t.status})}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx("span",{className:"text-xs",style:{color:s.primary},children:"View →"})})]},t.id)})})]})}),e.jsx("div",{className:"lg:hidden space-y-3",children:M.map(t=>{const n=S[t.status]||S.new;return e.jsxs("button",{onClick:()=>k(t),className:"w-full text-left rounded-xl p-4 border",style:{backgroundColor:`${s.panel}50`,borderColor:s.border},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",style:{color:s.text},children:t.full_name}),e.jsx("div",{className:"text-xs",style:{color:s.muted},children:F(t.created_at)})]}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-full font-semibold uppercase whitespace-nowrap",style:{backgroundColor:n.bg,color:n.text},children:t.status})]}),e.jsx("div",{className:"text-sm",style:{color:"#CBD5E1"},children:t.primary_issue||"—"}),e.jsxs("div",{className:"flex gap-3 mt-2 text-xs",style:{color:s.muted},children:[e.jsxs("span",{children:["Pain:"," ",e.jsx("span",{className:"font-bold",style:{color:E(t.pain_impact_score)},children:t.pain_impact_score??"—"})]}),e.jsxs("span",{children:["Commit:"," ",e.jsx("span",{className:"font-bold",style:{color:E(t.commitment_score)},children:t.commitment_score??"—"})]})]})]},t.id)})}),e.jsxs("div",{className:"flex items-center justify-between mt-6",children:[e.jsxs("div",{className:"text-sm",style:{color:s.muted},children:["Showing ",j*N+1,"–",Math.min((j+1)*N,C.length)," of"," ",C.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>D(t=>Math.max(0,t-1)),disabled:j===0,className:"flex items-center gap-1 px-3 py-2 rounded-lg border text-sm disabled:opacity-40",style:{borderColor:s.border,color:s.text},children:[e.jsx(H,{className:"w-4 h-4"})," Prev"]}),e.jsxs("button",{onClick:()=>D(t=>Math.min(L-1,t+1)),disabled:j>=L-1,className:"flex items-center gap-1 px-3 py-2 rounded-lg border text-sm disabled:opacity-40",style:{borderColor:s.border,color:s.text},children:["Next ",e.jsx(V,{className:"w-4 h-4"})]})]})]})]})]}),B&&e.jsx(J,{app:B,onClose:()=>k(null),onStatusUpdate:U})]}):e.jsx(Z,{onSignOut:T}):e.jsx(X,{})}export{ae 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.