Skip to content

Repository files navigation

Laundry Signup V1

Note: Please ensure you have installed nodejs

To preview and run the project on your device:

  1. Open project folder in Visual Studio Code
  2. In the terminal, run npm install
  3. Run npm start to view project in browser

API Responses expected:

Full Schedule page

API Endpoint: GET /api/schedule/{date} Example: GET /api/schedule/2024-12-21 Expected response:

  // Expected API Response Format
{
  "6 am - 8 am": {
    "washer1": {
      "reserved": false,
      "name": null
    },
    "washer2": {
      "reserved": false,
      "name": null
    }
  },
  "8 am - 10 am": {
    "washer1": {
      "reserved": false,
      "name": null
    },
    "washer2": {
      "reserved": true,
      "name": "Lesther"
    }
  },
  "10 am - 12 pm": {
    "washer1": {
      "reserved": true,
      "name": null  // null name means "RESERVED" will be displayed
    },
    "washer2": {
      "reserved": true,
      "name": null
    }
  }
  // ... and so on for each time slot
}

// Response Status Codes:
// 200 - Success
// 404 - Schedule not found for date
// 500 - Server error

Django API samples

@require_http_methods(["GET"])
def get_schedule(request, date):
    """
    Returns the schedule for a specific date.
    URL: /api/schedule/{date}
    Example: /api/schedule/2024-11-21
    """
    try:
        # For demonstration, return the same schedule for all dates
        return JsonResponse(SAMPLE_SCHEDULE)
    except Exception as e:
        return JsonResponse({"error": str(e)}, status=500)

@require_http_methods(["POST"])
def update_booking(request):
    """
    Updates a booking slot.
    URL: /api/bookings/
    """
    try:
        data = json.loads(request.body)
        date = data.get('date')
        time = data.get('time')
        name = data.get('name')
        
        # In a real application, you would update a database here
        # For now, just return success
        return JsonResponse({
            "success": True,
            "message": f"Booking updated for {date} at {time} for {name}"
        })
    except Exception as e:
        return JsonResponse({"error": str(e)}, status=500)

Booking page

Should be able to use same endpoint as full schedule page to fetch

Making a booking: POST /api/bookings/ Data sent:

{
  "name":"hi",
  "date":"12/12/2024",
  "time":"12:00 pm - 2:00 pm"
}

About

This is a repository for our final project for our HCI Final project. This project was done by Titus and Lesther

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages