PageSourceSearch

https://zeportal.com/assets/zoho-oauth-BpgQSRYi.js

js zeportal.com collected 2026-10-10 00:42:18 UTC 2,243 bytes, 1 lines download raw bytes

1import{b7 as m,Z as f,aH as n,aM as d,aQ as o}from"./index-_ZZN0Vhe.js";import{A as h}from"./AlertMessage-9iWMdgSj.js";import"./circle-check-p63msG30.js";function C(){const{t:e}=m(["toasts","errors","common","settings","subscription","ai","templates","portalItems","customActions","dialogs","portals","auth"]),t=f.useRouteContext();return console.log("[/utils/zoho-oauth] -> context:",t),n.jsx("div",{className:"flex flex-col items-center justify-center h-screen text-wrap",children:n.jsx("div",{className:"flex flex-col items-center max-w-md mx-auto",children:n.jsx(p,{context:t})})})}const g=async(e,t,a)=>{const s=await fetch("/api/public/getZohoAuthorizationCode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:t,accountServer:a})});if(!s.ok)throw new Error("Failed to fetch authorization code");return s.json()};function p({context:e}){const{t}=m(["toasts","errors","settings"]);console.log("ZohoOauth context ->",e);const[a,s]=d.useState("loading"),c=e?.search?.state||null,i=e?.search?.code||null,u=e?.search?.["accounts-server"]||null;return console.log("ZohoOauth state, code, accountServer ->",{state:c,code:i,accountServer:u}),d.useEffect(()=>{const l=o.loading(t("toasts:connectingZohoOAuth"));i&&c&&u?(async()=>{try{const r=await g(i,c,u);if(console.log("Authorization code:",r),!r||!r.success){o.dismiss(l),o.error(t("toasts:failedConnectZohoOAuth")),s("error");return}o.dismiss(l),s("success"),setTimeout(()=>{r?.zepSettingsPageUrl?window.location.href=r?.zepSettingsPageUrl:window.close()},3e3),o.success(t("toasts:zohoOAuthConnectedSuccess"))}catch(r){o.dismiss(l),s("error"),o.error(t("toasts:failedConnectZohoOAuth")),console.error("Error fetching authorization code:",r)}})():(s("error"),o.error(t("toasts:missingOAuthParams"),{id:l}))},[i,c,u]),!c||!i||!u?(console.error("Missing state or code in URL parameters"),n.jsx(h,{variant:"error",message:t("errors:invalidUrl")})):a==="loading"?n.jsx(h,{variant:"loading",message:t("toasts:connectingZohoOAuth")}):a==="error"?n.jsx(h,{variant:"error",message:t("settings:zohoOAuthConnectFailedRetry")}):a==="success"?n.jsx(h,{variant:"success",message:t("toasts:zohoOAuthConnectedSuccess")}):null}export{C as component,p 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.