Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mosoriob
left a comment
There was a problem hiding this comment.
Code Review - PR #16: AppHome landing page with Google Maps region selector
Checklist
- TypeScript strict -- no untyped
any(typed casts used appropriately) - No hardcoded secrets or API keys
- No debug statements (console.log, debugger)
- No AI/authorship indicators in code or commits
- Apollo query follows established patterns (gql tag, typed generic)
- Runtime config follows the
window.__MINT_CONFIG__ ?? import.meta.env.VITE_*pattern -
@types/google.mapspresent as transitive dep -- TypeScript compilation works - Tests cover: welcome message, loading state, signed-in username, unauthenticated, empty regions, welcome fallback
- Route registration not changed (existing /regions/:id path is used correctly)
- CSS layout classes undefined (see Warning 1 below)
- Map container height (see Warning 1 below)
- GeoJSON accumulation on reload (see Warning 2 below)
Warnings (should fix before merge)
1. Undefined CSS layout classes -- layout will be unstyled
AppHome.tsx uses several class names that are not defined in globals.css or Tailwind config:
content-page,main-content,middle2main,gray-section,concept-grid,concept-card
These appear to be legacy class names from the old LitElement app. Since they are not in globals.css and not Tailwind utility classes, they compile away silently -- no error, but no styling either. The two-column layout (concept-grid), the full-bleed grey section (gray-section), and the map container width (middle2main) will all be unstyled.
Fix option A: define these as @layer components rules in globals.css.
Fix option B: replace with Tailwind utility classes directly (e.g. concept-grid is already duplicated inline as grid gap-6 md:grid-cols-[1fr_420px] -- just remove the custom class).
Note: mapContainerClassName="middle2main" on <GoogleMap> is particularly risky -- if the class sets no height, the map renders at 0px despite the outer style={{ height: 500 }} wrapper. Fix: set mapContainerStyle={{ width: '100%', height: '100%' }} so the Google Maps DOM element fills the parent div.
2. GeoJSON layers accumulate on re-render without clearing
In onLoad, map.data.addGeoJson() is called for each region. If regions or onRegionClick changes (e.g. Apollo re-fetches), onLoad re-fires and all features get added a second time. Clicking a region would then trigger onRegionClick multiple times.
The eslint-disable on the dep array is acceptable since onLoad only fires once per GoogleMap mount -- but if the parent unmounts/remounts the map (e.g. mapReady flipping false then true), features double up.
Fix: add map.data.forEach(f => map.data.remove(f)) at the top of onLoad before adding features, OR ensure <RegionMap> is mounted only once (use display: none / visibility: hidden instead of conditional rendering so the map instance is preserved).
Suggestions (non-blocking)
-
Missing error state --
useQueryreturns{ data, loading, error }buterroris ignored. If Hasura is unreachable the user sees a spinner forever. A brief "Could not load regions" message usingerrorwould improve robustness. -
Inline magic numbers --
{ lat: 0, lng: 20 }andzoom: 3hardcoded in JSX. Consider named constants or awindow.__MINT_CONFIG__key if the default viewport will vary by deployment.
Looks Good
- Clean separation between
RegionMap(Google Maps rendering) andAppHome(data-fetching, navigation). window.__MINT_CONFIG__runtime override pattern applied consistently, matching existing convention.vite-env.d.tsextended correctly with optionalGOOGLE_MAPS_KEYandWELCOME_MESSAGEkeys.- GraphQL query is well-scoped: top-level regions only (
parent_region_id: { _is_null: true }), minimal fields. - Tests are meaningful and cover the key branches.
- No dependency on the legacy LitElement stack.
- Commit message is clean.
Verdict: Changes Requested -- the two warnings (undefined CSS layout classes breaking the page layout, and GeoJSON accumulation risk) need to be addressed before merge.
Port app-home.ts (265 LOC) from LitElement to React. - AppHome page with full DYNAMO description text and Getting Started card - Google Maps integration via @react-google-maps/api - Region selector: loads top-level regions from Hasura, renders GeoJSON polygons on the map, highlights on hover/click, navigates to region page - User greeting shows authenticated username via useAuth - Welcome message and Maps API key from window.__MINT_CONFIG__ / VITE_ env - Map styles ported from legacy map-style.ts (terrain, desaturated) - LIST_TOP_REGIONS Apollo query with geometry support - 9 unit tests covering rendering, auth state, empty state, loading state
Summary
1:1 port of AppHome landing page from LitElement to React.
Deliverables
Closes kanban card t_abfce889.