From e3f46073ef77ad99380e6353e6e73daae2e940b0 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Mon, 28 Apr 2025 13:35:10 +0000 Subject: [PATCH] feat: implement contact form submission endpoint with validation --- endpoints/email.post.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/endpoints/email.post.py b/endpoints/email.post.py index 2f3334d..90c2a7e 100644 --- a/endpoints/email.post.py +++ b/endpoints/email.post.py @@ -12,10 +12,10 @@ async def submit_contact_form( db: Session = Depends(get_db) ): """ - Submit a contact form with name, email, and message. + Submit a new contact form with name, email, and message. All fields are required and email must be in valid format. """ - # Validate the contact form data + # Validate the form data errors = validate_contact_form_data({ "name": contact_form.name, "email": contact_form.email, @@ -29,10 +29,15 @@ async def submit_contact_form( detail=errors ) - # Create the contact form entry in the database - create_contact_form(db=db, contact_form_data=contact_form) + # Create the contact form in the database + created_form = create_contact_form(db=db, contact_form_data=contact_form) return { "status": "success", - "message": "Contact form submitted successfully" + "message": "Contact form submitted successfully", + "data": { + "id": created_form.id, + "name": created_form.name, + "email": created_form.email + } } \ No newline at end of file