Updated flows tree
Deploy Frontend / build-and-deploy (push) Successful in 31s
Details
Deploy Frontend / build-and-deploy (push) Successful in 31s
Details
This commit is contained in:
parent
69d1c11f7d
commit
64ca5fd015
|
|
@ -31,7 +31,7 @@ import { notifications } from '@mantine/notifications'
|
|||
import {
|
||||
useHierarchies,
|
||||
useDeleteHierarchy,
|
||||
useUpdateHierarchy,
|
||||
useUpdateHierarchy, HIERARCHIES_QUERY_KEY,
|
||||
} from '@/features/hierarchies/hooks/useHierarchies'
|
||||
import { useUsers } from '@/features/users/hooks/useUsers'
|
||||
import { useDepartments } from '@/features/departments/hooks/useDepartments'
|
||||
|
|
@ -48,6 +48,8 @@ import ChainDuplicateModal from './components/ChainDuplicateModal'
|
|||
import HierarchyEditModal from './components/HierarchyEditModal'
|
||||
import PersonDuplicateModal from './components/PersonDuplicateModal'
|
||||
import type { UserHierarchy } from '@/types/api'
|
||||
import { hierarchiesApi } from '@/api/hierarchies'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
|
||||
const LIMIT = 20
|
||||
|
||||
|
|
@ -163,6 +165,8 @@ export default function HierarchiesPage() {
|
|||
setSelectedIds([])
|
||||
}
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const handleBulkDelete = () => {
|
||||
modals.openConfirmModal({
|
||||
title: 'Подтвердите массовое удаление',
|
||||
|
|
@ -173,18 +177,21 @@ export default function HierarchiesPage() {
|
|||
</Text>
|
||||
),
|
||||
labels: { confirm: 'Удалить все', cancel: 'Отмена' },
|
||||
confirmProps: { color: 'red' },
|
||||
confirmProps: { color: 'red', loading: isDeleting },
|
||||
onConfirm: async () => {
|
||||
setIsDeleting(true)
|
||||
try {
|
||||
// 🩹 ФИКС: раньше здесь ЕЩЁ было своё notifications.show
|
||||
// ("Удалено записей: N") поверх того, что уже показывает
|
||||
// useDeleteHierarchy в своём onSuccess. Promise.all вызывает
|
||||
// mutateAsync для КАЖДОГО выбранного id — то есть хук и так
|
||||
// покажет уведомление нужное число раз (по одному на запись).
|
||||
// Сводное уведомление сверху давало задвоение: при удалении
|
||||
// одной записи — ровно два одинаковых тоста подряд.
|
||||
await Promise.all(selectedIds.map((id) => deleteHierarchy.mutateAsync(id)))
|
||||
// Удаляем напрямую через API, не вызывая мутацию поштучно
|
||||
await Promise.all(selectedIds.map((id) => hierarchiesApi.delete(id)))
|
||||
|
||||
// Обновляем список один раз
|
||||
queryClient.invalidateQueries({ queryKey: [HIERARCHIES_QUERY_KEY] })
|
||||
|
||||
notifications.show({
|
||||
title: 'Успешно',
|
||||
message: `Успешно удалено записей: ${selectedIds.length}`,
|
||||
color: 'green',
|
||||
})
|
||||
setSelectedIds([])
|
||||
} catch (error) {
|
||||
notifications.show({
|
||||
|
|
@ -209,7 +216,9 @@ export default function HierarchiesPage() {
|
|||
),
|
||||
labels: { confirm: 'Удалить', cancel: 'Отмена' },
|
||||
confirmProps: { color: 'red' },
|
||||
onConfirm: () => deleteHierarchy.mutate(id),
|
||||
onConfirm: async () => {
|
||||
await deleteHierarchy.mutateAsync(id)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue