mdazfar2 / Ezyshop

EzyShop is a user-friendly platform that connects you to local stores, offering a seamless shopping experience. Compare prices, access exclusive deals, and enjoy hassle-free deliveries for groceries, essentials, and organic products—all in one app.
https://ezyshopz.vercel.app
Apache License 2.0
159 stars 227 forks source link

added backend actions and schema for chat functionality #1117

Closed ShivanshPlays closed 1 week ago

ShivanshPlays commented 1 week ago

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

  1. Chat Functionality:

    • Implemented createChat function to initialize a new chat between a customer and a vendor, with an initial message.
    • Added getAllChatsByVendorId and getAllChatsByCustomerId functions to retrieve all chats for a specific vendor or customer.
    • Developed getSpecificChat function to fetch a unique chat between a customer and a vendor for a particular dish.
  2. Message Management:

    • Created deleteMessage function to allow users to delete their own messages, with checks for sender identity.
    • Developed editMessage function to enable message updates, with validation for sender ownership of the message.
  3. Prisma Schema Enhancements:

    • Updated Prisma schema to define relationships for Chat and Message models, facilitating chat-based interactions:
      • Added Chat model with relations to Customer, Vendor, and Dish models, ensuring that each chat is unique between a customer and vendor.
      • Defined Message model with associations to Chat and Customer, allowing for structured message storage within a chat.
    • Introduced @@unique([customerId, vendorId]) constraint in the Chat model to ensure one-to-one chat mapping between a customer and vendor.
    • Enhanced the schema with Category and Tag enums, and added relations between Customer, Vendor, Dish, and Chat models.

Error Handling

Each function implements error handling, returning a structured response with success, data, and error 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


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

vercel[bot] commented 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.

vercel[bot] commented 1 week ago

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