@zango-core/crm-framework 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -173,5 +173,5 @@ export default App;`,w=`mkdir -p ${c}`,m={container:{padding:"32px",maxWidth:"90
|
|
|
173
173
|
0% { transform: rotate(0deg); }
|
|
174
174
|
100% { transform: rotate(360deg); }
|
|
175
175
|
}
|
|
176
|
-
`})]})},ul=()=>{const{menu:e,profileInfo:t,initializerEndpoint:r}=Se();return e.length===0&&t?.user_role&&t.user_role,s.jsx("div",{className:"flex flex-col items-center justify-center h-screen text-center p-6 bg-gray-100",children:s.jsxs("div",{className:"bg-white rounded-xl p-12 shadow-md max-w-2xl w-full",children:[s.jsx("h1",{className:"text-[40px] m-0 text-red-500 font-bold leading-none",children:"⚙️"}),s.jsx("h2",{className:"text-2xl my-4 text-gray-800 font-semibold",children:"Configuration Error"}),s.jsx("p",{className:"text-base text-gray-600 mb-6 leading-relaxed",children:"The application is trying to fetch configuration from:"}),s.jsx("code",{className:"block bg-gray-50 border border-gray-200 rounded-md p-3 text-sm text-gray-800 font-mono mb-6 break-all",children:r}),s.jsxs("div",{className:"text-left mb-8 p-4 bg-gray-50 rounded-lg",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-3 font-semibold",children:"The response is either missing or invalid. Please check:"}),s.jsxs("ul",{className:"text-sm text-gray-600 pl-5 m-0 list-disc space-y-2 pl-4",children:[s.jsx("li",{children:"Appbuilder package routes are configured correctly"}),s.jsx("li",{children:"Required policies are properly mapped"}),s.jsx("li",{children:"The endpoint is accessible and returns valid data"})]})]}),s.jsxs("div",{className:"flex gap-3 justify-center",children:[s.jsx(p.Button,{type:"primary",onClick:()=>window.location.reload(),children:"Retry"}),s.jsx(p.Button,{onClick:()=>window.location.href="/app",children:"Go Home"})]}),s.jsx("p",{className:"text-xs text-gray-500 mt-6",children:"Contact your administrator if this issue persists."})]})})},Oo=({customPages:e})=>{const t=H.useParams(),o=`${H.useLocation().pathname}-${Object.values(t).join("-")}`;return s.jsx(it,{customPages:e},o)},hl=({customPages:e})=>{const{routes:t,loading:r,menu:o,pageTypeRegistry:a,registryError:n}=Se(),i=o.length>0?o[0].uri:null;if(r)return s.jsx("div",{className:"zango-loading",children:"Loading..."});if(n)return s.jsxs("div",{className:"zango-error",children:["Failed to load page registry: ",n]});const c=[],d=[];return a&&t.forEach(l=>{const u=a[l.page_type];u&&u.standalone?c.push(l):d.push(l)}),s.jsxs(H.Routes,{children:[s.jsx(H.Route,{path:"app/login/*",element:s.jsx(dr,{basePath:"/app/login"})}),s.jsx(H.Route,{path:"app/logout",element:s.jsx(To,{})}),s.jsx(H.Route,{path:"app/configuration-error",element:s.jsx(ul,{})}),c.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(f.Fragment,{children:[s.jsx(H.Route,{path:`${u}/*`,element:s.jsx(it,{customPages:e,forceRoute:l})}),s.jsx(H.Route,{path:u,element:s.jsx(it,{customPages:e,forceRoute:l})})]},l.path)}),s.jsxs(H.Route,{path:"/",element:s.jsx(No,{}),children:[s.jsx(H.Route,{index:!0,element:i?s.jsx(H.Navigate,{to:i}):s.jsx("div",{children:"No menu items available"})}),s.jsx(H.Route,{path:"app",element:s.jsx("div",{className:"zango-loading",children:"Redirecting..."})}),d.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(f.Fragment,{children:[s.jsx(H.Route,{path:`${u}/*`,element:s.jsx(Oo,{customPages:e})}),s.jsx(H.Route,{path:u,element:s.jsx(Oo,{customPages:e})})]},l.path)})]}),s.jsx(H.Route,{path:"*",element:s.jsx(it,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),s.jsx(H.Route,{path:"/404",element:s.jsx(it,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},pl=({customPages:e})=>s.jsxs(s.Fragment,{children:[s.jsx(Eo,{}),s.jsx(hl,{customPages:e})]}),fl=({config:e={},customPages:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},appInitializerEndpoint:i})=>(i&&typeof window<"u"&&(console.log("app init endpoint here",i),window.app_initializer_endpoint=i),s.jsx(H.BrowserRouter,{children:s.jsx(bo,{config:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,children:s.jsx(pl,{customPages:t})})})),gl=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},appInitializerEndpoint:i})=>s.jsxs(s.Fragment,{children:[s.jsx(fl,{config:t,customPages:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,appInitializerEndpoint:i}),s.jsx(p.Toaster,{position:"bottom-right"})]});class ml{constructor(){this.setupInterceptors()}handleRedirect(t){if(t){const r=window.location.pathname+window.location.search+window.location.hash;if(r==="/app/logout/"||r==="/app/logout"){window.location.href=t;return}const o=encodeURIComponent(r),a=`${t}?next=${o}`;window.location.href=a}}setupInterceptors(){const t=window.fetch,r=this;window.fetch=async(...n)=>{try{const[i,c={}]=n,d=Date.now().toString(),
|
|
176
|
+
`})]})},ul=()=>{const{menu:e,profileInfo:t,initializerEndpoint:r}=Se();return e.length===0&&t?.user_role&&t.user_role,s.jsx("div",{className:"flex flex-col items-center justify-center h-screen text-center p-6 bg-gray-100",children:s.jsxs("div",{className:"bg-white rounded-xl p-12 shadow-md max-w-2xl w-full",children:[s.jsx("h1",{className:"text-[40px] m-0 text-red-500 font-bold leading-none",children:"⚙️"}),s.jsx("h2",{className:"text-2xl my-4 text-gray-800 font-semibold",children:"Configuration Error"}),s.jsx("p",{className:"text-base text-gray-600 mb-6 leading-relaxed",children:"The application is trying to fetch configuration from:"}),s.jsx("code",{className:"block bg-gray-50 border border-gray-200 rounded-md p-3 text-sm text-gray-800 font-mono mb-6 break-all",children:r}),s.jsxs("div",{className:"text-left mb-8 p-4 bg-gray-50 rounded-lg",children:[s.jsx("p",{className:"text-sm text-gray-600 mb-3 font-semibold",children:"The response is either missing or invalid. Please check:"}),s.jsxs("ul",{className:"text-sm text-gray-600 pl-5 m-0 list-disc space-y-2 pl-4",children:[s.jsx("li",{children:"Appbuilder package routes are configured correctly"}),s.jsx("li",{children:"Required policies are properly mapped"}),s.jsx("li",{children:"The endpoint is accessible and returns valid data"})]})]}),s.jsxs("div",{className:"flex gap-3 justify-center",children:[s.jsx(p.Button,{type:"primary",onClick:()=>window.location.reload(),children:"Retry"}),s.jsx(p.Button,{onClick:()=>window.location.href="/app",children:"Go Home"})]}),s.jsx("p",{className:"text-xs text-gray-500 mt-6",children:"Contact your administrator if this issue persists."})]})})},Oo=({customPages:e})=>{const t=H.useParams(),o=`${H.useLocation().pathname}-${Object.values(t).join("-")}`;return s.jsx(it,{customPages:e},o)},hl=({customPages:e})=>{const{routes:t,loading:r,menu:o,pageTypeRegistry:a,registryError:n}=Se(),i=o.length>0?o[0].uri:null;if(r)return s.jsx("div",{className:"zango-loading",children:"Loading..."});if(n)return s.jsxs("div",{className:"zango-error",children:["Failed to load page registry: ",n]});const c=[],d=[];return a&&t.forEach(l=>{const u=a[l.page_type];u&&u.standalone?c.push(l):d.push(l)}),s.jsxs(H.Routes,{children:[s.jsx(H.Route,{path:"app/login/*",element:s.jsx(dr,{basePath:"/app/login"})}),s.jsx(H.Route,{path:"app/logout",element:s.jsx(To,{})}),s.jsx(H.Route,{path:"app/configuration-error",element:s.jsx(ul,{})}),c.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(f.Fragment,{children:[s.jsx(H.Route,{path:`${u}/*`,element:s.jsx(it,{customPages:e,forceRoute:l})}),s.jsx(H.Route,{path:u,element:s.jsx(it,{customPages:e,forceRoute:l})})]},l.path)}),s.jsxs(H.Route,{path:"/",element:s.jsx(No,{}),children:[s.jsx(H.Route,{index:!0,element:i?s.jsx(H.Navigate,{to:i}):s.jsx("div",{children:"No menu items available"})}),s.jsx(H.Route,{path:"app",element:s.jsx("div",{className:"zango-loading",children:"Redirecting..."})}),d.map(l=>{const u=l.path.startsWith("/")?l.path.slice(1):l.path;return s.jsxs(f.Fragment,{children:[s.jsx(H.Route,{path:`${u}/*`,element:s.jsx(Oo,{customPages:e})}),s.jsx(H.Route,{path:u,element:s.jsx(Oo,{customPages:e})})]},l.path)})]}),s.jsx(H.Route,{path:"*",element:s.jsx(it,{customPages:e,forceRoute:{path:"*",page_type:"404"}})}),s.jsx(H.Route,{path:"/404",element:s.jsx(it,{customPages:e,forceRoute:{path:"/404",page_type:"404"}})})]})},pl=({customPages:e})=>s.jsxs(s.Fragment,{children:[s.jsx(Eo,{}),s.jsx(hl,{customPages:e})]}),fl=({config:e={},customPages:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},appInitializerEndpoint:i})=>(i&&typeof window<"u"&&(console.log("app init endpoint here",i),window.app_initializer_endpoint=i),s.jsx(H.BrowserRouter,{children:s.jsx(bo,{config:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,children:s.jsx(pl,{customPages:t})})})),gl=({customPages:e={},config:t={},layoutConfig:r={},topbarConfig:o={},navbarConfig:a={},customComponents:n={},appInitializerEndpoint:i})=>s.jsxs(s.Fragment,{children:[s.jsx(fl,{config:t,customPages:e,layoutConfig:r,topbarConfig:o,navbarConfig:a,customComponents:n,appInitializerEndpoint:i}),s.jsx(p.Toaster,{position:"bottom-right"})]});class ml{constructor(){this.setupInterceptors()}handleRedirect(t){if(t){const r=window.location.pathname+window.location.search+window.location.hash;if(r==="/app/logout/"||r==="/app/logout"){window.location.href=t;return}const o=encodeURIComponent(r),a=`${t}?next=${o}`;window.location.href=a}}setupInterceptors(){const t=window.fetch,r=this;window.fetch=async(...n)=>{try{const[i,c={}]=n,d=typeof i=="string"?i:i.toString();if(d.startsWith("http")&&!d.startsWith(window.location.origin))return await t(i,c);const u=Date.now().toString(),h=new Headers(c.headers||{});h.set("X-Client-Timestamp",u),h.set("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),h.set("X-Client-Platform",navigator.platform);const w={...c,headers:h},m=await t(i,w),g=window.location.origin+"/login/";return m.url&&m.url===g&&r.handleRedirect("/app/login/"),m}catch(i){throw i}};const o=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(...n){return this._requestUrl=n[1],o.apply(this,n)},XMLHttpRequest.prototype.send=function(...n){const i=this,c=this._requestUrl||"";if(!(c.startsWith("http")&&!c.startsWith(window.location.origin))){const l=Date.now().toString();this.setRequestHeader("X-Client-Timestamp",l),this.setRequestHeader("X-User-Agent",navigator.userAgent),this.setRequestHeader("X-Client-Timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),this.setRequestHeader("X-Client-Platform",navigator.platform)}return this.addEventListener("load",function(){const l=i.responseURL||i._requestUrl,u=window.location.origin+"/login/";l&&l===u&&r.handleRedirect("/app/login/")}),a.apply(this,n)}}}new ml,B.AppProvider=bo,B.CachedLogo=mr,B.CrudPage=es,B.CustomPageFallback=rs,B.CustomPageLoader=ss,B.DocumentHead=Eo,B.Layout=No,B.LoginPage=dr,B.LogoutPage=To,B.Navbar=vo,B.NotFoundPage=jt,B.SmartLink=Nt,B.Topbar=Lo,B.UserProfileDrawer=_o,B.ZangoApp=gl,B.buildApiUrl=me,B.callApi=we,B.callDeleteApi=Cr,B.callGetApi=wr,B.callPatchApi=vr,B.callPostApi=yr,B.callPutApi=br,B.changePassword=Ar,B.changeRole=qr,B.deleteCookie=_e,B.fetchAppInitData=Mr,B.fetchUserProfile=Ur,B.fetchUserSessions=Br,B.generateCSSVariables=pt,B.generatePalette=Be,B.generateQueryString=zo,B.getApiConfig=ba,B.getApiTimeout=Do,B.getApiUrl=ct,B.getAppInitData=xr,B.getColor=Qr,B.getContrastColor=wa,B.getCookie=ur,B.getEndpoint=jo,B.getUserProfile=Pr,B.getUserSessions=Nr,B.isAuthenticatedViaCookie=Po,B.isLightColor=Yr,B.logoCache=Ue,B.logout=Or,B.logoutAllSessions=Tr,B.logoutSession=Er,B.performAppLogout=jr,B.performDirectLogout=Dr,B.performLogout=Fr,B.removeAllSessions=$r,B.removeSession=Vr,B.saveUserProfile=dt,B.setCookie=xo,B.setTwoFactor=Zo,B.switchRole=Lr,B.toggleTwoFactor=_r,B.updatePassword=Ir,B.updateSvgColors=Et,B.updateUserProfile=Sr,B.uploadPhoto=Wo,B.uploadProfilePhoto=kr,B.useApiConfig=Re,B.useAppContext=Se,B.useRouteConfig=ya,B.useSmartNavigation=Co}));
|
|
177
177
|
//# sourceMappingURL=zango-crm-framework.umd.cjs.map
|