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:
1 parent
8b50f419e5
commit
497b0804d3
15 files changed
+360
-29
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user