feat: create event type atom (#17142)

* feat: create event type atom

* fixup! feat: create event type atom

* fixup! fixup! feat: create event type atom

* docs: base doc for create event type atom
This commit is contained in:
Morgan authored and GitHub committed 2024-10-17 21:51:23 +05:30
1 parent 8b50f419e5
commit 497b0804d3
15 files changed
+360 -29

No files matched your search

+12 -6
View File
@@ -13,12 +13,7 @@ import { trpc } from "@calcom/trpc/react";
export type CreateEventTypeFormValues = z.infer<typeof createEventTypeInput>;
export const useCreateEventType = (
onSuccessMutation: (eventType: EventType) => void,
onErrorMutation: (message: string) => void
) => {
const utils = trpc.useUtils();
const { t } = useLocale();
export const useCreateEventTypeForm = () => {
const form = useForm<CreateEventTypeFormValues>({
defaultValues: {
length: 15,
@@ -37,6 +32,17 @@ export const useCreateEventType = (
}
}, [schedulingTypeWatch]);
return { form, isManagedEventType };
};
export const useCreateEventType = (
onSuccessMutation: (eventType: EventType) => void,
onErrorMutation: (message: string) => void
) => {
const utils = trpc.useUtils();
const { t } = useLocale();
const { form, isManagedEventType } = useCreateEventTypeForm();
const createMutation = trpc.viewer.eventTypes.create.useMutation({
onSuccess: async ({ eventType }) => {
onSuccessMutation(eventType);