Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company 👇

655 B
Raw Blame
// ===================
// ©AngelaMos | 2026
// useDeleteToken.ts
// ===================

import { useMutation, useQueryClient } from '@tanstack/react-query'
import { apiDelete } from '../client'

const MANAGE_PATH_PREFIX = '/m/'
const MANAGE_KEY_PREFIX = ['canary', 'manage'] as const

export function useDeleteToken() {
  const queryClient = useQueryClient()
  return useMutation<void, Error, string>({
    mutationFn: (manageId) =>
      apiDelete(`${MANAGE_PATH_PREFIX}${encodeURIComponent(manageId)}`),
    onSuccess: (_data, manageId) => {
      queryClient.removeQueries({
        queryKey: [...MANAGE_KEY_PREFIX, manageId],
      })
    },
  })
}