diff --git a/frontend/src/client/@tanstack/react-query.gen.ts b/frontend/src/client/@tanstack/react-query.gen.ts index 094cc5a..e43d877 100644 --- a/frontend/src/client/@tanstack/react-query.gen.ts +++ b/frontend/src/client/@tanstack/react-query.gen.ts @@ -19,7 +19,8 @@ import { deleteGuest, getGuest, updateGuest, - setGuestStatusApiV1EventsGuestsGuestIdStatusPatch, + setGuestStatus, + createGuestRsvp, getRsvps, createRsvp, deleteRsvp, @@ -76,9 +77,12 @@ import type { UpdateGuestData, UpdateGuestError, UpdateGuestResponse, - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData, - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError, - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse, + SetGuestStatusData, + SetGuestStatusError, + SetGuestStatusResponse, + CreateGuestRsvpData, + CreateGuestRsvpError, + CreateGuestRsvpResponse, GetRsvpsData, CreateRsvpData, CreateRsvpError, @@ -609,18 +613,57 @@ export const updateGuestMutation = ( return mutationOptions; }; -export const setGuestStatusApiV1EventsGuestsGuestIdStatusPatchMutation = ( - options?: Partial< - Options - >, +export const setGuestStatusMutation = ( + options?: Partial>, ) => { const mutationOptions: UseMutationOptions< - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse, - AxiosError, - Options + SetGuestStatusResponse, + AxiosError, + Options > = { mutationFn: async (localOptions) => { - const { data } = await setGuestStatusApiV1EventsGuestsGuestIdStatusPatch({ + const { data } = await setGuestStatus({ + ...options, + ...localOptions, + throwOnError: true, + }); + return data; + }, + }; + return mutationOptions; +}; + +export const createGuestRsvpQueryKey = ( + options: Options, +) => createQueryKey("createGuestRsvp", options); + +export const createGuestRsvpOptions = ( + options: Options, +) => { + return queryOptions({ + queryFn: async ({ queryKey, signal }) => { + const { data } = await createGuestRsvp({ + ...options, + ...queryKey[0], + signal, + throwOnError: true, + }); + return data; + }, + queryKey: createGuestRsvpQueryKey(options), + }); +}; + +export const createGuestRsvpMutation = ( + options?: Partial>, +) => { + const mutationOptions: UseMutationOptions< + CreateGuestRsvpResponse, + AxiosError, + Options + > = { + mutationFn: async (localOptions) => { + const { data } = await createGuestRsvp({ ...options, ...localOptions, throwOnError: true, diff --git a/frontend/src/client/schemas.gen.ts b/frontend/src/client/schemas.gen.ts index 9894ba1..f8aa7f2 100644 --- a/frontend/src/client/schemas.gen.ts +++ b/frontend/src/client/schemas.gen.ts @@ -1506,6 +1506,29 @@ export const GuestUpdateSchema = { title: "GuestUpdate", } as const; +export const GuestWithRSVPResponseSchema = { + properties: { + guest: { + $ref: "#/components/schemas/GuestRead", + }, + rsvp: { + anyOf: [ + { + $ref: "#/components/schemas/RSVPSchema", + }, + { + type: "null", + }, + ], + }, + }, + type: "object", + required: ["guest"], + title: "GuestWithRSVPResponse", + description: `Combined response model that includes both guest and RSVP information. +This gives the frontend a complete picture of the guest's response in a single object.`, +} as const; + export const HTTPValidationErrorSchema = { properties: { detail: { diff --git a/frontend/src/client/sdk.gen.ts b/frontend/src/client/sdk.gen.ts index a78a7b9..7b2f5d7 100644 --- a/frontend/src/client/sdk.gen.ts +++ b/frontend/src/client/sdk.gen.ts @@ -55,9 +55,12 @@ import type { UpdateGuestData, UpdateGuestResponse, UpdateGuestError, - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData, - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse, - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError, + SetGuestStatusData, + SetGuestStatusResponse, + SetGuestStatusError, + CreateGuestRsvpData, + CreateGuestRsvpResponse, + CreateGuestRsvpError, GetRsvpsData, GetRsvpsResponse, GetRsvpsError, @@ -493,17 +496,12 @@ export const updateGuest = ( /** * Set Guest Status */ -export const setGuestStatusApiV1EventsGuestsGuestIdStatusPatch = < - ThrowOnError extends boolean = false, ->( - options: Options< - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData, - ThrowOnError - >, +export const setGuestStatus = ( + options: Options, ) => { return (options.client ?? _heyApiClient).patch< - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse, - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError, + SetGuestStatusResponse, + SetGuestStatusError, ThrowOnError >({ url: "/api/v1/events/guests/{guest_id}/status", @@ -511,6 +509,26 @@ export const setGuestStatusApiV1EventsGuestsGuestIdStatusPatch = < }); }; +/** + * Process Guest Rsvp + */ +export const createGuestRsvp = ( + options: Options, +) => { + return (options.client ?? _heyApiClient).post< + CreateGuestRsvpResponse, + CreateGuestRsvpError, + ThrowOnError + >({ + url: "/api/v1/events/guests/{guest_id}/rsvp", + ...options, + headers: { + "Content-Type": "application/json", + ...options?.headers, + }, + }); +}; + /** * Read Rsvps */ diff --git a/frontend/src/client/types.gen.ts b/frontend/src/client/types.gen.ts index 75ca693..b2e271c 100644 --- a/frontend/src/client/types.gen.ts +++ b/frontend/src/client/types.gen.ts @@ -240,6 +240,15 @@ export type GuestUpdate = { can_bring_guests?: boolean | null; }; +/** + * Combined response model that includes both guest and RSVP information. + * This gives the frontend a complete picture of the guest's response in a single object. + */ +export type GuestWithRsvpResponse = { + guest: GuestRead; + rsvp?: RsvpSchema | null; +}; + export type HttpValidationError = { detail?: Array; }; @@ -809,7 +818,7 @@ export type UpdateGuestResponses = { export type UpdateGuestResponse = UpdateGuestResponses[keyof UpdateGuestResponses]; -export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData = { +export type SetGuestStatusData = { body?: never; path: { guest_id: string; @@ -820,25 +829,54 @@ export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData = { url: "/api/v1/events/guests/{guest_id}/status"; }; -export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchErrors = { +export type SetGuestStatusErrors = { /** * Validation Error */ 422: HttpValidationError; }; -export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError = - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchErrors[keyof SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchErrors]; +export type SetGuestStatusError = + SetGuestStatusErrors[keyof SetGuestStatusErrors]; -export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponses = { +export type SetGuestStatusResponses = { /** * Successful Response */ 200: GuestRead; }; -export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse = - SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponses[keyof SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponses]; +export type SetGuestStatusResponse = + SetGuestStatusResponses[keyof SetGuestStatusResponses]; + +export type CreateGuestRsvpData = { + body: RsvpSchemaCreate; + path: { + guest_id: string; + }; + query?: never; + url: "/api/v1/events/guests/{guest_id}/rsvp"; +}; + +export type CreateGuestRsvpErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type CreateGuestRsvpError = + CreateGuestRsvpErrors[keyof CreateGuestRsvpErrors]; + +export type CreateGuestRsvpResponses = { + /** + * Successful Response + */ + 200: GuestWithRsvpResponse; +}; + +export type CreateGuestRsvpResponse = + CreateGuestRsvpResponses[keyof CreateGuestRsvpResponses]; export type GetRsvpsData = { body?: never;