Skip to content

Sanc 79 google maps integration for driver trip addresses#73

Merged
promatty merged 2 commits intomainfrom
SANC-79-Google-Maps-Integration-for-Driver-Trip-Addresses
Apr 4, 2026
Merged

Sanc 79 google maps integration for driver trip addresses#73
promatty merged 2 commits intomainfrom
SANC-79-Google-Maps-Integration-for-Driver-Trip-Addresses

Conversation

@Yemyam
Copy link
Copy Markdown
Contributor

@Yemyam Yemyam commented Apr 3, 2026

Changes

  • Adds Google Maps address autocomplete to the pickup address field, mirroring the existing destination address implementation.
  • Fixed syncing of dom and form state in both address fields, so bookings can now be created properly now

Summary by CodeRabbit

  • Refactor
    • Enhanced form validation for address input fields to ensure consistency and reliability during submission. Both pickup and destination addresses now undergo the same validation process before allowing form submission.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
salvationarmy Ready Ready Preview, Comment Apr 3, 2026 0:31am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

The pull request extends Google Places autocomplete and ref-based validation support to the pickup address field, mirroring the existing destination address handling in the agency form and interactive area components. This includes adding ref binding, validation state management, autocomplete integration, and updated form synchronization logic.

Changes

Cohort / File(s) Summary
Agency Form Ref Wiring
src/app/_components/agencycomponents/agency-form.tsx
Added pickupAddressRef prop to AgencyFormProps and destructured it in the component. Changed both pickupAddress and destinationAddress TextInput components from spreading full form props to explicitly binding onChange, error, and ref attributes for direct ref control.
Agency Interactive Area Validation & Autocomplete
src/app/_components/agencycomponents/agency-interactive-area.tsx
Added validationPickupAddressGood state and pickupInputElement ref. Implemented Google Places Autocomplete integration for pickup address with validation via geometry checks and form field updates. Extended edit-mode synchronization to populate both destination and pickup fields when loading a booking. Updated submit logic to validate pickup address before submission. Modified payload creation to read destinationAddress from form state instead of DOM ref. Added event listener management and modal cleanup for both address inputs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AgencyInteractiveArea
    participant AgencyForm
    participant GooglePlaces
    participant MantineForm
    
    User->>AgencyForm: Types in pickup address input
    AgencyForm->>AgencyInteractiveArea: Input event via ref
    AgencyInteractiveArea->>GooglePlaces: Validate with Google Places API
    GooglePlaces-->>AgencyInteractiveArea: Return geometry validation
    AgencyInteractiveArea->>AgencyInteractiveArea: Set validationPickupAddressGood state
    AgencyInteractiveArea->>MantineForm: Write pickupAddress to form via setFieldValueRef
    AgencyInteractiveArea->>User: Display validated pickup address
    
    User->>AgencyForm: Clicks submit
    AgencyForm->>AgencyInteractiveArea: Trigger submit handler
    AgencyInteractiveArea->>AgencyInteractiveArea: Check validationPickupAddressGood
    alt Validation Passes
        AgencyInteractiveArea->>MantineForm: Read form.values (pickup & destination)
        MantineForm-->>AgencyInteractiveArea: Return address values
        AgencyInteractiveArea->>User: Submit booking with addresses
    else Validation Fails
        AgencyInteractiveArea->>AgencyForm: Set field error for pickupAddress
        AgencyInteractiveArea->>User: Display validation error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • jason-duong4509
  • burtonjong
  • JustinTan-1
  • themaxboucher
  • wesleylui
  • tanvimahal
  • Lujarios

Poem

🐰 Hopping through pickups with care and precision,
Refs and validation guide every decision,
Google and Mantine now work as one,
Autocomplete magic—the hard work is done!
🎉 Checkout's more sturdy, our form's looking keen!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding Google Maps integration for pickup address autocomplete in the driver trip addresses form.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SANC-79-Google-Maps-Integration-for-Driver-Trip-Addresses

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/_components/agencycomponents/agency-interactive-area.tsx`:
- Around line 225-275: The effect currently depends on
pickupInputElement.current and removes listeners using the ref at cleanup time,
which can detach the wrong element; capture the DOM element in a local const
(e.g., const el = pickupInputElement.current) and use that local variable for
mounting, adding the input listener (pickupInputElementOnInput), and for cleanup
(removeEventListener), and likewise capture googleAutoCompleteElement locally
for clearing its listeners; replace pickupInputElement.current in the dependency
array with stable props like showBookingModal and isLoaded (also update the
inputElement effect the same way) and ensure you still call
setFieldValueRef.current("pickupAddress", el.value ?? "") when handling
place_changed so you reference the captured element.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17db6a0f-5231-4e04-a408-48fcbbe1e356

📥 Commits

Reviewing files that changed from the base of the PR and between a9f337f and a7cec6e.

📒 Files selected for processing (2)
  • src/app/_components/agencycomponents/agency-form.tsx
  • src/app/_components/agencycomponents/agency-interactive-area.tsx

Comment thread src/app/_components/agencycomponents/agency-interactive-area.tsx
Copy link
Copy Markdown
Contributor

@promatty promatty left a comment

Choose a reason for hiding this comment

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

lgtm

@promatty promatty merged commit edfd191 into main Apr 4, 2026
4 checks passed
@promatty promatty deleted the SANC-79-Google-Maps-Integration-for-Driver-Trip-Addresses branch April 4, 2026 02:16
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.

2 participants