mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-12 18:14:06 +00:00
26 lines
714 B
TypeScript
26 lines
714 B
TypeScript
"use client"
|
|
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
|
import { toast } from "sonner"
|
|
import { authClient } from "@lib/auth"
|
|
|
|
export function useDeleteOrganization() {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation({
|
|
mutationFn: async (organizationId: string) => {
|
|
const res = await authClient.organization.delete({ organizationId })
|
|
if (res?.error) {
|
|
throw new Error(res.error.message || "Failed to delete organization")
|
|
}
|
|
return res?.data
|
|
},
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries()
|
|
toast.success("Organization deleted.")
|
|
},
|
|
onError: (error: Error) => {
|
|
toast.error(error.message || "Failed to delete organization.")
|
|
},
|
|
})
|
|
}
|