PageSourceSearch

https://sortir.eu/assets/MagazineIssues-CuSX7_SR.js

js sortir.eu collected 2026-10-02 11:16:35 UTC 13,330 bytes, 1 lines download raw bytes

1import{r as c,j as e}from"./vendor-react-De19kUq8.js";import{u as ce,cm as de,ab as N,B as d,at as me,O as ue,Z as T,X as xe,a as b,bl as he,bj as pe,a5 as ge,a1 as je,a4 as fe,ac as ve,V as Ne,b1 as be,f as A,s as ye}from"./index-BNqnZmmX.js";import{a as Ce,L,c as we}from"./vendor-app-DH33cvx6.js";import{P as Ae}from"./page-header-BpDM-DGv.js";import{E as _e}from"./empty-state-nHq1Imsz.js";import{L as R}from"./label-BdtRRvBI.js";import{P as Se,a as Pe,b as ke}from"./popover-D7US8GUa.js";import{S as Me,a as De,b as Ee,c as ze,d as g}from"./select-_TqDQ6Qg.js";import{C as Ie}from"./checkbox-DiNeIMRN.js";import{T as Te,a as Re,b as F}from"./tabs-B4YiQNNO.js";import{P as Fe,a as Le,b as w,c as Oe,f as $e,d as Be}from"./pagination-C5PMDgL1.js";import{b as qe,c as J,d as Ue,e as He,f as Ge}from"./periodLabel-D8m7lj5x.js";import{C as Ve}from"./CreateIssueDialog-DYac0IOf.js";import{A as Qe,h as Ze,a as Ke,b as We,c as Xe,d as Je,e as Ye,f as es,g as ss}from"./alert-dialog-Durr9ujJ.js";import{s as Z}from"./useIssueScope-DNdYg7sR.js";import{u as as}from"./useDebounce-DaJG7Zat.js";import{F as K}from"./filter-BTtr7B1B.js";import{P as W}from"./plus-rqvIu4O8.js";import{B as ts}from"./hand-B96XhcHO.js";import{A as rs}from"./archive-Cfjjwrgu.js";import{T as is}from"./trash-2-oGRN__HM.js";import{p as _}from"./parseISO-hTs5v9Lq.js";import"./vendor-ui-pO556hdz.js";import"./vendor-supabase-Bm92Y2YK.js";import"./index-BdQq_4o_.js";import"./chevron-up-DYPkkba5.js";import"./ellipsis-D_KcROcZ.js";import"./dialog-C7CvZ_Sl.js";import"./wand-sparkles-C8yMYjkY.js";import"./circle-check-BCiAQQzZ.js";import"./types-BjXkjCz4.js";const X=24;function $s(){const{hasMinRole:s,getAssignedRegionIds:o}=ce(),r=o(),l=s("MODERATEUR"),i=s("MODERATEUR"),t=s("MODERATEUR"),[m,x
1]=c.useState(!1),[n,se]=c.useState("draft"),[S,O]=c.useState(""),P=as(S,250),[k,M]=c.useState(r??[]),[D,$]=c.useState(""),[E,B]=c.useState(""),[q,ae]=c.useState("period_desc"),[z,U]=c.useState("grid"),[p,u]=c.useState(1),H=c.useRef(!1);c.useEffect(()=>{H.current||r&&r.length>0&&(H.current=!0,M(r))},[r]);const{data:I}=Ce({queryKey:["regions"],queryFn:async()=>{const{data:a}=await ye.from("regions").select("id, name").order("name");return a??[]},staleTime:30*60*1e3,enabled:t}),te=[n],re=n==="archived",{data:h,isFetching:y,refetch:ie,dataUpdatedAt:G}=qe({q:P,statuses:te,regionIds:t?k:[],from:D||null,to:E||null,sort:q,page:p,pageSize:X,includeArchived:re}),V=(h==null?void 0:h.items)??[],j=(h==null?void 0:h.total)??0,f=Math.max(1,Math.ceil(j/X)),C=(t?k.length:0)+(D?1:0)+(E?1:0),ne=()=>{M(r??[]),$(""),B(""),u(1)};return e.jsxs(e.Fragment,{children:[e.jsx(de,{children:e.jsx("title",{children:"Projets magazine | Sortir"})}),e.jsx(Ae,{title:"Projets magazine",description:"Numéros en préparation, chemins de fer et exports PAO",actions:e.jsxs("div",{className:"flex gap-2 items-center",children:[G>0&&e.jsxs("span",{className:"hidden md:inline text-xs text-muted-foreground",children:["Mis à jour ",N(new Date(G),"HH:mm:ss")]}),e.jsx(d,{variant:"outline",size:"icon",onClick:()=>ie(),disabled:y,title:"Actualiser la liste",children:e.jsx(me,{className:`h-4 w-4 ${y?"animate-spin":""}`})}),i&&e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"outline",asChild:!0,children:e.jsxs(L,{to:"/app/magazine",children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),"Export rapide"]})}),e.jsxs(d,{onClick:()=>x(!0),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Nouveau numéro"]})]})]})}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-2 items-stretch md:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ue,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(T,{value:S,onChange:a=>{O(a.target.value),u(1)},placeholder:"Rechercher par titre, numéro ou note…",className:"pl-9"}),S&&e.jsx("button",{onClick:()=>O(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":"Effacer",children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsxs(Se,{children:[e.jsx(Pe,{asChild:!0,children:e.jsxs(d,{variant:"outline",className:"relative",children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),"Filtres",C>0&&e.jsx(b,{className:"ml-2 h-5 px-1.5 rounded-full",children:C})]})}),e.jsxs(ke,{align:"end",className:"w-80 space-y-4",children:[t&&e.jsxs("div",{children:[e.jsx(R,{className:"text-xs font-semibold",children:"Régions"}),e.jsx("div",{className:"mt-2 max-h-48 overflow-y-auto space-y-1.5 pr-1",children:I==null?void 0:I.map(a=>{const v=k.includes(a.id);return e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx(Ie,{checked:v,onCheckedChange:oe=>{u(1),M(Q=>oe?[...Q,a.id]:Q.filter(le=>le!==a.id))}}),a.name]},a.id)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-xs",children:"Période — début"}),e.jsx(T,{type:"date",value:D,onChange:a=>{$(a.target.value),u(1)}})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs",children:"Période — fin"}),e.jsx(T,{type:"date",value:E,onChange:a=>{B(a.target.value),u(1)}})]})]}),e.jsx(d,{variant:"ghost",size:"sm",className:"w-full",onClick:ne,children:"Réinitialiser"})]})]}),e.jsxs(Me,{value:q,onValueChange:a=>{ae(a),u(1)},children:[e.jsx(De,{className:"w-[180px]",children:e.jsx(Ee,{})}),e.jsxs(ze,{children:[e.jsx(g,{value:"period_desc",children:"Période récente"}),e.jsx(g,{value:"period_asc",children:"Période ancienne"}),e.jsx(g,{value:"edition_desc",children:"N° décroissant"}),e.jsx(g,{value:"edition_asc",children:"N° croissant"}),e.jsx(g,{value:"title_asc",children:"Titre A→Z"}),e.jsx(g,{value:"created_desc",children:"Créé récemment"})]})]}),e.jsxs("div",{className:"flex rounded-md border overflow-hidden",children:[e.jsx(d,{variant:z==="grid"?"default":"ghost",size:"icon",className:"rounded-none",onClick:()=>U("grid"),"aria-label":"Grille",children:e.jsx(he,{className:"h-4 w-4"})}),e.jsx(d,{variant:z==="list"?"default":"ghost",size:"icon",className:"rounded-none",onClick:()=>U("list"),"aria-label":"Liste",children:e.jsx(pe,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{value:n,onValueChange:a=>{se(a),u(1)},children:e.jsxs(Re,{children:[e.jsx(F,{value:"draft",children:"En préparation"}),e.jsx(F,{value:"locked",children:"Bouclés"}),e.jsx(F,{value:"archived",children:"Archivés"})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Cycle de vie d'un numéro : ",e.jsx("strong",{children:"En préparation"})," (modifiable) → ",e.jsx("strong",{children:"Bouclé"})," (figé, parti en impression) → ",e.jsx("strong",{children:"Archivé"}),"."]})]}),y&&!h&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((a,v)=>e.jsx(ge,{className:"h-40"},v))}),!y&&j===0&&e.jsx(_e,{icon:ts,title:"Aucun numéro",description:P||C>0?"Aucun résultat pour ces critères. Ajustez les filtres.":"Créez votre premier projet magazine pour commencer à travailler avec un chemin de fer digital.",action:!P&&C===0&&i?e.jsxs(d,{onClick:()=>x(!0),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Créer un numéro"]}):void 0}),j>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[j," numéro",j>1?"s":""]}),e.jsxs("span",{children:["Page ",p," / ",f]}
1)]}),z==="grid"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:V.map(a=>e.jsx(os,{issue:a,canDelete:l,canManage:i},a.id))}):e.jsx("div",{className:"rounded-md border divide-y bg-card overflow-hidden",children:V.map(a=>e.jsx(ls,{issue:a,canDelete:l,canManage:i},a.id))}),f>1&&e.jsx(Fe,{className:"mt-6",children:e.jsxs(Le,{children:[e.jsx(w,{children:e.jsx(Oe,{onClick:()=>u(a=>Math.max(1,a-1)),className:p===1?"pointer-events-none opacity-50":"cursor-pointer"})}),ns(p,f).map((a,v)=>a==="..."?e.jsx(w,{children:e.jsx("span",{className:"px-3 text-muted-foreground",children:"…"})},`e${v}`):e.jsx(w,{children:e.jsx($e,{isActive:a===p,onClick:()=>u(a),className:"cursor-pointer",children:a})},a)),e.jsx(w,{children:e.jsx(Be,{onClick:()=>u(a=>Math.min(f,a+1)),className:p===f?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})]}),e.jsx(Ve,{open:m,onOpenChange:x})]})}function ns(s,o){if(o<=7)return Array.from({length:o},(t,m)=>m+1);const l=[...new Set([1,o,s,s-1,s+1])].filter(t=>t>=1&&t<=o).sort((t,m)=>t-m),i=[];return l.forEach((t,m)=>{m>0&&t-l[m-1]>1&&i.push("..."),i.push(t)}),i}const Y={draft:"border-l-blue-500",locked:"border-l-emerald-500",archived:"border-l-muted-foreground/40"};function ee({issue:s,canDelete:o,canManage:r}){const l=Ue(),i=He(),t=Ge(),m=we(),{toast:x}=Ne();return!r&&!o?null:e.jsxs("div",{className:"flex items-center gap-1",onClick:n=>{n.preventDefault(),n.stopPropagation()},children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(d,{size:"icon",variant:"ghost",className:"h-7 w-7",title:"Dupliquer",onClick:async()=>{try{const n=await l.mutateAsync(s);x({title:"Numéro dupliqué"}),m(`/app/magazine/issues/${n}`)}catch(n){x({title:"Erreur",description:Z(n),variant:"destructive"})}},children:e.jsx(be,{className:"h-3.5 w-3.5"})}),s.status!=="archived"&&e.jsx(d,{size:"icon",variant:"ghost",className:"h-7 w-7",title:"Archiver",onClick:async()=>{await i.mutateAsync({id:s.id,status:"archived"}),x({title:"Numéro archivé"})},children:e.jsx(rs,{className:"h-3.5 w-3.5"})})]}),o&&e.jsxs(Qe,{children:[e.jsx(Ze,{asChild:!0,children:e.jsx(d,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10",title:"Supprimer",children:e.jsx(is,{className:"h-3.5 w-3.5"})})}),e.jsxs(Ke,{onClick:n=>n.stopPropagation(),children:[e.jsxs(We,{children:[e.jsx(Xe,{children:"Supprimer ce projet magazine ?"}),e.jsxs(Je,{children:["« ",s.title," » sera supprimé définitivement avec toutes ses pages, articles, événements et emplacements publicitaires. Cette action est irréversible."]})]}),e.jsxs(Ye,{children:[e.jsx(es,{children:"Annuler"}),e.jsx(ss,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:async()=>{try{await t.mutateAsync(s.id),x({title:"Projet supprimé"})}catch(n){x({title:"Erreur",description:Z(n),variant:"destructive"})}},children:"Supprimer définitivement"})]})]})]})]})}function os({issue:s,canDelete:o,canManage:r}){const l=J(s),i=Y[s.status];return e.jsxs("div",{className:"group relative",children:[e.jsx(L,{to:`/app/magazine/issues/${s.id}`,className:"block",children:e.jsx(je,{className:`h-full border-l-4 ${i} transition hover:shadow-md hover:border-primary/40`,children:e.jsxs(fe,{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground flex-wrap",children:[s.edition_number&&e.jsxs("span",{className:"font-mono",children:["N°",s.edition_number]}),(s.all_regions&&s.all_regions.length>0?s.all_regions:s.region_name?[{id:s.region_id,name:s.region_name,is_primary:!0}]:[]).map(t=>e.jsx(b,{variant:t.is_primary?"default":"secondary",className:"h-5 px-1.5 text-[10px] font-medium",children:t.name},t.id))]}),e.jsx("h3",{className:"font-semibold text-base leading-tight mt-1 truncate",children:s.title})]}),e.jsx(b,{variant:"outline",className:l.className,children:l.label})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Du ",N(_(s.peri
1od_start),"d MMM",{locale:A}),s.period_end?` au ${N(_(s.period_end),"d MMM yyyy",{locale:A})}`:" — en cours"]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.page_count," pages"]}),e.jsx(ve,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition"})]})]})})}),e.jsx("div",{className:"absolute top-3 right-3 opacity-0 group-hover:opacity-100 transition bg-background/95 backdrop-blur rounded-md border shadow-sm",children:e.jsx(ee,{issue:s,canDelete:o,canManage:r})})]})}function ls({issue:s,canDelete:o,canManage:r}){const l=J(s),i=Y[s.status];return e.jsxs(L,{to:`/app/magazine/issues/${s.id}`,className:`flex items-center gap-4 p-3 border-l-4 ${i} hover:bg-muted/50 transition`,children:[e.jsx("div",{className:"w-16 text-xs font-mono text-muted-foreground",children:s.edition_number?`N°${s.edition_number}`:"—"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1.5 flex-wrap mt-0.5",children:[(s.all_regions&&s.all_regions.length>0?s.all_regions:s.region_name?[{id:s.region_id,name:s.region_name,is_primary:!0}]:[]).map(t=>e.jsx(b,{variant:t.is_primary?"default":"secondary",className:"h-4 px-1.5 text-[10px]",children:t.name},t.id)),e.jsxs("span",{children:["· ",N(_(s.period_start),"d MMM",{locale:A}),s.period_end?` → ${N(_(s.period_end),"d MMM yyyy",{locale:A})}`:" → en cours"," · ",s.page_count," pages"]})]})]}),e.jsx(b,{variant:"outline",className:l.className,children:l.label}),e.jsx(ee,{issue:s,canDelete:o,canManage:r})]})}export{$s 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.