PageSourceSearch

https://clubpeinard.fr/assets/mes-partenaires-DP_f128z.js

js clubpeinard.fr collected 2026-09-24 14:23:19 UTC 19,353 bytes, 3 lines download raw bytes

1import{r as o,j as e,a as se,B as C,L as j,s as p,t as B}from"./index-R1fY2Chg.js";import{C as O,a as F,b as ae,c as ne}from"./card-DTMg5cBQ.js";import{B as S}from"./badge-DBvV2Gth.js";import{I as xe}from"./input-Bf3mra6h.js";import{C as pe,a as he,b as fe}from"./collapsible-lJYqx9tp.js";import{H as Q}from"./handshake-XMCBo_ET.js";import{D as ge}from"./download-CLPknXxf.js";import{T as A}from"./trophy-CavHzKF4.js";import{C as M}from"./calendar-DERR54K5.js";import{M as V}from"./megaphone-D8kYd53g.js";import{G as z}from"./gift-BKhgfnhO.js";import{S as je}from"./search-B3Z8qWsy.js";import{E as re}from"./external-link-KpI44Y64.js";import{C as be}from"./circle-user-round-Cj8KIilp.js";import{C as _e}from"./circle-check-DnH7o7sz.js";import{M as ve}from"./mail-BxbDcTV9.js";import{M as we}from"./map-pin-BxYhnIHm.js";import{G as Ne}from"./globe-Brra6beU.js";import{C as ye}from"./chevron-down-CteprVnA.js";import"./index-C4QOCNMl.js";import"./index-CdBx4K5z.js";import"./index-pSGF890B.js";function q(t){return(t??"").trim().toLowerCase()}function Ke(){const[t,x]=o.useState(!0),[m,u]=o.useState([]),[h,r]=o.useState([]),[b,I]=o.useState([]),[n,k]=o.useState([]),[_,P]=o.useState([]),[T,ie]=o.useState([]),[U,le]=o.useState([]),[J,ce]=o.useState([]),[D,oe]=o.useState([]),X=D.length,[Y,de]=o.useState(new Map),[G,me]=o.useState(""),H=async()=>{x(!0);const[{data:a},{data:d},{data:s},{data:i},{data:f},{data:l},{data:c},{data:W}]=await Promise.all([p.from("partner_requests").select("id, email, company_name, company_website, company_phone, company_city, contact_name, created_at, reviewed_at").eq("status","accepted").order("company_name",{ascending:!0}),p.from("contests").select("id, title, status, draw_date, partner_email, submission_status").not("partner_email","is",null),p.from("events").select("id, title, status, start_date, partner_email, submission_status").not("partner_email","is",null),p.from("ad_slots").select("id, title, status, ends_at, partner_email").not("partner_email","is",null),p.from("privilege_benefits").select("id, title, is_active, partner_email").not("partner_email","is",null),p.from("contests").select("id, title, status, draw_date, partner_email, submission_status").eq("submission_status","pending").order("submitted_at",{ascending:!1}),p.from("events").select("id, title, status, start_date, partner_email, submission_status").eq("submission_status","pending").order("submitted_at",{ascending:!1}),p.from("ad_slots").select("id, title, status, ends_at, partner_email").eq("status","pending_review").order("created_at",{ascending:!1})]);u(a??[]),r(d??[]),I(s??[]),k(i??[]),P(f??[]),ie(l??[]),le(c??[]),ce(W??[]);const{data:K}=await p.from("partner_requests").select("id, company_name, email, contact_name, company_city, company_phone, company_website, prize_types, promotions, message, created_at").eq("status","pending").order("created_at",{ascending:!1});oe(K??[]);const $=new Set;for(const L of[...a??[],...d??[],...s??[],...i??[],...f??[]]){const y=q(L.email??L.partner_email);y&&$.add(y)}const g=Array.from($),te=new Map;if(g.length>0){const{data:L}=await p.from("adherents").select("id, user_id, first_name, last_name, email").in("email",g);for(const y of L??[])te.set(q(y.email),y)}de(te),x(!1)};o.useEffect(()=>{H()},[]);const Z=async(a,d)=>{const{error:s}=await p.from("partner_requests").update({status:d,reviewed_at:new Date().toISOString()}).eq("id",a);if(s){B.error(s.message);return}B.success(d==="accepted"?"Demande acceptée":"Demande refusée"),await H()},v=o.useMemo(()=>{const a=new Map,d=(s,i={})=>{const f=q(s),l=a.get(f);if(!l){const c={email:s,display_name:i.display_name??s,city:i.city??null,website:i.website??null,phone:i.phone??null,contact:i.contact??null,is_accepted:i.is_accepted??!1,partner_request_id:i.partner_request_id??null,adherent:null,contests:[],events:[],ads:[],benefits:[]};return a.set(f,c),c}return i.is_accepted&&(l.is_accepted=!0,l.partner_request_id=i.partner_request_id??l.partner_request_id,l.display_name=i.display_name??l.display_name,l.city=i.city??l.city,l.website=i.website??l.website,l.phone=i.phone??l.phone,l.contact=i.contact??l.contact),l};for(const s of m)d(s.email,{display_name:s.company_name||s.email,city:s.company_city,website:s.company_website,phone:s.company_phone,contact:s.contact_name,is_accepted:!0,partner_request_id:s.id});for(const s of h)d(s.partner_email).contests.push(s);for(const s of b)d(s.partner_email).events.push(s);for(const s of n)d(s.partner_email).ads.push(s);for(const s of _)d(s.partner_email).benefits.push(s);for(const s of a.values())s.adherent=Y.get(q(s.email))??null;return Array.from(a.values()).sort((s,i)=>s.is_accepted!==i.is_accepted?s.is_accepted?-1:1:s.display_name.localeCompare(i.display_name,"fr"))},[m,h,b,n,_,Y]),ee=o.useMemo(()=>{const a=G.trim().toLowerCase();return a?v.filter(d=>
1[d.display_name,d.email,d.city,d.contact].some(s=>(s??"").toLowerCase().includes(a))):v},[v,G]),w=o.useMemo(()=>({partners:v.length,accepted:v.filter(a=>a.is_accepted).length,contests:h.length,events:b.length,ads:n.length,benefits:_.length}),[v,h,b,n,_]),ue=()=>{const a=v,s=[["Nom / Raison sociale","Email","Ville","Téléphone","Site web","Contact","Statut","Adhérent lié","Jeux","Évènements","Publicités","Avantages"].join(";")];for(const c of a){const W=c.adherent?[c.adherent.first_name,c.adherent.last_name].filter(Boolean).join(" ")||c.adherent.email:"",K=[c.display_name,c.email,c.city??"",c.phone??"",c.website??"",c.contact??"",c.is_accepted?"Validé":"Non validé",W,c.contests.length,c.events.length,c.ads.length,c.benefits.length].map($=>{const g=String($??"").replace(/"/g,'""');return g.includes(";")||g.includes('"')||g.includes(`
2`)?`"${g}"`:g}).join(";");s.push(K)}const i=new Blob([s.join(`
3`)],{type:"text/csv;charset=utf-8;"}),f=URL.createObjectURL(i),l=document.createElement("a");l.href=f,l.download=`partenaires_${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(f)};return t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(se,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-6 w-6 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Partenaires"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(C,{size:"sm",variant:"outline",className:"gap-1.5",onClick:ue,children:[e.jsx(ge,{className:"h-3.5 w-3.5"})," Exporter CSV"]}),e.jsxs(j,{to:"/admin/partenaires",className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted",children:[e.jsx(Q,{className:"h-3.5 w-3.5"})," Demandes partenaires",X>0&&e.jsx("span",{className:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:X})]}),e.jsxs(j,{to:"/admin/jeux-soumissions",className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted",children:[e.jsx(A,{className:"h-3.5 w-3.5"})," Jeux à valider",T.length>0&&e.jsx("span",{className:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:T.length})]}),e.jsxs(j,{to:"/admin/evenements-soumissions",className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted",children:[e.jsx(M,{className:"h-3.5 w-3.5"})," Évènements à valider",U.length>0&&e.jsx("span",{className:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:U.length})]}),e.jsxs(j,{to:"/admin/publicites",className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted",children:[e.jsx(V,{className:"h-3.5 w-3.5"})," Publicités",J.length>0&&e.jsx("span",{className:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-bold text-destructive-foreground",children:J.length})]}),e.jsxs(j,{to:"/admin/avantages",className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted",children:[e.jsx(z,{className:"h-3.5 w-3.5"})," Avantages"]})]})]}),D.length>0&&e.jsxs("div",{className:"rounded-lg border-2 border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsxs("h2",{className:"text-sm font-bold text-destructive flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4"}),"Demandes partenaires en attente (",D.length,")"]}),e.jsx(j,{to:"/admin/partenaires",className:"text-xs font-medium text-destructive hover:underline",children:"Voir tout →"})]}),e.jsx("div",{className:"space-y-2",children:D.map(a=>e.jsx("div",{className:"rounded-md border border-border bg-background p-3",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[e.jsx("span",{className:"font-semibold",children:a.company_name}),a.company_city&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",a.company_city]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[a.contact_name&&e.jsxs(e.Fragment,{children:[a.contact_name," · "]}),e.jsx("a",{href:`mailto:${a.email}`,className:"hover:underline",children:a.email}),a.company_phone&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:`tel:${a.company_phone}`,className:"hover:underline",children:a.company_phone})]})]}),a.prize_types&&e.jsxs("p",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Lots :"})," ",a.prize_types]}),a.promotions&&e.jsxs("p",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Promotions :"})," ",a.promotions]}),a.message&&e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:a.message})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(C,{size:"sm",className:"h-7 px-2 text-xs",onClick:()=>
3Z(a.id,"accepted"),children:"Accepter"}),e.jsx(C,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs",onClick:()=>Z(a.id,"refused"),children:"Refuser"})]})]})},a.id))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6",children:[e.jsx(N,{label:"Partenaires",value:w.partners}),e.jsx(N,{label:"Validés",value:w.accepted,accent:"emerald"}),e.jsx(N,{label:"Jeux",value:w.contests,icon:e.jsx(A,{className:"h-3 w-3"})}),e.jsx(N,{label:"Évènements",value:w.events,icon:e.jsx(M,{className:"h-3 w-3"})}),e.jsx(N,{label:"Publicités",value:w.ads,icon:e.jsx(V,{className:"h-3 w-3"})}),e.jsx(N,{label:"Avantages",value:w.benefits,icon:e.jsx(z,{className:"h-3 w-3"})})]}),e.jsx(Se,{contests:T,events:U,ads:J}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(je,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(xe,{placeholder:"Rechercher un partenaire…",className:"pl-9",value:G,onChange:a=>me(a.target.value)})]}),ee.length===0?e.jsx(O,{children:e.jsx(F,{className:"p-8 text-center text-sm text-muted-foreground",children:"Aucun partenaire à afficher."})}):e.jsx("div",{className:"space-y-3",children:ee.map(a=>e.jsx(Ce,{p:a,onReload:H},a.email))})]})}function N({label:t,value:x,icon:m,accent:u}){return e.jsx(O,{children:e.jsxs(F,{className:"flex flex-col gap-1 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:[m,t]}),e.jsx("div",{className:`text-xl font-bold ${u==="emerald"?"text-emerald-600":"text-foreground"}`,children:x})]})})}function Ce({p:t,onReload:x}){const[m,u]=o.useState(!1),[h,r]=o.useState(!1),b=t.contests.length+t.events.length+t.ads.length+t.benefits.length,I=async()=>{if(!t.adherent)return;r(!0);const{data:n}=await p.auth.getUser(),k=n.user?.id??null,_=[t.adherent.first_name,t.adherent.last_name].filter(Boolean).join(" ").trim(),{error:P}=await p.from("partner_requests").insert({adherent_id:t.adherent.id,user_id:t.adherent.user_id??k,email:t.email,company_name:_||t.email,contact_name:_||null,prize_types:"(à compléter par le partenaire)",promotions:"(à compléter par le partenaire)",status:"accepted",reviewed_at:new Date().toISOString(),reviewed_by:k,admin_note:"Validé directement depuis la liste des partenaires (membre existant). Le partenaire doit compléter ses informations depuis son espace."});if(r(!1),P){B.error("Erreur : "+P.message);return}B.success("Partenaire validé. Il pourra compléter ses informations depuis son espace membre."),await x()};return e.jsx(O,{children:e.jsxs(pe,{open:m,onOpenChange:u,children:[e.jsxs(ae,{className:"pb-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs(ne,{className:"flex flex-wrap items-center gap-2 text-base",children:[t.display_name,t.is_accepted?e.jsx(S,{className:"bg-emerald-600 hover:bg-emerald-600",children:"Partenaire validé"}):e.jsx(S,{variant:"outline",className:"border-amber-400 text-amber-700",children:"Non validé"}),t.adherent&&e.jsxs(S,{variant:"outline",className:"gap-1 border-blue-400 text-blue-700",children:[e.jsx(be,{className:"h-3 w-3"}),"Membre : ",[t.adherent.first_name,t.adherent.last_name].filter(Boolean).join(" ")||t.adherent.email]}),!t.is_accepted&&t.adherent&&e.jsxs(C,{size:"sm",variant:"default",className:"h-7 gap-1 bg-emerald-600 hover:bg-emerald-700",onClick:I,disabled:h,children:[h?e.jsx(se,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(_e,{className:"h-3.5 w-3.5"}),"Valider comme partenaire"]})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx(ve,{className:"mr-1 inline h-3 w-3"}),e.jsx("a",{href:`mailto:${t.email}`,className:"hover:underline",children:t.email})]}),t.city&&e.jsxs("span",{children:[e.jsx(we,{className:"mr-1 inline h-3 w-3"}),t.city]}),t.website&&e.jsxs("span",{children:[e.jsx(Ne,{className:"mr-1 inline h-3 w-3"}),e.jsx("a",{href:t.website.startsWith("http")?t.website:`https://${t.website}`,target:"_blank",rel:"noreferrer",className:"hover:underline",children:t.website})]}),t.contact&&e.jsx("span",{children:t.contact})]})]}),e.jsx(he,{asChild:!0,children:e.jsxs(C,{variant:"outline",size:"sm",children:[b," élément",b>1?"s":"",e.jsx(ye,{className:`ml-1 h-3 w-3 transition-transform ${m?"rotate-180":""}`})]})})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-xs",children:[e.jsx(R,{n:t.contests.length,icon:e.jsx(A,{className:"h-3 w-3"}),label:"jeux"}),e.jsx(R,{n:t.events.length,icon:e.jsx(M,{className:"h-3 w-3"}),label:"évènements"}),e.jsx(R,{n:t.ads.length,icon:e.jsx(V,{className:"h-3 w-3"}),label:"publicités"}),e.jsx(R,{n:t.benefits.length,icon:e.jsx(z,{className:"h-3 w-3"}),label:"avantages"})]})]}),e.jsx(fe,{children:e.jsxs(F,{className:"space-y-4 pt-0",children:[e.jsx(E,{title:"Jeux",icon:e.jsx(A,{className:"h-4 w-4"}),items:t.contests.map(n=>({id:n.id,title:n.title,meta:[n.status,n.submission_status!=="approved"?`soumission: ${n.submission_status}`:null,n.draw_date?`tirage ${new Date(n.draw_date).toLocaleDateString("fr-FR")}
3`:null].filter(Boolean),href:"/admin/jeux"}))}),e.jsx(E,{title:"Évènements",icon:e.jsx(M,{className:"h-4 w-4"}),items:t.events.map(n=>({id:n.id,title:n.title,meta:[n.status,n.submission_status!=="approved"?`soumission: ${n.submission_status}`:null,n.start_date?new Date(n.start_date).toLocaleDateString("fr-FR"):null].filter(Boolean),href:"/admin/evenements"}))}),e.jsx(E,{title:"Publicités",icon:e.jsx(V,{className:"h-4 w-4"}),items:t.ads.map(n=>({id:n.id,title:n.title,meta:[n.status,n.ends_at?`expire ${new Date(n.ends_at).toLocaleDateString("fr-FR")}`:null].filter(Boolean),href:"/admin/publicites"}))}),e.jsx(E,{title:"Avantages",icon:e.jsx(z,{className:"h-4 w-4"}),items:t.benefits.map(n=>({id:n.id,title:n.title,meta:[n.is_active?"actif":"inactif"],href:"/admin/avantages"}))})]})})]})})}function R({n:t,icon:x,label:m}){return t===0?null:e.jsxs(S,{variant:"secondary",className:"gap-1",children:[x,t," ",m]})}function E({title:t,icon:x,items:m}){return m.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[x," ",t," (",m.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:m.map(u=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:u.title}),u.meta.length>0&&e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:u.meta.join(" · ")})]}),e.jsxs(j,{to:u.href,className:"inline-flex flex-shrink-0 items-center gap-1 text-xs text-primary hover:underline",children:["Ouvrir ",e.jsx(re,{className:"h-3 w-3"})]})]},u.id))})]})}function Se({contests:t,events:x,ads:m}){const u=t.length+x.length+m.length;if(u===0)return null;const h=[...t.map(r=>({id:`c-${r.id}`,title:r.title,meta:`${r.partner_email??""}${r.draw_date?` · tirage ${new Date(r.draw_date).toLocaleDateString("fr-FR")}`:""}`,href:"/admin/jeux-soumissions",kind:"Jeu"})),...x.map(r=>({id:`e-${r.id}`,title:r.title,meta:`${r.partner_email??""}${r.start_date?` · ${new Date(r.start_date).toLocaleDateString("fr-FR")}`:""}`,href:"/admin/evenements-soumissions",kind:"Évènement"})),...m.map(r=>({id:`a-${r.id}`,title:r.title,meta:r.partner_email??"",href:"/admin/publicites",kind:"Publicité"}))];return e.jsxs(O,{className:"border-amber-300 bg-amber-50/60 dark:bg-amber-950/20",children:[e.jsx(ae,{className:"pb-3",children:e.jsxs(ne,{className:"flex items-center gap-2 text-base text-amber-900 dark:text-amber-200",children:[e.jsx("span",{className:"inline-flex h-6 min-w-6 items-center justify-center rounded-full bg-amber-500 px-1.5 text-xs font-bold text-white",children:u}),"À valider"]})}),e.jsx(F,{className:"space-y-1.5 pt-0",children:h.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-amber-200 bg-background px-3 py-2 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",className:"border-amber-400 text-amber-700",children:r.kind}),e.jsx("span",{className:"truncate font-medium",children:r.title})]}),r.meta&&e.jsx("div",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:r.meta}
3)]}),e.jsxs(j,{to:r.href,className:"inline-flex flex-shrink-0 items-center gap-1 text-xs text-primary hover:underline",children:["Valider ",e.jsx(re,{className:"h-3 w-3"})]})]},r.id))})]})}export{Ke 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.