Skip to content

Standardized time, added location support and fixed various small bugs - #73

Merged
Duckierstone42 merged 1 commit into
mainfrom
admin-vehicle-details
Apr 10, 2026
Merged

Standardized time, added location support and fixed various small bugs#73
Duckierstone42 merged 1 commit into
mainfrom
admin-vehicle-details

Conversation

@Duckierstone42

Copy link
Copy Markdown
Collaborator

No description provided.

@netlify

netlify Bot commented Apr 10, 2026

Copy link
Copy Markdown

Deploy Preview for able-alliance ready!

Name Link
🔨 Latest commit 7dabab1
🔍 Latest deploy log https://app.netlify.com/projects/able-alliance/deploys/69d982afbfc2ef00082bfc99
😎 Deploy Preview https://deploy-preview-73--able-alliance.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Duckierstone42
Duckierstone42 merged commit 10d0234 into main Apr 10, 2026
4 of 5 checks passed
@greptile-apps

greptile-apps Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR standardizes time handling to America/New_York via a new dateEst.ts utility, adds a Mapbox-backed location picker to the ride creation flow (replacing free-text fields with validated dropdown selects backed by the Locations collection), and fixes several small bugs across ride status transitions and the admin panel.

  • P1 — ChatlogAction.ts: getChatlogs filters by query.studentId and query.driverId, but the Chatlog schema stores these as embedded student and driver documents. These query fields don't exist in MongoDB, so filtering by student or driver silently returns all chatlogs instead of the expected subset.

PR checklist areas needing attention (score: 72/100):

  • Unused imports in dateEst.ts (endOfDay as _endOfDay, format as dateFnsFormat) — violates "no unused imports".
  • Hardcoded color literals in both new CSS files instead of CSS variables from the global stylesheet.
  • max-width: 1400px in rides/[id]/styles.module.css should be 140rem per the project's rem convention.

Confidence Score: 4/5

Mostly safe to merge but the chatlog filter bug should be fixed first — it silently returns all records instead of filtered ones.

One clear P1 defect in ChatlogAction where wrong MongoDB field names cause filtering to return unscoped data. Remaining findings are P2 style/cleanup issues (unused imports, hardcoded colors, px unit). The core features are implemented correctly.

src/server/db/actions/ChatlogAction.ts (P1 filter bug), src/utils/dateEst.ts (unused imports), src/app/rides/new/styles.module.css and src/app/rides/[id]/styles.module.css (hardcoded colors, px units)

Important Files Changed

Filename Overview
src/server/db/actions/ChatlogAction.ts Chatlog filter uses wrong field names (studentId/driverId) — these don't exist in the schema, so filtering by student or driver silently returns all records.
src/utils/dateEst.ts New EST/EDT-aware utility file; contains two unused imports (endOfDay as _endOfDay and format as dateFnsFormat) that should be removed.
src/app/rides/new/page.tsx New ride creation page with Mapbox integration and location dropdowns; lacks past-date validation in the calendar picker.
src/app/rides/new/styles.module.css New CSS module with several hardcoded color values that should use project CSS variables; otherwise uses rem units correctly.
src/app/rides/[id]/styles.module.css Updated styles module with a max-width: 1400px that should be 140rem, and several hardcoded colors that violate CSS variable conventions.
src/server/db/actions/RouteAction.ts Route action now uses EST-aware date utilities for driver availability checks; clean implementation with correct error handling.
src/server/db/models/RouteModel.ts Route model updated to use ObjectId references for pickup/dropoff locations; well-structured with appropriate indexes.
src/app/api/locations/[id]/route.ts New location API endpoint (GET/DELETE) with proper auth, role checks, and error handling.
src/components/TimeInput/TimeInput.tsx New searchable time picker component with keyboard navigation; 120ms blur delay is legitimate for mousedown-before-blur handling.
src/app/rides/RideCard.tsx RideCard updated to use EST-aware formatTime and isToday helpers; chat eligibility and status display logic looks correct.

Sequence Diagram

