PageSourceSearch

https://local-spotlight-widget.lovable.app/assets/AdminContact-CZpF6cy3.js

js local-spotlight-widget.lovable.app collected 2026-10-03 03:32:18 UTC 5,670 bytes, 1 lines download raw bytes

1import{a as S,b as L,r as f,s as n,j as e,S as E,B as o}from"./index-DU2aw4LF.js";import{I as g}from"./input-DEk8oPcI.js";import{L as u}from"./label-BqGS5p_1.js";import{T}from"./textarea-BNUZ3Edd.js";import{S as k}from"./switch-BtZx71qP.js";import{C as q,a as z,b as B,d as P}from"./card-DPlsqbr0.js";import{A as U}from"./arrow-left-9vsxVJ7Q.js";import{P as I}from"./plus-DaTlrAjn.js";import{A as M}from"./arrow-up-BrIO_wzM.js";import{A as R}from"./arrow-down-BoE282VN.js";import{T as D}from"./trash-2-o8REC8Yz.js";import{S as H}from"./save-b8ESY6rt.js";import{o as O,s as h,l as F}from"./schemas-BpZi69Sy.js";import"./index-DnEp3_HC.js";const G=O({title:h().trim().min(1,"Titre requis").max(120),subtitle:h().trim().max(280).optional().or(F("")),button_label:h().trim().min(1,"Libellé requis").max(60),button_url:h().trim().min(1,"URL requise").max(500)});function re(){const p=S(),{toast:l}=L(),[_,j]=f.useState(!0),[r,d]=f.useState([]);f.useEffect(()=>{(async()=>{const{data:{session:t}}=await n.auth.getSession();if(!t){p("/admin/auth");return}await C()})()},[p]);const C=async()=>{j(!0);const{data:t,error:i}=await n.from("contact_ctas").select("*").order("display_order",{ascending:!0});i?l({title:"Erreur",description:i.message,variant:"destructive"}):d(t||[]),j(!1)},w=async()=>{const t=r.length>0?Math.max(...r.map(a=>a.display_order))+1:0,{data:i,error:s}=await n.from("contact_ctas").insert({title:"Nouveau bloc",subtitle:"",button_label:"Bouton",button_url:"https://",display_order:t,is_active:!0}).select("*").single();if(s||!i){l({title:"Erreur",description:s==null?void 0:s.message,variant:"destructive"});return}d(a=>[...a,i])},c=(t,i)=>{d(s=>s.map(a=>a.id===t?{...a,...i}:a))},y=async t=>{var a;const i=G.safeParse({title:t.title,subtitle:t.subtitle||"",button_label:t.button_label,button_url:t.button_url});if(!i.success){l({title:"Validation",description:(a=i.error.issues[0])==null?void 0:a.message,variant:"destructive"});return}const{error:s}=await n.from("contact_ctas").update({title:t.title,subtitle:t.subtitle||null,button_label:t.button_label,button_url:t.button_url,display_order:t.display_order,is_active:t.is_active}).eq("id",t.id);l(s?{title:"Erreur",description:s.message,variant:"destructive"}:{title:"Enregistré",description:t.title})},N=async t=>{if(!confirm("Supprimer ce bloc ?"))return;const{error:i}=await n.from("contact_ctas").delete().eq("id",t);if(i){l({title:"Erreur",description:i.message,variant:"destructive"});return}d(s=>s.filter(a=>a.id!==t))},v=async(t,i)=>{const s=r.findIndex(A=>A.id===t),a=s+i;if(s<0||a<0||a>=r.length)return;const m=r[s],x=r[a],b=[...r];b[s]={...x,display_order:m.display_order},b[a]={...m,display_order:x.display_order},d(b),await Promise.all([n.from("contact_ctas").update({display_order:x.display_order}).eq("id",m.id),n.from("contact_ctas").update({display_order:m.display_order}).eq("id",x.id)])};return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"Admin Contact | Matsuri",description:"Gestion des blocs CTA de la page contact.",noindex:!0}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsxs("div",{className:"container mx-auto px-4 py-4 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(o,{variant:"ghost",size:"icon",onClick:()=>p("/admin"),children:e.jsx(U,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-2xl font-bold",children:"Contact — Blocs CTA"})]}),e.jsxs(o,{onClick:w,children:[e.jsx(I,{className:"mr-2 h-4 w-4"})," Ajouter un bloc"]})]})}),e.jsx("main",{className:"container mx-auto px-4 py-8 max-w-3xl",children:_?e.jsx("p",{className:"text-muted-foreground",children:"Chargement…"}):r.length===0?e.jsx("p",{className:"text-muted-foreground",children:"Aucun bloc. Cliquez sur « Ajouter un bloc »."}):e.jsx("div",{className:"flex flex-col gap-4",children:r.map((t,i)=>e.jsxs(q,{children:[e.jsxs(z,{className:"flex flex-row items-center justify-between gap-2 space-y-0",children:[e.jsx(B,{className:"text-base",children:t.title||"Sans titre"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(o,{variant:"ghost",size:"icon",disabled:i===0,onClick:()=>v(t.id,-1),children:e.jsx(M,{className:"h-4 w-4"})}),e.jsx(o,{variant:"ghost",size:"icon",disabled:i===r.length-1,onClick:()=>v(t.id,1),children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(o,{variant:"ghost",size:"icon",onClick:()=>N(t.id),children:e.jsx(D,{className:"h-4 w-4 text-destructive"})})]})]}),e.jsxs(P,{className:"flex flex-col gap-3",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Titre"}),e.jsx(g,{value:t.title,maxLength:120,onChange:s=>c(t.id,{title:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(u,{children:"Sous-titre"}),e.jsx(T,{value:t.subtitle||"",maxLength:280,rows:2,onChange:s=>c(t.id,{subtitle:s.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(u,{children:"Libellé du bouton"}),e.jsx(g,{value:t.button_label,maxLength:60,onChange:s=>c(t.id,{button_label:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(u,{children:"URL du bouton"}),e.jsx(g,{value:t.button_url,maxLength:500,placeholder:"https://… ou /chemin/interne",onChange:s=>c(t.id,{button_url:s.target.value})})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{checked:t.is_active,onCheckedChange:s=>c(t.id,{is_active:s})}),e.jsx(u,{children:"Actif"})]}),e.jsxs(o,{onClick:()=>y(t),children:[e.jsx(H,{className:"mr-2 h-4 w-4"})," Enregistrer"]})]})]})]},t.id))})})]})]})}export{re 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.