/** * A tenant's configured account at an email provider: provider slug, endpoint coordinates, and the NAME of the secret holding its credentials (never the credential itself) * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { useMutation, useQueryClient } from '@tanstack/react-query'; import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query'; import { getClient } from '../client'; import { buildSelectionArgs } from '../selection'; import type { SelectionConfig } from '../selection'; import { platformEmailProviderAccountKeys } from '../query-keys'; import { platformEmailProviderAccountMutationKeys } from '../mutation-keys'; import type { PlatformEmailProviderAccountSelect, PlatformEmailProviderAccountWithRelations, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformEmailProviderAccountSelect, PlatformEmailProviderAccountWithRelations, } from '../../orm/input-types'; /** * A tenant's configured account at an email provider: provider slug, endpoint coordinates, and the NAME of the secret holding its credentials (never the credential itself) * * @example * ```tsx * const { mutate, isPending } = useDeletePlatformEmailProviderAccountMutation({ * selection: { fields: { id: true } }, * }); * * mutate({ id: 'value-to-delete' }); * ``` */ export function useDeletePlatformEmailProviderAccountMutation< S extends PlatformEmailProviderAccountSelect, >( params: { selection: { fields: S & PlatformEmailProviderAccountSelect; } & HookStrictSelect, PlatformEmailProviderAccountSelect>; } & Omit< UseMutationOptions< { deletePlatformEmailProviderAccount: { platformEmailProviderAccount: InferSelectResult< PlatformEmailProviderAccountWithRelations, S >; }; }, Error, { id: string; } >, 'mutationFn' > ): UseMutationResult< { deletePlatformEmailProviderAccount: { platformEmailProviderAccount: InferSelectResult; }; }, Error, { id: string; } >; export function useDeletePlatformEmailProviderAccountMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformEmailProviderAccountMutationKeys.all, mutationFn: ({ id }: { id: string }) => getClient() .platformEmailProviderAccount.delete({ where: { id, }, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.removeQueries({ queryKey: platformEmailProviderAccountKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: platformEmailProviderAccountKeys.lists(), }); }, ...mutationOptions, }); }