NeahNew/.next/static/chunks/app/ms/page-1bc4d0131afa8931.js
2025-05-06 23:01:34 +02:00

1 line
2.5 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2759],{10950:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>o});var s=t(95155),n=t(12115),c=t(35695);function o(){let e=(0,c.useRouter)(),r=(0,c.useSearchParams)(),[t,o]=(0,n.useState)("Processing authentication..."),[a,u]=(0,n.useState)(null),[i,d]=(0,n.useState)(null);return(0,n.useEffect)(()=>{!async function(){try{let t=r.get("code"),s=r.get("state"),n=r.get("error"),c=r.get("error_description");if(n){if(u("Authentication error: ".concat(n)),c){let e=decodeURIComponent(c);d(e),console.error("Auth error details:",e)}return}if(!t||!s)return void u("Missing required parameters");o("Authentication successful. Exchanging code for tokens...");let a=await fetch("/api/courrier/microsoft/callback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:t,state:s})}),i=await a.json();if(!a.ok){u(i.error||"Failed to process authentication"),i.details&&d(i.details);return}o("Account connected successfully!"),setTimeout(()=>{e.push("/courrier")},2e3)}catch(e){u("An unexpected error occurred"),console.error("Callback processing error:",e)}}()},[e,r]),(0,s.jsx)("div",{className:"flex flex-col items-center justify-center min-h-screen bg-gray-50",children:(0,s.jsxs)("div",{className:"w-full max-w-md p-8 space-y-4 bg-white rounded-xl shadow-md",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-center",children:"Microsoft Account Connection"}),a?(0,s.jsxs)("div",{className:"p-4 bg-red-50 text-red-700 rounded-md",children:[(0,s.jsx)("p",{className:"font-medium",children:"Error"}),(0,s.jsx)("p",{children:a}),i&&(0,s.jsx)("div",{className:"mt-2 p-2 bg-red-100 rounded text-sm overflow-auto max-h-40",children:(0,s.jsx)("p",{children:i})}),(0,s.jsx)("button",{onClick:()=>e.push("/courrier"),className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Return to Email Client"})]}):(0,s.jsx)("div",{className:"p-4 bg-blue-50 text-blue-700 rounded-md",children:(0,s.jsx)("p",{children:t})})]})})}},35695:(e,r,t)=>{"use strict";var s=t(18999);t.o(s,"redirect")&&t.d(r,{redirect:function(){return s.redirect}}),t.o(s,"useParams")&&t.d(r,{useParams:function(){return s.useParams}}),t.o(s,"usePathname")&&t.d(r,{usePathname:function(){return s.usePathname}}),t.o(s,"useRouter")&&t.d(r,{useRouter:function(){return s.useRouter}}),t.o(s,"useSearchParams")&&t.d(r,{useSearchParams:function(){return s.useSearchParams}})},56617:(e,r,t)=>{Promise.resolve().then(t.bind(t,10950))}},e=>{var r=r=>e(e.s=r);e.O(0,[8441,1684,7358],()=>r(56617)),_N_E=e.O()}]);