Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c27dbf5
Return the new ride's id from /api/addride
ethanm9720 Nov 22, 2026
827a698
Add Figma form and state components for the new ride pages
ethanm9720 Nov 22, 2026
4037dfd
Add the Schedule a Ride page
ethanm9720 Nov 22, 2026
58e71a2
Remove the create-ride modal from All Rides
ethanm9720 Nov 22, 2026
7181959
Format the new ride page components with Prettier
ethanm9720 Nov 22, 2026
df711a2
Rebuild Your Rides with the shared ride card
ethanm9720 Nov 22, 2026
a6df934
Style the Schedule a Ride pickers' error state and popups with tokens
ethanm9720 Nov 22, 2026
3ec1e25
Address review findings on Schedule a Ride
ethanm9720 Nov 22, 2026
908e09b
Give the text field and empty state button 44px tap targets on phones
ethanm9720 Nov 22, 2026
26b4d6a
Address review findings on Your Rides
ethanm9720 Nov 22, 2026
e663de3
Add a danger button variant on the status-danger token
ethanm9720 Nov 22, 2026
cb8bd05
Restyle the ride editor with the design-system pieces
ethanm9720 Nov 22, 2026
4d81899
Keep Enter in the From and To fields from submitting Schedule a Ride
ethanm9720 Nov 22, 2026
7672555
Show an ellipsis on long place names in Schedule a Ride
ethanm9720 Nov 22, 2026
3f90fce
Don't repeat the airport name under a place picked by that name
ethanm9720 Nov 22, 2026
9ed521b
Use Figma's left arrow for the Schedule a Ride back button
ethanm9720 Nov 22, 2026
fb15205
Keep text field content still when the border thickens on focus
ethanm9720 Nov 22, 2026
f59ead6
Let a lone ride on Your Rides span the full width, as in Figma
ethanm9720 Nov 22, 2026
a2d085e
Line up side-by-side ride panels on Your Rides
ethanm9720 Nov 22, 2026
bc6b364
Label rides you were removed from on Your Rides
ethanm9720 Nov 22, 2026
63a3d89
Build new Home and Ride Details pages (TIG-339)
Laahini Nov 25, 2026
609ca73
Merge main into the Schedule a Ride and Your Rides pages.
niyathikukkapalli Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 83 additions & 15 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def api_dashboard():
None

Returns:
JSON: user information provided by CAS, all the rides, and
a mapping of available and upcoming rideshares, sorted by
upcoming date
JSON: user information provided by CAS, all upcoming rideshares
(including full ones), sorted by upcoming date, and a mapping
of the user's ride request statuses
"""

user_info = _cas.authenticate()
Expand All @@ -112,12 +112,12 @@ def api_dashboard():
"updated_at": ride[9],
"current_riders": ride[10],
"note": ride[11],
"departure_start": ride[12],
"departure_end": ride[13],
}

if (
updated_ride["arrival_time"] > current_time
and len(updated_ride["current_riders"]) < updated_ride["max_capacity"]
):
# full rides are included too; Home shows them with a "Full" button
if updated_ride["arrival_time"] > current_time:
updated_rides.append(updated_ride)

updated_rides.sort(key=lambda ride: ride["arrival_time"])
Expand Down Expand Up @@ -170,6 +170,8 @@ def get_my_rides():
"current_riders": ride[11],
"requested_riders": ride[12],
"phone_number": ride[13],
"departure_start": ride[14],
"departure_end": ride[15],
}

if updated_ride["arrival_time"] > current_time:
Expand Down Expand Up @@ -197,6 +199,8 @@ def get_my_rides():
"request_status": ride[12],
# only accepted riders get the poster's phone number
"phone_number": ride[13] if ride[12] == "accepted" else None,
"departure_start": ride[14],
"departure_end": ride[15],
}

if updated_ride["arrival_time"] > current_time:
Expand Down Expand Up @@ -236,9 +240,11 @@ def addride():
arrival_time: a datetime object with the arrival date & time
phone_number: the poster's US phone number, shown to accepted riders
note (optional): note with the rideshare
departure_start, departure_end (optional): ISO times for the window
the ride leaves in; both or neither, ending by the arrival time

Returns:
JSON: a success message
JSON: a success message and the new ride's ride_id
400: if the phone number or note is invalid, or unable to create rideshare
"""
user_info = _cas.authenticate()
Expand Down Expand Up @@ -283,11 +289,21 @@ def addride():

arrival_time = data.get("arrival_time")

