PageSourceSearch

https://www.bizware.ai/assets/bizware.impersonate-ChvMvgdY.js

js bizware.ai collected 2026-10-05 11:52:57 UTC 3,737 bytes, 1 lines download raw bytes

1import{u as _,r as t,X as I,t as u,j as e,B as L,Y as S}from"./index-BI34Wull.js";import{u as E}from"./useServerFn-CCokYi5s.js";import{I as C}from"./input-DSEt1Ik3.js";import{u as B}from"./access-C7KvlHlo.js";import{G as h}from"./ghost-CSUo6XJk.js";import{S as U}from"./search-B4HQYTdZ.js";import{L as f}from"./loader-circle-RJ_lzir4.js";import"./createLucideIcon-4AT48GiE.js";function R(){const{isMaster:r,loading:d}=B(),n=_(),[o,g]=t.useState([]),[j,N]=t.useState(!0),[i,v]=t.useState(""),[c,m]=t.useState(null),x=E(S),{begin:y,active:l}=I();t.useEffect(()=>{!d&&!r&&n({to:"/app/bizware"})},[d,r,n]),t.useEffect(()=>{r&&(async()=>{try{const s=await x();g(s.users)}catch(s){u.error(s instanceof Error?s.message:"Failed to load users")}finally{N(!1)}})()},[r,x]);const p=t.useMemo(()=>{const s=i.trim().toLowerCase();return s?o.filter(a=>[a.email,a.display_name].filter(Boolean).some(w=>w.toLowerCase().includes(s))):o},[o,i]);async function b(s){if(confirm(`Impersonate ${s.email}? Your actions will be logged.`)){m(s.user_id);try{await y(s.user_id),n({to:"/app"})}catch(a){u.error(a instanceof Error?a.message:"Impersonation failed")}finally{m(null)}}}return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2 text-2xl font-bold",children:[e.jsx(h,{className:"h-6 w-6"})," Impersonate user"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"View the app exactly as another user for support. Every session is logged."})]})}),l&&e.jsxs("div",{className:"rounded-xl border border-orange-500/40 bg-orange-500/10 p-3 text-sm text-orange-600 dark:text-orange-300",children:["You are currently viewing as ",e.jsx("strong",{children:l.target_email}),". Use the orange banner at the top to return to your account."]}),e.jsxs("div",{className:"relative",children:[e.jsx(U,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(C,{value:i,onChange:s=>v(s.target.value),placeholder:"Search by email or name…",className:"pl-9"})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border",children:j?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(f,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):p.length===0?e.jsx("div",{className:"p-8 text-center text-sm text-muted-foreground",children:"No users found."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-xs uppercase text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left",children:"User"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Last seen"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Last login"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:p.map(s=>e.jsxs("tr",{className:"border-t border-border",children:[e.jsxs("td",{className:"px-3 py-2",children:[e.jsx("div",{className:"font-medium",children:s.display_name??s.email}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.email})]}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:s.last_seen_at?new Date(s.last_seen_at).toLocaleString():"—"}),e.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:s.last_login_at?new Date(s.last_login_at).toLocaleString():"—"}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsxs(L,{size:"sm",variant:"outline",disabled:c===s.user_id||!!l,onClick:()=>b(s),children:[c===s.user_id?e.jsx(f,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(h,{className:"mr-1.5 h-3.5 w-3.5"}),"Impersonate"]})})]},s.user_id))})]})})]})}export{R as component};

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.