1import{u as p,r as o,j as t}from"./vendor-react-Zq6SgdQO.js";import{k,L as j,g as b}from"./index-CIS_QymX.js";import{C as w}from"./check-circle-2-Ci2k_4N6.js";import"./vendor-query-BEQz81D2.js";function F(){const[r]=p(),[c,i]=o.useState("exchanging"),[m,d]=o.useState(""),u=o.useRef(!1);o.useEffect(()=>{if(u.current)return;u.current=!0;const a=r.get("code"),s=r.get("state");if(!a||!s){const e="Missing code or state in URL";i("error"),d(e),l("error",s??"",e);return}k.post("/api/integrations/banking/callback",{code:a,state:s}).then(({data:e})=>{i("success"),l("success",e.connectionId,"")}).catch(e=>{var x,g,h,f;const n=((g=(x=e==null?void 0:e.response)==null?void 0:x.data)==null?void 0:g.detail)||((f=(h=e==null?void 0:e.response)==null?void 0:h.data)==null?void 0:f.error)||(e==null?void 0:e.message)||"Failed to complete bank connection";i("error"),d(n),l("error",s,n)})},[r]);function l(a,s,e){const n={type:"oauth-callback",status:a,connectionId:s,detail:e};try{sessionStorage.setItem("oauth-callback-result",JSON.stringify({status:a,connectionId:s,detail:e}))}catch{}if(window.opener){try{window.opener.postMessage(n,window.location.origin)}catch{}setTimeout(()=>{try{window.close()}catch{}},1500)}}return t.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:t.jsxs("div",{className:"max-w-sm w-full mx-4 rounded-lg border border-border bg-card p-8 text-center",children:[c==="exchanging"&&t.jsxs(t.Fragment,{children:[t.jsx(j,{className:"h-10 w-10 mx-auto animate-spin text-muted-foreground"}),t.jsx("h1",{className:"mt-4 text-lg font-medium",children:"Slutför anslutningâ¦"}),t.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Verifierar BankID-godkännandet med banken."})]}),c==="success"&&t.jsxs(t.Fragment,{children:[t.jsx(w,{className:"h-10 w-10 mx-auto text-emerald-500"}),t.jsx("h1",{className:"mt-4 text-lg font-medium",children:"Bankkoppling klar"}),t.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Du kan stänga det här fönstret."})]}),c==="error"&&t.jsxs(t.Fragment,{children:[t.jsx(b,{className:"h-10 w-10 mx-auto text-rose-500"}),t.jsx("h1",{className:"mt-4 text-lg font-medium",children:"Connection failed"}),m&&t.jsx("p",{className:"mt-1 text-sm text-muted-foreground break-words",children:m})]})]})})}export{F as BankingCallbackPage};
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.