3.8 KiB
Religion Dialog Dropdown + Radius Fix
Problem
- The religion-edit flow (
marker-edit-dialog.tsx) uses an olderSelectDropdown(@/components/ui/dropdown) for the religion-type field, while the create flow (religion-dialog.tsx) already uses the shareddropdown-menu.tsxprimitives. The two dialogs look inconsistent. - The edit dialog only offers 3 religion types (mosque/church/synagogue),
while the create dialog offers 7 (+ cathedral, temple, vihara, klenteng).
As a side effect, editing a cathedral/temple/vihara/klenteng POI shows no
type selector at all (
isReligionis false for those types). - The edit dialog has no way to change a religion POI's radius, even though the create dialog lets you set one.
- Radius circles never render on the map. Root cause: the live
poi_markerstable is missing theradius_meterscolumn entirely — the runningpba-new-backend-1container was built before this column was added todb-init.js/poi.routes.js, so radius data never persists.
Design
1. Shared RadiusSlider component
New file: frontend/components/poverty/radius-slider.tsx.
Extract the slider markup currently inline in religion-dialog.tsx
(0-2000m range input, step 50, live value badge, "0 = tidak tampilkan
lingkaran" hint). Props:
{ value: number; onChange: (v: number) => void }
Both dialogs render it inside their own <Field label="Radius Jangkauan (meter)">.
2. marker-edit-dialog.tsx
- Replace
SelectDropdownwithDropdownMenu/DropdownMenuTrigger/DropdownMenuContent/DropdownMenuRadioGroup/DropdownMenuRadioItemfrom@/components/ui/dropdown-menu, mirroring the trigger styling and icon rendering used inreligion-dialog.tsx. - Expand
RELIGION_OPTIONSto the same 7 entries asreligion-dialog.tsx(mosque/church/cathedral/temple/vihara/klenteng/synagogue, with Indonesian labels and icons). - Add
radiusMetersstate, populated fromrow.radius_meters ?? 0in the existing POI-loadinguseEffect. - Render
<Field label="Radius Jangkauan (meter)"><RadiusSlider .../></Field>only whenisReligion. - On submit, when
isReligion: includeradius_meters: radiusMetersin the PUT body, and includeradius: radiusMetersin themetapassed toonUpdatedso the map redraws the circle immediately. - Remove the now-dead
SelectDropdownimport.
3. components/ui/dropdown.tsx
Remove the now-unused SelectDropdown / SelectOption / dropdownSpring
exports (confirmed unused elsewhere via grep).
4. religion-dialog.tsx
Replace the inline slider block with <RadiusSlider value={radiusMeters} onChange={setRadiusMeters} />. No behavior change, just dedup.
5. Backend DB migration
Run docker compose up -d --build backend from /Users/pangkywaradjodi/pba-new
so initDb() re-runs ALTER TABLE poi_markers ADD COLUMN IF NOT EXISTS radius_meters INT DEFAULT 0 against the live database. Verify with
\d poi_markers afterward.
Data flow after the fix
- Create (
religion-dialog.tsx): POST/poiwithradius_meters→ now persists correctly once the column exists. - Edit (
marker-edit-dialog.tsx): GET/poi/:idreturnsradius_meters→ loaded into the slider → PUT/poi/:idsaves it →onUpdatedupdatesuserMarkers→leaflet-map.tsxredraws the circle (existing circle-drawing logic is already correct, it just never received real data). - Page load: GET
/poialready mapsradius_meters→meta.radius, so existing POIs with a radius now render circles too.
Testing
- Rebuild backend, confirm
radius_meterscolumn exists. - Manual flow via dev server: create a religion POI with radius > 0 → circle appears. Edit an existing religion POI (including a cathedral/temple/etc.), change type via the new dropdown, adjust radius, save → circle updates. Reload page → circle persists.