Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

729 B
Raw Blame
import {useMutation, useQueryClient} from "@tanstack/react-query";
import {IdParam} from "../types.ts";
import {locationClient, UpsertLocationPayload} from "../api/location.client.ts";
import {GET_ORGANIZER_LOCATIONS_QUERY_KEY} from "../queries/useGetOrganizerLocations.ts";

export const useCreateLocation = () => {
    const queryClient = useQueryClient();

    return useMutation({
        mutationFn: ({organizerId, payload}: {organizerId: IdParam; payload: UpsertLocationPayload}) =>
            locationClient.create(organizerId, payload),
        onSuccess: (_, variables) => {
            return queryClient.invalidateQueries({queryKey: [GET_ORGANIZER_LOCATIONS_QUERY_KEY, variables.organizerId]});
        },
    });
};