-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into workflow_link_issue
- Loading branch information
Showing
5 changed files
with
150 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/platform/atoms/hooks/event-types/private/useDeleteEventTypeById.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useMutation } from "@tanstack/react-query"; | ||
|
||
import { V2_ENDPOINTS, SUCCESS_STATUS } from "@calcom/platform-constants"; | ||
import type { ApiResponse, ApiSuccessResponse } from "@calcom/platform-types"; | ||
import type { EventType } from "@calcom/prisma/client"; | ||
|
||
import http from "../../../lib/http"; | ||
|
||
export const QUERY_KEY = "use-delete-event-by-id"; | ||
export type UseDeleteEventTypeProps = { | ||
onSuccess?: () => void; | ||
onError?: (err: Error) => void; | ||
onSettled?: () => void; | ||
}; | ||
export const useDeleteEventTypeById = ({ onSuccess, onError, onSettled }: UseDeleteEventTypeProps) => { | ||
return useMutation({ | ||
onSuccess, | ||
onError, | ||
onSettled, | ||
mutationFn: (id: number) => { | ||
if (!id) throw new Error("Event type id is required"); | ||
const pathname = `/${V2_ENDPOINTS.eventTypes}/${id}`; | ||
return http?.delete<ApiResponse<EventType>>(pathname).then((res) => { | ||
if (res.data.status === SUCCESS_STATUS) { | ||
return (res.data as ApiSuccessResponse<EventType>).data; | ||
} | ||
throw new Error(res.data.error.message); | ||
}); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters