Staff Management
Flight Home Tickets
| Path | /flight-home-tickets |
|---|---|
| Status | live |
| Drill-down pages | — |
| Pop-ups | Best flight (`components/TicketDialog`) |
| Tabs | — |
| API routes | /api/staff-flightsPUT /api/staff-flights/ticket/api/data/offices |
What's on the page
- Header with Export CSV (every row with the same filters; one line per airport, with the Google Flights and Hyatt links and the recorded flight). It waits for lookups still running; a row that isn't finished says so in the Status column.
- Filters on one line, all kept in the link: Search (staff name or Dental Day), Week Of (◀ date ▶, with "Mon, 11/30/2026 – Fri, 12/04/2026" under it; this week, or the coming one from Saturday on; a new week clears Calendar, which belongs to the old week), Calendar (type to search; each calendar once, with its dates that week), Office (type to search; the field units), Ticket (Needs ticket = not driving home, no flight recorded and not marked "No"; Done = the rest).
- Cards: People This Week (including anyone who drives home), Home Airport Not Set, Draft Seats, Flights Recorded (counted on the server with the same filters).
- Table grouped by Dental Day: a header row "Amazon INC1 · Ends Tue 12/1/26 · 7:00 PM EST", then its people by name. Columns: Staff (position, "draft" when the seat isn't published); Company; Last Dental Day ("12/01/2026 7:00 PM EST" = the day and its end time, city under it); Fly From (airport, "Closest airport" or "Nearest big hub", miles away, drive time); Home; Time (+2 Hours) ("12/01/2026 9:00 PM EST"); Flight Available Today? (Yes / No, saved at once); Google Flights; Hotel (closest Hyatt to that airport); Best Flight (pencil to record flight, departure airport, cost and departure time, picked from a list in 15-minute steps, "8:30 PM"); Cost; Departs. 50 per page. Dates and times are US format (MM/DD/YYYY, 12-hour) on the page and in the CSV. It refreshes when someone is assigned or removed on the Schedule page.
Business rules
Data comes from: dd_staff_assignments (who is on which Dental Day), schedules (end hour), calendars (site address, company, office), staff.preferred_airport (the home airport each person picks on My Account), airports (US airports with scheduled passenger flights: OurAirports, public domain, the same list as the My Account airport picker) and flight_home_tickets (what the booker recorded). API: GET /api/staff-flights, PUT /api/staff-flights/ticket.
How it works:
- Last Dental Day = each person's latest Dental Day that week, Monday to Friday (the later one if they work two that day). Cancelled and rescheduled days don't count. Active staff only.
- Time (+2 Hours) = the day's end time + 2 hours. For an airport further away (a hub over 1½ hours' drive), it is the end time + 30 minutes to pack up + the drive. Shown in the site's own time zone, worked out from its location (offline zone map, no Google call); the state's zone only if the site can't be located.
- Fly From = the closest airport with regular flights (large or medium) to the site, and also the closest large hub when that's a different airport (e.g. Fayetteville, NC: FAY and RDU). Miles are straight-line; drive time comes from Google Maps. The site's location and drive times are looked up a few at a time and saved for good; rows still waiting say "Looking up…" (no time or link yet, so a far hub never shows a time that is too early) and the list asks again by itself.
- Home = the airport the person picked on My Account. An older free-text value (e.g. "LAX/BUR") shows as needing one airport. A code that isn't a US airport in our list (e.g. YYZ) is still searched. Someone whose home airport is within 75 miles of the site drives home: no flight columns.
- Google Flights = one way, from that airport to their home airport on that date, in US dollars. Google Flights has no API, so the booker reads flights and prices there and records the answer: Flight Available Today? and Best Flight (flight like "AA 450", or "AA 450 / AA 1203" with a change; cost in dollars; departure time at that airport; which airport). Saved per person per Dental Day date, with who saved it, and audit-logged. Each save changes only what was edited: the Yes / No box sends only the answer, the Best Flight dialog only its four fields, so neither overwrites the other (or another booker's change to a different field). Departure time is local to the departure airport and shown with that airport's zone (a hub can be in another zone than the site). Cost is checked on the server (dollars and cents, under $100,000); shown as $234.00.
- Hotel = Google Maps search for the closest Hyatt to that airport, for when nothing leaves late enough.
- Office filter = the Dental Day calendar's office (
calendars.dentrix_office_id, a field unit; shared office filter). All Offices shows every Dental Day, including one whose calendar has no office set yet. Calendar = one Dental Day calendar. - Needs the Schedule access key (
staffing-schedule, or admin), checked on the server for viewing and saving: whoever plans the schedule books the travel.
Open questions (need your answer)
Known problems:
- Teterboro (TEB, New Jersey) is listed by OurAirports as having scheduled service, so it can show as the "closest" airport though it is mostly private jets; the hub row (LGA/EWR) is the one to book from.
- The zone map can pick the neighbouring zone for a site within a mile or two of a time-zone border.
Database tables & columns
| Table | Columns used |
|---|---|
airports | city, iata, latitude, longitude, name, size, state |
calendars | calendar_name, city, dentrix_office_id, hubspot_id, short_code, state, status, street_address, zip_code |
companies | hubspot_id, name |
dd_staff_assignments | calendar_id, position, published_at, schedule_date, staff_id |
dentrix_offices | app, dentrix_id |
flight_home_tickets | available, cost, dental_date, departs, flight, from_airport, staff_id |
geocode_cache | address, found, latitude, longitude, provider |
route_leg_cache | drive_meters, drive_seconds, drive_seconds_static, found, from_lat, from_lng, polyline, provider, to_lat, to_lng |
schedules | calendar_id, date, end_hour |
staff | first_name, id, last_name, preferred_airport, status |
File structure
Its own files
- apps/
- web/
- src/
- features/
- staff-flights/
- components/
- TicketDialog.tsx
- pages/
- FlightHomeTicketsPage.tsx
- api.ts
- hooks.ts
- index.ts
- components/
- staff-flights/
- features/
- src/
- worker/
- src/
- features/
- staff-flights/
- __tests__/
- service.test.ts
- index.ts
- queries.ts
- routes.ts
- service.ts
- __tests__/
- staff-flights/
- features/
- src/
- web/
Shared code it uses (followed through its imports and the helpers its API calls; sign-in/access plumbing and UI primitives left out)
- apps/
- web/
- src/
- components/
- data/
- DataTable.tsx
- forms/
- DatePicker.tsx
- SearchableSelect.tsx
- reports/
- DentrixSourceNote.tsx
- FilterSelect.tsx
- HowItWorksNote.tsx
- OfficeFilter.tsx
- ReportHeader.tsx
- SearchableFilter.tsx
- sortable-grid.tsx
- TablePagination.tsx
- data/
- hooks/
- useApi.ts
- usePagedList.ts
- lib/
- csv.ts
- dates.ts
- office.ts
- services/
- api.ts
- components/
- src/
- worker/
- src/
- db/
- index.ts
- lib/
- list-query.ts
- office-filter.ts
- routes/
- data.ts
- services/
- geo-timezone.ts
- van-legs.ts
- utils/
- office.ts
- db/
- src/
- web/