feat: Add edit pages with cache

This commit is contained in:
2025-06-08 08:33:43 +03:00
parent e37f9e14bc
commit b09c1b3214
37 changed files with 2223 additions and 772 deletions

View File

@ -1,23 +1,29 @@
import { Paper } from "@mui/material";
import { countryStore } from "@shared";
import { countryStore, languageStore } from "@shared";
import { observer } from "mobx-react-lite";
import { ArrowLeft } from "lucide-react";
import { useEffect } from "react";
import { useNavigate, useParams } from "react-router-dom";
import { LanguageSwitcher } from "@widgets";
export const CountryPreviewPage = observer(() => {
const { id } = useParams();
const { getCountry, country } = countryStore;
const { getCountry, country, setEditCountryData } = countryStore;
const navigate = useNavigate();
const { language } = languageStore;
useEffect(() => {
(async () => {
await getCountry(id as string);
if (id) {
const data = await getCountry(id as string, language);
setEditCountryData(data.name, language);
}
})();
}, [id]);
}, [id, language]);
return (
<Paper className="w-full h-full p-3 flex flex-col gap-10">
<LanguageSwitcher />
<div className="flex justify-between items-center">
<button
className="flex items-center gap-2"
@ -45,11 +51,11 @@ export const CountryPreviewPage = observer(() => {
</Button>
</div> */}
</div>
{country && (
{country[id!]?.[language] && (
<div className="flex flex-col gap-10 w-full">
<div className="flex flex-col gap-2">
<h1 className="text-lg font-bold">Название</h1>
<p>{country?.name}</p>
<p>{country[id!]?.[language]?.name}</p>
</div>
</div>
)}