palash-signoz 01bad0f18a
chore: eslint fix (#884)
* chore: eslint is updated

* chore: some eslint fixes are made

* chore: some more eslint fix are updated

* chore: some eslint fix is made

* chore: styled components type is added

* chore: some more eslint fix are made

* chore: some more eslint fix are updated

* chore: some more eslint fix are updated

* fix: eslint fixes

Co-authored-by: Pranshu Chittora <pranshu@signoz.io>
2022-03-24 12:06:57 +05:30

52 lines
1.1 KiB
TypeScript

import { Typography } from 'antd';
import get from 'api/channels/get';
import Spinner from 'components/Spinner';
import { SlackChannel } from 'container/CreateAlertChannels/config';
import EditAlertChannels from 'container/EditAlertChannels';
import useFetch from 'hooks/useFetch';
import React from 'react';
import { useParams } from 'react-router-dom';
import { PayloadProps, Props } from 'types/api/channels/get';
function ChannelsEdit(): JSX.Element {
const { id } = useParams<Params>();
const { errorMessage, payload, error, loading } = useFetch<
PayloadProps,
Props
>(get, {
id,
});
if (error) {
return <Typography>{errorMessage}</Typography>;
}
if (loading || payload === undefined) {
return <Spinner tip="Loading Channels..." />;
}
const { data } = payload;
const value = JSON.parse(data);
const channel: SlackChannel = value.slack_configs[0];
return (
<EditAlertChannels
{...{
initialValue: {
...channel,
type: 'slack',
name: value.name,
},
}}
/>
);
}
interface Params {
id: string;
}
export default ChannelsEdit;