Compare commits

...

3 Commits

Author SHA1 Message Date
Felipe Cardoso
a2c3f16dc7 Update guests-list to use RSVP data for dietary and notes
All checks were successful
Build and Push Docker Images / changes (push) Successful in 11s
Build and Push Docker Images / build-backend (push) Has been skipped
Build and Push Docker Images / build-frontend (push) Successful in 1m49s
Replaced `guest.dietary_restrictions` and `guest.notes` with `guest.rsvp.dietary_requirements` and `guest.rsvp.response_message`. This ensures the data reflects RSVP-specific fields and improves code consistency with the RSVP model.
2025-03-19 20:49:29 +01:00
Felipe Cardoso
44e6b2a6dc Refactor guest schema and add RSVP field to GuestBase.
Reorganized imports for better readability and compliance with standards. Added an optional `rsvp` field to the `GuestBase` model to include RSVP details. This enhances the schema's flexibility and supports additional guest-related data.
2025-03-19 20:47:12 +01:00
Felipe Cardoso
42508af610 Add optional RSVP field to guest schema
This commit introduces an optional `rsvp` field to the guest-related types and schemas. The field is nullable and references the `RSVPSchema`, allowing better handling of RSVP data in the application.
2025-03-19 20:47:07 +01:00
4 changed files with 26 additions and 10 deletions

View File

@@ -1,11 +1,10 @@
import uuid
from pydantic import BaseModel, EmailStr, ConfigDict
from datetime import datetime
from typing import Optional, Any, Dict
from app.models.guest import GuestStatus
from uuid import UUID
from pydantic import BaseModel, EmailStr, ConfigDict
from app.models.guest import GuestStatus
from app.schemas.rsvp import RSVPSchema, RSVPStatus
@@ -50,6 +49,8 @@ class GuestRead(GuestBase):
is_blocked: bool
model_config = ConfigDict(from_attributes=True)
invitation_code: str
rsvp: Optional[RSVPSchema] = None
class GuestWithRSVPResponse(BaseModel):
"""
@@ -62,6 +63,7 @@ class GuestWithRSVPResponse(BaseModel):
class Config:
from_attributes = True
def map_rsvp_status_to_guest_status(rsvp_status: RSVPStatus) -> GuestStatus:
if rsvp_status == RSVPStatus.ATTENDING:
return GuestStatus.CONFIRMED
@@ -70,4 +72,4 @@ def map_rsvp_status_to_guest_status(rsvp_status: RSVPStatus) -> GuestStatus:
elif rsvp_status == RSVPStatus.MAYBE:
return GuestStatus.PENDING
else:
return GuestStatus.INVITED
return GuestStatus.INVITED

View File

@@ -2427,6 +2427,16 @@ export const GuestReadSchema = {
type: "string",
title: "Invitation Code",
},
rsvp: {
anyOf: [
{
$ref: "#/components/schemas/RSVPSchema",
},
{
type: "null",
},
],
},
},
type: "object",
required: [

View File

@@ -370,6 +370,7 @@ export type GuestRead = {
actual_additional_guests: number;
is_blocked: boolean;
invitation_code: string;
rsvp?: RsvpSchema | null;
};
export type GuestStatus =

View File

@@ -578,8 +578,8 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
{/* Dietary Restrictions Column */}
<TableCell>
{guest.dietary_restrictions &&
guest.dietary_restrictions.length > 0 ? (
{guest.rsvp?.dietary_requirements &&
guest.rsvp.dietary_requirements.length > 0 ? (
<Popover>
<PopoverTrigger asChild>
<Button
@@ -592,7 +592,7 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
</PopoverTrigger>
<PopoverContent className="max-w-xs">
<p className="text-sm">
{guest.dietary_restrictions}
{guest.rsvp.dietary_requirements}
</p>
</PopoverContent>
</Popover>
@@ -603,7 +603,8 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
{/* Notes Column */}
<TableCell>
{guest.notes && guest.notes.length > 0 ? (
{guest.rsvp?.response_message &&
guest.rsvp.response_message.length > 0 ? (
<Popover>
<PopoverTrigger asChild>
<Button
@@ -615,7 +616,9 @@ const GuestListTable = ({ event }: GuestListTableProps) => {
</Button>
</PopoverTrigger>
<PopoverContent className="max-w-xs">
<p className="text-sm">{guest.notes}</p>
<p className="text-sm">
{guest.rsvp.response_message}
</p>
</PopoverContent>
</Popover>
) : (