1import{r as h,Z as S,M as C,j as e,h as _,i as q,k,I as T,m as $,J as w,B as j,g as f,s as g}from"./index-DLd_kDlx.js";import{u as I}from"./useMutation-CotV56Sa.js";import{S as P,H as E}from"./SuperAdminLayout-BsUvQU2j.js";import{T as M,a as z,b as y,c as i,d as H,e as r}from"./table-BOJIo-OD.js";import{S as L,a as A,c as B,d as F}from"./select-RSrodAEw.js";import{S as D}from"./search-DFH5eAlA.js";import{C as Q}from"./chevron-left-Wewsh5d7.js";import{C as R}from"./chevron-right-CD1gvy-q.js";import{f as J}from"./format-BTXglRCX.js";import"./NotificationIcon-C1wwYnH5.js";import"./popover-BMD5FOmU.js";import"./scroll-area-BXTuUF24.js";import"./index-Deh-4PO1.js";import"./index-BdQq_4o_.js";import"./NotificationItem-Dc2WXW-y.js";import"./formatDistanceToNow-57P64IbE.js";import"./en-US-9SRVm7yB.js";import"./differenceInCalendarMonths-BA0TPVs2.js";import"./endOfDay-DkR3ZXc8.js";import"./endOfMonth-CYn6pTOm.js";import"./message-square-CtxeCfRz.js";import"./trophy-DBX-jNOC.js";import"./triangle-alert-Chqk_WK7.js";import"./dropdown-menu-DSd1c3Vk.js";import"./index-lTaZyIGy.js";import"./crown-hzm_bRIt.js";import"./user-check-DxoAQXwU.js";import"./star-BH1OFEcs.js";import"./globe-C057RQ73.js";import"./timer-CZhDpZys.js";import"./briefcase-business-CphIeAJd.js";import"./key-round-B79BulHq.js";import"./chevron-down-DpJJsCer.js";import"./chevron-up-M4SAwIjf.js";const u=15,x=[{value:"new",label:"New",color:"bg-blue-100 text-blue-800"},{value:"contacted",label:"Contacted",color:"bg-yellow-100 text-yellow-800"},{value:"converted",label:"Converted",color:"bg-green-100 text-green-800"},{value:"dismissed",label:"Dismissed",color:"bg-gray-100 text-gray-600"}],K=t=>{var c;return((c=x.find(l=>l.value===t))==null?void 0:c.color)??"bg-gray-100 text-gray-600"},qe=()=>{const[t,c]=h.useState(""),[l,d]=h.useState(0),b=S(),{data:n,isLoading:v}=C({queryKey:["sponsorship-inquiries",t,l],queryFn:async()=>{let s=g.from("pod_sponsorship_inquiries").select("*",{count:"exact"}).order("created_at",{ascending:!1}).range(l*u,(l+1)*u-1);t.trim()&&(s=s.or(`company_name.ilike.%${t}%,full_name.ilike.%${t}%,email.ilike.%${t}%,industry.ilike.%${t}%,job_title.ilike.%${t}%,company_location.ilike.%${t}%,pod_type.ilike.%${t}%`));const{data:o,count:a,error:p}=await s;if(p)throw p;return{rows:o??[],count:a??0}}}),N=I({mutationFn:async({id:s,status:o})=>{const{error:a}=await g.from("pod_sponsorship_inquiries").update({status:o}).eq("id",s);if(a)throw a},onSuccess:()=>{b.invalidateQueries({queryKey:["sponsorship-inquiries"]}),f.success("Status updated")},onError:()=>f.error("Failed to update status")}),m=Math.ceil(((n==null?void 0:n.count)??0)/u);return e.jsx(P,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(E,{className:"h-7 w-7 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Pod Sponsorship Inquiries"})]}),e.jsxs(_,{children:[e.jsx(q,{className:"pb-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsx(k,{className:"text-lg",children:"All Inquiries"}),e.jsxs("div",{className:"flex items-center bg-muted px-3 py-1.5 rounded-lg w-full sm:w-72",children:[e.jsx(D,{className:"h-4 w-4 text-muted-foreground mr-2"}),e.jsx(T,{placeholder:"Search company, name, email...",value:t,onChange:s=>{c(s.target.value),d(0)},className:"border-0 bg-transparent h-auto p-0 focus-visible:ring-0 text-sm"})]})]})}),e.jsx($,{children:v?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loadingâ¦"}):n!=null&&n.rows.length?e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[e.jsx(z,{children:e.jsxs(y,{children:[e.jsx(i,{children:"Company"}),e.jsx(i,{children:"Industry"}),e.jsx(i,{children:"Size"}),e.jsx(i,{children:"Location"}),e.jsx(i,{children:"Contact"}),e.jsx(i,{children:"Job Title"}),e.jsx(i,{children:"Email"}),e.jsx(i,{children:"Phone"}),e.jsx(i,{children:"Pod Type"}),e.jsx(i,{children:"Status"}),e.jsx(i,{children:"Date"})]})}),e.jsx(H,{children:n.rows.map(s=>{var o;return e.jsxs(y,{children:[e.jsx(r,{className:"font-medium",children:s.company_name}),e.jsx(r,{className:"text-sm",children:s.industry||"â"}
1),e.jsx(r,{className:"text-sm",children:s.company_size||"â"}),e.jsx(r,{className:"text-sm",children:s.company_location||"â"}),e.jsx(r,{children:s.full_name}),e.jsx(r,{className:"text-sm",children:s.job_title||"â"}),e.jsx(r,{children:e.jsx("a",{href:`mailto:${s.email}`,className:"text-primary hover:underline",children:s.email})}),e.jsx(r,{children:s.phone}),e.jsx(r,{className:"text-sm capitalize",children:(s.pod_type||"â").replace(/_/g," ")}),e.jsx(r,{children:e.jsxs(L,{value:s.status,onValueChange:a=>N.mutate({id:s.id,status:a}),children:[e.jsx(A,{className:"w-[130px] h-8",children:e.jsx(w,{className:`${K(s.status)} border-0`,children:((o=x.find(a=>a.value===s.status))==null?void 0:o.label)??s.status})}),e.jsx(B,{children:x.map(a=>e.jsx(F,{value:a.value,children:a.label},a.value))})]})}),e.jsx(r,{className:"text-muted-foreground text-sm",children:J(new Date(s.created_at),"MMM d, yyyy")})]},s.id)})})]}),m>1&&e.jsxs("div",{className:"flex items-center justify-between pt-4",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[n.count," total · Page ",l+1," of ",m]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{variant:"outline",size:"sm",disabled:l===0,onClick:()=>d(l-1),children:e.jsx(Q,{className:"h-4 w-4"})}),e.jsx(j,{variant:"outline",size:"sm",disabled:l>=m-1,onClick:()=>d(l+1),children:e.jsx(R,{className:"h-4 w-4"})})]})]})]}):e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No inquiries found."})})]})]})})};export{qe 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.