import { Button, Paper, TextField } from "@mui/material"; import { observer } from "mobx-react-lite"; import { ArrowLeft, Save } from "lucide-react"; import { Loader2 } from "lucide-react"; import { useNavigate, useParams } from "react-router-dom"; import { toast } from "react-toastify"; import { countryStore, languageStore } from "@shared"; import { useEffect, useState } from "react"; import { LanguageSwitcher } from "@widgets"; export const CountryEditPage = observer(() => { const navigate = useNavigate(); const [isLoading, setIsLoading] = useState(false); const { language } = languageStore; const { id } = useParams(); const { editCountryData, editCountry, getCountry, setEditCountryData } = countryStore; const handleEdit = async () => { try { setIsLoading(true); await editCountry(id as string); toast.success("Страна успешно обновлена"); } catch (error) { toast.error("Ошибка при обновлении страны"); } finally { setIsLoading(false); } }; useEffect(() => { (async () => { if (id) { const data = await getCountry(id as string, language); setEditCountryData(data.name, language); } })(); }, [id, language]); return (
countryStore.setEditCountryData(e.target.value, language) } />
); });