import { api } from "../trpc"; // Adjust path as necessary
import { useQueryClient } from "@tanstack/react-query";
import { ObjectType, Staff } from "@nice/common";
import { findQueryData } from "../utils";
import { CrudOperation, emitDataChange } from "../../event";
import { useEntity } from "./useEntity";
export function useStaff() {
    const queryClient = useQueryClient()
    const getStaff = (key: string) => {
        return findQueryData<Staff>(queryClient, api.staff, key);
    };
    return {
        ...useEntity("staff", {
            create: {
                onSuccess(result) {
                    emitDataChange(ObjectType.STAFF, result, CrudOperation.CREATED)
                }
            },
            update: {
                onSuccess(result) {
                    emitDataChange(ObjectType.STAFF, result, CrudOperation.UPDATED)
                },
            }
        }),
        getStaff
    }

}
