Conversation
🚀 Preview deployment ready!Preview URL: https://pr-195.preview.opencouncil.gr The preview will be automatically updated when you push new commits. This preview uses the staging database - any changes will affect other previews. |
Greptile SummaryLarge feature PR that adds a comprehensive admin CRUD interface for consultations, a community picker with address search for the consultation map view, a welcome dialog with regulation summary, zoom-to-geometry on click, initial fit-to-bounds, and supporting scripts/documentation for the Athens cooking oil regulation consultation.
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Citizen as Citizen
participant MapView as ConsultationMap
participant Picker as LayerControlsPanel
participant Detail as DetailPanel
participant MapBox as Mapbox GL
Note over Citizen, MapBox: Community Picker with Address Search
Citizen->>Picker: Opens community picker
Picker-->>Citizen: Shows list of communities
Citizen->>Picker: Searches address via LocationSelector
Picker->>MapView: onSearchLocation(location)
MapView->>MapView: Add to searchLocations state
MapView->>MapBox: Add colored pin feature
MapView->>Detail: openSearchLocationDetail(location, index)
Detail->>Detail: Compute nearbyPoints (Haversine, 500m radius)
Detail-->>Citizen: Show nearest collection points sorted by distance
Citizen->>Picker: Clicks community name
Picker->>MapView: onOpenGeoSetDetail(geoSetId)
MapView->>MapBox: Zoom to community points
MapView->>Detail: Show geoset detail with point list
Citizen->>MapBox: Clicks point on map
MapBox->>MapView: handleMapFeatureClick (points prioritized)
MapView->>Detail: openGeometryDetail(geometryId)
MapView->>MapBox: Zoom to geometry
Last reviewed commit: 10bf549 |
Additional Comments (1)
Context Used: Context from 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! Prompt To Fix With AIThis is a comment left during a code review.
Path: src/app/[locale]/(city)/[cityId]/consultation/[id]/page.tsx
Line: 14:30
Comment:
**Duplicated `fetchRegulationData` function**
This function is now duplicated in three places with identical logic (here, `src/lib/db/consultations.ts:199`, and `src/app/[locale]/(city)/[cityId]/consultation/[id]/comments/page.tsx:16`). Since this PR updated the URL resolution logic in all three copies, this is a good candidate for consolidation. Per the project's DRY guidelines, consider exporting the function from `src/lib/db/consultations.ts` and importing it in both page files.
**Context Used:** Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=a3ddaa95-717d-48e6-81cd-93c42696bbed))
<sub>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!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
10bf549 to
6a04213
Compare
|
I force-pushed to address bot review comment(s) (1, 2, 3, 4):
|
Fixed in force-push — exported |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
fb18a30 to
d8a8fb8
Compare
|
I force-pushed to address bot review comment(s) (1, 2, 3):
|
Documents the consultation feature as actually implemented, covering the regulation JSON schema, dual-view frontend, comment system, geo-editor, and business rules.
Geocodes point geometries in regulation JSON files using Google Geocoding API. Finds points with textualDefinition but no geojson coordinates, geocodes each address scoped to Athens, and fills in the geojson field. Supports --dry-run, --force, and --delay options.
Adds CRUD API routes and an admin UI for creating and managing consultations. Includes city selector (filtered to consultationsEnabled cities), regulation JSON URL input, end date picker, active toggle, and a table listing all consultations with comment counts.
Server-side fetch cannot resolve relative paths like /regulation.json. Prepend NEXTAUTH_URL to relative jsonUrl values in both the consultation page and the comment validation helper.
Documents the regulation JSON production pipeline: PDF-to-JSON conversion, coordinate transformation, address geocoding, and consultation-specific generators. Includes a comparison table showing which scripts were used for each consultation.
Reference clicks and comment navigation switch to map view but didn't scroll to top, leaving the full-screen map hidden above the viewport.
When editing a point geometry, searching for an address now shows a button to directly use that location as the point's coordinates. Saves to localStorage like manual map clicks, with toast confirmation.
Clicking a point or polygon on the map now zooms to it. Hash-based navigation (e.g. #dk_3) zooms to the geoset's boundary polygon. Fixed zoom not firing when transitioning from document to map view by tracking map initialization state so pending zooms execute once the map is ready.
Admin dashboard now supports uploading regulation JSON files directly to S3 and editing JSON URLs inline in the consultations table. Also documents the regulation JSON hosting workflow.
…map view Redesign the map sidebar into a dual-mode panel: a simplified community picker (normal mode) with address search via LocationSelector, and the full layer controls (editing mode) for admins. Citizens can search their address to find nearby collection points within 500m, shown as colored pins on the map. A welcome dialog presents the regulation summary on first load with navigation options. Also: extract shared types (CurrentUser, GeoSetData, SEARCH_COLORS) to types.ts, deduplicate geometry list item rendering in DetailPanel, add GeometryCollection support to bounds calculation, improve map labels (point addresses at zoom, polygon names that fade), and update docs.
…in dev banner Use hardcoded opencouncil.gr sender domain instead of deriving from NEXTAUTH_URL, which breaks on preview deployments (unverified subdomain). Add a dev banner to overridden emails showing original To and CC recipients.
Pre-rendered pages built during nix build contain stale data (e.g. "Test City" from the build-time DB). The preview-start script symlinked the entire .next/server directory from the read-only nix store, preventing Next.js ISR from updating pages with fresh data at runtime (EROFS error). Copy .next/server/app/ to a writable location instead of symlinking so ISR can regenerate pre-rendered pages after the first real request.
Convert DetailPanel, LayerControlsPanel, and CommentsOverviewSheet to use vaul Drawer on mobile (<768px) instead of side Sheet/Dialog. The welcome dialog switches to Credenza for automatic desktop/mobile adaptation. - Non-modal drawers keep map interactive behind the sheet - Only one bottom sheet open at a time (opening detail closes controls) - Map zoom padding shifts content upward when drawer is open - ViewToggleButton FAB repositions above any open drawer - LayerControlsButton shows compact icon-only variant on mobile - DrawerContent gains hideOverlay prop for non-modal usage
Deduplicate the identical HTML sanitization function that was defined inline in both CommentSection and CommentsOverviewSheet.
Deduplicate the identical Haversine circle polygon generator that was defined inline in both ConsultationMap and NotificationMapDialog.
The Sheet (desktop) branch duplicated ~150 lines of JSX that the renderContent() helper already handles. Reuse renderContent() for both the mobile Drawer and desktop Sheet containers.
…component Extract raw Prisma queries from API routes into centralized functions in src/lib/db/consultations.ts (getConsultationsForAdmin, createConsultation, updateConsultation, deleteConsultation, getAdminCityOptions). Split the admin consultations page into a server component (auth + initial data fetch) and a client component (UI), matching the pattern used by other admin pages like offers and meetings.
d8a8fb8 to
b3ff100
Compare
|
Force-pushed with the following changes: History rewrite — removed regulation DRY refactors:
|
Move calculateGeometryBounds from lib/utils.ts, createCircleBuffer from lib/geo/buffer.ts, and haversineDistance from DetailPanel.tsx into a single shared geo module. Update all import sites.
Cover calculateGeometryBounds (Point, Polygon, MultiPolygon, GeometryCollection, null, unsupported), createCircleBuffer (shape, closure, radius accuracy), and haversineDistance (zero, known distance, symmetry).
b3ff100 to
5722304
Compare
Note
Medium Risk
Touches the Nix-based preview/production startup wiring for
.nextartifacts; a mistake here could break preview deployments or cause stale/incorrectly regenerated pages. Other changes are documentation and test-runner tuning with low functional risk.Overview
Adds internal documentation for the new public consultations feature (
docs/guides/consultations.md) and clarifies that development commands should be run inside the Nix dev shell (CLAUDE.md).Updates the Nix preview startup logic in
flake.nixto ensure.next/server/appis copied into a writable work directory (instead of symlinked) so Next.js ISR can regenerate pre-rendered pages, with cleanup for upgrade paths.Tunes Jest parallelism/memory (
maxWorkers,workerIdleMemoryLimit) and adds apublic/regulation-cooking-oil-geocode-failures.jsonartifact for geocoding failures.Written by Cursor Bugbot for commit d8a8fb8. This will update automatically on new commits. Configure here.
Greptile Summary
This PR adds a comprehensive public consultations feature to OpenCouncil, allowing municipalities to run geospatial consultations with comment collection.
Key Changes:
src/lib/utils.tsinto dedicatedsrc/lib/geo.tswith unit tests.next/server/appdirectory for writabilityQuality Indicators:
withUserAuthorizedToEditas anycasts, fixed ternary)Confidence Score: 4/5
flake.nixthat modify how.next/server/appis handled in preview deployments - this is critical path code for ISR functionality. While the implementation looks correct, it touches deployment infrastructure that could break preview environments if something was missed.flake.nixlines 943-1324 (preview startup script) - ensure preview deployments work correctly with the new copy-instead-of-symlink approach for.next/server/appImportant Files Changed
.next/server/appinstead of symlinking for ISR compatibility, adds cleanup for upgrade pathscalculateGeometryBounds,createCircleBuffer,haversineDistance) extracted from utils.ts, well-testedcreateCircleBufferto shared libLast reviewed commit: 5722304