feat: update color carrier
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { DataGrid, GridColDef, GridRenderCellParams } from "@mui/x-data-grid";
|
||||
import { ruRU } from "@mui/x-data-grid/locales";
|
||||
import { authStore, countryStore, languageStore, SearchInput } from "@shared";
|
||||
import { authStore, countryStore, languageStore, selectedCityStore, SearchInput } from "@shared";
|
||||
import { useEffect, useState, useMemo } from "react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Trash2, Minus } from "lucide-react";
|
||||
@@ -74,15 +74,20 @@ export const CountryListPage = observer(() => {
|
||||
];
|
||||
|
||||
const rows = useMemo(() => {
|
||||
const { selectedCity } = selectedCityStore;
|
||||
if (!selectedCity) {
|
||||
return [];
|
||||
}
|
||||
const query = searchQuery.trim().toLowerCase();
|
||||
return (countries[language]?.data ?? [])
|
||||
.filter((country) => country.code === selectedCity.country_code)
|
||||
.filter((country) => !query || (country.name ?? "").toLowerCase().includes(query))
|
||||
.map((country) => ({
|
||||
id: country.code,
|
||||
code: country.code,
|
||||
name: country.name,
|
||||
}));
|
||||
}, [countries[language]?.data, searchQuery]);
|
||||
}, [countries[language]?.data, searchQuery, selectedCityStore.selectedCity]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -92,7 +97,11 @@ export const CountryListPage = observer(() => {
|
||||
<div className="flex justify-between items-center mb-10">
|
||||
<h1 className="text-2xl">Страны</h1>
|
||||
{canWriteCountries && (
|
||||
<CreateButton label="Добавить страну" path="/country/add" />
|
||||
<CreateButton
|
||||
label="Добавить страну"
|
||||
path="/country/add"
|
||||
disabled={!selectedCityStore.selectedCityId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -148,7 +157,13 @@ export const CountryListPage = observer(() => {
|
||||
slots={{
|
||||
noRowsOverlay: () => (
|
||||
<Box sx={{ mt: 5, textAlign: "center", color: "text.secondary" }}>
|
||||
{isLoading ? <CircularProgress size={20} /> : "Нет стран"}
|
||||
{isLoading ? (
|
||||
<CircularProgress size={20} />
|
||||
) : !selectedCityStore.selectedCityId ? (
|
||||
"Выберите город"
|
||||
) : (
|
||||
"Нет стран"
|
||||
)}
|
||||
</Box>
|
||||
),
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user