PageSourceSearch

https://oresund.digital/assets/ContactLeads-CQpQFi1K.js

js oresund.digital collected 2026-10-07 21:51:46 UTC 5,639 bytes, 1 lines download raw bytes

1import{r as l,aR as L,j as e,aB as B,U as d}from"./index-Ce4_IyS-.js";import{C as I,a as M,b as $,d as k}from"./card-Lc38xdPG.js";import{T as q,a as E,b as m,c as i,d as P,e as n}from"./table-B398aFYs.js";import{B as N}from"./badge-DBAjr8H4.js";import{I as R}from"./input-DEg4QyHf.js";import{B as h}from"./button-C8g1r6uw.js";import{A as H,a as z,b as F,c as U,d as W,e as O,f as Y,g as G,h as J}from"./alert-dialog-Dxa6mOTu.js";import{S as K,U as Q,T as V}from"./upload-BlqbAifR.js";import{C as X}from"./circle-check-big-3LKwGjns.js";import{R as Z}from"./refresh-cw-B9qwMKkm.js";import"./index-DUqCGOuX.js";import"./index-Bmpq24cP.js";const ee={"one-page":"One-Page Website","custom-business":"Custom Business Website","something-else":"Something Else"},he=()=>{const[S,u]=l.useState([]),[j,C]=l.useState(""),[g,v]=l.useState(!0),[w,p]=l.useState(new Set),[x,f]=l.useState(null),[D,b]=l.useState(null),{toast:c}=L();l.useEffect(()=>{(async()=>{const[{data:t},{data:a}]=await Promise.all([d.from("contact_submissions").select("*").order("created_at",{ascending:!1}),d.from("monday_sync_log").select("submission_id").eq("submission_type","contact_form").eq("status","synced")]);u(t??[]),p(new Set((a??[]).map(r=>r.submission_id))),v(!1)})()},[]);const y=async s=>{f(s.id);try{const{data:t,error:a}=await d.functions.invoke("monday-sync",{body:{category:"contact_form",submission:s}});a||t!=null&&t.error?c({title:"Sync failed",description:(t==null?void 0:t.error)||(a==null?void 0:a.message),variant:"destructive"}):(c({title:"Pushed to Monday.com"}),p(r=>new Set(r).add(s.id)))}catch{c({title:"Sync failed",variant:"destructive"})}f(null)},T=async s=>{b(s);const{error:t}=await d.from("contact_submissions").delete().eq("id",s);t?c({title:"Delete failed",description:t.message,variant:"destructive"}):(u(a=>a.filter(r=>r.id!==s)),c({title:"Submission deleted"})),b(null)},o=S.filter(s=>{var a;const t=j.toLowerCase();return s.name.toLowerCase().includes(t)||s.email.toLowerCase().includes(t)||(((a=s.company)==null?void 0:a.toLowerCase().includes(t))??!1)}),A=s=>{const t=new Date(s),a=String(t.getDate()).padStart(2,"0"),r=String(t.getMonth()+1).padStart(2,"0"),_=String(t.getFullYear()).slice(-2);return`${a}-${r}-${_}`};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Contact Form Leads"}),e.jsx("p",{className:"text-muted-foreground",children:"All contact form submissions"})]}),e.jsxs(I,{className:"border-border/50",children:[e.jsxs(M,{className:"flex flex-row items-center justify-between",children:[e.jsx($,{className:"text-lg",children:g?"Loading…":`${o.length} submission${o.length!==1?"s":""}`}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(R,{placeholder:"Search name, email, company…",className:"pl-9",value:j,onChange:s=>C(s.target.value)})]})]}),e.jsx(k,{className:"p-0",children:e.jsxs(q,{children:[e.jsx(E,{children:e.jsxs(m,{children:[e.jsx(i,{children:"Date"}),e.jsx(i,{children:"Name"}),e.jsx(i,{children:"Email"}),e.jsx(i,{children:"Phone"}),e.jsx(i,{children:"Company"}),e.jsx(i,{children:"Topic"}),e.jsx(i,{children:"Source"}),e.jsx(i,{children:"Message"}),e.jsx(i,{className:"text-center",children:"Monday"}),e.jsx(i,{className:"text-center",children:"Actions"})]})}),e.jsx(P,{children:g?e.jsx(m,{children:e.jsx(n,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading…"})}):o.length===0?e.jsx(m,{children:e.jsxs(n,{colSpan:10,className:"text-center py-8",children:[e.jsx(B,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No submissions yet"})]})}):o.map(s=>e.jsxs(m,{children:[e.jsx(n,{className:"whitespace-nowrap text-sm",children:A(s.created_at)}),e.jsx(n,{className:"font-medium",children:s.name}),e.jsx(n,{className:"text-sm",children:s.email}),e.jsx(n,{className:"text-sm text-muted-foreground",children:s.phone||"—"}),e.jsx(n,{className:"text-sm",children:s.company||"—"}),e.jsx(n,{children:e.jsx(N,{variant:"secondary",children:ee[s.topic]??s.topic})}),e.jsx(n,{children:s.source_page?e.jsx(N,{variant:"outline",children:s.source_page}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(n,{className:"max-w-[200px] truncate text-sm text-muted-foreground",children:s.message||"—"}),e.jsx(n,{className:"text-center",children:w.has(s.id)?e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(X,{className:"h-4 w-4 text-green-500"}),e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 px-2",disabled:x===s.id,onClick:()=>y(s),children:e.jsx(Z,{className:`h-3.5 w-3.5 ${x===s.id?"animate-spin":""}`})})]}):e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 px-2",disabled:x===s.id,onClick:()=>y(s),children:e.jsx(Q,{className:"h-3.5 w-3.5"})})}
1),e.jsx(n,{className:"text-center",children:e.jsxs(H,{children:[e.jsx(z,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"ghost",className:"h-7 px-2 text-destructive hover:text-destructive",disabled:D===s.id,children:e.jsx(V,{className:"h-3.5 w-3.5"})})}),e.jsxs(F,{children:[e.jsxs(U,{children:[e.jsx(W,{children:"Delete submission?"}),e.jsxs(O,{children:["This will permanently delete the submission from ",s.name," (",s.email,"). This action cannot be undone."]})]}),e.jsxs(Y,{children:[e.jsx(G,{children:"Cancel"}),e.jsx(J,{onClick:()=>T(s.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]},s.id))})]})})]})]})};export{he 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.