import { LoaderFunctionArgs, MetaFunction, redirect } from "react-router"; import { Outlet, useLocation, useNavigate, useParams } from "react-router"; import { getTranslations } from "~/locale/i18next.server"; import { useEffect } from "react"; import { getTenantIdFromUrl } from "~/utils/services/.server/urlService"; import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService"; import TabsVertical from "~/components/ui/tabs/TabsVertical"; import { useTranslation } from "react-i18next"; import UrlUtils from "~/utils/app/UrlUtils"; export const meta: MetaFunction = ({ data }) => [{ title: data?.title }]; type LoaderData = { title: string; }; export const loader = async ({ request, params }: LoaderFunctionArgs) => { const { t } = await getTranslations(request); const tenantId = await getTenantIdFromUrl(params); await verifyUserHasPermission(request, "app.settings.roles.view", tenantId); if (UrlUtils.stripTrailingSlash(new URL(request.url).pathname) === UrlUtils.currentTenantUrl(params, "settings/roles-and-permissions")) { throw redirect(UrlUtils.currentTenantUrl(params, "settings/roles-and-permissions/users")); } const data: LoaderData = { title: `${t("models.role.plural")} | ${process.env.APP_NAME}`, }; return data; }; export default function AdminAccountUsersFromTenant() { const { t } = useTranslation(); const params = useParams(); const location = useLocation(); const navigate = useNavigate(); useEffect(() => { if (UrlUtils.stripTrailingSlash(location.pathname) === UrlUtils.currentTenantUrl(params, "settings/roles-and-permissions")) { navigate(UrlUtils.currentTenantUrl(params, "settings/roles-and-permissions/users")); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [location.pathname]); return (
); }