23 lines
746 B
TypeScript
23 lines
746 B
TypeScript
|
|
import { getQueryKey } from "@trpc/react-query";
|
||
|
|
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";
|
||
|
|
|
||
|
|
|
||
|
|
export function useTrainSituation(){
|
||
|
|
const queryClient = useQueryClient();
|
||
|
|
const queryKey = getQueryKey(api.trainSituation);
|
||
|
|
|
||
|
|
const create = api.trainSituation.create.useMutation({
|
||
|
|
onSuccess: (res:any) => {
|
||
|
|
queryClient.invalidateQueries({ queryKey });
|
||
|
|
emitDataChange(ObjectType.TRAIN_SITUATION, res, CrudOperation.CREATED);
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
return {
|
||
|
|
create
|
||
|
|
}
|
||
|
|
}
|