import Switch from '@components/forms/Switch' import Button, { LinkButton } from '@components/shared/Button' import ConnectEmptyState from '@components/shared/ConnectEmptyState' import { BellIcon } from '@heroicons/react/20/solid' import { useWallet } from '@solana/wallet-adapter-react' import { useHeaders } from 'hooks/notifications/useHeaders' import { useIsAuthorized } from 'hooks/notifications/useIsAuthorized' import { useNotificationSettings } from 'hooks/notifications/useNotificationSettings' import { useTranslation } from 'next-i18next' import { NOTIFICATION_API } from 'utils/constants' import NotificationCookieStore from '@store/notificationCookieStore' import mangoStore from '@store/mangoStore' import { createLedgerMessage, createSolanaMessage } from 'utils/notifications' const NotificationSettings = () => { const { t } = useTranslation(['common', 'notifications', 'settings']) const { data, refetch } = useNotificationSettings() const { connected } = useWallet() const wallet = useWallet() const setCookie = NotificationCookieStore((s) => s.setCookie) const headers = useHeaders() const isAuth = useIsAuthorized() const connection = mangoStore((s) => s.connection) const handleSettingChange = async (key: string, val: boolean) => { if (data) { const newSettings = { ...data, [key]: val, } await fetch(`${NOTIFICATION_API}notifications/user/editSettings`, { method: 'POST', headers: headers.headers, body: JSON.stringify({ ...newSettings, }), }) refetch() } } return ( <> {isAuth ? (

{t('settings:limit-order-filled')}

handleSettingChange( 'fillsNotifications', !data?.fillsNotifications, ) } />
) : (
{connected ? (

{t('notifications:unauth-desc')}

createLedgerMessage(wallet, setCookie, connection) } > {t('notifications:sign-using-ledger')}
) : ( )}
)} ) } export default NotificationSettings