1 line
27 KiB
JavaScript
1 line
27 KiB
JavaScript
(()=>{var e={};e.id=8974,e.ids=[8974],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},11723:e=>{"use strict";e.exports=require("querystring")},12412:e=>{"use strict";e.exports=require("assert")},14985:e=>{"use strict";e.exports=require("dns")},18567:(e,s,t)=>{"use strict";t.d(s,{eu:()=>y,q5:()=>v,BK:()=>w});var r=t(60687),a=t(43210),l=t(11273),n=t(13495),i=t(66156);t(51215);var o=t(8730),c=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,s)=>{let t=a.forwardRef((e,t)=>{let{asChild:a,...l}=e,n=a?o.DX:s;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,r.jsx)(n,{...l,ref:t})});return t.displayName=`Primitive.${s}`,{...e,[s]:t}},{}),d="Avatar",[m,x]=(0,l.A)(d),[u,h]=m(d),p=a.forwardRef((e,s)=>{let{__scopeAvatar:t,...l}=e,[n,i]=a.useState("idle");return(0,r.jsx)(u,{scope:t,imageLoadingStatus:n,onImageLoadingStatusChange:i,children:(0,r.jsx)(c.span,{...l,ref:s})})});p.displayName=d;var f="AvatarImage",g=a.forwardRef((e,s)=>{let{__scopeAvatar:t,src:l,onLoadingStatusChange:o=()=>{},...d}=e,m=h(f,t),x=function(e,s){let[t,r]=a.useState("idle");return(0,i.N)(()=>{if(!e)return void r("error");let t=!0,a=new window.Image,l=e=>()=>{t&&r(e)};return r("loading"),a.onload=l("loaded"),a.onerror=l("error"),a.src=e,s&&(a.referrerPolicy=s),()=>{t=!1}},[e,s]),t}(l,d.referrerPolicy),u=(0,n.c)(e=>{o(e),m.onImageLoadingStatusChange(e)});return(0,i.N)(()=>{"idle"!==x&&u(x)},[x,u]),"loaded"===x?(0,r.jsx)(c.img,{...d,ref:s,src:l}):null});g.displayName=f;var j="AvatarFallback",N=a.forwardRef((e,s)=>{let{__scopeAvatar:t,delayMs:l,...n}=e,i=h(j,t),[o,d]=a.useState(void 0===l);return a.useEffect(()=>{if(void 0!==l){let e=window.setTimeout(()=>d(!0),l);return()=>window.clearTimeout(e)}},[l]),o&&"loaded"!==i.imageLoadingStatus?(0,r.jsx)(c.span,{...n,ref:s}):null});N.displayName=j;var b=t(96241);let y=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)(p,{ref:t,className:(0,b.cn)("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...s}));y.displayName=p.displayName;let w=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)(g,{ref:t,className:(0,b.cn)("aspect-square h-full w-full",e),...s}));w.displayName=g.displayName;let v=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)(N,{ref:t,className:(0,b.cn)("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...s}));v.displayName=N.displayName},19121:e=>{"use strict";e.exports=require("next/dist/server/app-render/action-async-storage.external.js")},21820:e=>{"use strict";e.exports=require("os")},27910:e=>{"use strict";e.exports=require("stream")},28354:e=>{"use strict";e.exports=require("util")},28476:(e,s,t)=>{Promise.resolve().then(t.bind(t,55505))},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33653:(e,s,t)=>{"use strict";t.r(s),t.d(s,{GlobalError:()=>n.a,__next_app__:()=>m,pages:()=>d,routeModule:()=>x,tree:()=>c});var r=t(65239),a=t(48088),l=t(88170),n=t.n(l),i=t(30893),o={};for(let e in i)0>["default","tree","pages","GlobalError","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);t.d(s,o);let c=["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(t.bind(t,90597)),"/Users/alma/Documents/NeahNew/app/page.tsx"]}]},{layout:[()=>Promise.resolve().then(t.bind(t,58014)),"/Users/alma/Documents/NeahNew/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(t.t.bind(t,57398,23)),"next/dist/client/components/not-found-error"],forbidden:[()=>Promise.resolve().then(t.t.bind(t,89999,23)),"next/dist/client/components/forbidden-error"],unauthorized:[()=>Promise.resolve().then(t.t.bind(t,65284,23)),"next/dist/client/components/unauthorized-error"]}],d=["/Users/alma/Documents/NeahNew/app/page.tsx"],m={require:t,loadChunk:()=>Promise.resolve()},x=new r.AppPageRouteModule({definition:{kind:a.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:c}})},33873:e=>{"use strict";e.exports=require("path")},34631:e=>{"use strict";e.exports=require("tls")},41204:e=>{"use strict";e.exports=require("string_decoder")},55192:(e,s,t)=>{"use strict";t.d(s,{BT:()=>c,Wu:()=>d,ZB:()=>o,Zp:()=>n,aR:()=>i});var r=t(60687),a=t(43210),l=t(96241);let n=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)("div",{ref:t,className:(0,l.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",e),...s}));n.displayName="Card";let i=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)("div",{ref:t,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",e),...s}));i.displayName="CardHeader";let o=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)("div",{ref:t,className:(0,l.cn)("text-2xl font-semibold leading-none tracking-tight",e),...s}));o.displayName="CardTitle";let c=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)("div",{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",e),...s}));c.displayName="CardDescription";let d=a.forwardRef(({className:e,...s},t)=>(0,r.jsx)("div",{ref:t,className:(0,l.cn)("p-6 pt-0",e),...s}));d.displayName="CardContent",a.forwardRef(({className:e,...s},t)=>(0,r.jsx)("div",{ref:t,className:(0,l.cn)("flex items-center p-6 pt-0",e),...s})).displayName="CardFooter"},55505:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>R});var r=t(60687),a=t(78122),l=t(55192),n=t(43210);function i(){let e=async()=>{let e=await fetch("/quotes.json"),s=await e.json();return s[Math.floor(Math.random()*s.length)]},[s,t]=(0,n.useState)(null);return(0,r.jsx)(l.Zp,{className:"relative transition-transform duration-500 ease-in-out transform hover:scale-105",children:(0,r.jsxs)(l.Wu,{className:"p-6",children:[(0,r.jsxs)("blockquote",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-lg",children:s?s.quote:"Loading..."}),(0,r.jsx)("footer",{className:"text-sm text-gray-500",children:s?s.author:"Loading..."})]}),(0,r.jsx)("button",{className:"absolute bottom-4 right-4 p-1 hover:bg-gray-100 rounded-full",onClick:()=>{e().then(t)},children:(0,r.jsx)(a.A,{className:"w-4 h-4"})})]})})}var o=t(24934),c=t(40228),d=t(16189);function m(){let[e,s]=(0,n.useState)([]),[t,i]=(0,n.useState)(!0),[m,x]=(0,n.useState)(null);(0,d.useRouter)();let u=async()=>{i(!0);try{let e=await fetch("/api/calendars?refresh=true");if(!e.ok)throw Error("Failed to fetch events");let t=await e.json();console.log("Calendar Widget - Fetched calendars:",t);let r=new Date;r.setHours(0,0,0,0);let a=t.flatMap(e=>(e.events||[]).map(s=>({id:s.id,title:s.title,start:s.start,end:s.end,allDay:s.isAllDay,calendar:e.name,calendarColor:e.color}))).filter(e=>new Date(e.start)>=r).sort((e,s)=>new Date(e.start).getTime()-new Date(s.start).getTime()).slice(0,7);console.log("Calendar Widget - Processed events:",a),s(a),x(null)}catch(e){console.error("Error fetching events:",e),x("Failed to load events")}finally{i(!1)}},h=e=>{let s=new Date(e);return new Intl.DateTimeFormat("fr-FR",{day:"2-digit",month:"short"}).format(s)},p=e=>{let s=new Date(e);return new Intl.DateTimeFormat("fr-FR",{hour:"2-digit",minute:"2-digit"}).format(s)};return(0,r.jsxs)(l.Zp,{className:"transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg",children:[(0,r.jsxs)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:[(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(c.A,{className:"h-5 w-5 text-gray-600"}),"Agenda"]}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon",onClick:()=>u(),className:"h-7 w-7 p-0 hover:bg-gray-100/50 rounded-full",children:(0,r.jsx)(a.A,{className:"h-3.5 w-3.5 text-gray-600"})})]}),(0,r.jsx)(l.Wu,{className:"p-3",children:t?(0,r.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,r.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-blue-500 border-t-transparent"})}):m?(0,r.jsx)("div",{className:"text-xs text-red-500 text-center py-3",children:m}):0===e.length?(0,r.jsx)("div",{className:"text-xs text-gray-500 text-center py-6",children:"No upcoming events"}):(0,r.jsx)("div",{className:"space-y-2 max-h-[400px] overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent",children:e.map(e=>(0,r.jsx)("div",{className:"p-2 rounded-lg bg-white shadow-sm hover:shadow-md transition-all duration-200 border border-gray-100",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex-shrink-0 w-14 h-14 rounded-lg flex flex-col items-center justify-center border",style:{backgroundColor:`${e.calendarColor}10`,borderColor:e.calendarColor},children:[(0,r.jsx)("span",{className:"text-[10px] font-medium",style:{color:e.calendarColor},children:h(e.start)}),(0,r.jsx)("span",{className:"text-[10px] font-bold mt-0.5",style:{color:e.calendarColor},children:p(e.start)})]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-800 line-clamp-2 flex-1",children:e.title}),!e.allDay&&(0,r.jsxs)("span",{className:"text-[10px] text-gray-500 whitespace-nowrap",children:[p(e.start)," - ",p(e.end)]})]}),(0,r.jsx)("div",{className:"flex items-center text-[10px] px-1.5 py-0.5 rounded-md",style:{backgroundColor:`${e.calendarColor}10`,color:e.calendarColor},children:(0,r.jsx)("span",{className:"truncate",children:e.calendar})})]})]})},e.id))})})]})}var x=t(80464),u=t(82136);function h(){let[e,s]=(0,n.useState)([]),[t,i]=(0,n.useState)(!0),[c,d]=(0,n.useState)(null),[m,h]=(0,n.useState)(!1),{status:p}=(0,u.useSession)(),f=async(e=!1)=>{e&&h(!0),e||i(!0);try{let t=await fetch(e?"/api/news?refresh=true&limit=100":"/api/news?limit=100");if(!t.ok)throw Error("Failed to fetch news");let r=await t.json();console.log(`News component received ${r.length} articles`),s(r),d(null)}catch(e){d("Failed to fetch news"),console.error("Error fetching news:",e)}finally{i(!1),h(!1)}};return"loading"===p||t?(0,r.jsxs)(l.Zp,{className:"transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg",children:[(0,r.jsx)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(x.A,{className:"h-5 w-5 text-gray-600"}),"Nouvelles"]})}),(0,r.jsx)(l.Wu,{className:"p-3",children:(0,r.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,r.jsx)(a.A,{className:"h-4 w-4 animate-spin text-gray-400"})})})]}):(0,r.jsxs)(l.Zp,{className:"transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg",children:[(0,r.jsxs)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:[(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(x.A,{className:"h-5 w-5 text-gray-600"}),"Nouvelles",(0,r.jsxs)("span",{className:"text-sm font-normal ml-2 text-gray-500",children:["(",e.length,")"]})]}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon",onClick:()=>f(!0),disabled:m,className:"h-7 w-7 p-0 hover:bg-gray-100/50 rounded-full",children:(0,r.jsx)(a.A,{className:"h-3.5 w-3.5 text-gray-600"})})]}),(0,r.jsx)(l.Wu,{className:"p-3",children:c?(0,r.jsx)("div",{className:"text-xs text-red-500 text-center py-3",children:c}):(0,r.jsx)("div",{className:"space-y-2 max-h-[400px] overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent",children:0===e.length?(0,r.jsx)("div",{className:"text-xs text-gray-500 text-center py-6",children:"No news available"}):e.map(e=>(0,r.jsx)("div",{className:"p-2 rounded-lg bg-white shadow-sm hover:shadow-md transition-all duration-200 border border-gray-100",onClick:()=>window.open(e.url,"_blank"),children:(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsx)("div",{className:"flex items-center justify-between text-xs",children:(0,r.jsx)("span",{className:"text-gray-500",children:e.displayDate})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-800 line-clamp-2",title:e.title,children:e.title}),(0,r.jsx)("p",{className:"text-xs text-gray-500 line-clamp-2",title:e.description||void 0,children:e.description})]})},e.id))})})]})}var p=t(81620),f=t(82570);function g(){let[e,s]=(0,n.useState)([]),[t,i]=(0,n.useState)(null),[c,d]=(0,n.useState)(!0),[m,x]=(0,n.useState)(!1),u=e=>{switch(e){case 1:return"New";case 2:return"Blocked";case 3:return"In Progress";case 4:return"Waiting for Approval";case 5:return"Done";default:return"Unknown"}},h=e=>e.dateToFinish&&"0000-00-00 00:00:00"!==e.dateToFinish?e.dateToFinish:null,g=async()=>{d(!0),i(null);try{let e=await fetch("/api/leantime/tasks?refresh=true");if(!e.ok)throw Error("Failed to fetch tasks");let t=await e.json();if(console.log("Raw API response:",t),!Array.isArray(t)){console.warn("No tasks found in response",t),s([]);return}let r=t.filter(e=>{let s=5!==e.status;return s?console.log(`Keeping task ${e.id}: status=${e.status} (${u(e.status)}), type=${e.type||"main"}`):console.log(`Filtering out Done task ${e.id} (type: ${e.type||"main"}, status: ${e.status})`),s}).sort((e,s)=>{let t=h(e),r=h(s);if(t&&r){let e=new Date(t).getTime(),s=new Date(r).getTime();if(e!==s)return e-s}return t?-1:r?1:4===e.status&&4!==s.status?-1:+(4===s.status&&4!==e.status)});console.log("Sorted and filtered tasks:",r.map(e=>({id:e.id,date:e.dateToFinish,status:e.status,type:e.type||"main"}))),s(r.slice(0,7))}catch(e){console.error("Error fetching tasks:",e),i(e instanceof Error?e.message:"Failed to fetch tasks")}finally{d(!1)}},j=({task:e})=>{let s=e.dateToFinish;if(!s||"0000-00-00 00:00:00"===s)return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("span",{className:"text-[10px] text-gray-600 font-medium",children:"NO"}),(0,r.jsx)("span",{className:"text-sm text-gray-700 font-bold",children:"DATE"})]});try{let e=new Date(s);if(isNaN(e.getTime()))throw Error("Invalid date");let t=new Date;t.setHours(0,0,0,0);let a=e<t,l=e.toLocaleString("fr-FR",{month:"short"}).toUpperCase(),n=e.getDate(),i=e.getFullYear();return(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("span",{className:`text-[10px] font-medium uppercase ${a?"text-red-600":"text-blue-600"}`,children:l}),(0,r.jsx)("span",{className:`text-sm font-bold ${a?"text-red-700":"text-blue-700"}`,children:n})]}),(0,r.jsx)("span",{className:`text-[8px] font-medium ${a?"text-red-500":"text-blue-500"}`,children:i})]})}catch(s){return console.error("Error formatting date for task",e.id,s),(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("span",{className:"text-[10px] text-gray-600 font-medium",children:"ERR"}),(0,r.jsx)("span",{className:"text-sm text-gray-700 font-bold",children:"DATE"})]})}};return(0,r.jsxs)(l.Zp,{className:"transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg",children:[(0,r.jsxs)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:[(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(p.A,{className:"h-5 w-5 text-gray-600"}),"Devoirs"]}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon",onClick:()=>g(),className:"h-7 w-7 p-0 hover:bg-gray-100/50 rounded-full",children:(0,r.jsx)(a.A,{className:"h-3.5 w-3.5 text-gray-600"})})]}),(0,r.jsx)(l.Wu,{className:"p-3",children:c?(0,r.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,r.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-blue-500 border-t-transparent"})}):t?(0,r.jsx)("div",{className:"text-xs text-red-500 text-center py-3",children:t}):0===e.length?(0,r.jsx)("div",{className:"text-xs text-gray-500 text-center py-6",children:"No tasks with due dates found"}):(0,r.jsx)("div",{className:"space-y-2 max-h-[400px] overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent",children:e.map(e=>(0,r.jsx)("div",{className:"p-2 rounded-lg bg-white shadow-sm hover:shadow-md transition-all duration-200 border border-gray-100",children:(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("div",{className:"flex-shrink-0 w-12 h-12 rounded-lg bg-blue-50 flex flex-col items-center justify-center border border-blue-100",children:(0,r.jsx)(j,{task:e})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 space-y-1",children:[(0,r.jsx)("a",{href:`https://agilite.slm-lab.net/tickets/showTicket/${e.id}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-700 font-medium block text-sm line-clamp-2",children:e.headline}),(0,r.jsxs)("div",{className:"flex items-center text-gray-500 text-[10px] bg-gray-50 px-1.5 py-0.5 rounded-md",children:[(0,r.jsx)(f.A,{className:"h-2.5 w-2.5 mr-1 opacity-70"}),(0,r.jsx)("span",{className:"truncate",children:e.projectName})]})]})]})},e.id))})})]})}var j=t(41550),N=t(41862);let b=(0,t(62688).A)("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);var y=t(85814),w=t.n(y);function v(){let[e,s]=(0,n.useState)([]),[t,i]=(0,n.useState)(!1),[c,d]=(0,n.useState)(null),[m,x]=(0,n.useState)(null),u=async(e=!1)=>{i(!0),d(null);try{let t=await fetch("/api/courrier?folder=INBOX&page=1&perPage=5"+(e?"&refresh=true":""));if(!t.ok)throw Error("Failed to fetch emails");let r=await t.json();if(r.error)d(r.error),s([]);else{let e=r.emails.map(e=>({id:e.id,subject:e.subject,from:e.from[0]?.address||"",fromName:e.from[0]?.name||"",date:e.date,read:e.flags.seen,starred:e.flags.flagged,folder:e.folder})).sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime()).slice(0,5);s(e),x("/courrier")}}catch(e){console.error("Error fetching emails:",e),d("Failed to load emails"),s([])}finally{i(!1)}},h=e=>{try{let s=new Date(e);return new Intl.DateTimeFormat("fr-FR",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}catch(e){return""}};return(0,r.jsxs)(l.Zp,{className:"h-full",children:[(0,r.jsxs)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:[(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(j.A,{className:"h-5 w-5 text-gray-600"}),"Courrier"]}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon",onClick:()=>u(!0),disabled:t,children:t?(0,r.jsx)(N.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(a.A,{className:"h-4 w-4"})})]}),(0,r.jsx)(l.Wu,{className:"p-4",children:c?(0,r.jsx)("div",{className:"text-center py-4 text-gray-500",children:c}):t&&0===e.length?(0,r.jsxs)("div",{className:"text-center py-6 flex flex-col items-center",children:[(0,r.jsx)(N.A,{className:"h-6 w-6 animate-spin text-gray-400 mb-2"}),(0,r.jsx)("p",{className:"text-gray-500",children:"Chargement des emails..."})]}):0===e.length?(0,r.jsx)("div",{className:"text-center py-6",children:(0,r.jsx)("p",{className:"text-gray-500",children:"Aucun email non lu"})}):(0,r.jsxs)("div",{className:"space-y-3",children:[e.map(e=>(0,r.jsxs)("div",{className:"flex items-start gap-3 py-1 border-b border-gray-100 last:border-0",children:[(0,r.jsx)("div",{className:"pt-1",children:e.read?(0,r.jsx)(b,{className:"h-4 w-4 text-gray-400"}):(0,r.jsx)(j.A,{className:"h-4 w-4 text-blue-500"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("p",{className:"font-medium truncate",style:{maxWidth:"180px"},children:e.fromName||e.from.split("@")[0]}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:h(e.date)})]}),(0,r.jsx)("p",{className:"text-sm text-gray-700 truncate",children:e.subject})]})]},e.id)),m&&(0,r.jsx)("div",{className:"pt-2",children:(0,r.jsx)(w(),{href:m,className:"text-sm text-blue-600 hover:text-blue-800",children:"Voir tous les emails →"})})]})})]})}var k=t(58887),A=t(18567);function C(){let[e,s]=(0,n.useState)([]),[t,i]=(0,n.useState)(null),[c,m]=(0,n.useState)(!0),[x,h]=(0,n.useState)(!1),p=(0,d.useRouter)(),{data:f,status:g}=(0,u.useSession)(),j=async(e=!1)=>{try{e&&h(!0);let t=await fetch("/api/rocket-chat/messages"+(e?"?refresh=true":""),{cache:"no-store",next:{revalidate:0}});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to fetch messages")}let r=await t.json();Array.isArray(r.messages)?s(r.messages):(console.warn("Unexpected data format:",r),s([])),i(null)}catch(e){console.error("Error fetching messages:",e),i(e instanceof Error?e.message:"Failed to fetch messages")}finally{m(!1),h(!1)}};return"loading"===g?(0,r.jsxs)(l.Zp,{className:"transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg h-full",children:[(0,r.jsx)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(k.A,{className:"h-5 w-5 text-gray-600"}),"Parole"]})}),(0,r.jsx)(l.Wu,{className:"p-6",children:(0,r.jsx)("p",{className:"text-center text-gray-500",children:"Loading..."})})]}):"unauthenticated"===g||t&&t.includes("Session expired")?(0,r.jsxs)(l.Zp,{className:"transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg h-full",children:[(0,r.jsx)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(k.A,{className:"h-5 w-5 text-gray-600"}),"Parole"]})}),(0,r.jsx)(l.Wu,{className:"p-6",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("p",{className:"text-gray-500 mb-4",children:"Please sign in to view messages"}),(0,r.jsx)(o.$,{onClick:e=>{e.stopPropagation(),(0,u.signIn)("keycloak")},variant:"default",className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Sign In"})]})})]}):(0,r.jsxs)(l.Zp,{className:"transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg cursor-pointer w-full",onClick:()=>p.push("/parole"),children:[(0,r.jsxs)(l.aR,{className:"flex flex-row items-center justify-between pb-2 border-b border-gray-100",children:[(0,r.jsxs)(l.ZB,{className:"text-lg font-semibold text-gray-800 flex items-center gap-2",children:[(0,r.jsx)(k.A,{className:"h-5 w-5 text-gray-600"}),"Parole"]}),(0,r.jsx)(o.$,{variant:"ghost",size:"icon",onClick:e=>{e.stopPropagation(),j(!0)},disabled:x,className:`${x?"animate-spin":""} text-gray-600 hover:text-gray-900`,children:(0,r.jsx)(a.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)(l.Wu,{className:"p-4",children:[c&&(0,r.jsx)("p",{className:"text-center text-gray-500",children:"Loading messages..."}),t&&(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsxs)("p",{className:"text-red-500",children:["Error: ",t]}),(0,r.jsx)(o.$,{variant:"outline",onClick:e=>{e.stopPropagation(),j(!0)},className:"mt-2",children:"Try Again"})]}),!c&&!t&&(0,r.jsx)("div",{className:"space-y-4 max-h-[400px] overflow-y-auto pr-1 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent",children:0===e.length?(0,r.jsx)("p",{className:"text-center text-gray-500",children:"No messages found"}):e.map(e=>(0,r.jsxs)("div",{className:"flex items-start space-x-3 hover:bg-gray-50/50 p-3 rounded-lg transition-colors",children:[(0,r.jsxs)(A.eu,{className:"h-8 w-8",style:{backgroundColor:e.sender.color},children:[(0,r.jsx)(A.BK,{src:`https://ui-avatars.com/api/?name=${encodeURIComponent(e.sender.name)}&background=random`}),(0,r.jsx)(A.q5,{children:e.sender.initials})]}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between space-x-2",children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-gray-800 truncate max-w-[70%]",children:e.sender.name}),(0,r.jsx)("span",{className:"text-xs font-medium text-gray-500 flex-shrink-0",children:e.timestamp})]}),(0,r.jsx)("p",{className:"text-sm text-gray-600 whitespace-pre-wrap line-clamp-2 mt-1",children:e.text}),e.roomName&&(0,r.jsx)("div",{className:"flex items-center mt-2",children:(0,r.jsxs)("span",{className:`inline-flex items-center px-2 py-1 rounded-md text-xs font-medium ${e.room.isChannel?"bg-blue-50 text-blue-700":e.room.isPrivateGroup?"bg-purple-50 text-purple-700":"bg-green-50 text-green-700"}`,children:[e.room.isChannel?"#":e.room.isPrivateGroup?"\uD83D\uDD12":"\uD83D\uDCAC"," ",e.roomName]})})]})]},e.id))})]})]})}function R(){let{data:e,status:s}=(0,u.useSession)(),[t,a]=(0,n.useState)(!0);return t?(0,r.jsx)("main",{className:"h-screen flex items-center justify-center",children:(0,r.jsx)("div",{className:"animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-gray-900"})}):(0,r.jsx)("main",{className:"h-screen overflow-auto",children:(0,r.jsxs)("div",{className:"container mx-auto p-4 mt-12",children:[(0,r.jsxs)("div",{className:"grid grid-cols-12 gap-4 mb-4",children:[(0,r.jsx)("div",{className:"col-span-3",children:(0,r.jsx)(i,{})}),(0,r.jsx)("div",{className:"col-span-3",children:(0,r.jsx)(m,{})}),(0,r.jsx)("div",{className:"col-span-3",children:(0,r.jsx)(h,{})}),(0,r.jsx)("div",{className:"col-span-3",children:(0,r.jsx)(g,{})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 gap-4",children:[(0,r.jsx)("div",{className:"col-span-6",children:(0,r.jsx)(v,{})}),(0,r.jsx)("div",{className:"col-span-6",children:(0,r.jsx)(C,{})})]})]})})}},55511:e=>{"use strict";e.exports=require("crypto")},55591:e=>{"use strict";e.exports=require("https")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},70332:(e,s,t)=>{Promise.resolve().then(t.bind(t,90597))},74075:e=>{"use strict";e.exports=require("zlib")},78122:(e,s,t)=>{"use strict";t.d(s,{A:()=>r});let r=(0,t(62688).A)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},79428:e=>{"use strict";e.exports=require("buffer")},79551:e=>{"use strict";e.exports=require("url")},81630:e=>{"use strict";e.exports=require("http")},82570:(e,s,t)=>{"use strict";t.d(s,{A:()=>r});let r=(0,t(62688).A)("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]])},83997:e=>{"use strict";e.exports=require("tty")},90597:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>r});let r=(0,t(12907).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/Users/alma/Documents/NeahNew/app/page.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/alma/Documents/NeahNew/app/page.tsx","default")},91645:e=>{"use strict";e.exports=require("net")},94735:e=>{"use strict";e.exports=require("events")}};var s=require("../webpack-runtime.js");s.C(e);var t=e=>s(s.s=e),r=s.X(0,[4243,5419,8794,1642,6724,748,6781,5500],()=>t(33653));module.exports=r})(); |