1import{j as e,r as t}from"./react-vendor-hAxFZxNQ.js";import{D as s,af as a,ag as r,c as n,aj as l,L as d,au as c,f as i,ai as o,ah as m,_ as x,av as u,r as p}from"./main-C-ofR5-x.js";import{a as h}from"./admin-DboNpoWJ.js";import{teamsApi as f}from"./teams-C-pix82-.js";import"./ui-DlHKYJvh.js";const j=e=>`managed-teams:${e}`;function g(){const[s,g]=t.useState(()=>a(j(""))??[]),[w,v]=t.useState(()=>!r(j(""))),[k,C]=t.useState(""),[_,S]=t.useState(null),T=t.useRef(s);return T.current=s,t.useEffect(()=>{const e=setTimeout(()=>(async e=>{const t=j(e),s=a(t);s?(g(s),v(!1)):0===T.current.length&&v(!0);try{const s=await h.listManagedTeams({q:e||void 0});g(s.results),m(t,s.results)}catch(r){x({title:"Failed to load managed customers",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{v(!1)}})(k),250);return()=>clearTimeout(e)},[k]),e.jsxs("div",{className:"p-6 md:p-10 max-w-[1280px] mx-auto",children:[e.jsx("div",{className:"mb-6 flex items-start justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Managed Customers"}),e.jsxs("p",{className:"text-muted-foreground text-sm mt-1",children:["Click ",e.jsx("span",{className:"font-medium text-foreground",children:"Open"})," on a customer to post on their behalf."]})]})}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(n,{name:"Search",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(l,{placeholder:"Search by customer nameâ¦",value:k,onChange:e=>C(e.target.value),className:"pl-9"})]})}),w?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-12 justify-center",children:[e.jsx(n,{name:"LoaderCircle",className:"w-4 h-4 animate-spin"}),"Loading customersâ¦"]}):0===s.length?e.jsxs("div",{className:"text-center py-16 rounded-xl bg-muted/30 border border-dashed border-border",children:[e.jsx(n,{name:"Inbox",className:"w-12 h-12 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-medium mb-1",children:k?"No customers match that search":"No managed customers yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k?"Try a different name.":"Customers appear here once they subscribe to the Managed Postings plan."})]}):e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border bg-card",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-xs uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"Customer"}),e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"Tier"}),e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"Contact"}),e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"Accounts"}),e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"Readiness"}),e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"This month"}),e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"Last posted"}),e.jsx("th",{className:"text-left font-medium px-4 py-3",children:"Next scheduled"}),e.jsx("th",{className:"text-right font-medium px-4 py-3",children:" "})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{className:"border-t border-border hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs(d,{to:"/staff/managed-postings/$teamId",params:{teamId:String(t.id)},className:"flex items-center gap-3 group",children:[e.jsx("span",{className:"size-8 rounded-md bg-gradient-to-br from-primary/80 to-primary flex items-center justify-center text-xs font-bold text-white shrink-0",children:t.name.charAt(0).toUpperCase()}),e.jsx("span",{className:"font-medium group-hover:underline",children:t.name})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(N,{tier:t.managed_tier})}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground",children:t.owner?e.jsxs("div",{className:"flex flex-col leading-tight",children:[e.jsx("span",{className:"text-foreground",children:[t.owner.first_name,t.owner.last_name].filter(
1Boolean).join(" ")||t.owner.email}),e.jsx("span",{className:"text-xs",children:t.owner.email})]}):e.jsx("span",{className:"text-xs",children:"â"})}),e.jsx("td",{className:"px-4 py-3",children:0===t.connected_accounts.length?e.jsx("span",{className:"text-xs text-muted-foreground",children:"None"}):e.jsx("div",{className:"flex items-center gap-1",children:t.connected_accounts.slice(0,6).map((t,s)=>{const a=c(t.platform);return e.jsxs("span",{className:"relative flex items-center justify-center size-6 rounded-md bg-muted",title:`${t.platform} â ${t.status}`,children:[a?.icon?e.jsx(n,{name:a.icon,className:"w-3.5 h-3.5"}):e.jsx(n,{name:"Share2",className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx("span",{className:i("absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full ring-1 ring-background","connected"===t.status?"bg-green-500":"expired"===t.status?"bg-amber-500":"bg-red-500")})]},`${t.platform}-${s}`)})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(b,{row:t})}),e.jsx("td",{className:"px-4 py-3",children:t.posts_this_month}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground",children:y(t.last_posted)}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground",children:y(t.next_scheduled)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs(o,{size:"sm",disabled:_===t.id,onClick:()=>(async e=>{S(e.id);try{await f.activateTeam(e.id),u(e.id),window.location.href=p("/social")}catch(t){x({title:"Couldn't open workspace",description:t instanceof Error?t.message:"Unknown error",variant:"destructive"}),S(null)}})(t),children:[_===t.id?e.jsx(n,{name:"LoaderCircle",className:"w-3.5 h-3.5 animate-spin mr-1"}):null,"Open"]})})})]},t.id))})]})})]})}function N({tier:t}){return"creative"===t?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-semibold bg-gradient-to-r from-purple-100 to-fuchsia-100 text-purple-700 dark:from-purple-900/40 dark:to-fuchsia-900/40 dark:text-purple-200",children:[e.jsx(n,{name:"Palette",className:"w-3 h-3"}),"Creative"]}):"basic"===t?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-semibold bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-200",children:[e.jsx(n,{name:"Zap",className:"w-3 h-3"}),"Basic"]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"â"})}function b({row:t}){const s=Object.values(t.readiness).length,a=Object.values(t.readiness).filter(Boolean).length,r=a===s;return e.jsxs("span",{className:i("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",r?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300":"bg-muted text-muted-foreground"),children:[r?e.jsx(n,{name:"Check",className:"w-3 h-3"}):null,a,"/",s]})}function y(e){if(!e)return"â";try{return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return e}}const w=function(){return e.jsx(s,{children:e.jsx(g,{})})};export{w 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.