import Link from 'next/link';
import { useRouter } from 'next/router';
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import DiscordLogo from '../../assets/extlogos/discord.svg';
import SlackLogo from '../../assets/extlogos/slack.svg';
import TelegramLogo from '../../assets/extlogos/telegram.svg';
import PushbulletLogo from '../../assets/extlogos/pushbullet.svg';
import PushoverLogo from '../../assets/extlogos/pushover.svg';
import Bolt from '../../assets/bolt.svg';
import { Field, Form, Formik } from 'formik';
import useSWR from 'swr';
import Error from '../../pages/_error';
import LoadingSpinner from '../Common/LoadingSpinner';
import axios from 'axios';
import { useToasts } from 'react-toast-notifications';
import Button from '../Common/Button';
import PageTitle from '../Common/PageTitle';
import globalMessages from '../../i18n/globalMessages';
const messages = defineMessages({
notifications: 'Notifications',
save: 'Save Changes',
saving: 'Saving…',
notificationsettings: 'Notification Settings',
notificationsettingsDescription:
'Configure global notification settings. The options below will apply to all notification agents.',
notificationAgentsSettings: 'Notification Agents',
notificationAgentSettingsDescription:
'Choose the types of notifications to send, and which notification agents to use.',
notificationsettingssaved: 'Notification settings saved successfully!',
notificationsettingsfailed: 'Notification settings failed to save.',
enablenotifications: 'Enable Notifications',
email: 'Email',
webhook: 'Webhook',
});
interface SettingsRoute {
text: string;
content: React.ReactNode;
route: string;
regex: RegExp;
}
const SettingsNotifications: React.FC = ({ children }) => {
const router = useRouter();
const intl = useIntl();
const { addToast } = useToasts();
const { data, error, revalidate } = useSWR('/api/v1/settings/notifications');
const settingsRoutes: SettingsRoute[] = [
{
text: intl.formatMessage(messages.email),
content: (
{intl.formatMessage(messages.email)}
),
route: '/settings/notifications/email',
regex: /^\/settings\/notifications\/email/,
},
{
text: 'Discord',
content: (
{intl.formatMessage(messages.notificationsettingsDescription)}
{intl.formatMessage(messages.notificationAgentSettingsDescription)}