PageSourceSearch

https://pulsecars.co.uk/assets/admin.themes-uOiOHSGk.js

js pulsecars.co.uk collected 2026-10-08 06:12:36 UTC 8,267 bytes, 1 lines download raw bytes

1import{c as C,k as B,l as A,r as i,j as e,L as T,B as k,S as H,s as u,t as c}from"./main-BGPPHxHM.js";import{I as m}from"./input-D0ZnlPy7.js";import{L as n}from"./label-Cs-fnIPW.js";import{T as L}from"./textarea-C1GjMsvY.js";import{S as P}from"./switch-DwNKnf_m.js";import{B as F}from"./badge-zEFINaEp.js";import{A as E}from"./arrow-left-CFvWDBUx.js";import{P as I}from"./palette-D7Dp8342.js";import{C as $}from"./check-Cx29d-FE.js";import"./index-D3F3hwE6.js";const q=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],M=C("save",q);function W(){const{user:d,isAdmin:o,loading:h,roleChecked:p}=B(),f=A(),[g,v]=i.useState([]),[x,j]=i.useState(null),[N,_]=i.useState(!1);i.useEffect(()=>{h||!p||(!d||!o)&&f({to:"/admin/login"})},[h,p,d,o,f]);const b=async()=>{const{data:a}=await u.from("site_themes").select("*").order("sort_order"),s=a??[];v(s),!x&&s.length&&j(s.find(t=>t.is_active)?.id??s[0].id)};i.useEffect(()=>{d&&o&&b()},[d,o]);const r=g.find(a=>a.id===x)??null,y=async a=>{const{error:s}=await u.from("site_themes").update({is_active:!1}).eq("is_active",!0);if(s)return c.error(s.message);const{error:t}=await u.from("site_themes").update({is_active:!0}).eq("id",a);if(t)return c.error(t.message);c.success("Theme activated — visitors will see it instantly"),b()},w=async()=>{if(!r)return;_(!0);const{error:a}=await u.from("site_themes").update({name:r.name,palette:r.palette,decoration:r.decoration,hero_image_url:r.hero_image_url,banner_enabled:r.banner_enabled,banner_headline:r.banner_headline,banner_subtext:r.banner_subtext,banner_cta_label:r.banner_cta_label,banner_cta_link:r.banner_cta_link}).eq("id",r.id);if(_(!1),a)return c.error(a.message);c.success("Theme saved"),b()},l=a=>v(s=>s.map(t=>t.id===x?{...t,...a}:t)),S=a=>l({palette:{...r?.palette??{},...a}});return!d||!o?null:e.jsxs("div",{className:"min-h-screen bg-surface",children:[e.jsx("header",{className:"border-b border-border bg-card",children:e.jsxs("div",{className:"mx-auto flex h-16 max-w-7xl items-center justify-between px-4 sm:px-6 lg:px-8",children:[e.jsxs(T,{to:"/admin",className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground",children:[e.jsx(E,{className:"h-4 w-4"})," Back to dashboard"]}),e.jsxs("div",{className:"flex items-center gap-2 font-display font-semibold",children:[e.jsx(I,{className:"h-5 w-5"})," Seasonal Themes"]})]})}),e.jsxs("main",{className:"mx-auto grid max-w-7xl gap-6 px-4 py-8 sm:px-6 lg:grid-cols-[280px_1fr] lg:px-8",children:[e.jsxs("aside",{className:"space-y-2",children:[e.jsx("h2",{className:"px-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Themes"}),g.map(a=>{const s=a.id===x,t=a.palette?.gradientHero??`linear-gradient(135deg, ${a.palette?.primary??"#888"}, ${a.palette?.accent??"#444"})`;return e.jsxs("button",{onClick:()=>j(a.id),className:`flex w-full items-center gap-3 rounded-xl border p-3 text-left transition ${s?"border-primary bg-primary/5":"border-border bg-card hover:bg-accent/30"}`,children:[e.jsx("span",{className:"h-10 w-10 shrink-0 rounded-lg shadow-inner",style:{background:t}}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm font-semibold",children:a.name}),e.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:a.key})]}),a.is_active&&e.jsxs(F,{variant:"default",className:"ml-1",children:[e.jsx($,{className:"mr-1 h-3 w-3"})," Live"]})]},a.id)})]}),r?e.jsxs("section",{className:"space-y-6 rounded-2xl border border-border bg-card p-6 shadow-card",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold",children:r.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Edit colors, banner, and decorations. Activate to push live."})]}),e.jsxs("div",{className:"flex gap-2",children:[!r.is_active&&e.jsxs(k,{onClick:()=>y(r.id),variant:"default",children:[e.jsx(H,{className:"mr-2 h-4 w-4"})," Activate"]}),e.jsxs(k,{onClick:w,disabled:N,variant:"outline",children:[e.jsx(M,{className:"mr-2 h-4 w-4"})," ",N?"Saving…":"Save"]})]})]}),e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border",style:{background:r.palette?.background??"white",color:r.palette?.foreground??"black"},children:[e.jsx("div",{className:"px-4 py-2 text-center text-xs font-bold uppercase tracking-wide",style:{background:r.palette?.bannerBg??"#333",color:r.palette?.bannerFg??"#fff"},children:r.banner_enabled?r.banner_headline||"Banner preview":"Banner disabled"}),e.jsx("div",{className:"p-6",style:{background:r.palette?.gradientHero},children:e.jsx("p",{className:"font-display text-xl font-bold",style:{color:r.palette?.accentForeground??"#fff"},children:"Hero preview"})})]}),e.jsxs("div",{className:"space-y-3 rounded-xl border border-border bg-surface p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(n,{className:"font-semibold",children:"Sale banner"}),e.jsx(P,{checked:r.banner_enabled,onCheckedChange:a=>l({banner_enabled:a})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"Headline"}),e.jsx(m,{value:r.banner_headline??"",onChange:a=>l({banner_headline:a.target.value}),placeholder:"Summer Sale is ON"})]}),e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"Sub-text"}),e.jsx(m,{value:r.banner_subtext??"",onChange:a=>l({banner_subtext:a.target.value}),placeholder:"Up to £1000 off"})]}),e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"CTA label"}),e.jsx(m,{value:r.banner_cta_label??"",onChange:a=>l({banner_cta_label:a.target.value}),placeholder:"Shop deals"})]}),e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:"CTA link"}),e.jsx(m,{value:r.banner_cta_link??"",onChange:a=>l({banner_cta_link:a.target.value}),placeholder:"/inventory"})]})]})]}),e.jsxs("div",{className:"space-y-3 rounded-xl border border-border bg-surface p-4",children:[e.jsx(n,{className:"font-semibold",children:"Floating decorations"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{k:"none",l:"None"},{k:"snowflakes",l:"❄ Snowflakes"},{k:"leaves",l:"🍂 Leaves"},{k:"sun",l:"☀ Sun rays"},{k:"confetti",l:"🎉 Confetti"},{k:"petals",l:"🌸 Petals"}].map(a=>e.jsx("button",{type:"button",onClick:()=>l({decoration:a.k}),className:`rounded-full border px-3 py-1.5 text-sm ${r.decoration===a.k?"border-primary bg-primary text-primary-foreground":"border-border bg-card"}`,children:a.l},a.k))})]}),e.jsxs("div",{className:"space-y-3 rounded-xl border border-border bg-surface p-4",children:[e.jsx(n,{className:"font-semibold",children:"Palette (CSS values — hex, rgb, or oklch)"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:[["background","Backgroun
1d"],["foreground","Foreground (text)"],["primary","Primary"],["primaryGlow","Primary glow"],["accent","Accent"],["accentForeground","Accent text"],["gradientHero","Hero gradient (linear-gradient...)"],["bannerBg","Banner background"],["bannerFg","Banner text"]].map(([a,s])=>e.jsxs("div",{children:[e.jsx(n,{className:"text-xs",children:s}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-9 w-9 shrink-0 rounded-md border border-border",style:{background:r.palette?.[a]}}),e.jsx(m,{value:r.palette?.[a]??"",onChange:t=>S({[a]:t.target.value}),placeholder:a.includes("gradient")?"linear-gradient(135deg,#000,#fff)":"#ffffff"})]})]},a))})]}),e.jsxs("div",{className:"space-y-2 rounded-xl border border-border bg-surface p-4",children:[e.jsx(n,{className:"font-semibold",children:"Hero image URL (optional)"}),e.jsx(L,{rows:2,value:r.hero_image_url??"",onChange:a=>l({hero_image_url:a.target.value||null}),placeholder:"https://… leave empty to use the default showroom photo"})]})]}):e.jsx("section",{className:"rounded-2xl border border-border bg-card p-10 text-center text-muted-foreground",children:"Select a theme to edit."})]})]})}export{W 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.