feat: role system fix

This commit is contained in:
2026-03-18 21:38:50 +03:00
parent c3127b8d47
commit 591ca8104d
14 changed files with 267 additions and 183 deletions

View File

@@ -90,7 +90,7 @@ export const CountryListPage = observer(() => {
)}
</div>
{ids.length > 0 && (
{canWriteCountries && ids.length > 0 && (
<div className="flex justify-end mb-5 duration-300">
<button
className="px-4 py-2 bg-red-500 text-white rounded flex gap-2 items-center"
@@ -105,25 +105,37 @@ export const CountryListPage = observer(() => {
<DataGrid
rows={rows || []}
columns={columns}
checkboxSelection={authStore.canWrite("countries")}
checkboxSelection={canWriteCountries}
disableRowSelectionExcludeModel
loading={isLoading}
paginationModel={paginationModel}
onPaginationModelChange={setPaginationModel}
pageSizeOptions={[50]}
localeText={ruRU.components.MuiDataGrid.defaultProps.localeText}
onRowSelectionModelChange={(newSelection: any) => {
if (Array.isArray(newSelection)) {
const selectedIds = newSelection.map((id: string | number) => Number(id));
setIds(selectedIds);
} else if (newSelection && typeof newSelection === 'object' && 'ids' in newSelection) {
const idsSet = newSelection.ids as Set<string | number>;
const selectedIds = Array.from(idsSet).map((id: string | number) => Number(id));
setIds(selectedIds);
} else {
setIds([]);
}
}}
onRowSelectionModelChange={
canWriteCountries
? (newSelection: any) => {
if (Array.isArray(newSelection)) {
const selectedIds = newSelection.map(
(id: string | number) => Number(id)
);
setIds(selectedIds);
} else if (
newSelection &&
typeof newSelection === "object" &&
"ids" in newSelection
) {
const idsSet = newSelection.ids as Set<string | number>;
const selectedIds = Array.from(idsSet).map(
(id: string | number) => Number(id)
);
setIds(selectedIds);
} else {
setIds([]);
}
}
: undefined
}
slots={{
noRowsOverlay: () => (
<Box sx={{ mt: 5, textAlign: "center", color: "text.secondary" }}>