import { Button, Code, Menu, PasswordInput, Stack, Text } from '@mantine/core'; import { useForm } from '@mantine/form'; import { openModal } from '@mantine/modals'; import { showNotification } from '@mantine/notifications'; import { IconEdit, IconEditOff } from '@tabler/icons-react'; import axios from 'axios'; import { Trans, useTranslation } from 'next-i18next'; import { useEditModeInformationStore } from '../../../../hooks/useEditModeInformation'; function ModalContent() { const { t } = useTranslation('settings/general/edit-mode-toggle'); const form = useForm({ initialValues: { triedPassword: '', }, }); return (
{ axios .post('/api/configs/tryPassword', { tried: values.triedPassword, type: 'edit' }) .then((res) => { showNotification({ title: t('notification.success.title'), message: t('notification.success.message'), color: 'green', }); setTimeout(() => { window.location.reload(); }, 500); }) .catch((_) => { showNotification({ title: t('notification.error.title'), message: t('notification.error.message'), color: 'red', }); }); })} > }} />
); } export function EditModeToggle() { const { editModeEnabled } = useEditModeInformationStore(); const Icon = editModeEnabled ? IconEdit : IconEditOff; const { t } = useTranslation('settings/general/edit-mode-toggle'); return ( } onClick={() => openModal({ title: t('menu.toggle'), centered: true, size: 'lg', children: , }) } > {editModeEnabled ? t('menu.enable') : t('menu.disable')} ); }