PageSourceSearch

https://www.webcafetiere.ch/assets/Tickets-C-UHVtlp.js

js webcafetiere.ch collected 2026-10-10 00:03:35 UTC 8,322 bytes, 6 lines download raw bytes

1import{c as Y,r as l,j as e,B as g,L as V,s as A}from"./index-CUwMqWPJ.js";import{L as x,I as q}from"./label-ByMxbNfq.js";import{L as G}from"./list-checks-B82xFYg2.js";import{S as Z}from"./search-Bi4uh1Gp.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const H=Y("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]),L={to_evaluate:"À évaluer",scheduled:"Programmé",in_progress:"En cours",done:"Terminé"},T={critical:"Urgent",medium:"Moyen",low:"Faible"},J={critical:"bg-destructive/10 text-destructive",medium:"bg-primary/10 text-primary",low:"bg-muted text-muted-foreground"},K={to_evaluate:"bg-muted text-muted-foreground",scheduled:"bg-blue-100 text-blue-800",in_progress:"bg-amber-100 text-amber-800",done:"bg-emerald-100 text-emerald-800"},_=25,v=7,b=a=>Math.floor((Date.now()-new Date(a).getTime())/864e5),M=a=>{const n=b(a);return n<=0?"aujourd'hui":n===1?"hier":`il y a ${n} j`},Q=a=>[a==null?void 0:a.first_name,a==null?void 0:a.last_name].filter(Boolean).join(" ")||(a==null?void 0:a.email)||null,se=()=>{const[a,n]=l.useState([]),[y,N]=l.useState(!0),[h,I]=l.useState(""),[c,E]=l.useState(""),[d,P]=l.useState(""),[o,R]=l.useState(""),[m,F]=l.useState(""),[p,z]=l.useState(!1),[u,j]=l.useState(1);l.useEffect(()=>{(async()=>{N(!0);const{data:s}=await A.from("tickets").select("id, public_ref, title, status, priority, company_id, assignee_id, created_at, last_activity_at, companies:companies!inner(name)").order("created_at",{ascending:!1}),r=s??[],w=Array.from(new Set(r.map(i=>i.assignee_id).filter(Boolean))),{data:B}=w.length?await A.from("profiles").select("user_id, first_name, last_name, email").in("user_id",w):{data:[]},D=new Map((B??[]).map(i=>[i.user_id,i])),U=r.map(i=>{var C;return{id:i.id,public_ref:i.public_ref,title:i.title,status:i.status,priority:i.priority,company_id:i.company_id,assignee_id:i.assignee_id,created_at:i.created_at,last_activity_at:i.last_activity_at??i.created_at,company_name:((C=i.companies)==null?void 0:C.name)??"—",assignee_label:i.assignee_id?Q(D.get(i.assignee_id)):null}});n(U),N(!1)})()},[]);const O=l.useMemo(()=>{const t=new Map;for(const s of a)t.set(s.company_id,s.company_name);return Array.from(t,([s,r])=>({id:s,name:r})).sort((s,r)=>s.name.localeCompare(r.name))},[a]),$=l.useMemo(()=>{const t=new Map;for(const s of a)s.assignee_id&&s.assignee_label&&t.set(s.assignee_id,s.assignee_label);return Array.from(t,([s,r])=>({id:s,label:r})).sort((s,r)=>s.label.localeCompare(r.label))},[a]),f=l.useMemo(()=>{const t=h.trim().toLowerCase();return a.filter(s=>!(c&&s.company_id!==c||d&&s.status!==d||o&&s.priority!==o||m&&s.assignee_id!==m||p&&(s.status==="done"||b(s.last_activity_at)<v)||t&&!`${s.title} ${s.public_ref??""}`.toLowerCase().includes(t)))},[a,h,c,d,o,m,p]);l.useEffect(()=>{j(1)},[h,c,d,o,m,p]);const S=Math.max(1,Math.ceil(f.length/_)),k=f.slice((u-1)*_,u*_);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-semibold flex items-center gap-2",children:[e.jsx(G,{size:20})," Tous les tickets"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Vue globale multi-entreprises avec recherche et filtres."})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4 grid gap-3 md:grid-cols-5 items-end",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(x,{className:"text-xs",children:"Recherche (titre, référence)"}),e.jsxs("div",{className:"relative",children:[e.jsx(Z,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(q,{className:"pl-7",value:h,onChange:t=>I(t.target.value),placeholder:"Rechercher…"})]})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Entreprise"}),e.jsxs("select",{className:"w-full h-9 px-2 border rounded-md bg-background text-sm",value:c,onChange:t=>E(t.target.value),children:[e.jsx("option",{value:"",children:"Toutes"}),O.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Statut"}),e.jsxs("select",{className:"w-full h-9 px-2 border rounded-md bg-background text-sm",value:d,onChange:t=>P(t.target.value),children:[e.jsx("option",{value:"",children:"Tous"}
6),Object.entries(L).map(([t,s])=>e.jsx("option",{value:t,children:s},t))]})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs",children:"Priorité"}),e.jsxs("select",{className:"w-full h-9 px-2 border rounded-md bg-background text-sm",value:o,onChange:t=>R(t.target.value),children:[e.jsx("option",{value:"",children:"Toutes"}),Object.entries(T).map(([t,s])=>e.jsx("option",{value:t,children:s},t))]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(x,{className:"text-xs",children:"Assigné à"}),e.jsxs("select",{className:"w-full h-9 px-2 border rounded-md bg-background text-sm",value:m,onChange:t=>F(t.target.value),children:[e.jsx("option",{value:"",children:"Tous"}),$.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))]})]}),e.jsx("div",{className:"md:col-span-3",children:e.jsxs(g,{type:"button",size:"sm",variant:p?"default":"outline",onClick:()=>z(t=>!t),className:"gap-2",children:[e.jsx(H,{size:14}),"Tâches inactives (> ",v," jours)"]})})]}),e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs uppercase",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Référence"}),e.jsx("th",{className:"text-left p-3",children:"Titre"}),e.jsx("th",{className:"text-left p-3",children:"Entreprise"}),e.jsx("th",{className:"text-left p-3",children:"Statut"}),e.jsx("th",{className:"text-left p-3",children:"Priorité"}),e.jsx("th",{className:"text-left p-3",children:"Assigné"}),e.jsx("th",{className:"text-left p-3",children:"Créé"}),e.jsx("th",{className:"text-left p-3",children:"Dernière activité"}),e.jsx("th",{className:"p-3"})]})}),e.jsxs("tbody",{children:[y&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"p-6 text-center text-muted-foreground",children:"Chargement…"})}),!y&&k.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"p-6 text-center text-muted-foreground italic",children:"Aucun ticket"})}),k.map(t=>e.jsxs("tr",{className:"border-t",children:[e.jsx("td",{className:"p-3 font-mono text-xs",children:t.public_ref??"—"}),e.jsx("td",{className:"p-3 font-medium",children:t.title}),e.jsx("td",{className:"p-3",children:t.company_name}),e.jsx("td",{className:"p-3",children:e.jsx("span",{className:`text-xs px-2 py-1 rounded ${K[t.status]??""}`,children:L[t.status]??t.status})}),e.jsx("td",{className:"p-3",children:e.jsx("span",{className:`text-xs px-2 py-1 rounded ${J[t.priority]??""}`,children:T[t.priority]??t.priority})}),e.jsx("td",{className:"p-3",children:t.assignee_label??e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx("td",{className:"p-3 text-xs text-muted-foreground",children:new Date(t.created_at).toLocaleDateString("fr-FR")}),e.jsx("td",{className:"p-3 text-xs",children:t.status!=="done"&&b(t.last_activity_at)>=v?e.jsxs("span",{className:"px-2 py-1 rounded bg-destructive/10 text-destructive",children:["Inactive · ",M(t.last_activity_at)]}):e.jsx("span",{className:"text-muted-foreground",children:M(t.last_activity_at)})}),e.jsx("td",{className:"p-3 text-right",children:e.jsx(g,{asChild:!0,size:"sm",variant:"outline",children:e.jsx(V,{to:`/app/entreprise/${t.company_id}/ticket/${t.id}`,children:"Ouvrir"})})})]},t.id))]})]})}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[f.length," ticket",f.length>1?"s":""," · Page ",u,"/",S]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{size:"sm",variant:"outline",disabled:u<=1,onClick:()=>j(t=>t-1),children:"Précédent"}),e.jsx(g,{size:"sm",variant:"outline",disabled:u>=S,onClick:()=>j(t=>t+1),children:"Suivant"})]})]})]})};export{se 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.