PageSourceSearch

https://get.vaultshelf.com/assets/UserDetail-Cub-c9oF.js

js vaultshelf.com collected 2026-10-02 01:48:09 UTC 10,801 bytes, 1 lines download raw bytes

1import{W as B,y as U,r as g,U as O,F as $,j as e,L as q,B as i,ar as l,ao as R,ah as I,d as z}from"./index-B9xblx1X.js";import{p as F,A as j}from"./AdminBadge-BOwKRD__.js";import{C as M}from"./ChangePlanDialog-Jqa3zm3c.js";import{C as v}from"./ConfirmDestructiveDialog-B1PIECrX.js";import{M as K}from"./MetricGrid-B9fQdybB.js";import{C as u,b as p,c as x,a as h}from"./card-CK5sTH4r.js";import{I as Q}from"./input-BgkJCVH0.js";import{S as G}from"./skeleton-DfJRheVQ.js";import{T as H}from"./textarea-BoUB8h49.js";import{A as J}from"./arrow-left-bJDptuwE.js";import{E as V}from"./external-link-BKp7hCh4.js";import"./badge-4Ub-F2rG.js";import"./checkbox-Bp09YZP1.js";import"./index-fou4DczH.js";import"./check-BUi6PNNz.js";import"./dialog-XBgjYxRF.js";import"./index-CaFA2jif.js";import"./index-D45U-z8e.js";import"./Combination-R_zhYWsV.js";import"./label-pqjvqnDT.js";import"./index-DKFJyVm0.js";import"./index-ByduhlRr.js";import"./circle-BoK6zVHP.js";import"./alert-dialog-CqOkVI1E.js";function fe(){var w,A,P,L,D;const{userId:o=""}=B(),f=U(),[d,y]=g.useState(""),[C,S]=g.useState(""),[m,r]=g.useState(null),{data:_,isLoading:E,error:N}=O({queryKey:["admin","user",o],enabled:!!o,queryFn:()=>I("users.get",{userId:o})}),t=_==null?void 0:_.user,b=g.useMemo(()=>(t==null?void 0:t.tags)||[],[t==null?void 0:t.tags]),a=$({mutationFn:async s=>I(s.action,{userId:o,...s.body||{}}),onSuccess:async()=>{await f.invalidateQueries({queryKey:["admin","user",o]}),z.success("Updated"),r(null)},onError:s=>z.error(s.message)});if(E)return e.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((s,c)=>e.jsx(G,{className:"h-24"}
1,c))});if(N||!t)return e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:N instanceof Error?N.message:"User not found"});const T=F({plan:t.plan,subscriptionStatus:(w=t.subscription)==null?void 0:w.status,accountStatus:t.account_status,isAdmin:t.is_admin,lastSeenAt:t.last_seen_at,lifetimeUnlocked:!!t.lifetime_unlocked_at,adminGranted:!!t.admin_granted_pro_at}),k=t.stripe_customer_id?`https://dashboard.stripe.com/customers/${t.stripe_customer_id}`:null;return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(q,{to:"/admin/users",className:"mb-2 inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[e.jsx(J,{className:"h-3.5 w-3.5"})," Users"]}),e.jsx("h1",{className:"text-xl font-bold tracking-tight sm:text-2xl",children:t.display_name||t.email}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.email}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1",children:[T.map(s=>e.jsx(j,{label:s.label,tone:s.tone},s.label)),b.map(s=>e.jsx(j,{label:s},s))]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[k&&e.jsx(i,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:k,target:"_blank",rel:"noreferrer",children:["Open in Stripe ",e.jsx(V,{className:"ml-1 h-3.5 w-3.5"})]})}),t.account_status==="suspended"?e.jsx(i,{size:"sm",variant:"outline",onClick:()=>a.mutate({action:"users.restore"}),children:"Restore"}):e.jsx(i,{size:"sm",variant:"outline",onClick:()=>r("suspend"),children:"Suspend"}),e.jsx(i,{size:"sm",variant:"outline",onClick:()=>a.mutate({action:"users.resetPassword"}),children:"Password reset"}),e.jsx(i,{size:"sm",variant:"outline",onClick:()=>a.mutate({action:"users.resendVerification"}),children:"Resend verification"}),e.jsx(i,{size:"sm",variant:"outline",onClick:()=>r("changePlan"),children:"Change plan"}),e.jsx(i,{size:"sm",variant:"outline",onClick:()=>r("cancelSubscription"),children:"Cancel subscription"}),e.jsx(i,{size:"sm",variant:"destructive",onClick:()=>r("deleteContent"),children:"Delete content"}),e.jsx(i,{size:"sm",variant:"destructive",onClick:()=>r("deleteAccount"),children:"Delete account"})]})]}),e.jsxs(u,{className:"border-border/60 shadow-none",children:[e.jsx(p,{className:"pb-2",children:e.jsx(x,{className:"text-sm",children:"Account"})}),e.jsxs(h,{className:"grid gap-2 text-sm sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(n,{label:"User ID",value:t.user_id,mono:!0}),e.jsx(n,{label:"Email verified",value:t.email_verified?"Yes":"No"}),e.jsx(n,{label:"Provider",value:t.provider}),e.jsx(n,{label:"Joined",value:l(t.joined_at)}),e.jsx(n,{label:"Last seen",value:l(t.last_seen_at)}),e.jsx(n,{label:"Last login",value:l(t.last_login_at)}),e.jsx(n,{label:"Plan",value:t.plan}),e.jsx(n,{label:"Subscription",value:((A=t.subscription)==null?void 0:A.status)||"none"}),e.jsx(n,{label:"Period end",value:l((P=t.subscription)==null?void 0:P.current_period_end)}),e.jsx(n,{label:"Lifetime",value:t.lifetime_unlocked_at?l(t.lifetime_unlocked_at):"—"}),e.jsx(n,{label:"Admin grant",value:t.admin_granted_pro_at?l(t.admin_granted_pro_at):"—"}),e.jsx(n,{label:"Apple",value:(L=t.apple)!=null&&L.entitlement_active?`Active${t.apple.product_id?` · ${t.apple.product_id}`:""}`:"—"}),e.jsx(n,{label:"Account status",value:t.account_status}),e.jsx(n,{label:"Suspended at",value:l(t.suspended_at)}),e.jsx(n,{label:"Suspended reason",value:t.suspended_reason||"—"})]})]}),e.jsx(K,{items:[{label:"Stored items",value:t.item_count},{label:"Items 7d",value:t.items_7d},{label:"Items 30d",value:t.items_30d},{label:"Storage",value:R(t.storage_bytes)},{label:"Shelves",value:t.collection_count},{label:"Captures OK",value:t.captures_completed},{label:"Captures failed",value:t.captures_failed},{label:"Latest capture",value:((D=t.latest_item)==null?void 0:D.title)||"—",hint:t.latest_item?l(t.latest_item.saved_at):void 0}]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 shadow-none",children:[e.jsx(p,{className:"pb-2",children:e.jsx(x,{className:"text-sm",children:"Recent activity"})}),e.jsxs(h,{className:"max-h-80 space-y-2 overflow-y-auto",children:[(t.recent_activity||[]).length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No activity events yet."}),(t.recent_activity||[]).map((s,c)=>e.jsxs("div",{className:"rounded-md border border-border/50 px-2.5 py-1.5 text-sm",children:[e.jsx("p",{className:"font-medium capitalize",children:String(s.type||"event").replace(/_/g," ")}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[l(String(s.at||"")),s.title?` · ${String(s.title)}`:"",s.name?` · ${String(s.name)}`:""]})]},c))]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(u,{className:"border-border/60 shadow-none",children:[e.jsx(p,{className:"pb-2",children:e.jsx(x,{className:"text-sm",children:"Support feedback"})}),e.jsxs(h,{className:"max-h-64 space-y-2 overflow-y-auto",children:[(t.feedback||[]).length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No feedback submitted."}),(t.feedback||[]).map(s=>e.jsxs("div",{className:"rounded-md border border-border/50 px-2.5 py-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(j,{label:s.category}),e.jsx(j,{label:s.status,tone:s.status==="open"?"warning":s.status==="resolved"?"success":"muted"})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap",children:s.message}),e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[l(s.created_at),s.page_path?` · ${s.page_path}`:""]})]},s.id))]})]}),e.jsxs(u,{className:"border-border/60 shadow-none",children:[e.jsx(p,{className:"pb-2",children:e.jsx(x,{className:"text-sm",children:"Internal notes"})}),e.jsxs(h,{className:"space-y-3",children:[e.jsx(H,{value:d,onChange:s=>y(s.target.value),placeholder:"Early adopter, reported bug, support requested…",className:"min-h-[80px] text-sm"}),e.jsx(i,{size:"sm",disabled:!d.trim()||a.isPending,onClick:()=>a.mutate({action:"users.setNotes",body:{body:d.trim()}},{onSuccess:()=>y("")}),children:"Add note"}),e.jsx("div",{className:"space-y-2",children:(t.notes||[]).map(s=>e.jsxs("div",{className:"rounded-md bg-muted/50 px-2.5 py-2 text-sm",children:[e.jsx("p",{children:s.body}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:l(s.created_at)})]},s.id))})]})]}),e.jsxs(u,{className:"border-border/60 shadow-none",children:[e.jsx(p,{className:"pb-2",children:e.jsx(x,{className:"text-sm",children:"Internal tags"})}),e.jsxs(h,{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Q,{value:C,onChange:s=>S(s.target.value),placeholder:"Add tag then press Save",className:"h-8 text-sm"}),e.jsx(i,{size:"sm",className:"h-8",onClick:()=>{const s=Array.from(new Set([...b,...C.split(",").map(c=>
1c.trim()).filter(Boolean)]));a.mutate({action:"users.setTags",body:{tags:s}},{onSuccess:()=>S("")})},children:"Save"})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:b.map(s=>e.jsxs("button",{type:"button",className:"rounded-md border border-border px-2 py-0.5 text-[11px] hover:bg-destructive/10",title:"Remove tag",onClick:()=>a.mutate({action:"users.setTags",body:{tags:b.filter(c=>c!==s)}}),children:[s," ×"]},s))})]})]})]})]}),e.jsx(v,{open:m==="suspend",onOpenChange:s=>!s&&r(null),title:"Suspend account",description:"The user will be banned from signing in. Type their email to confirm.",confirmEmail:t.email,loading:a.isPending,confirmLabel:"Suspend",onConfirm:s=>a.mutate({action:"users.suspend",body:{confirmEmail:s,reason:"Suspended by admin"}})}),e.jsx(v,{open:m==="deleteContent",onOpenChange:s=>!s&&r(null),title:"Delete all stored content",description:"Deletes items, collections, tags, and media for this user. Account remains.",confirmEmail:t.email,loading:a.isPending,confirmLabel:"Delete content",onConfirm:s=>a.mutate({action:"users.deleteContent",body:{confirmEmail:s}})}),e.jsx(v,{open:m==="deleteAccount",onOpenChange:s=>!s&&r(null),title:"Delete account permanently",description:"This removes the auth user and all content. This cannot be undone.",confirmEmail:t.email,loading:a.isPending,confirmLabel:"Delete account",onConfirm:s=>a.mutate({action:"users.deleteAccount",body:{confirmEmail:s}})}),e.jsx(v,{open:m==="cancelSubscription",onOpenChange:s=>!s&&r(null),title:"Cancel Stripe subscription",description:"Cancels via Stripe API. Local plan will update when the webhook arrives.",confirmEmail:t.email,loading:a.isPending,confirmLabel:"Cancel subscription",onConfirm:s=>a.mutate({action:"users.cancelSubscription",body:{confirmEmail:s}})}),e.jsx(M,{open:m==="changePlan",onOpenChange:s=>!s&&r(null),userId:t.user_id,email:t.email})]})}function n({label:o,value:f,mono:d}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:o}),e.jsx("p",{className:`mt-0.5 break-all ${d?"font-mono text-xs":""}`,children:f})]})}export{fe 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.