PageSourceSearch

https://sentitrack.ai/assets/Admin-HO79GHuo.js

js sentitrack.ai collected 2026-10-05 12:46:03 UTC 28,840 bytes, 1 lines download raw bytes

1import{u as $,f as W,j as e,O as G,a as B,h as O,r as l,i as q,e as N,C as U,B as f,L as k,I as o,A as I,E as R,T as H,b as m,c as i,d as T,s as J}from"./index-CxYxjiaW.js";function le(){const{t:s}=$("app"),{me:u,isLoading:c}=W();return c?e.jsx("div",{className:"text-fg-dim text-sm",children:s("admin.loading")}):u!=null&&u.user.is_platform_admin?e.jsxs("div",{className:"max-w-5xl mx-auto space-y-4",children:[e.jsx("h1",{className:"text-xl font-semibold text-fg",children:s("admin.title")}),e.jsxs("p",{className:"text-xs text-fg-dim",children:[s("admin.subtitlePrefix")," ",e.jsx("code",{className:"text-fg",children:"is_platform_admin=true"})," ",s("admin.subtitleSuffix")]}),e.jsx(X,{}),e.jsx(Y,{}),e.jsx(Z,{}),e.jsx(ee,{}),e.jsx(ae,{})]}):e.jsx(G,{to:"/settings",replace:!0})}function X(){var y;const{t:s}=$("app"),u=B(),c=O({queryKey:["admin-blog"],queryFn:()=>N("/blog/admin/posts")}),[n,r]=l.useState(""),[x,g]=l.useState(null),p=q({mutationFn:t=>N("/blog/admin/generate",{method:"POST",body:t}),onSuccess:t=>{r(""),g(s("admin.blog.generateNotice",{message:t.message,scheduled:t.scheduled})),[2e4,6e4,12e4].forEach(a=>setTimeout(()=>u.invalidateQueries({queryKey:["admin-blog"]}),a))}}),d=q({mutationFn:({id:t,published:a})=>N(`/blog/admin/posts/${t}`,{method:"PATCH",body:{published:a}}),onSuccess:()=>u.invalidateQueries({queryKey:["admin-blog"]})}),h=q({mutationFn:t=>N(`/blog/admin/posts/${t}`,{method:"DELETE"}),onSuccess:()=>u.invalidateQueries({queryKey:["admin-blog"]})}),v=q({mutationFn:({id:t,force:a})=>N(`/blog/admin/posts/${t}/social`,{method:"POST",body:{force:a}}),onSuccess:t=>{g(s("admin.blog.socialQueued",{job:t.job_id})),[2e4,6e4].forEach(a=>setTimeout(()=>u.invalidateQueries({queryKey:["admin-blog"]}),a))}}),S=c.data??[],C=S.filter(t=>t.published).length;return e.jsx(U,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg mb-0.5",children:s("admin.blog.title")}),e.jsxs("p",{className:"text-xs text-fg-dim",children:[s("admin.blog.descPrefix")," ",e.jsx("code",{className:"text-fg",children:((y=S[0])==null?void 0:y.model_used)??"opus"})," ",s("admin.blog.descMiddle")," ",s("admin.blog.descStats",{total:S.length,published:C})," ",s("admin.blog.descSuffix")]})]}),e.jsx(f,{variant:"secondary",onClick:()=>u.invalidateQueries({queryKey:["admin-blog"]}),children:s("admin.blog.refresh")})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-[240px]",children:[e.jsx(k,{children:s("admin.blog.topicLabel")}),e.jsx(o,{value:n,onChange:t=>r(t.target.value),placeholder:s("admin.blog.topicPlaceholder")})]}),e.jsx(f,{onClick:()=>p.mutate({topic:n.trim()||void 0,count:1}),disabled:p.isPending,children:p.isPending?s("admin.blog.generating"):s("admin.blog.generateNow")})]}),x&&e.jsx("p",{className:"text-[11px] text-ok",children:x}),p.error instanceof I&&e.jsx(R,{message:p.error.message}
1),e.jsxs(H,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(m,{children:s("admin.blog.table.article")}),e.jsx(m,{children:s("admin.blog.table.category")}),e.jsx(m,{children:s("admin.blog.table.status")}),e.jsx(m,{children:s("admin.blog.table.social")}),e.jsx(m,{className:"text-right",children:s("admin.blog.table.read")}),e.jsx(m,{children:s("admin.blog.table.actions")})]})}),e.jsxs("tbody",{children:[S.map(t=>e.jsxs("tr",{children:[e.jsx(i,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[t.published&&t.header_image_url?e.jsx("img",{src:t.header_image_url,alt:"",className:"w-12 h-8 object-cover rounded shrink-0"}):e.jsx("div",{className:"w-12 h-8 rounded bg-bg border border-border shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-fg truncate max-w-[280px]",children:t.title}),e.jsx("div",{className:"text-[11px] text-fg-dim font-mono truncate max-w-[280px]",children:t.slug})]})]})}),e.jsx(i,{className:"text-xs",children:t.category}),e.jsx(i,{children:t.published?e.jsx(T,{tone:"ok",children:s("admin.blog.statusPublished")}):e.jsx(T,{tone:"default",children:s("admin.blog.statusDraft")})}),e.jsx(i,{children:t.social_post_id?e.jsx(T,{tone:t.social_draft?"default":"ok",children:t.social_draft?s("admin.blog.socialDraft"):s("admin.blog.socialPosted",{platforms:t.social_platforms.join(", ")})}):e.jsx("span",{className:"text-[11px] text-fg-dim",children:s("admin.blog.socialNone")})}),e.jsxs(i,{className:"text-right text-xs font-mono",children:[t.reading_minutes,"m"]}),e.jsx(i,{children:e.jsxs("div",{className:"flex gap-1",children:[t.published&&e.jsx("a",{href:`/blog/${t.slug}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center px-2 h-8 rounded-md border border-border text-xs text-fg-dim hover:text-fg",children:s("admin.blog.view")}),e.jsx(f,{variant:"secondary",onClick:()=>d.mutate({id:t.id,published:!t.published}),disabled:d.isPending,children:t.published?s("admin.blog.unpublish"):s("admin.blog.publish")}),t.published&&e.jsx(f,{variant:"secondary",onClick:()=>{const a=!!t.social_post_id,w=a?s("admin.blog.socialRepostConfirm",{title:t.title}):s("admin.blog.socialConfirm",{title:t.title});confirm(w)&&v.mutate({id:t.id,force:a})},disabled:v.isPending,children:t.social_post_id?s("admin.blog.socialRepost"):s("admin.blog.socialPost")}),e.jsx(f,{variant:"ghost",onClick:()=>{confirm(s("admin.blog.deleteConfirm",{title:t.title}))&&h.mutate(t.id)},children:s("admin.blog.delete")})]})})]},t.id)),S.length===0&&!c.isLoading&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-3 border-b border-border/60",children:e.jsx("span",{className:"text-xs text-fg-dim",children:s("admin.blog.empty")})})})]})]})]})})}function Y(){const s=B(),u=J(),c=O({queryKey:["admin-pages"],queryFn:()=>N("/pages/admin")}),[n,r]=l.useState(""),[x,g]=l.useState(""),[p,d]=l.useState(null),h=q({mutationFn:a=>N("/pages/admin",{method:"POST",body:a}),onSuccess:a=>{r(""),g(""),s.invalidateQueries({queryKey:["admin-pages"]}),u(`/admin/pages/${a.id}/edit`)}}),v=q({mutationFn:({id:a,published:w})=>N(`/pages/admin/${a}`,{method:"PATCH",body:{published:w}}),onSuccess:()=>s.invalidateQueries({queryKey:["admin-pages"]})}),S=q({mutationFn:a=>N(`/pages/admin/${a}`,{method:"DELETE"}),onSuccess:()=>s.invalidateQueries({queryKey:["admin-pages"]})}),C=q({mutationFn:a=>N(`/pages/admin/${a}/translate`,{method:"POST"}),onSuccess:()=>{d("Translation started in the background — refresh in a minute to see progress."),[3e4,9e4].forEach(a=>setTimeout(()=>s.invalidateQueries({queryKey:["admin-pages"]}),a))}}),y=c.data??[],t=y.filter(a=>a.published).length;return e.jsx(U,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg mb-0.5",children:"Pages (visual builder)"}),e.jsxs("p",{className:"text-xs text-fg-dim",children:["Build & edit public marketing pages with the Puck editor."," ",y.length," page",y.length===1?"":"s",", ",t," published. A page with slug ",e.jsx("code",{className:"text-fg",children:"home"})," overrides the landing page at"," ",e.jsx("code",{className:"text-fg",children:"/"}),"."]})]}),e.jsx(f,{variant:"secondary",onClick:()=>s.invalidateQueries({queryKey:["admin-pages"]}),children:"Refresh"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"min-w-[200px]",children:[e.jsx(k,{children:"Slug"}),e.jsx(o,{value:n,onChange:a=>r(a.target.value),placeholder:"home, about, partners…"})]}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx(k,{children:"Title"}),e.jsx(o,{value:x,onChange:a=>g(a.target.value),placeholder:"Page title"})]}),e.jsx(f,{onClick:()=>h.mutate({slug:n.trim(),title:x.trim()||"Untitled page"}),disabled:h.isPending||!n.trim(),children:h.isPending?"Creating…":"Create & edit"})]}),p&&e.jsx("p",{className:"text-[11px] text-ok",children:p}),h.error instanceof I&&e.jsx(R,{message:h.error.message}
1),e.jsxs(H,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(m,{children:"Page"}),e.jsx(m,{children:"Nav"}),e.jsx(m,{children:"Status"}),e.jsx(m,{className:"text-right",children:"Translated"}),e.jsx(m,{children:"Actions"})]})}),e.jsxs("tbody",{children:[y.map(a=>e.jsxs("tr",{children:[e.jsxs(i,{children:[e.jsx("div",{className:"text-sm text-fg truncate max-w-[280px]",children:a.title}),e.jsxs("div",{className:"text-[11px] text-fg-dim font-mono truncate max-w-[280px]",children:["/",a.slug==="home"?"":a.slug]})]}),e.jsx(i,{children:a.show_in_nav?e.jsxs(T,{tone:"accent",children:["#",a.nav_order]}):e.jsx("span",{className:"text-fg-dim text-xs",children:"—"})}),e.jsx(i,{children:a.published?e.jsx(T,{tone:"ok",children:"Published"}):e.jsx(T,{tone:"default",children:"Draft"})}),e.jsxs(i,{className:"text-right text-xs font-mono",children:[a.translated_langs.length,"/7"]}),e.jsx(i,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(f,{variant:"secondary",onClick:()=>u(`/admin/pages/${a.id}/edit`),children:"Edit"}),a.published&&e.jsx("a",{href:`/${a.slug==="home"?"":a.slug}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center px-2 h-8 rounded-md border border-border text-xs text-fg-dim hover:text-fg",children:"View"}),e.jsx(f,{variant:"secondary",onClick:()=>v.mutate({id:a.id,published:!a.published}),disabled:v.isPending,children:a.published?"Unpublish":"Publish"}),e.jsx(f,{variant:"ghost",onClick:()=>C.mutate(a.id),disabled:C.isPending,children:"Translate"}),e.jsx(f,{variant:"ghost",onClick:()=>{confirm(`Delete "${a.title}"? This cannot be undone.`)&&S.mutate(a.id)},children:"Delete"})]})})]},a.id)),y.length===0&&!c.isLoading&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-3 py-3 border-b border-border/60",children:e.jsx("span",{className:"text-xs text-fg-dim",children:"No pages yet. Create one above — try slug “home” to replace the landing page."})})})]})]})]})})}function Z(){const{t:s}=$("app"),u=B(),c=O({queryKey:["admin-stripe-config"],queryFn:()=>N("/admin/stripe-config")}),n=q({mutationFn:j=>N("/admin/stripe-config",{method:"PATCH",body:j}),onSuccess:()=>u.invalidateQueries({queryKey:["admin-stripe-config"]})}),r=c.data,[x,g]=l.useState(""),[p,d]=l.useState(""),[h,v]=l.useState(""),[S,C]=l.useState(""),[y,t]=l.useState(""),[a,w]=l.useState("");l.useEffect(()=>{r&&(v(r.publishable_key??""),C(r.sales_contact_email??""),t(r.billing_success_url??""),w(r.billing_cancel_url??""))},[r]);async function E(j){j.preventDefault();const P={publishable_key:h||null,sales_contact_email:S||null,billing_success_url:y||null,billing_cancel_url:a||null};x&&(P.secret_key=x),p&&(P.webhook_secret=p),await n.mutateAsync(P),g(""),d("")}return e.jsx(U,{children:e.jsxs("form",{onSubmit:E,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg mb-0.5",children:s("admin.stripe.title")}),e.jsx("p",{className:"text-xs text-fg-dim",children:s("admin.stripe.desc")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs(k,{children:[s("admin.stripe.secretKeyLabel")," ",r!=null&&r.secret_key_configured?e.jsx("span",{className:"text-ok text-[10px] uppercase ml-1",children:s("admin.stripe.saved")}):e.jsx("span",{className:"text-danger text-[10px] uppercase ml-1",children:s("admin.stripe.missing")})]}),e.jsx(o,{type:"password",value:x,onChange:j=>g(j.target.value),placeholder:r!=null&&r.secret_key_configured?s("admin.stripe.secretSavedPlaceholder"):s("admin.stripe.secretKeyPlaceholder"),autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsxs(k,{children:[s("admin.stripe.webhookSecretLabel")," ",r!=null&&r.webhook_secret_configured?e.jsx("span",{className:"text-ok text-[10px] uppercase ml-1",children:s("admin.stripe.saved")}):e.jsx("span",{className:"text-danger text-[10px] uppercase ml-1",children:s("admin.stripe.missing")})]}),e.jsx(o,{type:"password",value:p,onChange:j=>d(j.target.value),placeholder:r!=null&&r.webhook_secret_configured?s("admin.stripe.secretSavedPlaceholder"):s("admin.stripe.webhookSecretPlaceholder"),autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsx(k,{children:s("admin.stripe.publishableKeyLabel")}),e.jsx(o,{value:h,onChange:j=>v(j.target.value),placeholder:"pk_live_… or pk_test_…"})]}),e.jsxs("div",{children:[e.jsx(k,{children:s("admin.stripe.salesEmail
1Label")}),e.jsx(o,{type:"email",value:S,onChange:j=>C(j.target.value),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"col-span-2 grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{children:s("admin.stripe.successUrlLabel")}),e.jsx(o,{value:y,onChange:j=>t(j.target.value),placeholder:"https://sentitrack.ai/settings?billing=ok"})]}),e.jsxs("div",{children:[e.jsx(k,{children:s("admin.stripe.cancelUrlLabel")}),e.jsx(o,{value:a,onChange:j=>w(j.target.value),placeholder:"https://sentitrack.ai/settings?billing=cancelled"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(f,{type:"submit",disabled:n.isPending,children:n.isPending?s("admin.stripe.saving"):s("admin.stripe.saveButton")}),n.error instanceof I&&e.jsx(R,{message:n.error.message})]}),e.jsxs("p",{className:"text-[11px] text-fg-dim",children:[s("admin.stripe.webhookUrlLabel")," ",e.jsx("code",{className:"text-fg",children:"https://sentitrack.ai/api/v1/billing/webhook"}),". ",s("admin.stripe.eventsLabel")," ",e.jsx("code",{className:"text-fg",children:"checkout.session.completed"}),","," ",e.jsx("code",{className:"text-fg",children:"customer.subscription.created/updated/deleted"}),","," ",e.jsx("code",{className:"text-fg",children:"invoice.paid"}),","," ",e.jsx("code",{className:"text-fg",children:"invoice.payment_failed"}),"."]})]})})}function ee(){const{t:s}=$("app"),u=B(),c=O({queryKey:["admin-plans"],queryFn:()=>N("/admin/plans")}),n=q({mutationFn:({slug:d,body:h})=>N(`/admin/plans/${d}`,{method:"PATCH",body:h}),onSuccess:()=>u.invalidateQueries({queryKey:["admin-plans"]})}),r=q({mutationFn:d=>N("/admin/plans",{method:"POST",body:d}),onSuccess:()=>u.invalidateQueries({queryKey:["admin-plans"]})}),x=q({mutationFn:d=>N(`/admin/plans/${d}`,{method:"DELETE"}),onSuccess:()=>u.invalidateQueries({queryKey:["admin-plans"]})}),[g,p]=l.useState(!1);return e.jsx(U,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg mb-0.5",children:s("admin.plans.title")}),e.jsxs("p",{className:"text-xs text-fg-dim",children:[s("admin.plans.descPrefix")," (",e.jsx("code",{className:"text-fg",children:"price_…"}),") ",s("admin.plans.descOr")," (",e.jsx("code",{className:"text-fg",children:"prod_…"}),") ",s("admin.plans.descSuffix")]})]}),e.jsx(f,{variant:"secondary",onClick:()=>p(d=>!d),children:s("admin.plans.newPlan")})]}),g&&e.jsx(se,{onCreate:async d=>{await r.mutateAsync(d),p(!1)},onCancel:()=>p(!1)}
1),e.jsxs(H,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(m,{children:s("admin.plans.table.slug")}),e.jsx(m,{children:s("admin.plans.table.name")}),e.jsx(m,{className:"text-right",children:s("admin.plans.table.pricePerMo")}),e.jsx(m,{className:"text-right",children:s("admin.plans.table.employees")}),e.jsx(m,{className:"text-right",children:s("admin.plans.table.teamSeats")}),e.jsx(m,{className:"text-right",children:s("admin.plans.table.emailDomains")}),e.jsx(m,{className:"text-right",children:s("admin.plans.table.sentiaiPerMo")}),e.jsx(m,{children:s("admin.plans.table.stripeId")}),e.jsx(m,{children:s("admin.plans.table.flags")}),e.jsx(m,{children:s("admin.plans.table.actions")})]})}),e.jsx("tbody",{children:(c.data??[]).map(d=>e.jsx(te,{plan:d,onSave:async h=>{await n.mutateAsync({slug:d.slug,body:h})},onDelete:async()=>{if(confirm(s("admin.plans.deleteConfirm",{name:d.name,slug:d.slug})))try{await x.mutateAsync(d.slug)}catch(h){h instanceof I&&alert(h.message)}}},d.slug))})]})]})})}function se({onCreate:s,onCancel:u}){const{t:c}=$("app"),[n,r]=l.useState(""),[x,g]=l.useState(""),[p,d]=l.useState(""),[h,v]=l.useState(""),[S,C]=l.useState(""),[y,t]=l.useState(""),[a,w]=l.useState(""),[E,j]=l.useState(""),[P,F]=l.useState(""),[D,K]=l.useState(null),[Q,_]=l.useState(!1);async function M(b){if(b.preventDefault(),K(null),!/^[a-z][a-z0-9_-]*$/.test(n)){K(c("admin.plans.slugError"));return}_(!0);try{await s({slug:n,name:x.trim(),price_monthly_usd:p===""?null:Number(p),employee_limit:h===""?null:Number(h),sentiai_monthly_limit:S===""?null:Number(S),team_member_limit:y===""?null:Number(y),email_domain_limit:a===""?null:Number(a),stripe_price_or_product_id:E||null,blurb:P,is_public:!0,is_checkoutable:!0}),r(""),g(""),d(""),v(""),C(""),t(""),w(""),j(""),F("")}catch(A){K(A instanceof I?A.message:c("admin.plans.failed"))}finally{_(!1)}}return e.jsxs("form",{onSubmit:M,className:"rounded-md border border-border bg-bg/60 p-3 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.slug")}),e.jsx(o,{value:n,onChange:b=>r(b.target.value),placeholder:"plus"})]}),e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.name")}),e.jsx(o,{value:x,onChange:b=>g(b.target.value),placeholder:"Plus"})]}),e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.pricePerMo")}),e.jsx(o,{type:"number",min:0,value:p,onChange:b=>d(b.target.value),placeholder:"59"})]}),e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.employees")}),e.jsx(o,{type:"number",min:0,value:h,onChange:b=>v(b.target.value),placeholder:"75"})]}),e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.teamSeats")}),e.jsx(o,{type:"number",min:1,value:y,onChange:b=>t(b.target.value),placeholder:c("admin.plans.form.teamSeatsPlaceholder")})]}),e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.emailDomains")}),e.jsx(o,{type:"number",min:0,value:a,onChange:b=>w(b.target.value),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.sentiaiPerMo")}),e.jsx(o,{type:"number",min:0,value:S,onChange:b=>C(b.target.value),placeholder:"50000"})]}),e.jsxs("div",{className:"col-span-4",children:[e.jsx(k,{children:c("admin.plans.form.stripeId")}),e.jsx(o,{value:E,onChange:b=>j(b.target.value),placeholder:"price_… or prod_…"})]})]}),e.jsxs("div",{children:[e.jsx(k,{children:c("admin.plans.form.blurb")}),e.jsx(o,{value:P,onChange:b=>F(b.target.value),placeholder:c("admin.plans.form.blurbPlaceholder")})]}),D&&e.jsx(R,{message:D}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(f,{type:"button",variant:"secondary",onClick:u,children:c("admin.plans.form.cancel")}),e.jsx(f,{type:"submit",disabled:Q||!n||!x,children:c(Q?"admin.plans.form.creating":"admin.plans.form.createButton")})]})]})}function te({plan:s,onSave:u,onDelete:c}){var M,b,A,z,V;const{t:n}=$("app"),[r,x]=l.useState(!1),[g,p]=l.useState(s.name),[d,h]=l.useState(((M=s.price_monthly_usd)==null?void 0:M.toString())??""),[v,S]=l.useState(((b=s.employee_limit)==null?void 0:b.toString())??""),[C,y]=l.useState(((A=s.sentiai_monthly_limit)==null?void 0:A.toString())??""),[t,a]=l.useState(((z=s.team_member_limit)==null?void 0:z.toString())??""),[w,E]=l.useState(((V=s.email_domain_limit)==null?void 0:V.toString())??""),[j,P]=l.useState(s.stripe_price_or_product_id??""),[F,D]=l.useState(s.blurb),[K,Q]=l.useState(!1);async function _(){Q(!0);try{await u({name:g,price_monthly_usd:d===""?null:Number(d),employee_limit:v===""?null:Number(v),sentiai_monthly_limit:C===""?null:Number(C),team_member_limit:t===""?null:Number(t),email_domain_limit:w===""?null:Number(w),stripe_price_or_product_id:j||null,blurb:F}),x(!1)}finally{Q(!1)}}return r?e.jsxs("tr",{children:[e.jsx(i,{className:"font-mono text-xs",children:s.slug}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1",value:g,onChange:L=>p(L.target.value)})}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1 text-right",type:"number",min:0,value:d,onChange:L=>h(L.target.value),placeholder:"—"})}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1 text-right",type:"number",min:0,value:v,onCh
1ange:L=>S(L.target.value),placeholder:"∞"})}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1 text-right",type:"number",min:1,value:t,onChange:L=>a(L.target.value),placeholder:"∞"})}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1 text-right",type:"number",min:0,value:w,onChange:L=>E(L.target.value),placeholder:"∞"})}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1 text-right",type:"number",min:0,value:C,onChange:L=>y(L.target.value),placeholder:"∞"})}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1 font-mono text-xs",value:j,onChange:L=>P(L.target.value),placeholder:"price_… or prod_…"})}),e.jsx(i,{children:e.jsx(o,{className:"h-8 py-1",value:F,onChange:L=>D(L.target.value),placeholder:n("admin.plans.row.blurbPlaceholder")})}),e.jsx(i,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(f,{onClick:_,disabled:K,children:K?"…":n("admin.plans.row.save")}),e.jsx(f,{variant:"secondary",onClick:()=>x(!1),children:n("admin.plans.row.cancel")})]})})]}):e.jsxs("tr",{children:[e.jsx(i,{className:"font-mono text-xs",children:s.slug}),e.jsx(i,{children:s.name}),e.jsx(i,{className:"text-right font-mono",children:s.price_monthly_usd==null?"—":`$${s.price_monthly_usd}`}),e.jsx(i,{className:"text-right font-mono",children:s.employee_limit==null?"∞":s.employee_limit}),e.jsx(i,{className:"text-right font-mono",children:s.team_member_limit==null?"∞":s.team_member_limit}),e.jsx(i,{className:"text-right font-mono",children:s.email_domain_limit==null?"∞":s.email_domain_limit}),e.jsx(i,{className:"text-right font-mono",children:s.sentiai_monthly_limit==null?"∞":s.sentiai_monthly_limit.toLocaleString()}),e.jsx(i,{children:s.stripe_price_or_product_id?e.jsx("code",{className:"text-xs",children:s.stripe_price_or_product_id}):e.jsx("span",{className:"text-fg-dim text-xs",children:"—"})}),e.jsx(i,{children:e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[s.is_public&&e.jsx(T,{tone:"default",children:n("admin.plans.flags.public")}),s.is_checkoutable&&e.jsx(T,{tone:"ok",children:n("admin.plans.flags.checkoutable")}),!s.is_public&&!s.is_checkoutable&&e.jsx(T,{tone:"default",children:n("admin.plans.flags.internal")})]})}),e.jsx(i,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(f,{variant:"secondary",onClick:()=>x(!0),children:n("admin.plans.row.edit")}),e.jsx(f,{variant:"ghost",onClick:c,children:n("admin.plans.row.delete")})]})})]})}function ae(){const{t:s}=$("app"),u=B(),c=O({queryKey:["admin-orgs"],queryFn:()=>N("/admin/organizations")}),n=O({queryKey:["admin-plans"],queryFn:()=>N("/admin/plans")}),r=q({mutationFn:({id:x,body:g})=>N(`/admin/organizations/${x}`,{method:"PATCH",body:g}),onSuccess:()=>u.invalidateQueries({queryKey:["admin-orgs"]})});return e.jsx(U,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg mb-0.5",children:s("admin.orgs.title")}),e.jsx("p",{className:"text-xs text-fg-dim",children:s("admin.orgs.desc")})]}
1),e.jsxs(H,{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(m,{children:s("admin.orgs.table.org")}),e.jsx(m,{children:s("admin.orgs.table.admin")}),e.jsx(m,{children:s("admin.orgs.table.plan")}),e.jsx(m,{children:s("admin.orgs.table.status")}),e.jsx(m,{className:"text-right",children:s("admin.orgs.table.employees")}),e.jsx(m,{className:"text-right",children:s("admin.orgs.table.team")}),e.jsx(m,{className:"text-right",children:s("admin.orgs.table.domains")}),e.jsx(m,{className:"text-right",children:s("admin.orgs.table.sentiaiThisPeriod")}),e.jsx(m,{children:s("admin.orgs.table.overrides")})]})}),e.jsx("tbody",{children:(c.data??[]).map(x=>e.jsx(ie,{org:x,plans:n.data??[],onSave:async g=>{await r.mutateAsync({id:x.id,body:g})}},x.id))})]})]})})}function ie({org:s,plans:u,onSave:c}){var F,D,K,Q;const{t:n}=$("app"),[r,x]=l.useState(!1),[g,p]=l.useState(s.plan_slug),[d,h]=l.useState(((F=s.custom_employee_limit)==null?void 0:F.toString())??""),[v,S]=l.useState(((D=s.custom_sentiai_monthly_limit)==null?void 0:D.toString())??""),[C,y]=l.useState(((K=s.custom_team_member_limit)==null?void 0:K.toString())??""),[t,a]=l.useState(((Q=s.custom_email_domain_limit)==null?void 0:Q.toString())??""),[w,E]=l.useState(!1);async function j(){E(!0);try{await c({plan_slug:g!==s.plan_slug?g:void 0,custom_employee_limit:d===""?null:Number(d),custom_sentiai_monthly_limit:v===""?null:Number(v),custom_team_member_limit:C===""?null:Number(C),custom_email_domain_limit:t===""?null:Number(t)}),x(!1)}finally{E(!1)}}const P=(_,M)=>M==null?`${_.toLocaleString()} / ∞`:`${_.toLocaleString()} / ${M.toLocaleString()}`;return r?e.jsxs("tr",{children:[e.jsxs(i,{children:[e.jsx("div",{className:"text-sm text-fg",children:s.name}),e.jsx("div",{className:"text-[11px] text-fg-dim",children:s.slug})]}),e.jsx(i,{className:"font-mono text-xs",children:s.admin_email??"—"}),e.jsx(i,{children:e.jsx("select",{value:g,onChange:_=>p(_.target.value),className:"rounded-md bg-bg border border-border px-2 py-1 text-sm",children:u.map(_=>e.jsx("option",{value:_.slug,children:_.name},_.slug))})}),e.jsx(i,{children:e.jsx(T,{tone:"default",children:s.status})}),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.employees_used,s.employees_limit)}),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.team_members_used,s.team_members_limit)}),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.email_domains_used,s.email_domains_limit)}),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.sentiai_used,s.sentiai_limit)}),e.jsx(i,{children:e.jsxs("div",{className:"grid grid-cols-1 gap-1",children:[e.jsx(o,{className:"h-7 py-0.5 text-xs",placeholder:n("admin.orgs.override.empPlaceholder"),type:"number",min:0,value:d,onChange:_=>h(_.target.value)}),e.jsx(o,{className:"h-7 py-0.5 text-xs",placeholder:n("admin.orgs.override.teamPlaceholder"),type:"number",min:1,value:C,onChange:_=>y(_.target.value)}),e.jsx(o,{className:"h-7 py-0.5 text-xs",placeholder:n("admin.orgs.override.domainsPlaceholder"),type:"number",min:0,value:t,onChange:_=>a(_.target.value)}),e.jsx(o,{className:"h-7 py-0.5 text-xs",placeholder:n("admin.orgs.override.sentiaiPlaceholder"),type:"number",min:0,value:v,onChange:_=>S(_.target.value)}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(f,{className:"h-7 px-2 text-xs",onClick:j,disabled:w,children:w?"…":n("admin.orgs.override.save")}),e.jsx(f,{variant:"secondary",className:"h-7 px-2 text-xs",onClick:()=>x(!1),children:n("admin.orgs.override.cancel")})]})]})})]}):e.jsxs("tr",{children:[e.jsxs(i,{children:[e.jsx("div",{className:"text-sm text-fg",children:s.name}),e.jsx("div",{className:"text-[11px] text-fg-dim",children:s.slug})]}),e.jsx(i,{className:"font-mono text-xs",children:s.admin_email??"—"}),e.jsx(i,{children:s.plan_name}),e.jsxs(i,{children:[e.jsx(T,{tone:s.status==="active"?"ok":"default",children:s.status}),s.trial_end_at&&s.status==="trialing"&&e.jsxs("div",{className:"text-[10px] text-fg-dim mt-0.5",children:[n("admin.orgs.trialLabel")," ",new Date(s.trial_end_at).toLocaleDateString()]})]}),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.employees_used,s.employees_limit)}),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.team_members_used,s.team_members_limit)}),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.email_domains_used,s.email_domains_limit)}
1),e.jsx(i,{className:"text-right font-mono text-xs",children:P(s.sentiai_used,s.sentiai_limit)}),e.jsx(i,{children:e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("div",{className:"text-[11px] text-fg-dim space-x-2",children:[s.custom_employee_limit!=null&&e.jsxs("span",{children:[n("admin.orgs.override.empBadge")," ",e.jsx("code",{className:"text-fg",children:s.custom_employee_limit})]}),s.custom_team_member_limit!=null&&e.jsxs("span",{children:[n("admin.orgs.override.teamBadge")," ",e.jsx("code",{className:"text-fg",children:s.custom_team_member_limit})]}),s.custom_email_domain_limit!=null&&e.jsxs("span",{children:[n("admin.orgs.override.domBadge")," ",e.jsx("code",{className:"text-fg",children:s.custom_email_domain_limit})]}),s.custom_sentiai_monthly_limit!=null&&e.jsxs("span",{children:[n("admin.orgs.override.sentiaiBadge")," ",e.jsx("code",{className:"text-fg",children:s.custom_sentiai_monthly_limit})]}),s.custom_employee_limit==null&&s.custom_team_member_limit==null&&s.custom_email_domain_limit==null&&s.custom_sentiai_monthly_limit==null&&e.jsx("span",{children:"—"})]}),e.jsx(f,{variant:"secondary",onClick:()=>x(!0),children:n("admin.orgs.editButton")})]})})]})}export{le as AdminPage};

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.