1import{am as l,by as w,dl as E,r as m,j as t,g as h,u as C,s as N}from"./index-CQUKYlXd.js";import{u as R,a as S,B as I,N as M}from"./BoiteMessages-Dpz8QML0.js";import{b as q,u as D}from"./use-formateur-data-C9CubGIv.js";import{e as k}from"./messagerie-envoi-CyWBz7DK.js";import{u as F}from"./use-sender-profiles-BXd0h-KK.js";import{r as L}from"./dashboard-state-NCIK7r_b.js";import{L as T}from"./ListeEtatEcran-B8LcqcDW.js";import{P as A}from"./plus-v7zdgTAJ.js";import"./field-CA1q7qyp.js";import"./select-CldniKbg.js";import"./index-y4Z5g52o.js";import"./chevron-up-Bo9u0uWV.js";import"./search-BNkMh4rv.js";import"./liste-filtree-Bd_25-K0.js";import"./trash-2-CbkIbP7r.js";import"./send-D7fjPYUs.js";import"./search-input-yTDAzVm9.js";import"./participant-display-DK4L1JsI.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"9fa78d70a723bd2838aaf490b98303ec97a6cffc"};var a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="a0b9013b-09c2-4502-96dc-e089e6ba5a56",e._sentryDebugIdIdentifier="sentry-dbid-a0b9013b-09c2-4502-96dc-e089e6ba5a56")}catch{}})();function O(){const{user:e}=l();return C({queryKey:["formateur-journal-for-messages",e==null?void 0:e.id],enabled:!!e,queryFn:async()=>{const{data:a,error:o}=await N.from("journal_pedagogique").select("*, sessions(start_date, end_date, location, formations(title, marketing_title), entreprises(name), parcours_formation(dates, lieu, lieu_distanciel)), profiles:formateur_id(first_name, last_name)").eq("formateur_id",e.id).order("created_at",{ascending:!1});if(o)throw o;return a??[]}})}const d=["formateur-conversations"];function re(){const{user:e}=l(),{data:a,isLoading:o,isError:c}=q(),{data:f}=D(),{data:p}=O(),b=w(),{reads:y,markAsRead:g}=E(),[v,u]=m.useState(!1),n=m.useRef(null);R(d,e==null?void 0:e.id);const i=L({isLoading:o,isError:c,items:a}),_=[...new Set((a??[]).flatMap(s=>(s.messages??[]).map(r=>r.sender_id)))],{data:x}=F(_);S(a,s=>{var r;return(r=n.current)==null?void 0:r.ouvrir(s)});const j=async(s,r)=>{await k(s,e.id,r),b.invalidateQueries({queryKey:d})};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("h1",{className:"text-2xl font-bold",children:"Messages"}),t.jsxs(h,{onClick:()=>u(!0),children:[t.jsx(A,{className:"mr-2 h-4 w-4","aria-hidden":"true"})," Nouvelle conversation"]})]}),i==="erreur"?t.jsx(T,{etat:i,objet:"messages"}):t.jsx(I,{ref:n,etat:i,conversations:a??[],notes:p??[],currentUserId:e.id,reads:y,senderMap:x,onMarkRead:g,onSend:j}),t.jsx(M,{open:v,onClose:s=>{var r;u(!1),s&&((r=n.current)==null||r.ouvrir(s))},sessions:(f??[]).map(s=>({id:s.id,formations:s.formations,entreprises:s.entreprises})),userRole:"formateur",queryKeyToInvalidate:d})]})}export{re as default}; 2//# sourceMappingURL=Messages-BxvwGBJy.js.map
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.