fix: use pathname to get channel id while saving (#8303)

This commit is contained in:
Yunus M 2025-06-19 20:27:32 +05:30 committed by GitHub
parent 4f7d84aa37
commit 81fcca3bd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,