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