departure_start, departure_end, window_error = parse_departure_window(
data.get("departure_start"), data.get("departure_end"), arrival_time
)
if window_error:
return jsonify({"success": False, "message": window_error}), 400

origin_json = Json(origin)
dest_json = Json(dest)

failed = (
jsonify({"success": False, "message": "Failed to create rideshare."}),
400,
)
try:
database.create_ride(
ride_id = database.create_ride(
user_info["netid"],
user_info["displayname"],
user_info["mail"],
Expand All @@ -297,13 +313,63 @@ def addride():
arrival_time,
note,
phone_number,
departure_start,
departure_end,
)
return jsonify({"success": True, "message": "Rideshare successfully created!"})
except:
return (
jsonify({"success": False, "message": "Failed to create rideshare."}),
400,
)
except Exception:
return failed
if ride_id is None:
return failed
return jsonify(
{
"success": True,
"message": "Rideshare successfully created!",
"ride_id": ride_id,
}
)


def parse_iso_time(value):
"""
Parses an ISO 8601 time like "2026-11-20T21:00:00.000Z" into a UTC
datetime, or returns None if it's missing or invalid.
"""
if not isinstance(value, str) or not value:
return None
try:
parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))
except ValueError:
return None
if parsed.tzinfo is None:
parsed = parsed.replace(tzinfo=timezone.utc)
return parsed.astimezone(timezone.utc)


def parse_departure_window(start, end, arrival_time):
"""
Checks an optional departure window. Both ends or neither must be set;
the window must start before it ends, end by the arrival time, and not
be over already.

Returns:
(start, end, error): ISO strings to store (or None, None), and an
error message if the window is invalid
"""
if not start and not end:
return None, None, None

start_time = parse_iso_time(start)
end_time = parse_iso_time(end)
if not start_time or not end_time:
return None, None, "Please give both a start and end for the departure window."
if start_time >= end_time:
return None, None, "The departure window must start before it ends."
arrival = parse_iso_time(arrival_time)
if arrival and end_time > arrival:
return None, None, "The departure window must end by the arrival time."
if end_time <= datetime.now(timezone.utc):
return None, None, "The departure window can't be in the past."
return start, end, None


def normalize_phone_number(phone_number):
Expand Down Expand Up @@ -494,6 +560,8 @@ def searchrides():
"updated_at": ride[9],
"current_riders": ride[10],
"note": ride[11],
"departure_start": ride[12],
"departure_end": ride[13],
}

