23 lines
624 B
TypeScript
23 lines
624 B
TypeScript
import { useMutation } from "@tanstack/react-query";
|
|
import { createParticle } from "@/lib/firestore-particles";
|
|
import type { ParticleType, ParticlePropertiesMap } from "@/api/types";
|
|
|
|
interface CreateParticleParams<T extends ParticleType = ParticleType> {
|
|
collectionPath: string;
|
|
type: T;
|
|
properties: ParticlePropertiesMap[T];
|
|
createdByEmail: string;
|
|
}
|
|
|
|
export function useCreateParticle() {
|
|
return useMutation({
|
|
mutationFn: (params: CreateParticleParams) =>
|
|
createParticle(
|
|
params.collectionPath,
|
|
params.type,
|
|
params.properties,
|
|
params.createdByEmail,
|
|
),
|
|
});
|
|
}
|