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) }) }, }) }