PageSourceSearch

https://concept-studio.ai/assets/_authenticated.admin.users-C2Q4TUJ3.js

js concept-studio.ai collected 2026-10-05 15:02:41 UTC 13,320 bytes, 1 lines download raw bytes

1import{i as G,r as l,t as c,j as e,B as h,u as I,b1 as Q,a$ as H}from"./index-CFv9XKiB.js";import{u as z}from"./useQuery-DQfTiywB.js";import{u as P}from"./useMutation-Ou9Q83JG.js";import{u as b}from"./useServerFn-DJOSWF3u.js";import{B as K}from"./badge-sq-DRzk8.js";import{D as V,a as J,b as O,d as v}from"./dropdown-menu-Be6ya9Jw.js";import{I as y}from"./input-CcozFbXh.js";import{S as Z,a as W,b as X,c as Y,d as C}from"./select-t0bn6R_5.js";import{T as ee,a as se,b as B,c as x,d as ae,e as u}from"./table-B0SMdW22.js";import{E as te,L as ne}from"./list-pagination-D5WtcdPG.js";import{D as ie,a as re,b as le,c as de}from"./dialog-CITrCC0q.js";import{L as w}from"./label-DGWP3VjG.js";import{g as ce,u as oe,a as me,c as ue,l as xe,m as he,b as pe}from"./admin-management.functions-Dc4OkdKI.js";import{S as ge}from"./search-lF4B9wEs.js";import"./index-Bf2Jiyvi.js";import"./index-J0TyYv5_.js";import"./index-D4zhKhw0.js";import"./chevron-right-o698nvI-.js";import"./chevron-down-CHCp_ATj.js";import"./chevron-left-DnriL53w.js";function je({userId:i,onClose:o}){const n=b(ce),d=b(oe),A=b(me),E=G(),t=z({queryKey:["admin","public-user",i],queryFn:()=>n({data:{userId:i}}),enabled:!!i}),[q,N]=l.useState("15"),[T,_]=l.useState(""),[p,D]=l.useState(""),[k,g]=l.useState(""),[L,S]=l.useState(""),[M,j]=l.useState(""),r=t.data?.credits??null;l.useEffect(()=>{t.data&&(_(String(r?.monthlyAllowance??10)),D(String(r?.bonusRemaining??0)),g(String(r?.baseRemaining??0)),S(t.data.profile?.display_name??""),j(t.data.profile?.company??""))},[t.data]);const R=()=>{E.invalidateQueries({queryKey:["admin","public-user",i]}),E.invalidateQueries({queryKey:["admin","public-users"]})},m=P({mutationFn:a=>d({data:{userId:i,...a}}),onSuccess:()=>{c.success("Credits updated"),R()},onError:a=>c.error(a.message)}),U=P({mutationFn:()=>A({data:{userId:i,display_name:L||null,company:M||null}}),onSuccess:()=>{c.success("Profile saved"),R()},onError:a=>c.error(a.message)});return e.jsx(ie,{open:!!i,onOpenChange:a=>!a&&o(),children:e.jsxs(re,{className:"max-h-[88vh] overflow-y-auto sm:max-w-2xl",children:[e.jsx(le,{children:e.jsx(de,{children:"Manage account"})}),t.isLoading&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading account…"}),t.isError&&e.jsx("p",{className:"text-sm text-destructive",children:t.error.message}),t.data&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:t.data.profile?.display_name??t.data.user.email??"Anonymous visitor"}),t.data.user.suspended&&e.jsx(K,{variant:"destructive",children:"Suspended"}),t.data.user.anonymous&&e.jsx(K,{variant:"outline",children:"Anonymous"})]}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t.data.user.email??t.data.user.id}),e.jsxs("div",{className:"mt-2 grid gap-1 text-xs text-muted-foreground sm:grid-cols-2",children:[e.jsxs("span",{children:["Joined ",new Date(t.data.user.created_at).toLocaleDateString()]}),e.jsxs("span",{children:["Last sign-in"," ",t.data.user.last_sign_in_at?new Date(t.data.user.last_sign_in_at).toLocaleString():"Never"]}),e.jsxs("span",{children:[t.data.counts.projects," projects · ",t.data.counts.concepts," concepts"]}),e.jsxs("span",{children:[t.data.counts.submissions," submissions"]})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Concept credits"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx($,{label:"Monthly (base)",value:r?.baseRemaining??0,note:`of ${r?.monthlyAllowance??10}`}),e.jsx($,{label:"Gifted (bonus)",value:r?.bonusRemaining??0,note:"never expires"}),e.jsx($,{label:"Total left",value:r?.remaining??0,note:r?.resetsAt?`refills ${new Date(r.resetsAt).toLocaleDateString()}`:""})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Gifted credits are always spent before the monthly base credits."}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{children:[e.jsx(w,{className:"text-xs",children:"Gift credits"}),e.jsx(y,{className:"mt-1 w-28",type:"number",value:q,onChange:a=>N(a.target.value)})]}),e.jsx(h,{disabled:m.isPending,onClick:()=>m.mutate({gift:Number(q)||0}),children:"Add gifted credits"}),e.jsx(h,{variant:"outline",disabled:m.isPending,onClick:()=>m.mutate({refillNow:!0}),children:"Refill base now"})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx(w,{className:"text-xs",children:"Monthly allowance"}),e.jsx(y,{className:"mt-1",type:"number",value:T,onChange:a=>_(a.target.value)})]}),e.jsxs("div",{children:[e.jsx(w,{className:"text-xs",children:"Base remaining"}),e.jsx(y,{className:"mt-1",type:"number",value:k,onChange:a=>g(a.target.value)})]}),e.jsxs("div",{children:[e.jsx(w,{className:"text-xs",children:"Gifted remaining"}),e.jsx(y,{className:"mt-1",type:"number",value:p,onChange:a=>D(a.target.value)})]}),e.jsx("div",{className:"flex items-end",children:e.jsx(h,{variant:"secondary",className:"w-full",disabled:m.isPending,onClick:()=>m.mutate({monthlyAllowance:Number(T)||0,setBase:Number(k)||0,setBonus:Number(p)||0}),children:"Save exact values"})})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Profile"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(w,{className:"text-xs",children:"Full name"}),e.jsx(y,{className:"mt-1",value:L,onChange:a=>S(a.target.value)})]}),e.jsxs("div",{children:[e.jsx(w,{className:"text-xs",children:"Company"}),e.jsx(y,{className:"mt-1",value:M,onChange:a=>j(a.target.value)})]})]}),e.jsx(h,{variant:"outline",disabled:U.isPending,onClick:()=>U.mutate(),children:"Save profile"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Credit history"}),t.data.ledger.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No activity yet."}),e.jsx("ul",{className:"divide-y rounded-md border text-xs",children:t.data.ledger.map(a=>e.jsxs("li",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"text-muted-foreground",children:[new Date(a.created_at).toLocaleStr
1ing()," · ",a.kind," · ",a.bucket,a.reason?` · ${a.reason}`:""]}),e.jsx("span",{className:a.delta>0?"font-semibold text-emerald-500":"font-semibold",children:a.delta>0?`+${a.delta}`:a.delta})]},a.id))})]})]})]})})}function $({label:i,value:o,note:n}){return e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:i}),e.jsx("div",{className:"font-display text-2xl font-semibold",children:o}),n&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:n})]})}const F=24;function Fe(){const i=I({from:Q.fullPath}),{page:o,q:n,kind:d}=Q.useSearch(),A=b(xe),E=b(pe),t=b(ue),q=b(he),N=G(),[T,_]=l.useState(null),[p,D]=l.useState(n);l.useEffect(()=>D(n),[n]),l.useEffect(()=>{if(p===n)return;const s=setTimeout(()=>i({search:{page:1,q:p,kind:d}}),300);return()=>clearTimeout(s)},[p,n,d,i]);const k={search:n,kind:d,offset:(o-1)*F,limit:F},g=z({queryKey:["admin","public-users",n,d,o],queryFn:()=>A({data:k}),placeholderData:H}),L=P({mutationFn:s=>E({data:s}),onSuccess:()=>{c.success("Account updated"),N.invalidateQueries({queryKey:["admin","public-users"]})},onError:s=>c.error(s.message)}),S=P({mutationFn:()=>t(),onSuccess:s=>{c.success(`Cleaned up ${s.deleted} empty anonymous session${s.deleted===1?"":"s"}${s.errors?.length?` (${s.errors.length} errors)`:""}.`),N.invalidateQueries({queryKey:["admin","public-users"]})},onError:s=>c.error(s.message)}),M=P({mutationFn:s=>q({data:{...s,origin:window.location.origin}}),onSuccess:s=>{c.success(s?.message??"Done."),N.invalidateQueries({queryKey:["admin","public-users"]})},onError:s=>c.error(s.message)}),j=(s,f)=>{f==="confirm_email"&&!confirm("Mark this email address as confirmed so they can sign in?")||M.mutate({userId:s,action:f})},r=(s,f)=>{(f==="delete"||f==="suspend")&&!confirm(f==="delete"?"Permanently delete this account and its working designs? Submitted business records will be retained.":"Suspend this account?")||L.mutate({userId:s,action:f})},R=()=>{N.prefetchQuery({queryKey:["admin","public-users",n,d,o+1],queryFn:()=>A({data:{...k,offset:o*F}})})},m=g.data?.rows??[],U=g.data?.total??0,a=g.data?.unconfirmedTotal??0;return e.jsxs("div",{className:"space-y-4",children:[a>0&&d!=="unconfirmed"&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:[e.jsxs("span",{children:[a," account",a===1?"":"s"," signed up but never confirmed their email — they can't sign in yet."]}),e.jsx(h,{size:"sm",variant:"outline",onClick:()=>i({search:{page:1,q:n,kind:"unconfirmed"}}),children:"Review them"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-[1fr_220px_auto]",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ge,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(y,{className:"pl-9",placeholder:"Search email, name, or company",value:p,onChange:s=>D(s.target.value)})]}),e.jsxs(Z,{value:d,onValueChange:s=>i({search:{page:1,q:n,kind:s}}),children:[e.jsx(W,{children:e.jsx(X,{})}),e.jsxs(Y,{children:[e.jsx(C,{value:"all",children:"Real users (default)"}),e.jsx(C,{value:"registered",children:"Registered"}),e.jsx(C,{value:"unconfirmed",children:"Unconfirmed email"}),e.jsx(C,{value:"anonymous",children:"Anonymous (with activity)"}),e.jsx(C,{value:"empty_anonymous",children:"Empty anonymous sessions"}),e.jsx(C,{value:"suspended",children:"Suspended"})]})]}),e.jsx(h,{variant:"outline",disabled:S.isPending,onClick:()=>{confirm("Delete all anonymous sessions older than 24 hours with zero activity? This cannot be undone.")&&S.mutate()},children:S.isPending?"Cleaning…":"Clean up empty anon"})]}),e.jsx("div",{className:"overflow-x-auto rounded-md border",children:e.jsxs(ee,{children:[e.jsx(se,{children:e.jsxs(B,{children:[e.jsx(x,{children:"User"}),e.jsx(x,{children:"Status"}),e.jsx(x,{className:"text-right",children:"Credits"}),e.jsx(x,{className:"text-right",children:"Projects"}),e.jsx(x,{className:"text-right",children:"Concepts"}),e.jsx(x,{className:"text-right",children:"Submissions"}),e.jsx(x,{children:"Last sign-in"}),e.jsx(x,{})]})}),e.jsxs(ae,{children:[m.map(s=>e.jsxs(B,{children:[e.jsxs(u,{children:[e.jsx("div",{className:"font-medium",children:s.display_name??s.email??"Anonymous visitor"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.email??s.id})]}),e.jsxs(u,{children:[e.jsx(K,{variant:s.suspended?"destructive":s.anonymous||s.unconfirmed?"outline":"secondary",children:s.suspended?"Suspended":s.anonymous?"Anonymous":s.unconfirmed?"Not confirmed":"Active"}),s.unconfirmed&&e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Signed up ",new Date(s.created_at).toLocaleDateString()," · never signed in"]})]}),e.jsx(u,{className:"text-right",children:s.anonymous?e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}):s.credits?e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.credits.base+s.credits.bonus}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.credits.base," base · ",s.credits.bonus," gifted"]})]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"not set up"})}),e.jsx(u,{className:"text-right",children:s.projects}),e.jsx(u,{className:"text-right",children:s.concepts}),e.jsx(u,{className:"text-right",children:s.submissions}),e.jsx(u,{className:"text-xs text-muted-foreground",children:s.last_sign_in_at?new Date(s.last_sign_in_at).toLocaleStr
1ing():"Never"}),e.jsx(u,{children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[!s.anonymous&&e.jsx(h,{variant:"outline",size:"sm",onClick:()=>_(s.id),children:"Manage"}),e.jsxs(V,{children:[e.jsx(J,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon",children:e.jsx(te,{className:"h-4 w-4"})})}),e.jsxs(O,{align:"end",children:[!s.anonymous&&s.unconfirmed&&e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:()=>j(s.id,"resend_confirmation"),children:"Resend confirmation email"}),e.jsx(v,{onClick:()=>j(s.id,"confirm_email"),children:"Confirm email manually"})]}),!s.anonymous&&e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:()=>j(s.id,"send_magic_link"),children:"Send sign-in link"}),e.jsx(v,{onClick:()=>j(s.id,"send_password_reset"),children:"Send password reset"})]}),e.jsx(v,{onClick:()=>r(s.id,s.suspended?"reactivate":"suspend"),children:s.suspended?"Reactivate":"Suspend"}),e.jsx(v,{onClick:()=>r(s.id,"reset_usage"),children:"Reset monthly usage"}),e.jsx(v,{className:"text-destructive",onClick:()=>r(s.id,"delete"),children:"Delete account"})]})]})]})})]},s.id)),!g.isLoading&&m.length===0&&e.jsx(B,{children:e.jsx(u,{colSpan:8,className:"py-10 text-center text-muted-foreground",children:"No users match these filters."})})]})]})}),e.jsx(ne,{page:o,pageSize:F,total:U,onPageChange:s=>i({search:{page:s,q:n,kind:d}}),onPrefetchNext:R}),e.jsx(je,{userId:T,onClose:()=>_(null)})]})}export{Fe 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.