explore-siargao / es-main

0 stars 0 forks source link

[Feature] Calendar View Rental Get Reservation #481

Open jpmadrigal07 opened 4 days ago

jpmadrigal07 commented 4 days ago

Requirements

Create a get request endpoint that will use to rental calendar view then implement it to frontend.

1. Get endpoint

Params:

  1. hostId - res.locals.user.id
  2. category - [car, motorcycle, bicycle]
  3. fromDate - Date
  4. toDate - Date

Use the aggregate to connect reservations to the rentals.

2. Implement to the UI

  1. Create a custom hook to connect the backend to frontend
  2. Using the custom hook get data from backend and display it to frontend

Example output

image

Acceptance Criteria

Expected output for get request endpoint

if category is car

"items":[
    {
      "name": "2022 Honda Civic",
      "price": "800",
      "cars": [
        {
          "abbr": "2022 Honda Civic 1",
          "status": "occupied",
          "reservations": [
            {
              "name": "Maria",
              "start_date": "2024-06-03",
              "end_date": "2024-06-07",
              "guest_count": 4
            },
            {
              "name": "Mario",
              "start_date": "2024-06-07",
              "end_date": "2024-06-10",
              "guest_count": 2
            }
          ]
        },
        {
          "abbr": "2022 Honda Civic 2",
          "status": "available",
          "reservations": []
        },
        {
          "abbr": "2022 Honda Civic 3",
          "status": "occupied",
          "reservations": [
            {
              "name": "Big Chuck",
              "start_date": "2024-06-08",
              "end_date": "2024-06-10",
              "guest_count": 3
            }
          ]
        },
        {
          "abbr": "2022 Honda Civic 4",
          "status": "available",
          "reservations": []
        }
      ]
    },
    {
      "name": "2020 Honda VIOS MT",
      "price": "1200",
      "cars": [
        {
          "abbr": "2020 Honda VIOS MT 1",
          "status": "available",
          "reservations": [
            {
              "name": "John",
              "start_date": "2024-06-12",
              "end_date": "2024-06-14",
              "guest_count": 1
            }
          ]
        },
        {
          "abbr": "2020 Honda VIOS MT 2",
          "status": "available",
          "reservations": []
        },
        {
          "abbr": "2020 Honda VIOS MT 3",
          "status": "available",
          "reservations": []
        }
      ]
    }
  ]

if category is motorcycle

"items":[
    {
      "name": "1996 Honda Wave SAT",
      "price": "800",
      "motorcycles": [
        {
          "abbr": "1996 Honda Wave SAT 1",
          "status": "occupied",
          "reservations": [
            {
              "name": "Maria",
              "start_date": "2024-06-03",
              "end_date": "2024-06-07",
              "guest_count": 4
            },
            {
              "name": "Mario",
              "start_date": "2024-06-07",
              "end_date": "2024-06-10",
              "guest_count": 2
            }
          ]
        },
        {
          "abbr": "1996 Honda Wave SAT 2",
          "status": "available",
          "reservations": []
        },
        {
          "abbr": "1996 Honda Wave SAT 3",
          "status": "occupied",
          "reservations": [
            {
              "name": "Big Chuck",
              "start_date": "2024-06-08",
              "end_date": "2024-06-10",
              "guest_count": 3
            }
          ]
        },
        {
          "abbr": "1996 Honda Wave SAT 4",
          "status": "available",
          "reservations": []
        }
      ]
    },
    {
      "name": "2000 Honda XRM MT",
      "price": "1200",
      "motorcycles": [
        {
          "abbr": "2000 Honda XRM MT 1",
          "status": "available",
          "reservations": [
            {
              "name": "John",
              "start_date": "2024-06-12",
              "end_date": "2024-06-14",
              "guest_count": 1
            }
          ]
        },
        {
          "abbr": "2000 Honda XRM MT 2",
          "status": "available",
          "reservations": []
        },
        {
          "abbr": "2000 Honda XRM MT 3",
          "status": "available",
          "reservations": []
        }
      ]
    }
  ]

if category is bicycle

"items":[
    {
      "name": "BMX",
      "price": "800",
      "bicycles": [
        {
          "abbr": "BMX 1",
          "status": "occupied",
          "reservations": [
            {
              "name": "Maria",
              "start_date": "2024-06-03",
              "end_date": "2024-06-07",
              "guest_count": 4
            },
            {
              "name": "Mario",
              "start_date": "2024-06-07",
              "end_date": "2024-06-10",
              "guest_count": 2
            }
          ]
        },
        {
          "abbr": "BMX  2",
          "status": "available",
          "reservations": []
        },
        {
          "abbr": "BMX  3",
          "status": "occupied",
          "reservations": [
            {
              "name": "Big Chuck",
              "start_date": "2024-06-08",
              "end_date": "2024-06-10",
              "guest_count": 3
            }
          ]
        },
        {
          "abbr": "BMX  4",
          "status": "available",
          "reservations": []
        }
      ]
    }
    }
  ]

Frontend output

Rentals Car, Motorcycle and Bicycle

image

Tasks (if any)