Remove ModuleLaunchRedirect component and its associated route from tenant admin routes. Update Modules component to directly open launch URLs in a new tab, streamlining the redirection process.
This commit is contained in:
parent
46e8fd466b
commit
146d47a6a7
@ -1,36 +0,0 @@
|
|||||||
import { useEffect } from 'react';
|
|
||||||
import type { ReactElement } from 'react';
|
|
||||||
import { useSearchParams } from 'react-router-dom';
|
|
||||||
|
|
||||||
const ModuleLaunchRedirect = (): ReactElement => {
|
|
||||||
const [searchParams] = useSearchParams();
|
|
||||||
const launchUrl = searchParams.get('url');
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (launchUrl) {
|
|
||||||
// Make a fetch request with custom headers
|
|
||||||
fetch(launchUrl, {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'bypass-tunnel-reminder': 'true',
|
|
||||||
},
|
|
||||||
credentials: 'include',
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
// Ignore fetch errors, we'll still open the URL
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
// Open the external URL in a new tab
|
|
||||||
window.open(launchUrl, '_blank', 'noopener,noreferrer');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [launchUrl]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center min-h-screen">
|
|
||||||
<div className="text-sm text-[#6b7280]">Redirecting...</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ModuleLaunchRedirect;
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import type { ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { Layout } from '@/components/layout/Layout';
|
import { Layout } from '@/components/layout/Layout';
|
||||||
import {
|
import {
|
||||||
StatusBadge,
|
StatusBadge,
|
||||||
@ -28,7 +27,6 @@ const getStatusVariant = (status: string | null): 'success' | 'failure' | 'proce
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Modules = (): ReactElement => {
|
const Modules = (): ReactElement => {
|
||||||
const navigate = useNavigate();
|
|
||||||
const { roles, tenantId } = useAppSelector((state) => state.auth);
|
const { roles, tenantId } = useAppSelector((state) => state.auth);
|
||||||
// const tenantId = useAppSelector((state) => state.auth.tenantId);
|
// const tenantId = useAppSelector((state) => state.auth.tenantId);
|
||||||
const [modules, setModules] = useState<AssignedModule[]>([]);
|
const [modules, setModules] = useState<AssignedModule[]>([]);
|
||||||
@ -82,9 +80,7 @@ const Modules = (): ReactElement => {
|
|||||||
const launchTenantId = isSuperAdmin ? tenantId : null;
|
const launchTenantId = isSuperAdmin ? tenantId : null;
|
||||||
const response = await moduleService.launch(moduleId, launchTenantId);
|
const response = await moduleService.launch(moduleId, launchTenantId);
|
||||||
if (response.success && response.data.launch_url) {
|
if (response.success && response.data.launch_url) {
|
||||||
// Navigate to redirect page with launch URL as query param
|
window.open(response.data.launch_url, '_blank', 'noopener,noreferrer');
|
||||||
const encodedUrl = encodeURIComponent(response.data.launch_url);
|
|
||||||
navigate(`/tenant/module-launch?url=${encodedUrl}`);
|
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setError(err?.response?.data?.error?.message || 'Failed to launch module');
|
setError(err?.response?.data?.error?.message || 'Failed to launch module');
|
||||||
|
|||||||
@ -8,7 +8,6 @@ const Settings = lazy(() => import('@/pages/tenant/Settings'));
|
|||||||
const Users = lazy(() => import('@/pages/tenant/Users'));
|
const Users = lazy(() => import('@/pages/tenant/Users'));
|
||||||
const AuditLogs = lazy(() => import('@/pages/tenant/AuditLogs'));
|
const AuditLogs = lazy(() => import('@/pages/tenant/AuditLogs'));
|
||||||
const Modules = lazy(() => import('@/pages/tenant/Modules'));
|
const Modules = lazy(() => import('@/pages/tenant/Modules'));
|
||||||
const ModuleLaunchRedirect = lazy(() => import('@/pages/ModuleLaunchRedirect'));
|
|
||||||
|
|
||||||
// Loading fallback component
|
// Loading fallback component
|
||||||
const RouteLoader = (): ReactElement => (
|
const RouteLoader = (): ReactElement => (
|
||||||
@ -55,8 +54,4 @@ export const tenantAdminRoutes: RouteConfig[] = [
|
|||||||
path: '/tenant/settings',
|
path: '/tenant/settings',
|
||||||
element: <LazyRoute component={Settings} />,
|
element: <LazyRoute component={Settings} />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/tenant/module-launch',
|
|
||||||
element: <LazyRoute component={ModuleLaunchRedirect} />,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user