PageSourceSearch

https://seoagencyusa.com/assets/AdminPortalManagementPage-d0GmNh35.js

js seoagencyusa.com collected 2026-10-05 18:07:00 UTC 41,050 bytes, 1 lines download raw bytes

1import{ai as e,b8 as s,r as a,s as n,j as i,I as t,f as r,aZ as l,a6 as d,a4 as c,b9 as o,X as h,N as m,$ as x,K as u}from"./index-Bxf4WVqQ.js";import{u as j}from"./useQuery-B4Swo9VN.js";import{u as g}from"./useMutation-B6d6nuxN.js";import{A as p}from"./AdminLayout-BE6BiPSh.js";import{C as y}from"./card-0mQSvXdi.js";import{L as v}from"./label-BncmV5Cs.js";import{B as f}from"./badge-DyhoOTF1.js";import{T as N,a as w,b as _,c as b}from"./tabs-VbF6CFHI.js";import{S as C,a as S,b as k,c as z,d as q}from"./select-C1hpcDMa.js";import{D as M,a as P,b as D,c as O,e as A,g as K,f as F}from"./dialog-CnSEfNd1.js";import{A as T,h as I,a as E,b as L,c as V,d as Q,e as $,f as B,g as U}from"./alert-dialog-DeHsipIu.js";import{T as G,a as R,b as Y,c as X,d as H,e as W}from"./table-CwXHOE9t.js";import{T as Z}from"./textarea-CWaoCUxR.js";import{u as J}from"./index-DiGzDlgs.js";import{T as ee}from"./trash-2-Bc7HU77E.js";import{P as se}from"./plus--NhaKZeo.js";import{C as ae}from"./checkbox-bVzYW_RP.js";import{U as ne}from"./user-plus-DKDkQwEU.js";import{S as ie}from"./save-CCA6iGMH.js";import{X as te}from"./x-CeJSzODY.js";import{P as re}from"./pencil-BYQfQBud.js";import{C as le}from"./copy-DSY1B87R.js";import{L as de}from"./link-C2j7WZF2.js";import{C as ce}from"./circle-x-BD2zFCmu.js";import{C as oe}from"./clock-CgoUxhMQ.js";import{S as he}from"./send-BcMg2uNy.js";import{f as me}from"./format-Bjjn0sLG.js";import"./layout-dashboard-DzQa4qhb.js";import"./database-CEmPktck.js";import"./mic-BY9TW_Qi.js";import"./layers-DZdJq9bV.js";import"./image-CDNaBGo6.js";import"./calendar-days-BXuJ1Mdk.js";import"./log-out-CwnmSaE1.js";import"./index-CorMk9hW.js";import"./index-78aP2QZY.js";import"./index-C4XUyvTb.js";import"./index-jVOyRz7F.js";import"./Combination-CY2C21oC.js";import"./index-DD5FvDgL.js";import"./index-DRJbPNi9.js";import"./chevron-up-DRPWawXW.js";import"./index-0JBFi9Y6.js";import"./en-US-sfFA8co_.js";const xe=e("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);function ue({campaign:e,open:d,onOpenChange:c}){const o=s(),[h,m]=a.useState(e.keywords_tracked||0),[x,u]=a.useState(e.keywords_top_10||0),[j,p]=a.useState(e.domain_authority||0),y=e.ai_visibility_data||{},[f,C]=a.useState({chatgpt:y.chatgpt??0,perplexity:y.perplexity??0,claude:y.claude??0,gemini:y.gemini??0,copilot:y.copilot??0,grok:y.grok??0}),[S,k]=a.useState(()=>{const s=e.organic_traffic_data;if(Array.isArray(s)&&s.length>0)return s;const a=[],n=new Date;for(let e=11;e>=0;e--){const s=new Date(n.getFullYear(),n.getMonth()-e,1);a.push({month:s.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),traffic:0,sessions:0})}return a}),z=(e,s,a)=>{k(n=>n.map((n,i)=>i===e?{...n,[s]:a}:n))},q=g({mutationFn:async()=>{const{error:s}=await n.from("client_campaigns").update({keywords_tracked:h,keywords_top_10:x,domain_authority:j,ai_visibility_data:f,organic_traffic_data:S}).eq("id",e.id);if(s)throw s},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-campaigns"]}),o.invalidateQueries({queryKey:["portal-campaigns"]}),J.success("Campaign metrics updated"),c(!1)},onError:e=>J.error(e.message)});return i.jsx(M,{open:d,onOpenChange:c,children:i.jsxs(P,{className:"sm:max-w-2xl max-h-[85vh] overflow-y-auto",children:[i.jsx(D,{children:i.jsxs(O,{children:["Edit Metrics - ",e.name]})}),i.jsxs(N,{defaultValue:"keywords",className:"space-y-4",children:[i.jsxs(w,{className:"w-full",children:[i.jsx(_,{value:"keywords",className:"flex-1",children:"Keywords & DA"}),i.jsx(_,{value:"ai",className:"flex-1",children:"AI Visibility"}),i.jsx(_,{value:"traffic",className:"flex-1",children:"Organic Traffic"})]}),i.jsx(b,{value:"keywords",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Keywords Tracked"}),i.jsx(t,{type:"number",value:h,onChange:e=>m(Number(e.target.value)),min:0})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Keywords in Top 10"}),i.jsx(t,{type:"number",value:x,onChange:e=>u(Number(e.target.value)),min:0})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Domain Authority"}),i.jsx(t,{type:"number",value:j,onChange:e=>p(Number(e.target.value)),min:0,max:100})]})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:"These values appear on the client's dashboard KPI cards and campaign table."})]})}),i.jsx(b,{value:"ai",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"Set visibility scores (0–100) for each AI model. These power the radar chart on the client dashboard."}),i.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{key:"chatgpt",label:"ChatGPT"},{key:"perplexity",label:"Perplexity"},{key:"claude",label:"Claude"},{key:"gemini",label:"Gemini"},{key:"copilot",label:"Copilot"},{key:"grok",label:"Grok"}].map(({key:e,label:s})=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(v,{className:"w-24 text-sm shrink-0",children:s}),i.jsx(t,{type:"number",value:f[e],onChange:s=>{return a=e,n=Number(s.target.value),void C(e=>({...e,[a]:Math.min(100,Math.max(0,n))}));var a,n},min:0,max:100,className:"w-24"}),i.jsx("div",{className:"flex-1 h-2 rounded-full bg-muted overflow-hidden",children:i.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${f[e]}%`}})})]},e))})]})}),i.jsx(b,{value:"traffic",children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{className:"text-sm text-muted-foreground",children:"Monthly organic traffic and session data. This powers the 12-month area chart on the client dashboard."}),i.jsxs("div",{className:"grid grid-cols-[1fr_100px_100px_32px] gap-2 text-xs font-medium text-muted-foreground px-1",children:[i.jsx("span",{children:"Month"}),i.jsx("span",{children:"Traffic"}),i.jsx("span",{children:"Sessions"}),i.jsx("span",{})]}),i.jsx("div",{className:"max-h-72 overflow-y-auto space-y-1.5",children:S.map((e,s)=>i.jsxs("div",{className:"grid grid-cols-[1fr_100px_100px_32px] gap-2 items-center",children:[i.jsx(t,{value:e.month,onChange:e=>{const a=[...S];a[s]={...a[s],month:e.target.value},k(a)},className:"h-8 text-sm"}),i.jsx(t,{type:"number",value:e.traffic,onChange:e=>z(s,"traffic",Number(e.target.value)),className:"h-8 text-sm",min:0}),i.jsx(t,{type:"number",value:e.sessions,onChange:e=>z(s,"sessions",Number(e.target.value)),className:"h-8 text-sm",min:0}),i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>{return e=s,void k(s=>s.filter((s,a)=>a!==e));var e},children:i.jsx(ee,{className:"w-3.5 h-3.5"})})]},s))}),i.jsxs(r,{variant:"outline",size:"sm",onClick:()=>{const e=S[S.length-1],s=e?new Date(Date.parse("01 "+e.month)):new Date;s.setMonth(s.getMonth()+1),k([...S,{month:s.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),traffic:0,sessions:0}])},className:"gap-1",children:[i.jsx(se,{className:"w-3.5 h-3.5"})," Add Month"]})]})})]}),i.jsxs(A,{className:"mt-4",children:[i.jsx(K,{asChild:!0,children:i.jsx(r,{variant:"outline",children:"Cancel"})}),i.jsxs(r,{onClick:()=>q.mutate(),disabled:q.isPending,children:[q.isPending?i.jsx(l,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Save Metrics"]})]})]})})}
1function je(){const e=s(),[c,o]=a.useState(""),[h,x]=a.useState(!1),[u,p]=a.useState({name:"",slug:"",website:"",industry:""}),[N,w]=a.useState(null),[_,b]=a.useState({name:"",slug:"",website:"",industry:""}),{data:C=[],isLoading:S}=j({queryKey:["admin-orgs"],queryFn:async()=>{const{data:e,error:s}=await n.from("organizations").select("*, org_members(id, user_id, role)").order("created_at",{ascending:!1});if(s)throw s;return e}}),k=g({mutationFn:async e=>{const s=e.slug||e.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),{error:a}=await n.from("organizations").insert({name:e.name,slug:s,website:e.website||null,industry:e.industry||null});if(a)throw a},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-orgs"]}),J.success("Organization created"),x(!1),p({name:"",slug:"",website:"",industry:""})},onError:e=>J.error(e.message)}),z=g({mutationFn:async({id:e,...s})=>{const{error:a}=await n.from("organizations").update({name:s.name,slug:s.slug,website:s.website||null,industry:s.industry||null}).eq("id",e);if(a)throw a},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-orgs"]}),e.invalidateQueries({queryKey:["admin-orgs-list"]}),J.success("Organization updated"),w(null)},onError:e=>J.error(e.message)}),q=g({mutationFn:async e=>{const{error:s}=await n.from("organizations").delete().eq("id",e);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-orgs"]}),e.invalidateQueries({queryKey:["admin-orgs-list"]}),J.success("Organization deleted")},onError:e=>J.error(e.message)}),Z=a.useMemo(()=>{if(!c)return C;const e=c.toLowerCase();return C.filter(s=>s.name.toLowerCase().includes(e)||s.slug.toLowerCase().includes(e))},[C,c]);return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[i.jsxs("div",{className:"relative flex-1 max-w-sm",children:[i.jsx(m,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),i.jsx(t,{placeholder:"Search organizations...",value:c,onChange:e=>o(e.target.value),className:"pl-9"})]}),i.jsxs(M,{open:h,onOpenChange:x,children:[i.jsx(F,{asChild:!0,children:i.jsxs(r,{children:[i.jsx(se,{className:"w-4 h-4 mr-2"})," New Organization"]})}),i.jsxs(P,{children:[i.jsx(D,{children:i.jsx(O,{children:"Create Organization"})}),i.jsxs("div",{className:"space-y-4 py-2",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Name *"}),i.jsx(t,{value:u.name,onChange:e=>p({...u,name:e.target.value}),placeholder:"Acme Corp"})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Slug"}),i.jsx(t,{value:u.slug,onChange:e=>p({...u,slug:e.target.value}),placeholder:"acme-corp (auto-generated if blank)"})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Website"}),i.jsx(t,{value:u.website,onChange:e=>p({...u,website:e.target.value}),placeholder:"https://acme.com"})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Industry"}),i.jsx(t,{value:u.industry,onChange:e=>p({...u,industry:e.target.value}),placeholder:"Technology"})]})]}),i.jsxs(A,{children:[i.jsx(K,{asChild:!0,children:i.jsx(r,{variant:"outline",children:"Cancel"})}),i.jsxs(r,{onClick:()=>k.mutate(u),disabled:!u.name||k.isPending,children:[k.isPending?i.jsx(l,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Create"]})]})]})]})]}),S?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(l,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):i.jsx(y,{children:i.jsxs(G,{children:[i.jsx(R,{children:i.jsxs(Y,{children:[i.jsx(X,{children:"Organization"}),i.jsx(X,{children:"Slug"}),i.jsx(X,{children:"Industry"}),i.jsx(X,{children:"Members"}),i.jsx(X,{children:"Created"}),i.jsx(X,{className:"w-[100px]",children:"Actions"})]})}),i.jsxs(H,{children:[Z.map(e=>i.jsx(Y,{children:N===e.id?i.jsxs(i.Fragment,{children:[i.jsx(W,{children:i.jsx(t,{value:_.name,onChange:e=>b({..._,name:e.target.value}),className:"h-8 text-sm"})}),i.jsx(W,{children:i.jsx(t,{value:_.slug,onChange:e=>b({..._,slug:e.target.value}),className:"h-8 text-sm"})}),i.jsx(W,{children:i.jsx(t,{value:_.industry,onChange:e=>b({..._,industry:e.target.value}),className:"h-8 text-sm"})}),i.jsx(W,{children:i.jsx(f,{variant:"secondary",children:e.org_members?.length||0})}),i.jsx(W,{className:"text-muted-foreground text-sm",children:me(new Date(e.created_at),"MMM d, yyyy")}),i.jsx(W,{children:i.jsxs("div",{className:"flex gap-1",children:[i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>z.mutate({id:e.id,..._}),disabled:!_.name||z.isPending,children:z.isPending?i.jsx(l,{className:"w-3.5 h-3.5 animate-spin"}):i.jsx(ie,{className:"w-3.5 h-3.5 text-green-600"})}),i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>w(null),children:i.jsx(te,{className:"w-3.5 h-3.5"})})]})})]}):i.jsxs(i.Fragment,{children:[i.jsx(W,{children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d,{className:"w-4 h-4 text-muted-foreground"}),i.jsx("span",{className:"font-medium",children:e.name})]})}),i.jsx(W,{children:i.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",children:e.slug})}),i.jsx(W,{children:e.industry||" - "}),i.jsx(W,{children:i.jsx(f,{variant:"secondary",children:e.org_members?.length||0})}),i.jsx(W,{className:"text-muted-foreground text-sm",children:me(new Date(e.created_at),"MMM d, yyyy")}),i.jsx(W,{children:i.jsxs("div",{className:"flex gap-1",children:[i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>(e=>{w(e.id),b({name:e.name,slug:e.slug,website:e.website||"",industry:e.industry||""})})(e),children:i.jsx(re,{className:"w-3.5 h-3.5"})}),i.jsxs(T,{children:[i.jsx(I,{asChild:!0,children:i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive",children:i.jsx(ee,{className:"w-3.5 h-3.5"})})}),i.jsxs(E,{children:[i.jsxs(L,{children:[i.jsxs(V,{children:['Delete "',e.name,'"?']}),i.jsx(Q,{children:"This will permanently delete this organization, its members, campaigns, and invoices. This action cannot be undone."})]}),i.jsxs($,{children:[i.jsx(B,{children:"Cancel"}),i.jsx(U,{onClick:()=>q.mutate(e.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})]})},e.id)),0===Z.length&&i.jsx(Y,{children:i.jsx(W,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No organizations foun
1d"})})]})]})})]})}function ge(){const e=s(),[d,c]=a.useState(!1),[o,h]=a.useState({org_id:"",email:"",role:"member"}),[m,u]=a.useState(""),{data:p=[]}=j({queryKey:["admin-orgs-list"],queryFn:async()=>{const{data:e,error:s}=await n.from("organizations").select("id, name").order("name");if(s)throw s;return e}}),{data:N=[],isLoading:w}=j({queryKey:["admin-invites"],queryFn:async()=>{const{data:e,error:s}=await n.from("org_invites").select("*, organizations:org_id(name)").order("created_at",{ascending:!1}).limit(100);if(s)throw s;return e}}),_=g({mutationFn:async e=>{const{data:s,error:a}=await n.from("org_invites").insert({org_id:e.org_id,email:e.email||null,role:e.role}).select("token").single();if(a)throw a;return s},onSuccess:s=>{e.invalidateQueries({queryKey:["admin-invites"]});const a=`${window.location.origin}/portal/invite/${s.token}`;u(a),J.success("Invite created!")},onError:e=>J.error(e.message)});return i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex justify-end",children:i.jsxs(M,{open:d,onOpenChange:e=>{c(e),e||u("")},children:[i.jsx(F,{asChild:!0,children:i.jsxs(r,{children:[i.jsx(ne,{className:"w-4 h-4 mr-2"})," Create Invite"]})}),i.jsxs(P,{children:[i.jsx(D,{children:i.jsx(O,{children:"Create Client Invite"})}),m?i.jsxs("div",{className:"space-y-4 py-2",children:[i.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[i.jsx(x,{className:"w-5 h-5"}),i.jsx("span",{className:"font-medium",children:"Invite link generated!"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(t,{readOnly:!0,value:m,className:"text-xs"}),i.jsx(r,{variant:"outline",size:"icon",onClick:()=>{navigator.clipboard.writeText(m),J.success("Link copied to clipboard")},children:i.jsx(le,{className:"w-4 h-4"})})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:"Send this link to the client. It expires in 7 days."}),i.jsx(A,{children:i.jsx(r,{onClick:()=>{c(!1),u(""),h({org_id:"",email:"",role:"member"})},children:"Done"})})]}):i.jsxs("div",{className:"space-y-4 py-2",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Organization *"}),i.jsxs(C,{value:o.org_id,onValueChange:e=>h({...o,org_id:e}),children:[i.jsx(S,{children:i.jsx(k,{placeholder:"Select organization"})}),i.jsx(z,{children:p.map(e=>i.jsx(q,{value:e.id,children:e.name},e.id))})]})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Email (optional)"}),i.jsx(t,{value:o.email,onChange:e=>h({...o,email:e.target.value}),placeholder:"[email protected]"}),i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Pre-fills the signup form if provided"})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Role"}),i.jsxs(C,{value:o.role,onValueChange:e=>h({...o,role:e}),children:[i.jsx(S,{children:i.jsx(k,{})}),i.jsxs(z,{children:[i.jsx(q,{value:"member",children:"Member"}),i.jsx(q,{value:"admin",children:"Admin"}),i.jsx(q,{value:"owner",children:"Owner"})]})]})]}),i.jsxs(A,{children:[i.jsx(K,{asChild:!0,children:i.jsx(r,{variant:"outline",children:"Cancel"})}),i.jsxs(r,{onClick:()=>_.mutate(o),disabled:!o.org_id||_.isPending,children:[_.isPending?i.jsx(l,{className:"w-4 h-4 mr-2 animate-spin"}):i.jsx(de,{className:"w-4 h-4 mr-2"}),"Generate Link"]})]})]})]})]})}),w?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(l,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):i.jsx(y,{children:i.jsxs(G,{children:[i.jsx(R,{children:i.jsxs(Y,{children:[i.jsx(X,{children:"Organization"}),i.jsx(X,{children:"Email"}),i.jsx(X,{children:"Role"}),i.jsx(X,{children:"Status"}),i.jsx(X,{children:"Created"})]})}),i.jsxs(H,{children:[N.map(e=>{const s=new Date(e.expires_at)<new Date,a=!!e.accepted_at;return i.jsxs(Y,{children:[i.jsx(W,{className:"font-medium",children:e.organizations?.name||" - "}),i.jsx(W,{children:e.email||i.jsx("span",{className:"text-muted-foreground italic",children:"Open invite"})}),i.jsx(W,{children:i.jsx(f,{variant:"outline",className:"capitalize",children:e.role})}),i.jsx(W,{children:a?i.jsxs(f,{className:"bg-green-100 text-green-700 border-green-200",children:[i.jsx(x,{className:"w-3 h-3 mr-1"})," Accepted"]}):s?i.jsxs(f,{variant:"destructive",children:[i.jsx(ce,{className:"w-3 h-3 mr-1"})," Expired"]}):i.jsxs(f,{variant:"secondary",children:[i.jsx(oe,{className:"w-3 h-3 mr-1"})," Pending"]})}),i.jsx(W,{className:"text-muted-foreground text-sm",children:me(new Date(e.created_at),"MMM d, yyyy")})]},e.id)}),0===N.length&&i.jsx(Y,{children:i.jsx(W,{colSpan:5,className:"text-center text-muted-foreground py-8",children:"No invites yet"})})]})]})})]})}
1function pe(){const e=s(),[d,c]=a.useState(!1),[o,h]=a.useState({org_id:"",name:"",type:"seo",status:"active",start_date:"",monthly_budget:"",notes:""}),[m,x]=a.useState(null),[u,p]=a.useState({name:"",type:"seo",status:"active",monthly_budget:"",notes:""}),[N,w]=a.useState(null),{data:_=[]}=j({queryKey:["admin-orgs-list"],queryFn:async()=>{const{data:e,error:s}=await n.from("organizations").select("id, name").order("name");if(s)throw s;return e}}),{data:b=[],isLoading:ae}=j({queryKey:["admin-campaigns"],queryFn:async()=>{const{data:e,error:s}=await n.from("client_campaigns").select("*, organizations:org_id(name)").order("created_at",{ascending:!1});if(s)throw s;return e}}),ne=g({mutationFn:async e=>{const{error:s}=await n.from("client_campaigns").insert({org_id:e.org_id,name:e.name,type:e.type,status:e.status,start_date:e.start_date||null,monthly_budget:e.monthly_budget?Number(e.monthly_budget):null,notes:e.notes||null});if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-campaigns"]}),J.success("Campaign created"),c(!1),h({org_id:"",name:"",type:"seo",status:"active",start_date:"",monthly_budget:"",notes:""})},onError:e=>J.error(e.message)}),le=g({mutationFn:async({id:e,...s})=>{const{error:a}=await n.from("client_campaigns").update({name:s.name,type:s.type,status:s.status,monthly_budget:s.monthly_budget?Number(s.monthly_budget):null,notes:s.notes||null}).eq("id",e);if(a)throw a},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-campaigns"]}),J.success("Campaign updated"),x(null)},onError:e=>J.error(e.message)}),de=g({mutationFn:async e=>{const{error:s}=await n.from("client_campaigns").delete().eq("id",e);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-campaigns"]}),J.success("Campaign deleted")},onError:e=>J.error(e.message)});return i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex justify-end",children:i.jsxs(M,{open:d,onOpenChange:c,children:[i.jsx(F,{asChild:!0,children:i.jsxs(r,{children:[i.jsx(se,{className:"w-4 h-4 mr-2"})," Assign Campaign"]})}),i.jsxs(P,{className:"sm:max-w-lg",children:[i.jsx(D,{children:i.jsx(O,{children:"Assign Campaign to Client"})}),i.jsxs("div",{className:"space-y-4 py-2",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Organization *"}),i.jsxs(C,{value:o.org_id,onValueChange:e=>h({...o,org_id:e}),children:[i.jsx(S,{children:i.jsx(k,{placeholder:"Select organization"})}),i.jsx(z,{children:_.map(e=>i.jsx(q,{value:e.id,children:e.name},e.id))})]})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Campaign Name *"}),i.jsx(t,{value:o.name,onChange:e=>h({...o,name:e.target.value}),placeholder:"Enterprise SEO Campaign"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Type"}),i.jsxs(C,{value:o.type,onValueChange:e=>h({...o,type:e}),children:[i.jsx(S,{children:i.jsx(k,{})}),i.jsxs(z,{children:[i.jsx(q,{value:"seo",children:"SEO"}),i.jsx(q,{value:"geo",children:"GEO / AI Visibility"}),i.jsx(q,{value:"ppc",children:"PPC"}),i.jsx(q,{value:"content",children:"Content"}),i.jsx(q,{value:"link_building",children:"Link Building"})]})]})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Status"}),i.jsxs(C,{value:o.status,onValueChange:e=>h({...o,status:e}),children:[i.jsx(S,{children:i.jsx(k,{})}),i.jsxs(z,{children:[i.jsx(q,{value:"active",children:"Active"}),i.jsx(q,{value:"paused",children:"Paused"}),i.jsx(q,{value:"completed",children:"Completed"})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Start Date"}),i.jsx(t,{type:"date",value:o.start_date,onChange:e=>h({...o,start_date:e.target.value})})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Monthly Budget ($)"}),i.jsx(t,{type:"number",value:o.monthly_budget,onChange:e=>h({...o,monthly_budget:e.target.value}),placeholder:"5000"})]})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Notes"}),i.jsx(Z,{value:o.notes,onChange:e=>h({...o,notes:e.target.value}),placeholder:"Campaign details...",rows:3})]})]}),i.jsxs(A,{children:[i.jsx(K,{asChild:!0,children:i.jsx(r,{variant:"outline",children:"Cancel"})}),i.jsxs(r,{onClick:()=>ne.mutate(o),disabled:!o.org_id||!o.name||ne.isPending,children:[ne.isPending?i.jsx(l,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Create Campaign"]})]})]})]})}),ae?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(l,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):i.jsx(y,{children:i.jsxs(G,{children:[i.jsx(R,{children:i.jsxs(Y,{children:[i.jsx(X,{children:"Campaign"}),i.jsx(X,{children:"Organization"}),i.jsx(X,{children:"Type"}),i.jsx(X,{children:"Status"}),i.jsx(X,{children:"Budget"}),i.jsx(X,{children:"Start Date"}),i.jsx(X,{className:"w-[100px]",children:"Actions"})]})}
1),i.jsxs(H,{children:[b.map(e=>i.jsx(Y,{children:m===e.id?i.jsxs(i.Fragment,{children:[i.jsx(W,{children:i.jsx(t,{value:u.name,onChange:e=>p({...u,name:e.target.value}),className:"h-8 text-sm"})}),i.jsx(W,{children:e.organizations?.name||" - "}),i.jsx(W,{children:i.jsxs(C,{value:u.type,onValueChange:e=>p({...u,type:e}),children:[i.jsx(S,{className:"h-8 text-xs",children:i.jsx(k,{})}),i.jsxs(z,{children:[i.jsx(q,{value:"seo",children:"SEO"}),i.jsx(q,{value:"geo",children:"GEO"}),i.jsx(q,{value:"ppc",children:"PPC"}),i.jsx(q,{value:"content",children:"Content"}),i.jsx(q,{value:"link_building",children:"Link Building"})]})]})}),i.jsx(W,{children:i.jsxs(C,{value:u.status,onValueChange:e=>p({...u,status:e}),children:[i.jsx(S,{className:"h-8 text-xs",children:i.jsx(k,{})}),i.jsxs(z,{children:[i.jsx(q,{value:"active",children:"Active"}),i.jsx(q,{value:"paused",children:"Paused"}),i.jsx(q,{value:"completed",children:"Completed"})]})]})}),i.jsx(W,{children:i.jsx(t,{type:"number",value:u.monthly_budget,onChange:e=>p({...u,monthly_budget:e.target.value}),className:"h-8 text-sm w-24",placeholder:"$"})}),i.jsx(W,{className:"text-muted-foreground text-sm",children:e.start_date?me(new Date(e.start_date),"MMM d, yyyy"):" - "}),i.jsx(W,{children:i.jsxs("div",{className:"flex gap-1",children:[i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>le.mutate({id:e.id,...u}),disabled:!u.name||le.isPending,children:le.isPending?i.jsx(l,{className:"w-3.5 h-3.5 animate-spin"}):i.jsx(ie,{className:"w-3.5 h-3.5 text-green-600"})}),i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>x(null),children:i.jsx(te,{className:"w-3.5 h-3.5"})})]})})]}):i.jsxs(i.Fragment,{children:[i.jsx(W,{className:"font-medium",children:e.name}),i.jsx(W,{children:e.organizations?.name||" - "}),i.jsx(W,{children:i.jsx(f,{variant:"outline",className:"uppercase text-xs",children:e.type})}),i.jsx(W,{children:i.jsx(f,{className:"active"===e.status?"bg-green-100 text-green-700 border-green-200":"paused"===e.status?"bg-yellow-100 text-yellow-700 border-yellow-200":"bg-muted text-muted-foreground",children:e.status})}),i.jsx(W,{children:e.monthly_budget?`$${Number(e.monthly_budget).toLocaleString()}/mo`:" - "}),i.jsx(W,{className:"text-muted-foreground text-sm",children:e.start_date?me(new Date(e.start_date),"MMM d, yyyy"):" - "}),i.jsx(W,{children:i.jsxs("div",{className:"flex gap-1",children:[i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7",title:"Edit metrics",onClick:()=>w(e),children:i.jsx(xe,{className:"w-3.5 h-3.5 text-primary"})}),i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>(e=>{x(e.id),p({name:e.name,type:e.type,status:e.status,monthly_budget:e.monthly_budget?String(e.monthly_budget):"",notes:e.notes||""})})(e),children:i.jsx(re,{className:"w-3.5 h-3.5"})}),i.jsxs(T,{children:[i.jsx(I,{asChild:!0,children:i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive",children:i.jsx(ee,{className:"w-3.5 h-3.5"})})}),i.jsxs(E,{children:[i.jsxs(L,{children:[i.jsxs(V,{children:['Delete "',e.name,'"?']}),i.jsx(Q,{children:"This will permanently delete this campaign. This action cannot be undone."})]}),i.jsxs($,{children:[i.jsx(B,{children:"Cancel"}),i.jsx(U,{onClick:()=>de.mutate(e.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})]})},e.id)),0===b.length&&i.jsx(Y,{children:i.jsx(W,{colSpan:7,className:"text-center text-muted-foreground py-8",children:"No campaigns yet"})})]})]})}),N&&i.jsx(ue,{campaign:N,open:!!N,onOpenChange:e=>{e||w(null)}})]})}
1function ye(){const e=s(),[d,c]=a.useState(!1),[o,h]=a.useState({org_id:"",title:"",amount:"",invoice_number:"",due_date:"",status:"sent"}),{data:m=[]}=j({queryKey:["admin-orgs"],queryFn:async()=>{const{data:e}=await n.from("organizations").select("id, name").order("name");return e??[]}}),{data:x=[],isLoading:u}=j({queryKey:["admin-invoices"],queryFn:async()=>{const{data:e,error:s}=await n.from("client_invoices").select("*, organizations:org_id (name)").order("created_at",{ascending:!1});if(s)throw s;return e??[]}}),p=g({mutationFn:async()=>{const e=Math.round(100*Number(o.amount)),{error:s}=await n.from("client_invoices").insert({org_id:o.org_id,title:o.title.trim(),amount_cents:e,invoice_number:o.invoice_number.trim()||null,due_date:o.due_date||null,status:o.status});if(s)throw s;try{await n.functions.invoke("notify-portal-email",{body:{type:"invoice_update",org_id:o.org_id,data:{title:o.title.trim(),status:o.status,amount_cents:e,invoice_number:o.invoice_number.trim()||null,due_date:o.due_date||null}}})}catch(a){}},onSuccess:()=>
1{J.success("Invoice created"),e.invalidateQueries({queryKey:["admin-invoices"]}),c(!1),h({org_id:"",title:"",amount:"",invoice_number:"",due_date:"",status:"sent"})},onError:e=>J.error(e.message)}),y=g({mutationFn:async({id:e,status:s})=>{const a={status:s};"paid"===s&&(a.paid_at=(new Date).toISOString());const{error:i}=await n.from("client_invoices").update(a).eq("id",e);if(i)throw i;const t=x.find(s=>s.id===e);if(t)try{await n.functions.invoke("notify-portal-email",{body:{type:"invoice_update",org_id:t.org_id,data:{title:t.title,status:s,amount_cents:t.amount_cents,invoice_number:t.invoice_number,due_date:t.due_date}}})}catch(r){}},onSuccess:()=>{J.success("Invoice updated"),e.invalidateQueries({queryKey:["admin-invoices"]})},onError:e=>J.error(e.message)}),N=g({mutationFn:async e=>{const{error:s}=await n.from("client_invoices").delete().eq("id",e);if(s)throw s},onSuccess:()=>{J.success("Invoice deleted"),e.invalidateQueries({queryKey:["admin-invoices"]})},onError:e=>J.error(e.message)}),w={draft:"bg-muted text-muted-foreground",sent:"bg-yellow-500/10 text-yellow-700 border-yellow-200",paid:"bg-green-500/10 text-green-700 border-green-200",overdue:"bg-red-500/10 text-red-700 border-red-200",cancelled:"bg-muted text-muted-foreground"};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("p",{className:"text-sm text-muted-foreground",children:[x.length," invoices"]}),i.jsxs(M,{open:d,onOpenChange:c,children:[i.jsx(F,{asChild:!0,children:i.jsxs(r,{size:"sm",className:"gap-1",children:[i.jsx(se,{className:"w-4 h-4"})," Create Invoice"]})}),i.jsxs(P,{children:[i.jsx(D,{children:i.jsx(O,{children:"Create Invoice"})}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Organization"}),i.jsxs(C,{value:o.org_id,onValueChange:e=>h({...o,org_id:e}),children:[i.jsx(S,{children:i.jsx(k,{placeholder:"Select organization"})}),i.jsx(z,{children:m.map(e=>i.jsx(q,{value:e.id,children:e.name},e.id))})]})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Title"}),i.jsx(t,{value:o.title,onChange:e=>h({...o,title:e.target.value}),placeholder:"Monthly SEO Retainer - March 2026"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Amount ($)"}),i.jsx(t,{type:"number",min:"0",step:"0.01",value:o.amount,onChange:e=>h({...o,amount:e.target.value}),placeholder:"5000.00"})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Invoice #"}),i.jsx(t,{value:o.invoice_number,onChange:e=>h({...o,invoice_number:e.target.value}),placeholder:"INV-001"})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Due Date"}),i.jsx(t,{type:"date",value:o.due_date,onChange:e=>h({...o,due_date:e.target.value})})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Status"}),i.jsxs(C,{value:o.status,onValueChange:e=>h({...o,status:e}),children:[i.jsx(S,{children:i.jsx(k,{})}),i.jsxs(z,{children:[i.jsx(q,{value:"draft",children:"Draft"}),i.jsx(q,{value:"sent",children:"Sent"}),i.jsx(q,{value:"paid",children:"Paid"})]})]})]})]})]}),i.jsxs(A,{children:[i.jsx(K,{asChild:!0,children:i.jsx(r,{variant:"outline",children:"Cancel"})}),i.jsxs(r,{onClick:()=>p.mutate(),disabled:!o.org_id||!o.title||!o.amount||p.isPending,children:[p.isPending?i.jsx(l,{className:"w-4 h-4 animate-spin mr-2"}):null,"Create"]})]})]})]})]}),u?i.jsx("div",{className:"py-8 text-center",children:i.jsx(l,{className:"w-6 h-6 animate-spin mx-auto"})}):0===x.length?i.jsx("p",{className:"text-muted-foreground text-sm text-center py-8",children:"No invoices yet"}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs(G,{children:[i.jsx(R,{children:i.jsxs(Y,{children:[i.jsx(X,{children:"Invoice #"}),i.jsx(X,{children:"Organization"}),i.jsx(X,{children:"Title"}),i.jsx(X,{children:"Amount"}),i.jsx(X,{children:"Status"}),i.jsx(X,{children:"Due"}),i.jsx(X,{className:"text-right",children:"Actions"})]})}),i.jsx(H,{children:x.map(e=>i.jsxs(Y,{children:[i.jsx(W,{className:"font-mono text-xs",children:e.invoice_number||" - "}),i.jsx(W,{children:e.organizations?.name||" - "}),i.jsx(W,{children:e.title}),i.jsx(W,{className:"font-medium",children:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e.amount_cents/100)}),i.jsx(W,{children:i.jsxs(C,{value:e.status,onValueChange:s=>y.mutate({id:e.id,status:s}),children:[i.jsx(S,{className:"h-7 w-28",children:i.jsx(f,{className:`${w[e.status]||""} text-xs`,children:e.status})}),i.jsx(z,{children:["draft","sent","paid","overdue","cancelled"].map(e=>i.jsx(q,{value:e,className:"capitalize",children:e},e))})]})}),i.jsx(W,{className:"text-muted-foreground text-xs",children:e.due_date?me(new Date(e.due_date),"MMM d, yyyy"):" - "}),i.jsx(W,{className:"text-right",children:i.jsxs(T,{children:[i.jsx(I,{asChild:!0,children:i.jsx(r,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",children:i.jsx(ee,{className:"w-3.5 h-3.5"})})}),i.jsxs(E,{children:[i.jsxs(L,{children:[i.jsx(V,{children:"Delete Invoice?"}),i.jsx(Q,{children:"This will permanently delete this invoice."})]}),i.jsxs($,{children:[i.jsx(B,{children:"Cancel"}),i.jsx(U,{onClick:()=>N.mutate(e.id),children:"Delete"})]})]})]})})]},e.id))})]})})]})}
1function ve(){const e=s(),[t,d]=a.useState(""),[c,o]=a.useState([]),[m,x]=a.useState(""),[g,p]=a.useState(!1),[N,w]=a.useState("all"),{data:_=[]}=j({queryKey:["admin-orgs-list"],queryFn:async()=>{const{data:e,error:s}=await n.from("organizations").select("id, name").order("name");if(s)throw s;return e}}),{data:b=[]}=j({queryKey:["admin-content-campaigns"],queryFn:async()=>{const{data:e,error:s}=await n.from("content_campaigns").select("id, title").order("created_at",{ascending:!1});if(s)throw s;return e}}),{data:M=[],isLoading:P}=j({queryKey:["admin-content-assets-pushable",N],queryFn:async()=>{let e=n.from("content_assets").select("id, title, asset_type, status, campaign_id, content_campaigns(title)").in("status",["approved","published"]).order("updated_at",{ascending:!1});"all"!==N&&(e=e.eq("campaign_id",N));const{data:s,error:a}=await e;if(a)throw a;return s}}),{data:D=[],isLoading:O}=j({queryKey:["admin-pushed-content"],queryFn:async()=>{const{data:e,error:s}=await n.from("client_content_items").select("id, title, asset_type, status, org_id, created_at, organizations:org_id(name)").order("created_at",{ascending:!1}).limit(50);if(s)throw s;return e}}),A={blog_outline:"Blog Outline",linkedin_post:"LinkedIn Post",twitter_thread:"Twitter Thread"},K={pending_review:"bg-yellow-100 text-yellow-800",approved:"bg-green-100 text-green-800",revision_requested:"bg-red-100 text-red-800"},F=e=>{o(s=>s.includes(e)?s.filter(s=>s!==e):[...s,e])};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs(y,{className:"p-6 space-y-4",children:[i.jsxs("h3",{className:"font-semibold text-lg flex items-center gap-2",children:[i.jsx(he,{className:"w-5 h-5"})," Push Content to Client Portal"]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx(v,{children:"Target Organization *"}),i.jsxs(C,{value:t,onValueChange:d,children:[i.jsx(S,{children:i.jsx(k,{placeholder:"Select organization"})}),i.jsx(z,{children:_.map(e=>i.jsx(q,{value:e.id,children:e.name},e.id))})]})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Filter by Campaign"}),i.jsxs(C,{value:N,onValueChange:w,children:[i.jsx(S,{children:i.jsx(k,{})}),i.jsxs(z,{children:[i.jsx(q,{value:"all",children:"All Campaigns"}),b.map(e=>i.jsx(q,{value:e.id,children:e.title},e.id))]})]})]})]}),i.jsxs("div",{children:[i.jsx(v,{children:"Admin Notes (optional)"}),i.jsx(Z,{value:m,onChange:e=>x(e.target.value),placeholder:"Add internal notes for this content push...",className:"h-20"})]})]}),i.jsxs(y,{children:[i.jsxs("div",{className:"p-4 border-b flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h3",{className:"font-semibold",children:"Available Content Assets"}),i.jsxs(f,{variant:"secondary",children:[M.length," assets"]}),c.length>0&&i.jsxs(f,{className:"bg-primary text-primary-foreground",children:[c.length," selected"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(r,{variant:"outline",size:"sm",onClick:()=>{c.length===M.length?o([]):o(M.map(e=>e.id))},children:c.length===M.length&&M.length>0?"Deselect All":"Select All"}),i.jsxs(r,{size:"sm",onClick:async()=>{if(t&&0!==c.length){p(!0);try{const s=M.filter(e=>c.includes(e.id)),{data:a}=await n.auth.getUser(),i=a?.user?.id,r=s.map(e=>({org_id:t,source_asset_id:e.id,asset_type:e.asset_type,title:e.title,body:"",status:"pending_review",admin_notes:m||null,pushed_by:i||null})),{error:l}=await n.from("client_content_items").insert(r);if(l)throw l;const d=_.find(e=>e.id===t)?.name||"",h=s[0]?.title||"",u=s[0]?.asset_type||"";await n.functions.invoke("notify-portal-email",{body:{type:"content_ready",org_id:t,org_name:d,data:{title:1===s.length?h:void 0,asset_type:1===s.length?u:void 0,count:s.length}}}),e.invalidateQueries({queryKey:["admin-pushed-content"]}),J.success(`${s.length} item(s) pushed to ${d} with email notification`),o([]),x("")}catch(s){J.error(s.message||"Failed to push content")}finally{p(!1)}}else J.error("Select an organization and at least one content asset")},disabled:g||0===c.length||!t,children:[g?i.jsx(l,{className:"w-4 h-4 mr-2 animate-spin"}):i.jsx(he,{className:"w-4 h-4 mr-2"}),"Push ",c.length>0?`(${c.length})`:""]})]})]}),P?i.jsx("div",{className:"flex justify-center py-12",children:i.jsx(l,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):0===M.length?i.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[i.jsx(h,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),i.jsx("p",{children:"No approved/published content assets found"})]}):i.jsxs(G,{children:[i.jsx(R,{children:i.jsxs(Y,{children:[i.jsx(X,{className:"w-[40px]"}),i.jsx(X,{children:"Title"}),i.jsx(X,{children:"Type"}),i.jsx(X,{children:"Campaign"}),i.jsx(X,{children:"Status"})]})}),i.jsx(H,{children:M.map(e=>i.jsxs(Y,{className:"cursor-pointer "+(c.includes(e.id)?"bg-accent/50":""),onClick:()=>F(e.id),children:[i.jsx(W,{children:i.jsx(ae,{checked:c.includes(e.id),onCheckedChange:()=>F(e.id)})}),i.jsx(W,{className:"font-medium",children:e.title}),i.jsx(W,{children:i.jsx(f,{variant:"outline",children:A[e.asset_type]||e.asset_type})}),i.jsx(W,{className:"text-sm text-muted-foreground",children:e.content_campaigns?.title||" - "}),i.jsx(W,{children:i.jsx(f,{variant:"secondary",className:"capitalize",children:e.status})})]},e.id))})]})]}),i.jsxs(y,{children:[i.jsx("div",{className:"p-4 border-b",children:i.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[i.jsx(u,{className:"w-4 h-4"})," Recently Pushed Content"]})}),O?i.jsx("div",{className:"flex justify-center py-8",children:i.jsx(l,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):0===D.length?i.jsx("div",{className:"text-center py-8 text-muted-foreground text-sm",children:"No content has been pushed yet"}):i.jsxs(G,{children:[i.jsx(R,{children:i.jsxs(Y,{children:[i.jsx(X,{children:"Title"}),i.jsx(X,{children:"Organization"}),i.jsx(X,{children:"Type"}),i.jsx(X,{children:"Status"}),i.jsx(X,{children:"Pushed"})]})}),i.jsx(H,{children:D.map(e=>i.jsxs(Y,{children:[i.jsx(W,{className:"font-medium",children:e.title}),i.jsx(W,{children:e.organizations?.name||" - "}),i.jsx(W,{children:i.jsx(f,{variant:"outline",children:A[e.asset_type]||e.asset_type})}),i.jsx(W,{children:i.jsx(f,{className:K[e.status]||"bg-muted text-muted-foreground",children:(e.status||"").replace(/_/g," ")})}),i.jsx(W,{className:"text-sm text-muted-foreground",children:me(new Date(e.created_at),"MMM d, yyyy")})]},e.id))})]})]})]})}function fe(){return i.jsx(p,{children:i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-display font-bold",children:"Client Portal Management"}),i.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage organizations, send invites, assign campaigns, handle billing, and push content."})]}),i.jsxs(N,{defaultValue:"organizations",className:"space-y-4",children:[i.jsxs(w,{className:"flex-wrap",children:[i.jsxs(_,{value:"organizations",className:"gap-2",children:[i.jsx(d,{className:"w-4 h-4"})," Organizations"]}),i.jsxs(_,{value:"invites",className:"gap-2",children:[i.jsx(ne,{className:"w-4 h-4"})," Invites"]}),i.jsxs(_,{value:"campaigns",className:"gap-2",children:[i.jsx(c,{className:"w-4 h-4"})," Campaigns"]}),i.jsxs(_,{value:"billing",className:"gap-2",children:[i.jsx(o,{className:"w-4 h-4"})," Billing"]}),i.jsxs(_,{value:"content-push",className:"gap-2",children:[i.jsx(h,{className:"w-4 h-4"})," Content Push"]})]}),i.jsx(b,{value:"organizations",children:i.jsx(je,{})}),i.jsx(b,{value:"invites",children:i.jsx(ge,{})}),i.jsx(b,{value:"campaigns",children:i.jsx(pe,{})}),i.jsx(b,{value:"billing",children:i.jsx(ye,{})}),i.jsx(b,{value:"content-push",children:i.jsx(ve,{})})]})]})})}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.