Files
adminka-frontend/src/features/admin/hooks/useCreateOrganizationWallets.ts
2026-06-10 16:56:59 +03:00

19 lines
901 B
TypeScript

import { useMutation, useQueryClient } from '@tanstack/react-query'
import { createOrganizationWallets } from '../api/adminApi'
import { ORGANIZATIONS_QUERY_KEY } from './useOrganizations'
import { ORGANIZATION_QUERY_KEY } from './useOrganization'
import { WALLETS_QUERY_KEY } from './useOrganizationWallets'
export function useCreateOrganizationWallets() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (organizationId: string) => createOrganizationWallets(organizationId),
onSuccess: (_result, organizationId) => {
// `has_wallets` flips to true server-side — refresh list and detail view.
queryClient.invalidateQueries({ queryKey: ORGANIZATIONS_QUERY_KEY })
queryClient.invalidateQueries({ queryKey: ORGANIZATION_QUERY_KEY(organizationId) })
queryClient.invalidateQueries({ queryKey: WALLETS_QUERY_KEY(organizationId) })
},
})
}