Refactor client scope mapping to React Router v6 (#4181)

This commit is contained in:
Jon Koops 2023-01-12 10:58:08 +01:00 committed by GitHub
parent e32cdaebec
commit 2e79123bee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,9 +13,9 @@ import {
import { useState } from "react"; import { useState } from "react";
import { FormProvider, useForm } from "react-hook-form"; import { FormProvider, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useRouteMatch } from "react-router-dom"; import { Link, useMatch, useNavigate } from "react-router-dom-v5-compat";
import { Link, useNavigate } from "react-router-dom-v5-compat";
import { toClient } from "../../clients/routes/Client";
import { useAlerts } from "../../components/alert/Alerts"; import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { DynamicComponents } from "../../components/dynamic/DynamicComponents"; import { DynamicComponents } from "../../components/dynamic/DynamicComponents";
@ -53,11 +53,11 @@ export default function MappingDetails() {
const isGuid = /^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/; const isGuid = /^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/;
const isUpdating = !!mapperId.match(isGuid); const isUpdating = !!mapperId.match(isGuid);
const isOnClientScope = !!useRouteMatch(MapperRoute.path); const isOnClientScope = !!useMatch(MapperRoute.path);
const toDetails = () => const toDetails = () =>
isOnClientScope isOnClientScope
? toClientScope({ realm, id, tab: "mappers" }) ? toClientScope({ realm, id, tab: "mappers" })
: `/${realm}/clients/${id}/mappers`; : toClient({ realm, clientId: id, tab: "mappers" });
useFetch( useFetch(
async () => { async () => {