Remove useAssume from layouts now that we have the /assume page that redirects
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -11,7 +11,7 @@ export function OrganizationErrorBoundary() {
|
||||
|
||||
const search = new URLSearchParams([
|
||||
["organization-id", organizationId],
|
||||
["redirect-path", window.location.href],
|
||||
["redirect-path", window.location.pathname + window.location.search],
|
||||
]);
|
||||
|
||||
if (error instanceof UnAuthenticatedError) {
|
||||
|
||||
@@ -6,7 +6,9 @@ import { PageError } from "./PageError";
|
||||
export function RootErrorBoundary() {
|
||||
const error = useRouteError();
|
||||
|
||||
const search = new URLSearchParams([["redirect-path", window.location.href]]);
|
||||
const search = new URLSearchParams([
|
||||
["redirect-path", window.location.pathname + window.location.search],
|
||||
]);
|
||||
|
||||
if (error instanceof UnAuthenticatedError) {
|
||||
return <Navigate to={{ pathname: "/auth/login", search: "?" + search.toString() }} />;
|
||||
|
||||
@@ -58,7 +58,7 @@ export function useAssume(params: UseAssumeParameters) {
|
||||
if (error instanceof UnAuthenticatedError) {
|
||||
const search = new URLSearchParams([
|
||||
["organization-id", organizationId],
|
||||
["redirect-path", afterAssumePath ?? window.location.href],
|
||||
["redirect-path", afterAssumePath ?? window.location.pathname + window.location.search],
|
||||
]);
|
||||
|
||||
void navigate({ pathname: "/auth/login", search: "?" + search.toString() });
|
||||
@@ -76,7 +76,7 @@ export function useAssume(params: UseAssumeParameters) {
|
||||
switch (result.__typename) {
|
||||
case "PasswordRequired":
|
||||
search.set("organization-id", organizationId);
|
||||
search.set("redirect-path", afterAssumePath ?? window.location.href);
|
||||
search.set("redirect-path", afterAssumePath ?? window.location.pathname + window.location.search);
|
||||
|
||||
void navigate({ pathname: "/auth/passord-login", search: "?" + search.toString() });
|
||||
break;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Skeleton } from "@probo/ui";
|
||||
import { Suspense, useCallback } from "react";
|
||||
import { Suspense, useEffect } from "react";
|
||||
import { useQueryLoader } from "react-relay";
|
||||
|
||||
import type { ViewerMembershipLayoutQuery } from "#/__generated__/iam/ViewerMembershipLayoutQuery.graphql";
|
||||
import { useAssume } from "#/hooks/iam/useAssume";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
import { IAMRelayProvider } from "#/providers/IAMRelayProvider";
|
||||
|
||||
@@ -19,16 +18,9 @@ function ViewerMembershipLayoutQueryLoader() {
|
||||
viewerMembershipLayoutQuery,
|
||||
);
|
||||
|
||||
const onAssumeSuccess = useCallback(
|
||||
() =>
|
||||
loadQuery({
|
||||
organizationId,
|
||||
hideSidebar: false,
|
||||
}),
|
||||
[loadQuery, organizationId],
|
||||
);
|
||||
|
||||
useAssume({ onSuccess: onAssumeSuccess });
|
||||
useEffect(() => {
|
||||
loadQuery({ organizationId, hideSidebar: false });
|
||||
}, [organizationId, loadQuery]);
|
||||
|
||||
if (!queryRef) {
|
||||
return <Skeleton className="w-full h-screen" />;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Skeleton } from "@probo/ui";
|
||||
import { Suspense, useCallback } from "react";
|
||||
import { Suspense, useEffect } from "react";
|
||||
import { useQueryLoader } from "react-relay";
|
||||
|
||||
import type { ViewerMembershipLayoutQuery } from "#/__generated__/iam/ViewerMembershipLayoutQuery.graphql";
|
||||
import { useAssume } from "#/hooks/iam/useAssume";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
import { IAMRelayProvider } from "#/providers/IAMRelayProvider";
|
||||
|
||||
@@ -18,16 +17,9 @@ function EmployeeLayoutQueryLoader() {
|
||||
viewerMembershipLayoutQuery,
|
||||
);
|
||||
|
||||
const onAssumeSuccess = useCallback(
|
||||
() =>
|
||||
loadQuery({
|
||||
organizationId,
|
||||
hideSidebar: false,
|
||||
}),
|
||||
[loadQuery, organizationId],
|
||||
);
|
||||
|
||||
useAssume({ onSuccess: onAssumeSuccess });
|
||||
useEffect(() => {
|
||||
loadQuery({ organizationId, hideSidebar: true });
|
||||
}, [organizationId, loadQuery]);
|
||||
|
||||
if (!queryRef) {
|
||||
return <Skeleton className="w-full h-screen" />;
|
||||
|
||||
@@ -122,7 +122,6 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: "/organizations/:organizationId",
|
||||
ErrorBoundary: OrganizationErrorBoundary,
|
||||
children: [
|
||||
{
|
||||
path: "assume",
|
||||
@@ -130,6 +129,7 @@ const routes = [
|
||||
},
|
||||
{
|
||||
path: "employee",
|
||||
ErrorBoundary: OrganizationErrorBoundary,
|
||||
Component: lazy(
|
||||
() => import("./pages/organizations/employee/EmployeeLayoutLoader"),
|
||||
),
|
||||
@@ -154,6 +154,7 @@ const routes = [
|
||||
Component: lazy(
|
||||
() => import("./pages/iam/organizations/ViewerMembershipLayoutLoader"),
|
||||
),
|
||||
ErrorBoundary: OrganizationErrorBoundary,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
|
||||
Reference in New Issue
Block a user