The useEventTypes returns all event types associated with a user. Simply provide a username to fetch all their available event types. This hook is useful when you need to display or manage a user’s entire collection of event configurations.Below code snippet shows how to use the useEventTypes hook to fetch the event types of a specific user.
The useTeamEventTypes returns all event types associated with a team. Simply provide the team id to fetch all their available event types. This hook is useful when you need to display or manage a team’s entire collection of event configurations.Below code snippet shows how to use the useTeamEventTypes hook to fetch the event types of a team.
The useEventTypeById returns data for a specific event type, provided you pass in the correct event type id. This hook is useful when you need to display or manage a specific event type.Below code snippet shows how to use the useEventTypeById hook to fetch a specific event type.
The useCreateEventType hook allows you to create a new event type. This hook returns a mutation function that handles the event type creation process. The mutation function accepts an object with the following properties: lengthInMinutes which is the length of the event in minutes, title which is the title of the event, slug which is the slug of the event, and description which is the description of the event.Below code snippet shows how to use the useCreateEventType hook to set up an event type.
Copy
Ask AI
import { useCreateEventType } from "@calcom/atoms";export default function CreateEventType() { const { mutate: createEventType, isPending } = useCreateEventType({ onSuccess: () => { console.log("Event type created successfully!"); }, onError: () => { console.log("Error creating event type"); }, }); return ( <> <button disabled={isPending} onClick={() => { createEventType({ lengthInMinutes: 15, title: "Coffee chat", slug: "coffee-chat", description: "Quick chat about coffee and life in general!", }) }}> Create event type </button> </> );}
The useCreateTeamEventType hook allows you to create a new team event type. This hook returns a mutation function that handles the event type creation process. The mutation function accepts an object with the following properties: lengthInMinutes which is the length of the event in minutes, title which is the title of the event, slug which is the slug of the event, description which is the description of the event, schedulingType which can be either COLLECTIVE, ROUND_ROBIN or MANAGED, hosts which is an array of hosts for the event and the teamId which is the id of the team.Below code snippet shows how to use the useCreateTeamEventType hook to set up a team event type.
Copy
Ask AI
import { useCreateTeamEventType } from "@calcom/atoms";export default function CreateTeamEventType() { const { mutate: createTeamEventType, isPending } = useCreateTeamEventType({ onSuccess: () => { console.log("Event type created successfully!"); }, onError: () => { console.log("Error creating event type"); }, }); return ( <> <button disabled={isPending} onClick={() => { createTeamEventType({ lengthInMinutes: 30, title: "Daily standup", slug: "daily-standup", description: "Daily standup for the team", schedulingType: "COLLECTIVE", hosts: [{"userId": 1456}, {"userId": 2357}], teamId: 1234, }) }}> Create team event type </button> </> );}