feat(client): add resize button and status badge to GalleryGrid

This commit is contained in:
Kirill
2026-05-17 18:09:12 +05:00
parent cf6b5da4fc
commit 5411f8ae24
2 changed files with 71 additions and 20 deletions
@@ -6,7 +6,7 @@ import Stack from '@mui/material/Stack'
import Typography from '@mui/material/Typography'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { fetchAdminCatalogSlider } from '@/entities/catalog-slider'
import { deleteGalleryImage, fetchAdminGallery, GalleryGrid } from '@/entities/gallery'
import { deleteGalleryImage, fetchAdminGallery, GalleryGrid, resizeGalleryImage } from '@/entities/gallery'
import { uploadAdminProductImages } from '@/entities/product/api/product-api'
import { formatAdminImageMaxSizeHint } from '@/shared/constants/upload-limits'
import { invalidateQueryKeys } from '@/shared/lib/invalidate-query-keys'
@@ -50,6 +50,13 @@ export function AdminGalleryPage() {
},
})
const resizeMut = useMutation({
mutationFn: (id: string) => resizeGalleryImage(id),
onSuccess: () => {
void invalidateQueryKeys(queryClient, [['admin', 'gallery'], ['admin', 'catalog-slider'], ['catalog-slider']])
},
})
const items = galleryQuery.data?.items ?? []
return (
@@ -122,7 +129,13 @@ export function AdminGalleryPage() {
</Typography>
)}
<GalleryGrid items={items} deleting={deleteMut.isPending} onDelete={(id) => deleteMut.mutate(id)} />
<GalleryGrid
items={items}
deleting={deleteMut.isPending}
resizing={resizeMut.isPending ? (resizeMut.variables ?? null) : null}
onDelete={(id) => deleteMut.mutate(id)}
onResize={(id) => resizeMut.mutate(id)}
/>
{!galleryQuery.isLoading && items.length === 0 && (
<Typography color="text.secondary">Пока нет загруженных изображений.</Typography>