PageSourceSearch

https://www.bowmorewealth.com/assets/_admin.admin.email-templates.index-Bz9eCjVf.js

js bowmorewealth.com collected 2026-10-04 21:03:43 UTC 6,344 bytes, 1 lines download raw bytes

1import{r as N,bw as v,F as b,u as C,ak as d,j as e,B as g,M as L,L as y,A as S,s as D,D as T,bH as _,a as q,bI as k,b as B}from"./index-BumohzBS.js";import{u as f}from"./useMutation-CnNyVA22.js";import{u as c}from"./auth-middleware-BWJI7Br7.js";import{C as F,a as K,b as A,c as M}from"./card-BPVtbXih.js";import{T as $,a as P,b as G,c as I}from"./tabs-wJYtmp2Z.js";import{K as o,d as Q,B as j,E as R}from"./types-IB0TUUdV.js";import{l as H,u as O,d as U,c as Y}from"./campaigns.functions-CysGC54W.js";import{L as x}from"./loader-circle-zihHFCs1.js";import{P as W}from"./plus-CYfDEW5c.js";import{T as z}from"./trash-2-xSbSNGtl.js";import{S as V}from"./sparkles-B6K1wGKo.js";import"./index-4WvxixMo.js";import"./index-CE2V6Q7A.js";const w=["weekly_note","quarterly_note","quarterly_newsletter"];function ce(){const[a,m]=N.useState("quarterly_newsletter"),u=c(H),p=c(O),h=c(U),i=v(),l=b(),t=C({queryKey:["email-campaigns",a],queryFn:()=>u({data:{kind:a}})}),n=f({mutationFn:async()=>await p({data:{kind:a,title:`New ${o[a]} — ${new Date().toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}`,eyebrow:a==="weekly_note"?"WEEKLY MARKET NOTE":a==="quarterly_note"?"QUARTERLY UPDATE":"QUARTERLY BUSINESS UPDATE",entity:a==="weekly_note"?"BAM":"BWG",sections:Q(a)}}),onSuccess:s=>{i.invalidateQueries({queryKey:["email-campaigns"]}),l({to:"/admin/email-templates/$id",params:{id:s.id}})},onError:s=>d.error(s.message)}),E=f({mutationFn:s=>h({data:{id:s}}),onSuccess:()=>{i.invalidateQueries({queryKey:["email-campaigns"]}),d.success("Deleted")},onError:s=>d.error(s.message)});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"Email templates"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Branded weekly notes, quarterly notes and client newsletters. Export HTML to HubSpot when a draft is ready."})]}),e.jsxs(g,{onClick:()=>n.mutate(),disabled:n.isPending,children:[n.isPending?e.jsx(x,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(W,{className:"w-4 h-4 mr-2"}),"New ",o[a].toLowerCase()]})]}),e.jsxs($,{value:a,onValueChange:s=>m(s),children:[e.jsx(P,{children:w.map(s=>e.jsx(G,{value:s,children:o[s]},s))}),w.map(s=>e.jsx(I,{value:s,className:"mt-6",children:e.jsxs(F,{children:[e.jsxs(K,{className:"flex flex-row items-center justify-between",children:[e.jsxs(A,{className:"text-base flex items-center gap-2",children:[e.jsx(L,{className:"w-4 h-4"})," Drafts & sent"]}),a==="weekly_note"&&e.jsx(J,{})]}),e.jsx(M,{children:t.isLoading?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:e.jsx(x,{className:"w-4 h-4 mx-auto animate-spin"})}):(t.data??[]).length===0?e.jsxs("div",{className:"py-10 text-center text-sm text-muted-foreground",children:["No ",o[s].toLowerCase(),'s yet. Click "New ',o[s].toLowerCase(),'" to draft one.']}):e.jsx("ul",{className:"divide-y divide-border",children:(t.data??[]).map(r=>e.jsxs("li",{className:"py-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{to:"/admin/email-templates/$id",params:{id:r.id},className:"text-sm font-medium hover:underline truncate",children:r.title}),e.jsx(j,{variant:"outline",className:"text-[10px] uppercase",children:r.status}),e.jsx(j,{variant:"secondary",className:"text-[10px]",children:R[r.entity]}),r.hubspot_email_id&&e.jsx(j,{className:"bg-orange-100 text-orange-800 text-[10px]",children:"HubSpot draft"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:["Updated ",new Date(r.updated_at).toLocaleString("en-GB"),r.sent_at&&` · Sent ${new Date(r.sent_at).toLocaleDateString("en-GB")}`]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(g,{asChild:!0,size:"sm",variant:"ghost",children:e.jsxs(y,{to:"/admin/email-templates/$id",params:{id:r.id},children:["Open ",e.jsx(S,{className:"w-3 h-3 ml-1"})]})}),e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{confirm(`Delete "${r.title}"?`)&&E.mutate(r.id)},children:e.jsx(z,{className:"w-3 h-3"})})]})]},r.id))})})]})},s))]})]})}function J(){const[a,m]=N.useState(!1),u=b(),p=v(),h=c(Y),i=C({queryKey:["market-overview-insights"],enabled:a,queryFn:async()=>{const{data:t,error:n}=await D.from("insights").select("id,title,slug,published_at,excerpt").eq("category","Market Overview").order("published_at",{ascending:!1,nullsFirst:!1}).limit(50);if(n)throw new Error(n.message);return t??[]}}),l=f({mutationFn:t=>h({data:{insight_id:t}}
1),onSuccess:t=>{p.invalidateQueries({queryKey:["email-campaigns"]}),d.success("Weekly email draft created"),m(!1),u({to:"/admin/email-templates/$id",params:{id:t.id}})},onError:t=>d.error(t.message)});return e.jsxs(T,{open:a,onOpenChange:m,children:[e.jsx(_,{asChild:!0,children:e.jsxs("button",{type:"button",className:"text-xs text-secondary underline inline-flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3"})," Generate from a market-overview insight"]})}),e.jsxs(q,{className:"max-w-xl",children:[e.jsx(k,{children:e.jsx(B,{children:"Choose a market overview"})}),i.isLoading?e.jsx("div",{className:"py-8 text-center",children:e.jsx(x,{className:"w-4 h-4 mx-auto animate-spin"})}):(i.data??[]).length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center",children:'No insights found in the "Market Overview" category yet.'}):e.jsx("ul",{className:"divide-y divide-border max-h-[60vh] overflow-auto -mx-6",children:(i.data??[]).map(t=>e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:l.isPending,onClick:()=>l.mutate(t.id),className:"w-full text-left px-6 py-3 hover:bg-muted/50 disabled:opacity-50",children:[e.jsx("div",{className:"text-sm font-medium",children:t.title}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[t.published_at?new Date(t.published_at).toLocaleDateString("en-GB"):"Draft",t.excerpt?` · ${t.excerpt.slice(0,90)}${t.excerpt.length>90?"…":""}`:""]})]})},t.id))}),l.isPending&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center pt-2",children:[e.jsx(x,{className:"w-3 h-3 inline animate-spin mr-1"})," Creating draft…"]})]})]})}export{ce 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.