Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wishlist Backend Implementation: schema, server actions, API #264

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

ShivanshPlays
Copy link
Contributor

Wishlist Backend Implementation

Summary

This pull request introduces the backend infrastructure for managing Wishlists within the application. It adds schema definitions, server actions, and API endpoints necessary to support Wishdish functionality for customers, allowing them to save dishes.

Changes Overview

  1. Database Schema:

    • Added a Wishlist model to create a many-to-many relationship between customer and dish.
    • Defined relations to enable seamless querying and management of Wishlists in the Prisma schema.
    • Updated the schema with referential integrity constraints and default values where applicable.
  2. Server Actions:

    • Created CRUD server actions in the actions/customer folder to handle Wishdish operations.
    • Implemented the following actions:
      • Add Wishlist: Allows customers to Wishlist dishs.
      • Remove Wishlist: Deletes a Wishlist for a customer.
      • Get All Wishlists: Retrieves all Wishlists for a specific customer.
      • Check Wishlist Existence: Confirms if a particular dish is Wishlisted by a customer.
    • Each server action follows consistent error handling and success responses, enabling clear communication between the backend and frontend.
  3. API Endpoints:

    • Built RESTful API endpoints to test and interact with the server actions in a structured manner.
    • The following API routes were created:
      • POST: /api/Wishlist/:customerId/:dishId - Adds a Wishlist for a specific customer and dish.
      • DELETE: /api/Wishlist/:customerId/:dishId - Removes a Wishlist.
      • GET: /api/Wishlist/:customerId - Retrieves all Wishlists for a customer.
      • GET: /api/Wishlist/exist/:customerId/:dishId - Checks if a Wishlist exists for the given customer and dish.
    • All routes return JSON responses with status codes to indicate success or failure, facilitating ease of integration and debugging.

Testing

tested all endpoints

Additional Notes

  • This implementation lays the foundation for front-end Wishlist functionality, allowing customers to interact with dishs in a personalized manner.
  • Future enhancements could include Wishlist pagination, customer notifications upon successful Wishlist actions, and analytics on Wishlisted dishs.

This PR is ready for review. Please check for adherence to backend standards and consistency with the overall project architecture.

1.mp4

PR2 #242

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Thank you for contributing to this project, your support is much appreciated.

Stay awesome! 😎

@ShivanshPlays ShivanshPlays changed the title Wishlist Wishlist Backend Implementation: schema, server actions, API Nov 9, 2024
Copy link
Owner

@Vimall03 Vimall03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ShivanshPlays please fix the conflicts

@ShivanshPlays
Copy link
Contributor Author

okay

@ShivanshPlays ShivanshPlays reopened this Nov 9, 2024
@ShivanshPlays
Copy link
Contributor Author

@Vimall03 please check now

@Vimall03 Vimall03 merged commit f1ca9f9 into Vimall03:main Nov 9, 2024
@ShivanshPlays ShivanshPlays deleted the wishlist branch November 10, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants