import { useMutation, useQueryClient, } from '@tanstack/react-query';
import { NullSeamClientError, useSeamClient } from '../../../lib/seam/use-seam-client.js';
export function useCreateAccessCode() {
    const { client } = useSeamClient();
    const queryClient = useQueryClient();
    return useMutation({
        mutationFn: async (variables) => {
            if (client === null)
                throw new NullSeamClientError();
            return await client.accessCodes.create(variables);
        },
        onSuccess: (data) => {
            queryClient.setQueryData(['access_codes', 'get', { access_code_id: data.access_code_id }], data);
            void queryClient.invalidateQueries({ queryKey: ['access_codes', 'list'] });
        },
    });
}
//# sourceMappingURL=use-create-access-code.js.map