bsoc-bitbyte / busify

A centralised bus ticket booking system that will allow the students to book tickets in advance through an online website, saving time and effort.
https://busify.vercel.app
30 stars 67 forks source link

feat(admin-dashboard): created recent orders functionality #92

Closed rohansen856 closed 1 week ago

rohansen856 commented 2 weeks ago

Overview

  1. This PR fixes or fixes part of #89 .
  2. This PR does the following: created recent orders details card with data fetching.

Essential Checklist

Proof that changes are correct

Screenshot 2024-06-16 232750 Screenshot 2024-06-16 232726

responsiveness: Screenshot 2024-06-16 232508 Screenshot 2024-06-16 232534 Screenshot 2024-06-16 232523

works done in this pr:

frontend

  1. created a list view of the recent orders (orders done inn the same day).
  2. created order details card, viewable when clicked View Details

backend

  1. modified the orders.service.ts file to add the logic to get the data in required format
  2. modified the orders.controller.ts file to add the route handler to get the details.
  3. fixed the seed file to push the data in better format.

PR Pointers

vercel[bot] commented 2 weeks ago

@rohansen856 is attempting to deploy a commit to the Busify Team on Vercel.

A member of the Team first needs to authorize it.

RISHIKESHk07 commented 2 weeks ago

@rohansen856 we will be having relationship between tickets and orders as well , it make it easier for the other issue for data fetching , please make changes according to this schema WhatsApp Image 2024-06-17 at 9 46 09 AM

rohansen856 commented 2 weeks ago

@RISHIKESHk07 i will fix the issue and update the schema with the correct relationships, and also check if there is any need to change the data fetching method using prisma with the updated relationship.

rohansen856 commented 2 weeks ago

@RISHIKESHk07 @Pratik2026 i have updated the schema.prisma file to make relations between orders, tickets and schedule schma. also updated the data fetching method in order.service.ts in my latest pr. the current relationship is:

model Schedule {
    id            String   @id
    busNumber     String
    bus           Bus      @relation(fields: [busNumber], references: [number])
    checkpoints   String[]
    from          String
    to            String
    departureTime String
    days          String[]
    ticketPrice   Int
    orders        Order[]
}

model Ticket {
    id             Int @id @default(autoincrement())
    orderId        String @unique
    passengerEmail String[]
    order          Order @relation(fields: [orderId], references: [id])
}

model Order {
    id         String     @id
    userId     String
    scheduleId String
    status     String     @default("pending") // how to make this enum
    amount     Int
    attempts   Int        @default(0)
    receipt    String     @unique
    createdAt  DateTime   @default(now())
    user       Users      @relation(fields: [userId], references: [id])
    ticket     Ticket?
    schedule   Schedule  @relation(fields: [scheduleId], references: [id])
}

the relationship are:

  1. order -> ticket: one-to-one
  2. schedule -> order: many to one

    thank you.

RISHIKESHk07 commented 1 week ago

@Pratik2026 LGTM codewise , any changes as per you ?

rohansen856 commented 1 week ago

@rohansen856 did you verify if page works when we add a ticket through the razorpay UI (dummy order) instead of seeding the data ? i tried it here (Left: Busify & Right:Ptisma Studio) , there is a ticket created but does not appear in the admin page , maybe its a date issue , you can test razorpay UPI with success@razorpay image

@RISHIKESHk07 i will double check the payments issue with razorpay, and also check any issues with the data.

rohansen856 commented 1 week ago

@RISHIKESHk07 i have solved the following issues in the latest pr:

  1. updated the prisma Ticket schema with the discussed changes.
  2. updated the order of database seeding in prisma/seed.mjs.
  3. updated orders.service.ts to fix the issue with the date object in razorpay payment datetime.
  4. fixed the frontend issue with parsing the datetime by encapsulation the field in new Date().
  5. fixed the issue with formatting in frontend/src/components/AdminPanel/OrderDetailsCard/index.tsx. proof of work:

https://github.com/bsoc-bitbyte/busify/assets/108976786/e01cbc5c-5195-46ae-b71b-cd60db4765d8

https://github.com/bsoc-bitbyte/busify/assets/108976786/57c85be1-8913-4363-9193-5273edd08616

thank you.