Add support for deleting event themes
This commit introduces functionality to delete event themes via the API. It includes type definitions, SDK methods, and a React Query mutation for `deleteEventTheme`. Users can perform both soft and hard deletes with this implementation.
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
getCurrentUserInfo,
|
||||
listEventThemes,
|
||||
createEventTheme,
|
||||
deleteEventTheme,
|
||||
getEventTheme,
|
||||
updateEventTheme,
|
||||
createEvent,
|
||||
@@ -44,6 +45,8 @@ import type {
|
||||
CreateEventThemeData,
|
||||
CreateEventThemeError,
|
||||
CreateEventThemeResponse,
|
||||
DeleteEventThemeData,
|
||||
DeleteEventThemeError,
|
||||
GetEventThemeData,
|
||||
UpdateEventThemeData,
|
||||
UpdateEventThemeError,
|
||||
@@ -387,6 +390,26 @@ export const createEventThemeMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const deleteEventThemeMutation = (
|
||||
options?: Partial<Options<DeleteEventThemeData>>,
|
||||
) => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
unknown,
|
||||
AxiosError<DeleteEventThemeError>,
|
||||
Options<DeleteEventThemeData>
|
||||
> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await deleteEventTheme({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getEventThemeQueryKey = (options: Options<GetEventThemeData>) =>
|
||||
createQueryKey("getEventTheme", options);
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ import type {
|
||||
CreateEventThemeData,
|
||||
CreateEventThemeResponse,
|
||||
CreateEventThemeError,
|
||||
DeleteEventThemeData,
|
||||
DeleteEventThemeError,
|
||||
GetEventThemeData,
|
||||
GetEventThemeResponse,
|
||||
GetEventThemeError,
|
||||
@@ -287,6 +289,29 @@ export const createEventTheme = <ThrowOnError extends boolean = false>(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Delete Theme
|
||||
* Delete specific theme by ID.
|
||||
*/
|
||||
export const deleteEventTheme = <ThrowOnError extends boolean = false>(
|
||||
options: Options<DeleteEventThemeData, ThrowOnError>,
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).delete<
|
||||
unknown,
|
||||
DeleteEventThemeError,
|
||||
ThrowOnError
|
||||
>({
|
||||
security: [
|
||||
{
|
||||
scheme: "bearer",
|
||||
type: "http",
|
||||
},
|
||||
],
|
||||
url: "/api/v1/event_themes/{theme_id}",
|
||||
...options,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Theme
|
||||
* Get specific theme by ID.
|
||||
|
||||
@@ -413,6 +413,37 @@ export type CreateEventThemeResponses = {
|
||||
export type CreateEventThemeResponse =
|
||||
CreateEventThemeResponses[keyof CreateEventThemeResponses];
|
||||
|
||||
export type DeleteEventThemeData = {
|
||||
body?: never;
|
||||
path: {
|
||||
theme_id: string;
|
||||
};
|
||||
query?: {
|
||||
/**
|
||||
* Perform hard delete instead of soft delete
|
||||
*/
|
||||
hard_delete?: boolean;
|
||||
};
|
||||
url: "/api/v1/event_themes/{theme_id}";
|
||||
};
|
||||
|
||||
export type DeleteEventThemeErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type DeleteEventThemeError =
|
||||
DeleteEventThemeErrors[keyof DeleteEventThemeErrors];
|
||||
|
||||
export type DeleteEventThemeResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: unknown;
|
||||
};
|
||||
|
||||
export type GetEventThemeData = {
|
||||
body?: never;
|
||||
path: {
|
||||
|
||||
Reference in New Issue
Block a user