PageSourceSearch

https://dualpilot.app/assets/SalesforceCallback-BWWVzBH3.js

js dualpilot.app collected 2026-10-02 01:14:05 UTC 3,114 bytes, 1 lines download raw bytes

1import{b as w,u as v,a as N,e as S,r as o,j as e,d as k}from"./index-CdeDfzB2.js";import{c as C}from"./salesforceOAuth-CUI-XvJc.js";import{f as E}from"./useIntegrations-DNaWo1TW.js";import"./cmsApi-cKurv9H7.js";const A=()=>{const[s]=w(),c=v(),{activeSite:l}=N(),{user:d}=S(),{refetch:g}=E((l==null?void 0:l.id)||(s.get("state")?JSON.parse(atob(s.get("state"))).siteId:void 0)),[n,t]=o.useState("processing"),[m,x]=o.useState(!1),[p,i]=o.useState("");o.useEffect(()=>{j()},[]);const j=async()=>{const u=s.get("code"),r=s.get("state"),a=s.get("error"),y=s.get("error_description");if(a){t("error"),i(y||"Authorization failed");return}if(!u||!r){t("error"),i("Invalid callback parameters");return}try{const b=JSON.parse(atob(r)).siteId,h=d==null?void 0:d.id;if(!h)throw new Error("User not authenticated. Please log in again.");await C(u,h,b),t("verifying"),x(!0)}catch(f){console.error("Salesforce Callback Error:",f),t("error"),i(f.message||"Failed to connect Salesforce")}};return o.useEffect(()=>{m&&(async()=>{const{data:r}=await g();r!=null&&r.connected?(t("success"),setTimeout(()=>c("/settings/integrations"),2e3)):setTimeout(async()=>{const{data:a}=await g();a!=null&&a.connected?(t("success"),setTimeout(()=>c("/settings/integrations"),2e3)):(t("error"),i("Connection verification failed. Please try again."))},1e3),x(!1)})()},[m,g]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"max-w-md w-full bg-white rounded-lg shadow-lg p-8 text-center",children:[(n==="processing"||n==="verifying")&&e.jsxs(e.Fragment,{children:[e.jsx(k,{}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mt-4",children:n==="processing"?"Connecting Salesforce...":"Verifying Connection..."}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Please wait while we complete the connection"})]}),n==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mt-4",children:"Salesforce Connected!"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Redirecting you back to settings..."})]}),n==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto",children:e.jsx("svg",{className:"w-8 h-8 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mt-4",children:"Connection Failed"}),e.jsx("p",{className:"text-red-600 mt-2",children:p}),e.jsx("button",{onClick:()=>c("/settings/integrations"),className:"mt-6 px-6 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800",children:"Back to Settings"})]})]})})};export{A 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.