sequenceDiagram
    participant S as Student Browser
    participant API as /api/routes POST
    participant RA as RouteAction
    participant LM as LocationModel
    participant UM as UserModel
    participant MB as Mapbox API
    participant DB as MongoDB

    S->>API: POST pickupLocation dropoffLocation scheduledPickupTime
    API->>API: Auth check and schema validation
    API->>RA: createRoute(data)
    RA->>LM: findById(pickupLocationId)
    RA->>LM: findById(dropoffLocationId)
    RA->>UM: findById(studentId)
    RA->>DB: check duplicate route
    RA->>MB: getMapboxTravelDuration
    MB-->>RA: durationSeconds
    RA->>DB: RouteModel.create
    DB-->>RA: saved route
    RA-->>API: route object
    API-->>S: 201 Created
Loading

Comments Outside Diff (3)

  1. src/app/rides/new/styles.module.css, line 5-13 (link)

    P2 Hardcoded color values instead of CSS variables

    Several colors in this file (and in src/app/rides/[id]/styles.module.css) are hardcoded rather than using CSS variables from the global stylesheet. Examples include #fde8e8, #f4a0a0, #c73a3a, #5B9BD5, #325CE8, #3aaa5c, #183777, and #2563eb. The same pattern applies in src/app/rides/[id]/styles.module.css with #16a34a, rgba(22, 163, 74, 0.06), and rgba(34, 7, 11, 0.5). These should be replaced with CSS variable equivalents (e.g., var(--color-status-red-fill), var(--color-brand-text), etc.).

    Rule Used: Use color variables from the global stylesheet (`s... (source)

    Learnt From
    GTBitsOfGood/design-system#61

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  2. src/app/rides/[id]/styles.module.css, line 51-52 (link)

    P2 px used for max-width instead of rem

    The project convention is 1rem = 10px, so 1400px should be 140rem to stay consistent with the rest of the codebase.

    Rule Used: Use rem units instead of px for measurements like ... (source)

    Learnt From
    GTBitsOfGood/design-system#59

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  3. src/app/rides/new/page.tsx, line 300-304 (link)

    P2 No past-date guard in calendar

    The form allows selecting dates in the past and submitting them. Students could accidentally book a ride for a date that has already passed. Consider disabling past days in the calendar and/or validating in handleSubmit that scheduledPickupDate is in the future before hitting the API.

Reviews (1): Last reviewed commit: "Standardized time, added location suppor..." | Re-trigger Greptile

Comment on lines 13 to 14
if (filters.studentId) query.studentId = filters.studentId;
if (filters.driverId) query.driverId = filters.driverId;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Wrong field names in Chatlog filter query

The Chatlog schema stores participants as embedded documents named student and driver, not studentId and driverId. Assigning query.studentId and query.driverId sets fields that don't exist in MongoDB, so these filters silently match nothing — any caller filtering by student or driver will always get every chatlog.

Suggested change
if (filters.studentId) query.studentId = filters.studentId;
if (filters.driverId) query.driverId = filters.driverId;
if (filters.studentId) query["student._id"] = filters.studentId;
if (filters.driverId) query["driver._id"] = filters.driverId;

Comment thread src/utils/dateEst.ts
Comment on lines +1 to +15
/**
* EST/EDT-aware date utilities backed by date-fns + date-fns-tz.
* All timezone math is delegated to the library — no manual offset arithmetic.
*/

import {
startOfDay,
endOfDay,
startOfWeek,
endOfDay as _endOfDay,
addDays,
addWeeks,
getDay,
format as dateFnsFormat,
} from "date-fns";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unused imports

endOfDay as _endOfDay is imported as a second alias for endOfDay (already imported above), and format as dateFnsFormat is never referenced in this file. Both should be removed to satisfy the "no unused imports" checklist requirement and avoid lint errors.

Suggested change
/**
* EST/EDT-aware date utilities backed by date-fns + date-fns-tz.
* All timezone math is delegated to the library no manual offset arithmetic.
*/
import {
startOfDay,
endOfDay,
startOfWeek,
endOfDay as _endOfDay,
addDays,
addWeeks,
getDay,
format as dateFnsFormat,
} from "date-fns";
import {
startOfDay,
endOfDay,
startOfWeek,
addDays,
addWeeks,
getDay,
} from "date-fns";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant