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'; import axios from 'axios'; import { useEditModeInformationStore } from '../../../../hooks/useEditModeInformation'; function ModalContent() { const form = useForm({ initialValues: { triedPassword: '', }, }); return (
{ axios.post('/api/configs/tryToggleEdit', { tried: values.triedPassword }).then((res) => { if (res.data.success) { showNotification({ title: 'Success', message: 'Successfully toggled edit mode, reloading the page...', color: 'green', }); setTimeout(() => { window.location.reload(); }, 500); } else { showNotification({ title: 'Wrong password', message: 'The password you entered is wrong.', color: 'red', }); } }); })} > In order to toggle edit mode, you need to enter the password you entered in the environment variable named EDIT_MODE_PASSWORD
); } export function EditModeToggle() { const { editModeEnabled } = useEditModeInformationStore(); const Icon = editModeEnabled ? IconEdit : IconEditOff; return ( } onClick={() => openModal({ title: 'Toggle edit mode', centered: true, size: 'lg', children: , }) } > {editModeEnabled ? 'Enable edit mode' : 'Disable edit mode'} ); }