PageSourceSearch

https://bluethread.lovable.app/assets/PartnerMarketplaceAdmin-iMnrcgiP.js

js bluethread.lovable.app collected 2026-10-03 03:27:19 UTC 13,250 bytes, 1 lines download raw bytes

1import{r as m,j as e}from"./react-vendor-DHoSUuS3.js";import{s as c,L as K,a as Y,B as g,C as Z,a6 as J,I as C,Z as Q,$ as W,a0 as X,a1 as ee,d as v,T as se,a3 as te}from"./index-DaNgbS5L.js";import{T as re,a as ae,b as _,c as k}from"./tabs-BT9QBz_L.js";import{u as ie}from"./use-toast-CLOfSIzX.js";import{P as ne}from"./PartnerLogo-6Dki41yU.js";import{E as L}from"./eye-DUMAyoMU.js";import{I as R}from"./workspaceRoles-DDWLpInq.js";import{G as le}from"./globe-Bl0ieyzJ.js";import{f as oe}from"./formatDistanceToNow-fKExwOYA.js";import{T as A}from"./trash-2-BLNxNvWW.js";import{P as de}from"./plus-D_8_fuJA.js";import{C as I}from"./circle-COvJjXT1.js";const ce={planned:{label:"Planned",icon:I,color:"text-muted-foreground"},in_progress:{label:"In Progress",icon:J,color:"text-amber-500"},done:{label:"Done",icon:Z,color:"text-emerald-500"}},D={low:{label:"Low",color:"bg-muted text-muted-foreground"},medium:{label:"Medium",color:"bg-primary/15 text-primary"},high:{label:"High",color:"bg-rose-500/15 text-rose-500"}};function Ce(){const{toast:t}=ie(),[l,u]=m.useState(!0),[p,o]=m.useState([]),[d,a]=m.useState([]),[x,U]=m.useState(0),[V,q]=m.useState(0),[j,S]=m.useState([]),[P,w]=m.useState(null),[z,N]=m.useState(!1);m.useEffect(()=>{T()},[]);const T=async()=>{u(!0);const s=new Date(Date.now()-7*864e5).toISOString(),[r,i,n,h,f]=await Promise.all([c.from("partner_applications").select("*").order("created_at",{ascending:!1}),c.from("partners").select("id, name, tags, active, website, logo_url, logo_initials, logo_color").order("name"),c.from("partners_roadmap").select("*").order("sort_order").order("created_at"),c.from("page_views").select("id",{count:"exact",head:!0}).like("path","/partners%"),c.from("page_views").select("id",{count:"exact",head:!0}).like("path","/partners%").gte("created_at",s)]);r.data&&o(r.data),i.data&&a(i.data),n.data&&S(n.data),U(h.count??0),q(f.count??0),u(!1)},M=async(s,r)=>{const{error:i}=await c.from("partner_applications").update({status:r}).eq("id",s);if(i){t({title:"Update failed",description:i.message,variant:"destructive"});return}o(n=>n.map(h=>h.id===s?{...h,status:r}:h))},$=async s=>{if(!confirm("Delete this application?"))return;const{error:r}=await c.from("partner_applications").delete().eq("id",s);if(r){t({title:"Delete failed",description:r.message,variant:"destructive"});return}o(i=>i.filter(n=>n.id!==s))},H=async s=>{const{error:r}=await c.from("partners").update({active:!s.active}).eq("id",s.id);if(r){t({title:"Update failed",description:r.message,variant:"destructive"});return}a(i=>i.map(n=>n.id===s.id?{...n,active:!n.active}:n))},B=async(s,r)=>{const i=r?.trim()||null,{error:n}=await c.from("partners").update({logo_url:i}).eq("id",s);if(n){t({title:"Update failed",description:n.message,variant:"destructive"});return}a(h=>h.map(f=>f.id===s?{...f,logo_url:i}:f)),t({title:"Logo updated"})},O=async s=>{if(!s.title?.trim()){t({title:"Title required",variant:"destructive"});return}if(s.id){const{error:r}=await c.from("partners_roadmap").update({title:s.title,description:s.description??null,status:s.status??"planned",priority:s.priority??"medium",sort_order:s.sort_order??0}).eq("id",s.id);if(r)return t({title:"Save failed",description:r.message,variant:"destructive"})}else{const{error:r}=await c.from("partners_roadmap").insert({title:s.title,description:s.description??null,status:s.status??"planned",priority:s.priority??"medium",sort_order:s.sort_order??j.length});if(r)return t({title:"Create failed",description:r.message,variant:"destructive"})}w(null),N(!1),T()},F=async s=>{if(!confirm("Delete this roadmap item?"))return;const{error:r}=await c.from("partners_roadmap").delete().eq("id",s);if(r)return t({title:"Delete failed",description:r.message,variant:"destructive"});S(i=>i.filter(n=>n.id!==s))};if(l)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(K,{className:"h-6 w-6 animate-spin text-muted-foreground"})});const y=p.filter(s=>s.status==="pending").length,G=d.filter(s=>s.active).length;return e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-8 space-y-8",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Partner Marketplace"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Track usage, review applications, and plan future build items."})]}),e.jsxs("a",{href:"/partners",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-sm text-primary hover:underline",children:["View public page ",e.jsx(Y,{className:"w-3.5 h-3.5"})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(b,{icon:L,label:"Page Views (all time)",value:x}),e.jsx(b,{icon:L,label:"Page Views (7d)",value:V}
1),e.jsx(b,{icon:R,label:"Pending Applications",value:y}),e.jsx(b,{icon:le,label:"Active Listings",value:G})]}),e.jsxs(re,{defaultValue:"applications",children:[e.jsxs(ae,{children:[e.jsxs(_,{value:"applications",children:["Applications ",y>0&&e.jsx("span",{className:"ml-1.5 text-xs bg-primary text-primary-foreground rounded-full px-1.5",children:y})]}),e.jsxs(_,{value:"listings",children:["Listings (",d.length,")"]}),e.jsxs(_,{value:"roadmap",children:["Roadmap (",j.length,")"]})]}),e.jsx(k,{value:"applications",className:"mt-6",children:p.length===0?e.jsx(E,{icon:R,title:"No applications yet",desc:"Submissions from /partners will appear here."}):e.jsx("div",{className:"space-y-3",children:p.map(s=>e.jsx("div",{className:"rounded-lg border border-border bg-card p-5",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:s.company_name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:s.category}),e.jsx(me,{status:s.status})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[s.applicant_name," · ",e.jsx("a",{href:`mailto:${s.work_email}`,className:"hover:underline",children:s.work_email}),s.website&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:s.website,target:"_blank",rel:"noopener noreferrer",className:"hover:underline",children:s.website})]})]}),s.message&&e.jsx("p",{className:"text-sm text-foreground/80 mt-3 leading-relaxed whitespace-pre-wrap",children:s.message}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:oe(new Date(s.created_at),{addSuffix:!0})})]}),e.jsxs("div",{className:"flex flex-col gap-2 shrink-0",children:[e.jsxs("select",{value:s.status,onChange:r=>M(s.id,r.target.value),className:"h-8 rounded-md border border-input bg-background px-2 text-xs",children:[e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"reviewing",children:"Reviewing"}),e.jsx("option",{value:"approved",children:"Approved"}),e.jsx("option",{value:"rejected",children:"Rejected"})]}),e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>$(s.id),children:e.jsx(A,{className:"w-3.5 h-3.5"})})]})]})},s.id))})}),e.jsxs(k,{value:"listings",className:"mt-6",children:[e.jsx("div",{className:"space-y-3",children:d.map(s=>e.jsx(ue,{partner:s,onToggle:()=>H(s),onSaveLogoUrl:r=>B(s.id,r)},s.id))}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Logos auto-fetch from Brandfetch using the partner's website. Paste a custom Logo URL to override."})]}),e.jsxs(k,{value:"roadmap",className:"mt-6",children:[e.jsx("div",{className:"flex justify-end mb-4",children:e.jsxs(g,{size:"sm",onClick:()=>N(!0),children:[e.jsx(de,{className:"w-4 h-4 mr-1"})," New item"]})}),j.length===0?e.jsx(E,{icon:I,title:"No roadmap items yet",desc:"Add future build items for the Partner Marketplace."}):e.jsx("div",{className:"space-y-2",children:j.map(s=>{const r=ce[s.status],i=r.icon;return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 flex items-start gap-3",children:[e.jsx(i,{className:`w-5 h-5 mt-0.5 shrink-0 ${r.color}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-medium text-foreground",children:s.title}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${D[s.priority].color}`,children:D[s.priority].label})]}),s.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 whitespace-pre-wrap",children:s.description})]}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>w(s),children:"Edit"}),e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>F(s.id),children:e.jsx(A,{className:"w-3.5 h-3.5"})})]})]},s.id)})})]})]}),e.jsx(xe,{open:z||!!P,item:P,onClose:()=>{w(null),N(!1)},onSave:O})]})}function b({icon:t,label:l,value:u}){return e.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/[0.05] p-5 flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/[0.12] flex items-center justify-center flex-none",children:e.jsx(t,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-foreground tabular-nums",children:u.toLocaleStr
1ing()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l})]})]})}function me({status:t}){const l={pending:"bg-amber-500/15 text-amber-500",reviewing:"bg-primary/15 text-primary",approved:"bg-emerald-500/15 text-emerald-500",rejected:"bg-muted text-muted-foreground"};return e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${l[t]??"bg-muted text-muted-foreground"}`,children:t})}function E({icon:t,title:l,desc:u}){return e.jsxs("div",{className:"text-center py-16 border border-dashed border-border rounded-lg",children:[e.jsx(t,{className:"w-8 h-8 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"font-medium",children:l}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:u})]})}function ue({partner:t,onToggle:l,onSaveLogoUrl:u}){const[p,o]=m.useState(t.logo_url??""),d=(p||"")!==(t.logo_url??"");return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 flex items-center gap-4",children:[e.jsx(ne,{name:t.name,website:t.website,logoUrl:t.logo_url,initials:t.logo_initials,c
1olor:t.logo_color,size:48}),e.jsxs("div",{className:"flex-1 min-w-0 grid grid-cols-1 md:grid-cols-[1fr_2fr] gap-3 items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:t.name}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${t.active?"bg-emerald-500/15 text-emerald-500":"bg-muted text-muted-foreground"}`,children:t.active?"Active":"Hidden"})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:(t.tags??[]).join(" · ")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{value:p,onChange:a=>o(a.target.value),placeholder:"Logo URL override (optional)",className:"h-8 text-xs"}),d&&e.jsx(g,{size:"sm",variant:"outline",onClick:()=>u(p),children:"Save"})]})]}),e.jsx(g,{size:"sm",variant:"outline",onClick:l,className:"shrink-0",children:t.active?"Hide":"Activate"})]})}function xe({open:t,item:l,onClose:u,onSave:p}){const[o,d]=m.useState({});return m.useEffect(()=>{t&&d(l??{title:"",description:"",status:"planned",priority:"medium",sort_order:0})},[t,l]),e.jsx(Q,{open:t,onOpenChange:a=>!a&&u(),children:e.jsxs(W,{children:[e.jsx(X,{children:e.jsx(ee,{children:l?"Edit roadmap item":"New roadmap item"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{children:"Title"}),e.jsx(C,{value:o.title??"",onChange:a=>d(x=>({...x,title:a.target.value})),maxLength:150})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Description"}),e.jsx(se,{rows:4,value:o.description??"",onChange:a=>d(x=>({...x,description:a.target.value})),maxLength:2e3})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(v,{children:"Status"}),e.jsxs("select",{value:o.status??"planned",onChange:a=>d(x=>({...x,status:a.target.value})),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"planned",children:"Planned"}),e.jsx("option",{value:"in_progress",children:"In Progress"}),e.jsx("option",{value:"done",children:"Done"})]})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Priority"}),e.jsxs("select",{value:o.priority??"medium",onChange:a=>d(x=>({...x,priority:a.target.value})),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{children:[e.jsx(v,{children:"Order"}),e.jsx(C,{type:"number",value:o.sort_order??0,onChange:a=>d(x=>({...x,sort_order:parseInt(a.target.value)||0}))})]})]})]}),e.jsxs(te,{children:[e.jsx(g,{variant:"outline",onClick:u,children:"Cancel"}),e.jsx(g,{onClick:()=>p({...o,id:l?.id}),children:"Save"})]})]})})}export{Ce 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.