1import{a as j,r as a,ab as w,ac as v,p as N,j as e}from"./index-CmUU21-Z.js";import{B as y}from"./BottomNav-DLZh7Yjq.js";import{R as E}from"./refresh-cw-B6Jnrcf-.js";import{M as n}from"./message-circle-BDBNRnhQ.js";import{C as F}from"./chevron-right-DezxzltI.js";import{U as k}from"./users-CGrO1piK.js";import{C}from"./calendar-CtOC_ifY.js";import"./createLucideIcon-DbP3VZv4.js";import"./user-CGjPwUhp.js";const _=()=>{const h=j(),[l,o]=a.useState([]),[c,x]=a.useState(!0),[m,d]=a.useState(""),r=a.useCallback(async()=>{x(!0),d("");try{let t=null;if(w.isNativePlatform()){const{value:f}=await v.get({key:"customer_token"});t=f}else t=localStorage.getItem("customer_token");if(!t)throw new Error("Non authentifie");const s=await N.request("/api/chat/my-channels",{method:"GET",headers:{Authorization:`Bearer ${t}`}},!1);o(s||[])}catch(t){console.error("Error fetching channels:",t),d(t.message||"Erreur lors du chargement des conversations"),o([])}finally{x(!1)}},[]);a.useEffect(()=>{r()},[r]);const u=t=>{if(!t)return"";const s=new Date(t),b=new Date().getTime()-s.getTime(),i=Math.floor(b/(1e3*60*60*24));return i===0?s.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"}):i===1?"Hier":i<7?s.toLocaleDateString("fr-FR",{weekday:"short"}):s.toLocaleDateString("fr-FR",{day:"numeric",month:"short"})},p=t=>{switch(t){case"booking_departure":return e.jsx(C,{className:"w-6 h-6 text-white"});case"group":return e.jsx(k,{className:"w-6 h-6 text-white"});default:return e.jsx(n,{className:"w-6 h-6 text-white"})}},g=t=>{switch(t){case"booking_departure":return"bg-[#34C759]";case"group":return"bg-[#007AFF]";default:return"bg-[#8E8E93]"}};return e.jsxs("div",{className:"fixed inset-0 z-[20000] bg-[#F2F2F7] overflow-auto",children:[e.jsxs("div",{className:"min-h-full flex flex-col",style:{paddingTop:"max(env(safe-area-inset-top), 20px)",paddingBottom:"max(env(safe-area-inset-bottom), 100px)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)"},children:[e.jsxs("div",{className:"px-5 pt-2 pb-4 flex items-center justify-between",children:[e.jsx("h1",{className:"text-[34px] font-bold text-black tracking-tight",children:"Messages"}),e.jsx("button",{onClick:r,className:"w-10 h-10 flex items-center justify-center active:opacity-50",children:e.jsx(E,{className:`w-5 h-5 text-[#007AFF] ${c?"animate-spin":""}`})})]}),e.jsx("div",{className:"px-5 flex-1",children:c?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-2 border-[#007AFF] border-t-transparent rounded-full animate-spin"})}):m?e.jsxs("div",{className:"bg-white rounded-2xl p-8 text-center shadow-sm",children:[e.jsx("div",{className:"w-16 h-16 bg-[#FF3B30]/10 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(n,{className:"w-8 h-8 text-[#FF3B30]"})}),e.jsx("h3",{className:"text-[17px] font-semibold text-black mb-2",children:"Erreur"}),e.jsx("p",{className:"text-[15px] text-[#8E8E93] mb-6",children:m}),e.jsx("button",{onClick:r,className:"bg-[#007AFF] text-white text-[15px] font-semibold px-6 py-3 rounded-xl active:bg-[#0056b3]",children:"Reessayer"})]}):l.length===0?e.jsxs("div",{className:"bg-white rounded-2xl p-8 text-center shadow-sm",children:[e.jsx("div",{className:"w-16 h-16 bg-[#F2F2F7] rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(n,{className:"w-8 h-8 text-[#8E8E93]"})}),e.jsx("h3",{className:"text-[17px] font-semibold text-black mb-2",children:"Aucune conversation"}),e.jsx("p",{className:"text-[15px] text-[#8E8E93]",children:"Vos groupes de discussion apparaitront ici apres votre premiere reservation"})]}):e.jsx("div",{className:"bg-white rounded-2xl overflow-hidden shadow-sm divide-y divide-[#E5E5EA]",children:l.map(({channel:t,unreadCount:s})=>e.jsxs("button",{onClick:()=>h(`/mobile/chat/${t.id}`),className:"w-full p-4 flex items-center gap-4 active:bg-[#F2F2F7] transition-colors text-left",children:[e.jsx("div",{className:`w-14 h-14 rounded-full flex items-center justify-center flex-shrink-0 ${g(t.type)}`,children:t.avatar?e.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full rounded-full object-cover"}):p(t.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("h3",{className:`text-[17px] truncate ${s>0?"font-semibold text-black":"font-normal text-black"}`,children:t.name}),e.jsx("span",{className:"text-[13px] text-[#8E8E93] ml-2 flex-shrink-0",children:u(t.lastMessageAt)}
1)]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:`text-[15px] truncate ${s>0?"text-black":"text-[#8E8E93]"}`,children:t.description||`${t.messageCount} messages`}),s>0&&e.jsx("span",{className:"ml-2 bg-[#34C759] text-white text-[12px] font-bold px-2 py-0.5 rounded-full min-w-[22px] text-center",children:s>99?"99+":s})]})]}),e.jsx(F,{className:"w-5 h-5 text-[#C7C7CC] flex-shrink-0"})]},t.id))})})]}),e.jsx(y,{})]})};export{_ 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.