mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-18 16:07:10 +00:00
fix: use pathname to get channel id while saving (#8303)
This commit is contained in:
parent
4f7d84aa37
commit
81fcca3bd3
@ -28,7 +28,6 @@ import { useNotifications } from 'hooks/useNotifications';
|
|||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useParams } from 'react-router-dom';
|
|
||||||
import APIError from 'types/api/error';
|
import APIError from 'types/api/error';
|
||||||
|
|
||||||
function EditAlertChannels({
|
function EditAlertChannels({
|
||||||
@ -53,7 +52,11 @@ function EditAlertChannels({
|
|||||||
const [savingState, setSavingState] = useState<boolean>(false);
|
const [savingState, setSavingState] = useState<boolean>(false);
|
||||||
const [testingState, setTestingState] = useState<boolean>(false);
|
const [testingState, setTestingState] = useState<boolean>(false);
|
||||||
const { notifications } = useNotifications();
|
const { notifications } = useNotifications();
|
||||||
const { id } = useParams<{ id: string }>();
|
|
||||||
|
// Extract channelId from URL pathname since useParams doesn't work in nested routing
|
||||||
|
const { pathname } = window.location;
|
||||||
|
const channelIdMatch = pathname.match(/\/settings\/channels\/edit\/([^/]+)/);
|
||||||
|
const id = channelIdMatch ? channelIdMatch[1] : '';
|
||||||
|
|
||||||
const [type, setType] = useState<ChannelType>(
|
const [type, setType] = useState<ChannelType>(
|
||||||
initialValue?.type ? (initialValue.type as ChannelType) : ChannelType.Slack,
|
initialValue?.type ? (initialValue.type as ChannelType) : ChannelType.Slack,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user