import { api } from "../trpc";

export function useRole() {
    const utils = api.useUtils();

    return {
        // Create mutations
        create: api.role.create.useMutation({
            onSuccess: () => utils.role.findMany.invalidate(),
        }),
        createMany: api.role.createMany.useMutation({
            onSuccess: () => utils.role.findMany.invalidate(),
        }),
        update: api.role.update.useMutation({
            onSuccess: () => utils.role.findMany.invalidate(),
        }),
        // Delete mutation
        softDeleteByIds: api.role.softDeleteByIds.useMutation({
            onSuccess: () => utils.role.findMany.invalidate(),
        }),

        // Update mutation
        updateOrder: api.role.updateOrder.useMutation({
            onSuccess: () => utils.role.findMany.invalidate(),
        }),

        // Queries
        findFirst: api.role.findFirst.useQuery,
        findMany: api.role.findMany.useQuery,
        findManyWithCursor: api.role.findManyWithCursor.useQuery,
        findManyWithPagination: api.role.findManyWithPagination.useQuery,
    };
}