import axiosInstance from '../../../src/axiosSecure'; import { useState, useEffect } from 'react'; import ProtectedRoute from "../../../components/protectedRoute"; import { UserRole } from "@prisma/client"; // Simulate importing locales from a config or define directly here const locales = ['en', 'bg', 'ru']; const AdminTranslations = () => { const [translations, setTranslations] = useState({}); const [locale, setLocale] = useState('en'); useEffect(() => { axiosInstance.get(`/api/translations/${locale}`).then(res => setTranslations(res.data)); }, [locale]); const handleSave = () => { axiosInstance.post(`/api/translations/${locale}/modified`, translations) .then(res => { if (res.data.status === 'Updated') { alert('Translations updated!'); } }); }; const handleChange = (key, value) => { setTranslations(prev => ({ ...prev, [key]: value })); }; return (

Edit Translations

{Object.entries(translations).map(([key, value]) => ( ))}
{key} handleChange(key, e.target.value)} style={{ width: '100%' }} />
); }; export default AdminTranslations;