'use client'; import { useState, useEffect } from 'react'; import { useNotification } from '@/app/context/NotificationContext'; import GrantSudoLink from '@/app/components/GrantSudoLink'; export default function ConfigurePage() { const [config, setConfig] = useState(''); const { showNotification } = useNotification(); const [showDialog, setShowDialog] = useState(false); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); // Function to fetch the DHCP configuration const fetchConfig = async () => { try { const response = await fetch('/api/dhcp/config'); const data = await response.json(); if (response.ok) { setConfig(data.config); showNotification('DHCP configuration loaded successfully.', 'success'); } else { showNotification(data.error, 'error'); } } catch (error) { showNotification('Error loading DHCP configuration', 'error'); } }; useEffect(() => { // Initial load of the DHCP configuration fetchConfig(); }, []); const handleConfigChange = (event) => { setConfig(event.target.value); }; const handleSave = async () => { try { const response = await fetch('/api/dhcp/config', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ config }), }); const data = await response.json(); if (response.ok) { showNotification('DHCP configuration updated and server restarted successfully.', 'success'); } else { showNotification(data.error, 'error'); } } catch (error) { showNotification('Error updating configuration or restarting server', 'error'); } }; return (

Configure DHCP Options