PageSourceSearch

https://thesaashub.com/assets/AdminMerchantLeads-uKDXN6gQ.js

js thesaashub.com collected 2026-10-06 11:03:28 UTC 7,724 bytes, 4 lines download raw bytes

1import{j as e}from"./ui-vendor-CoYFvwbA.js";import{r as c}from"./react-vendor-SCck3TKl.js";import{u as w}from"./query-vendor-5_ACa-1l.js";import{n as C,C as S,j as T,k as A,c as D,m,d as L,e as E,f as M,g as z,h as l,B as p,s as o}from"./index-ClNvF6Go.js";import{T as I,a as q,b as g,c as i,d as B,e as n}from"./table-BLn2vBiY.js";import{D as H,b as R,c as V,d as k,e as F}from"./dialog-CGQAmItK.js";import{L as a}from"./label-rGNKPrLe.js";import{E as O}from"./eye-RbHLTtQX.js";import{T as P}from"./trash-2-TaxehwvY.js";import{M as $}from"./mail-DuK0iQiq.js";import{P as Q}from"./phone-YscyaOcL.js";const ae=()=>{const[t,f]=c.useState(null),[N,x]=c.useState(!1);c.useState(!1);const{toast:d}=C(),{data:h,isLoading:v,refetch:u}=w({queryKey:["merchant-leads"],queryFn:async()=>{const{data:s,error:r}=await o.from("merchant_leads").select(`
2          *,
3          apps!inner(name, slug)
4        `).order("created_at",{ascending:!1});if(r)throw r;return s}}),y=async(s,r)=>{const{error:_}=await o.from("merchant_leads").update({status:r}).eq("id",s);_?d({title:"Error",description:"Failed to update lead status",variant:"destructive"}):(d({title:"Success",description:"Lead status updated successfully"}),u())},b=async s=>{if(!confirm("Are you sure you want to delete this lead?"))return;const{error:r}=await o.from("merchant_leads").delete().eq("id",s);r?d({title:"Error",description:"Failed to delete lead",variant:"destructive"}):(d({title:"Success",description:"Lead deleted successfully"}),u())},j=s=>{switch(s){case"urgent":return"bg-red-100 text-red-800";case"high":return"bg-orange-100 text-orange-800";case"medium":return"bg-blue-100 text-blue-800";case"low":return"bg-gray-100 text-gray-800";default:return"bg-gray-100 text-gray-800"}};return v?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-1/3"}),e.jsx("div",{className:"h-64 bg-muted rounded"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Merchant Leads"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage customer leads for your apps"})]})}),e.jsxs(S,{children:[e.jsx(T,{children:e.jsxs(A,{children:["All Leads (",h?.length||0,")"]})}),e.jsx(D,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(I,{children:[e.jsx(q,{children:e.jsxs(g,{children:[e.jsx(i,{children:"Merchant"}),e.jsx(i,{children:"App"}),e.jsx(i,{children:"Company"}),e.jsx(i,{children:"Interest"}),e.jsx(i,{children:"Status"}),e.jsx(i,{children:"Timeline"}),e.jsx(i,{children:"Created"}),e.jsx(i,{children:"Actions"})]})}),e.jsx(B,{children:h?.map(s=>e.jsxs(g,{children:[e.jsx(n,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.merchant_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s.merchant_email})]})}),e.jsx(n,{children:e.jsx("div",{className:"font-medium",children:s.apps?.name})}),e.jsx(n,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.company_name||"N/A"}),s.company_size&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s.company_size," employees"]})]})}),e.jsx(n,{children:e.jsx(m,{className:j(s.interest_level||"medium"),children:s.interest_level})}),e.jsx(n,{children:e.jsxs(L,{value:s.status||"new",onValueChange:r=>y(s.id,r),children:[e.jsx(E,{className:"w-32",children:e.jsx(M,{})}),e.jsxs(z,{children:[e.jsx(l,{value:"new",children:"New"}),e.jsx(l,{value:"contacted",children:"Contacted"}),e.jsx(l,{value:"qualified",children:"Qualified"}),e.jsx(l,{value:"converted",children:"Converted"}),e.jsx(l,{value:"closed",children:"Closed"})]})]})}),e.jsx(n,{children:s.timeline&&e.jsx(m,{variant:"outline",children:s.timeline.replace("_","-")})}),e.jsx(n,{children:new Date(s.created_at).toLocaleDateString()}),e.jsx(n,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{size:"sm",variant:"ghost",onClick:()=>{f(s),x(!0)},children:e.jsx(O,{className:"h-4 w-4"})}),e.jsx(p,{size:"sm",variant:"ghost",onClick:()=>b(s.id),children:e.jsx(P,{className:"h-4 w-4"})})]})})]},s.id))})]})})})]}),e.jsx(H,{open:N,onOpenChange:x,children:e.jsxs(R,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(V,{children:[e.jsx(k,{children:"Lead Details"}),e.jsx(F,{children:"Detailed information about this merchant lead"})]}),t&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Merchant Name"}),e.jsx("p",{className:"text-sm",children:t.merchant_name})]}),e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("p",{className:"text-sm",children:t.merchant_email})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Company"}),e.jsx("p",{className:"text-sm",children:t.company_name||"N/A"})]}),e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Company Size"}
4),e.jsx("p",{className:"text-sm",children:t.company_size||"N/A"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Phone"}),e.jsx("p",{className:"text-sm",children:t.phone_number||"N/A"})]}),e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Website"}),e.jsx("p",{className:"text-sm",children:t.website_url||"N/A"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Industry"}),e.jsx("p",{className:"text-sm",children:t.industry||"N/A"})]}),e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Budget Range"}),e.jsx("p",{className:"text-sm",children:t.budget_range||"N/A"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Interest Level"}),e.jsx(m,{className:j(t.interest_level||"medium"),children:t.interest_level})]}),e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Timeline"}),e.jsx("p",{className:"text-sm",children:t.timeline?.replace("_","-")||"N/A"})]})]}),t.use_case&&e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Use Case"}),e.jsx("p",{className:"text-sm mt-1",children:t.use_case})]}),t.current_solution&&e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Current Solution"}),e.jsx("p",{className:"text-sm mt-1",children:t.current_solution})]}),t.additional_notes&&e.jsxs("div",{children:[e.jsx(a,{className:"text-sm font-medium text-muted-foreground",children:"Additional Notes"}),e.jsx("p",{className:"text-sm mt-1",children:t.additional_notes})]}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("a",{href:`mailto:${t.merchant_email}?subject=Regarding your interest in ${t.apps?.name}`,className:"flex items-center gap-2 text-sm text-blue-600 hover:text-blue-800",children:[e.jsx($,{className:"h-4 w-4"}),"Send Email"]}),t.phone_number&&e.jsxs("a",{href:`tel:${t.phone_number}`,className:"flex items-center gap-2 text-sm text-blue-600 hover:text-blue-800",children:[e.jsx(Q,{className:"h-4 w-4"}),"Call"]})]})})]})]})})]})};export{ae 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.