Closed ShivanshPlays closed 1 week ago
@ShivanshPlays is attempting to deploy a commit to the MD AZFAR ALAM's projects Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
ezyshopz | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 10, 2024 1:44am |
PR Description: Chat and Message Functionality with Schema Enhancements
Overview
This pull request introduces chat and message management features, enabling customers and vendors to communicate within the application. These changes include functions for creating, fetching, editing, and deleting messages and chats, alongside necessary schema updates in Prisma for chat and message relationships.
Key Changes
Chat Functionality:
createChat
function to initialize a new chat between a customer and a vendor, with an initial message.getAllChatsByVendorId
andgetAllChatsByCustomerId
functions to retrieve all chats for a specific vendor or customer.getSpecificChat
function to fetch a unique chat between a customer and a vendor for a particular dish.Message Management:
deleteMessage
function to allow users to delete their own messages, with checks for sender identity.editMessage
function to enable message updates, with validation for sender ownership of the message.Prisma Schema Enhancements:
Chat
andMessage
models, facilitating chat-based interactions:Chat
model with relations toCustomer
,Vendor
, andDish
models, ensuring that each chat is unique between a customer and vendor.Message
model with associations toChat
andCustomer
, allowing for structured message storage within a chat.@@unique([customerId, vendorId])
constraint in theChat
model to ensure one-to-one chat mapping between a customer and vendor.Category
andTag
enums, and added relations betweenCustomer
,Vendor
,Dish
, andChat
models.Error Handling
Each function implements error handling, returning a structured response with
success
,data
, anderror
fields to ensure consistent and clear API responses across all operations.Database
Utilizes MongoDB as the primary database with Prisma as the ORM, aligning with the project requirements for scalability and reliability.
Testing & Validation
Future Improvements
Dependencies
prisma-client-js
) and MongoDB setup with updated environment configurations.This PR establishes the foundation for in-app communication between users, with robust error handling, schema alignment, and response consistency to support smooth functionality and user experience.
closes PR1 #1110