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