if (
Expand Down
38 changes: 30 additions & 8 deletions backend/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,25 @@ def create_ride(
arrival_time,
note="",
phone_number=None,
departure_start=None,
departure_end=None,
):
"""
Adds a ride to the Rides database
Adds a ride to the Rides database. departure_start / departure_end are
an optional window for when the ride leaves.

Returns:
int: the new ride's id, or None if the ride could not be added
"""

current_riders = []

sql_command = f"""
INSERT INTO Rides (admin_netid, admin_name, admin_email, max_capacity, current_riders,
origin_dict, destination_dict, arrival_time, note, phone_number, updated_at) VALUES (%s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, CURRENT_TIMESTAMP);
origin_dict, destination_dict, arrival_time, note, phone_number, departure_start,
departure_end, updated_at) VALUES (%s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, CURRENT_TIMESTAMP)
RETURNING id;
"""

values = (
Expand All @@ -172,24 +180,31 @@ def create_ride(
arrival_time,
note,
phone_number,
departure_start,
departure_end,
)

ride_id = None
conn = connect()

# if it was successful connection, execute SQL commands to database & commit
if conn:
try:
with conn.cursor() as cursor:
cursor.execute(sql_command, values)
ride_id = cursor.fetchone()[0]
conn.commit()
print("Ride addded successfully!")
except Exception as e:
ride_id = None
print(f"Error adding ride: {e}")
finally:
conn.close()
else:
print("Connection not established.")

return ride_id


def delete_ride(netid, ride_id):
"""
Expand Down Expand Up @@ -441,7 +456,9 @@ def get_users_rides(netid):
ELSE ARRAY[RideRequests.netid, RideRequests.full_name, RideRequests.mail, RideRequests.note]
END
) FILTER (WHERE RideRequests.netid IS NOT NULL), ARRAY[]::text[][]) AS riderequesters,
Rides.phone_number
Rides.phone_number,
Rides.departure_start,
Rides.departure_end
FROM
Rides
LEFT JOIN
Expand All @@ -461,7 +478,9 @@ def get_users_rides(netid):
Rides.updated_at,
Rides.note,
Rides.current_riders,
Rides.phone_number;
Rides.phone_number,
Rides.departure_start,
Rides.departure_end;
"""

values = (str(netid),)
Expand All @@ -488,7 +507,8 @@ def get_all_rides():

sql_command = """
SELECT id, admin_netid, admin_name, admin_email, max_capacity, origin_dict,
destination_dict, arrival_time, creation_time, updated_at, current_riders, note FROM Rides
destination_dict, arrival_time, creation_time, updated_at, current_riders, note,
departure_start, departure_end FROM Rides
"""
conn = connect()

Expand Down Expand Up @@ -516,7 +536,8 @@ def search_rides(
):
query = """
SELECT id, admin_netid, admin_name, admin_email, max_capacity, origin_dict,
destination_dict, arrival_time, creation_time, updated_at, current_riders, note FROM Rides
destination_dict, arrival_time, creation_time, updated_at, current_riders, note,
departure_start, departure_end FROM Rides
WHERE 1=1
"""

Expand Down Expand Up @@ -572,7 +593,8 @@ def get_users_requested_rides(netid):
sql_command = """
SELECT Rides.id, admin_netid, admin_name, admin_email, max_capacity, origin_dict, destination_dict,
arrival_time, creation_time, updated_at, Rides.note,
current_riders, RideRequests.status as ride_request_status, Rides.phone_number
current_riders, RideRequests.status as ride_request_status, Rides.phone_number,
Rides.departure_start, Rides.departure_end
FROM Rides
JOIN RideRequests ON Rides.id = RideRequests.ride_id
WHERE RideRequests.netid = %s;
Expand Down
6 changes: 6 additions & 0 deletions backend/migrations/002_ride_departure_window.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Adds an optional departure window to rides ("leave between 4:00 and
-- 5:30PM"). Both columns are nullable, so existing rides without a window
-- still load.

ALTER TABLE Rides ADD COLUMN IF NOT EXISTS departure_start TIMESTAMP;
ALTER TABLE Rides ADD COLUMN IF NOT EXISTS departure_end TIMESTAMP;
4 changes: 3 additions & 1 deletion backend/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ CREATE TABLE Rides (
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
current_riders TEXT[][],
note VARCHAR(300),
phone_number VARCHAR(20)
phone_number VARCHAR(20),
departure_start TIMESTAMP,
departure_end TIMESTAMP
);

CREATE TABLE IF NOT EXISTS RideRequests (
Expand Down
75 changes: 75 additions & 0 deletions backend/tests/test_add_ride.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
Tests for posting a ride: /api/addride returns the new ride's id, rejects
invalid input without creating a ride, and both posted and requested rides
show up under the user's /api/myrides.
"""

from datetime import datetime, timedelta, timezone


def place(name):
return {
"formatted_address": "1 Main St, Princeton, NJ 08540, USA",
"name": name,
"place_id": "place-" + name,
}


def ride_body(**overrides):
body = {
"capacity": 3,
"origin": place("Frist"),
"destination": place("PHL"),
"arrival_time": (datetime.now(timezone.utc) + timedelta(days=2)).isoformat(),
"note": "Meet at the front steps",
"phone_number": "(609) 555-1234",
}
body.update(overrides)
return body


def test_addride_returns_new_ride_id(api):
response = api.as_user("poster").post("/api/addride", json=ride_body())

assert response.status_code == 200
data = response.get_json()
assert data["success"] is True
assert isinstance(data["ride_id"], int)

my_rides = api.as_user("poster").get("/api/myrides").get_json()
posted_ids = [ride["id"] for ride in my_rides["upcoming_posted_rides"]]
assert data["ride_id"] in posted_ids


def test_addride_rejects_invalid_phone(api):
response = api.as_user("poster").post(
"/api/addride", json=ride_body(phone_number="123")
)

assert response.status_code == 400
data = response.get_json()
assert data["success"] is False
assert "ride_id" not in data

my_rides = api.as_user("poster").get("/api/myrides").get_json()
assert my_rides["upcoming_posted_rides"] == []


def test_requested_ride_shows_under_my_rides(api, ride_id):
api.as_user("rider").post(
"/api/requestride",
json={
"rideid": ride_id,
"origin_name": "Frist",
"destination_name": "EWR",
"formatted_arrival_time": "soon",
"note": "",
},
)

my_rides = api.as_user("rider").get("/api/myrides").get_json()
requested = [
ride for ride in my_rides["upcoming_requested_rides"] if ride["id"] == ride_id
]
assert len(requested) == 1
assert requested[0]["request_status"] == "pending"
Loading
Loading