31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
|
|
import { getQueryKey } from "@trpc/react-query";
|
||
|
|
import { api } from "../trpc"; // Adjust path as necessary
|
||
|
|
import { useQueryClient } from "@tanstack/react-query";
|
||
|
|
import { ObjectType } from "@nice/common";
|
||
|
|
import { CrudOperation, emitDataChange } from "../../event";
|
||
|
|
|
||
|
|
export function useSport() {
|
||
|
|
const queryClient = useQueryClient();
|
||
|
|
const queryKey = getQueryKey(api.sportProject);
|
||
|
|
const queryKeyStandard = getQueryKey(api.sportStandard);
|
||
|
|
|
||
|
|
const createSportProject = api.sportProject.create.useMutation({
|
||
|
|
onSuccess: (result) => {
|
||
|
|
queryClient.invalidateQueries({ queryKey });
|
||
|
|
emitDataChange(ObjectType.SPORT_PROJECT, result, CrudOperation.CREATED);
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
const createSportStandard = api.sportStandard.createStandard.useMutation({
|
||
|
|
onSuccess: (result) => {
|
||
|
|
queryClient.invalidateQueries({ queryKey: queryKeyStandard });
|
||
|
|
emitDataChange(ObjectType.SPORT_STANDARD, result, CrudOperation.CREATED);
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
return {
|
||
|
|
createSportProject,
|
||
|
|
//createSportStandard
|
||
|
|
};
|
||
|
|
}
|