mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(console): close deletion modal on connector changed (#2749)
This commit is contained in:
parent
46260a3410
commit
aaf92a6ef5
1 changed files with 7 additions and 2 deletions
|
@ -1,9 +1,9 @@
|
||||||
import type { ConnectorResponse } from '@logto/schemas';
|
import type { ConnectorResponse } from '@logto/schemas';
|
||||||
import { ConnectorType } from '@logto/schemas';
|
import { ConnectorType } from '@logto/schemas';
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { toast } from 'react-hot-toast';
|
import { toast } from 'react-hot-toast';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||||
import useSWR, { useSWRConfig } from 'swr';
|
import useSWR, { useSWRConfig } from 'swr';
|
||||||
|
|
||||||
import Back from '@/assets/images/back.svg';
|
import Back from '@/assets/images/back.svg';
|
||||||
|
@ -39,6 +39,7 @@ const getConnectorsPathname = (isSocial: boolean) =>
|
||||||
`/connectors/${isSocial ? ConnectorsTabs.Social : ConnectorsTabs.Passwordless}`;
|
`/connectors/${isSocial ? ConnectorsTabs.Social : ConnectorsTabs.Passwordless}`;
|
||||||
|
|
||||||
const ConnectorDetails = () => {
|
const ConnectorDetails = () => {
|
||||||
|
const { pathname } = useLocation();
|
||||||
const { connectorId } = useParams();
|
const { connectorId } = useParams();
|
||||||
const { mutate: mutateGlobal } = useSWRConfig();
|
const { mutate: mutateGlobal } = useSWRConfig();
|
||||||
const [isDeleted, setIsDeleted] = useState(false);
|
const [isDeleted, setIsDeleted] = useState(false);
|
||||||
|
@ -55,6 +56,10 @@ const ConnectorDetails = () => {
|
||||||
const isSocial = data?.type === ConnectorType.Social;
|
const isSocial = data?.type === ConnectorType.Social;
|
||||||
const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState(false);
|
const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsDeleteAlertOpen(false);
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
const onDeleteClick = async () => {
|
const onDeleteClick = async () => {
|
||||||
if (!isSocial || !inUse) {
|
if (!isSocial || !inUse) {
|
||||||
await handleDelete();
|
await handleDelete();
|
||||||
|
|
Loading…
Reference in a new issue