/**
 * Redeemable credit codes managed by admins with the add_credits permission
 * @generated by @constructive-io/graphql-codegen
 * DO NOT EDIT - changes will be overwritten
 */
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { getClient } from '../client';
import { buildSelectionArgs } from '../selection';
import { appLimitCreditCodeKeys } from '../query-keys';
import { appLimitCreditCodeMutationKeys } from '../mutation-keys';
export function useDeleteAppLimitCreditCodeMutation(params) {
    const args = buildSelectionArgs(params.selection);
    const { selection: _selection, ...mutationOptions } = params ?? {};
    void _selection;
    const queryClient = useQueryClient();
    return useMutation({
        mutationKey: appLimitCreditCodeMutationKeys.all,
        mutationFn: ({ id }) => getClient()
            .appLimitCreditCode.delete({
            where: {
                id,
            },
            select: args.select,
        })
            .unwrap(),
        onSuccess: (_, variables) => {
            queryClient.removeQueries({
                queryKey: appLimitCreditCodeKeys.detail(variables.id),
            });
            queryClient.invalidateQueries({
                queryKey: appLimitCreditCodeKeys.lists(),
            });
        },
        ...mutationOptions,
    });
}
