Skip to content

feat: implement dynamic searchbar with location, date, and guests filters [#198]#208

Merged
respp merged 1 commit intoStellar-Rent:mainfrom
sublime247:dynamic-searchbar
Jan 22, 2026
Merged

feat: implement dynamic searchbar with location, date, and guests filters [#198]#208
respp merged 1 commit intoStellar-Rent:mainfrom
sublime247:dynamic-searchbar

Conversation

@sublime247
Copy link
Contributor

@sublime247 sublime247 commented Jan 22, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Location autocomplete with dropdown suggestions in search
    • Date picker for convenient date selection
    • Enhanced guest selection with separate adult and child count controls (1–16 adults, 0–10 kids)
    • Loading indicator during search operations
  • Performance

    • Optimized image format delivery for faster page loads

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

The pull request updates the web app with image format conversion to .webp, refactors PropertyGrid to use default export and accept dynamic properties, significantly enhances SearchBar with location autocomplete, date picker, and granular guest controls, and converts useUserRole hook from storage-based to API-driven role resolution.

Changes

Cohort / File(s) Summary
Mock Data Image Updates
apps/web/public/mock-data.ts
Converted all property image references from .jpg/.jpeg to .webp format; preserved image order and count per property; reformatted some arrays from single-line to multi-line structure.
Component Export & Import Refactoring
apps/web/src/app/page.tsx, apps/web/src/components/search/PropertyGrid.tsx
Changed PropertyGrid from named export to default export; updated page.tsx import accordingly; PropertyGrid now accepts PropertyGridProps (properties, onLoadMore) and maps incoming properties to PropertyCard format.
SearchBar Feature Enhancement
apps/web/src/components/features/search/SearchBar.tsx
Added location autocomplete with LOCATIONS constant and suggestion filtering; introduced date picker via Popover/Calendar; replaced static guests field with adult/kids controls (1–16 adults, 0–10 kids); added Search button with loading state; refactored navigation to use explicit router.push with query parameters instead of URLSearchParams.
Role Resolution Hook Refactoring
apps/web/src/hooks/useUserRole.tsx
Replaced storage-only role computation with API-driven flow via profileAPI.getUserProfile(); added explicit isLoading state; implemented try/catch fallback to localStorage on API failure; updated return type to UseUserRoleReturn (extends RoleInfo with isLoading).

Sequence Diagrams

sequenceDiagram
    participant User
    participant SearchBar
    participant Router
    participant SearchPage as /search

    User->>SearchBar: Enters location
    SearchBar->>SearchBar: Filter location suggestions
    SearchBar->>SearchBar: Display suggestions
    User->>SearchBar: Select location
    SearchBar->>SearchBar: Update location field

    User->>SearchBar: Click date input
    SearchBar->>SearchBar: Show Calendar popover
    User->>SearchBar: Select date
    SearchBar->>SearchBar: Update selectedDate

    User->>SearchBar: Increment/decrement adults/kids
    SearchBar->>SearchBar: Validate limits (1-16 adults, 0-10 kids)
    SearchBar->>SearchBar: Update guestsLabel
    User->>SearchBar: Click Done
    SearchBar->>SearchBar: Close guests popover

    User->>SearchBar: Click Search button
    SearchBar->>SearchBar: Validate location length
    SearchBar->>SearchBar: Build query params
    SearchBar->>Router: router.push(/search?...)
    Router->>SearchPage: Navigate with params
Loading
sequenceDiagram
    participant Component
    participant useUserRole
    participant profileAPI
    participant localStorage

    Component->>useUserRole: Call useUserRole()
    useUserRole->>useUserRole: Check user authentication
    alt User authenticated
        useUserRole->>profileAPI: getUserProfile(user.id)
        alt API success
            profileAPI-->>useUserRole: Return profile
            useUserRole->>useUserRole: Extract hostStatus, hasProperties
            useUserRole->>localStorage: Store hostStatus, hasProperties
            useUserRole-->>Component: Return roleInfo + isLoading=false
        else API failure
            useUserRole->>localStorage: Retrieve cached hostStatus, hasProperties
            useUserRole->>useUserRole: Compute role/permissions from fallback
            useUserRole-->>Component: Return roleInfo + isLoading=false
        end
    else User not authenticated
        useUserRole-->>Component: Return guest role + isLoading=false
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Images shimmer in webp delight,
PropertyGrid dons new export bright,
SearchBar dances with dates and places,
Guests count smoothly, API embraces,
The web app blooms with features new!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 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 feature: implementing a dynamic searchbar with location, date, and guests filters, which aligns with the primary changes in SearchBar.tsx.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@sublime247
Copy link
Contributor Author

sublime247 commented Jan 22, 2026

Closes #[198]
Below are the Changes I made:

Transforms the static SearchBar component into a fully interactive search experience, allowing users to filter properties by location, date, and guest count.

Changes Made
SearchBar.tsx

  • Complete Interactive Overhaul
    Location Input: Searchable text input with autocomplete dropdown
    Filters from predefined list of cities (Buenos Aires, New York, Miami, etc.)
    Shows suggestions as user types (minimum 2 characters)
    Click-to-select functionality with smooth transitions
    Date Picker: Interactive calendar popover
    Uses date-fns for formatting
    Disables past dates
    Displays selected date in "MMM d, yyyy" format
    Guests Selector: Adults/Kids counter with popover
    Increment/decrement buttons with min/max limits
    Adults: 1-16 range
    Kids: 0-10 range
    Dynamic label showing total guests breakdown
    Search Button: Visible submit button with loading state
    Shows spinner + "Searching..." during submission

Form validation with Zod schema
search/page.tsx

  • Filter Integration
    Reads location from URL search params
    Filters property results based on search criteria
    Maintains existing sort and filter sidebar functionality

Copy link
Contributor

@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: 2

🤖 Fix all issues with AI agents
In `@apps/web/src/components/features/search/SearchBar.tsx`:
- Around line 4-5: The import for date formatting in the SearchBar component is
using a named import from the subpath (`import { format } from
'date-fns/format'`) which is incorrect; change it to import the named export
from the main package (e.g., `import { format } from 'date-fns'`) so the
SearchBar.tsx component (and any usage of format inside that component) uses the
correct date-fns import and avoids build errors.
- Around line 92-96: handleDateSelect currently stores date using
date.toISOString() and doesn't clear formData.date when deselected; update it to
setSelectedDate(date) then if date is defined call setFormData(prev => ({
...prev, date: format(date, 'yyyy-MM-dd') })) (import format from 'date-fns'),
and when date is undefined call setFormData(prev => ({ ...prev, date: '' })) to
clear the value; reference the handleDateSelect, setSelectedDate, setFormData
and formData.date symbols when making the change.

Comment on lines +4 to +5
import { format } from 'date-fns/format';
import { Loader2, Minus, Plus, Search } from 'lucide-react';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find package.json and check date-fns version
find . -name "package.json" -type f | head -5

Repository: Stellar-Rent/stellar-rent

Length of output: 194


🏁 Script executed:

# Check if package-lock.json exists
ls -la package*.json 2>/dev/null || echo "No package files in root"

Repository: Stellar-Rent/stellar-rent

Length of output: 201


🏁 Script executed:

# Search for date-fns in package files
rg "date-fns" --type json

Repository: Stellar-Rent/stellar-rent

Length of output: 777


🏁 Script executed:

# Check the SearchBar.tsx file to see the context
cat -n apps/web/src/components/features/search/SearchBar.tsx | head -20

Repository: Stellar-Rent/stellar-rent

Length of output: 937


🌐 Web query:

date-fns 4.1.0 import format subpath date-fns/format vs date-fns named import

💡 Result:

Short answer

  • Both work in date-fns v4.1.0: you can import the function via the subpath (import format from "date-fns/format") or as a named export (import { format } from "date-fns"). [1][2]

When to use which (brief)

  • Use named imports (import { format } from "date-fns") when your bundler supports ESM tree-shaking — it's simplest and idiomatic. date-fns provides ESM and tree-shaking support. [1][8]
  • Use the subpath (import format from "date-fns/format") if you need to force importing a single file (older bundlers/Node setups, CDNs, or to be explicit about a single-module import). Historically that was recommended for smaller bundles and some CommonJS setups. [1][4]

Notes about v4.1.0

  • v4.1.0 added time‑zone support to format and other fixes; import semantics remain the same as in v2+ (ESM, per-function modules with sideEffects=false). [5][1]

Sources

  • date-fns blog: ECMAScript Modules / tree-shaking explanation. [1]
  • date-fns docs / format usage examples (shows both subpath and named imports). [4]
  • date-fns v4.1.0 release notes (adds timezone support; confirms v4 series). [5]

Fix date-fns import syntax to prevent build errors.

Line 4 uses import { format } from 'date-fns/format', treating the subpath export as a named export. In date-fns v4.1.0 (and all v2+), date-fns/format is a default export, not a named export, which will fail at build time. Use a named import from the main package instead.

🛠️ Proposed fix
-import { format } from 'date-fns/format';
+import { format } from 'date-fns';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { format } from 'date-fns/format';
import { Loader2, Minus, Plus, Search } from 'lucide-react';
import { format } from 'date-fns';
import { Loader2, Minus, Plus, Search } from 'lucide-react';
🤖 Prompt for AI Agents
In `@apps/web/src/components/features/search/SearchBar.tsx` around lines 4 - 5,
The import for date formatting in the SearchBar component is using a named
import from the subpath (`import { format } from 'date-fns/format'`) which is
incorrect; change it to import the named export from the main package (e.g.,
`import { format } from 'date-fns'`) so the SearchBar.tsx component (and any
usage of format inside that component) uses the correct date-fns import and
avoids build errors.

Comment on lines +92 to +96
const handleDateSelect = useCallback((date: Date | undefined) => {
setSelectedDate(date);
if (date) {
setFormData((prev) => ({ ...prev, date: date.toISOString() }));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check how the `date` query param is consumed elsewhere
rg -n "searchParams.*date|date.*searchParams" -g "*.tsx" apps/web/src

Repository: Stellar-Rent/stellar-rent

Length of output: 51


🏁 Script executed:

# Also search for date handling in general to understand the pattern
rg -n "\.date|date:" -g "*.tsx" apps/web/src/components/features/search --max-count=20

Repository: Stellar-Rent/stellar-rent

Length of output: 600


🏁 Script executed:

# Check the imports in SearchBar.tsx to see what date library is available
head -50 apps/web/src/components/features/search/SearchBar.tsx

Repository: Stellar-Rent/stellar-rent

Length of output: 1518


🏁 Script executed:

# Search for the full handleDateSelect implementation and surrounding context
sed -n '85,110p' apps/web/src/components/features/search/SearchBar.tsx

Repository: Stellar-Rent/stellar-rent

Length of output: 903


🏁 Script executed:

# Search for where the date search param is used/parsed
rg -n "searchParams.*get.*date|date.*searchParams" -g "*.tsx" apps/web/src

Repository: Stellar-Rent/stellar-rent

Length of output: 51


🏁 Script executed:

# Search for API calls that might use the date parameter
rg -n "date.*param|param.*date" -g "*.ts" -g "*.tsx" apps/web/src --max-count=30

Repository: Stellar-Rent/stellar-rent

Length of output: 759


🏁 Script executed:

# Check if there's any server-side handling of the date parameter
rg -n "\.date|date:" -g "*.ts" apps/web/src --max-count=20

Repository: Stellar-Rent/stellar-rent

Length of output: 2433


🏁 Script executed:

# Look at the full handleDateSelect and see if there's any date deselection logic
sed -n '92,102p' apps/web/src/components/features/search/SearchBar.tsx

Repository: Stellar-Rent/stellar-rent

Length of output: 448


Store date as YYYY-MM-DD format and clear on deselect.

Line 95 uses toISOString() which stores ISO 8601 format with time component, but the rest of the codebase expects YYYY-MM-DD format (as seen in mock data and type definitions). Additionally, when the date selection is removed (undefined), formData.date is not cleared—the old value persists. Use format(date, 'yyyy-MM-dd') and reset to an empty string on undefined.

Suggested fix
 const handleDateSelect = useCallback((date: Date | undefined) => {
   setSelectedDate(date);
-  if (date) {
-    setFormData((prev) => ({ ...prev, date: date.toISOString() }));
-  }
+  setFormData((prev) => ({
+    ...prev,
+    date: date ? format(date, 'yyyy-MM-dd') : '',
+  }));
 }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleDateSelect = useCallback((date: Date | undefined) => {
setSelectedDate(date);
if (date) {
setFormData((prev) => ({ ...prev, date: date.toISOString() }));
}
const handleDateSelect = useCallback((date: Date | undefined) => {
setSelectedDate(date);
setFormData((prev) => ({
...prev,
date: date ? format(date, 'yyyy-MM-dd') : '',
}));
}, []);
🤖 Prompt for AI Agents
In `@apps/web/src/components/features/search/SearchBar.tsx` around lines 92 - 96,
handleDateSelect currently stores date using date.toISOString() and doesn't
clear formData.date when deselected; update it to setSelectedDate(date) then if
date is defined call setFormData(prev => ({ ...prev, date: format(date,
'yyyy-MM-dd') })) (import format from 'date-fns'), and when date is undefined
call setFormData(prev => ({ ...prev, date: '' })) to clear the value; reference
the handleDateSelect, setSelectedDate, setFormData and formData.date symbols
when making the change.

@respp respp merged commit e15f0c3 into Stellar-Rent:main Jan 22, 2026
1 check passed
@sublime247
Copy link
Contributor Author

sublime247 commented Jan 22, 2026

This issue is not showing closed on the drips dashboard and I didn't see no point for it too.
@respp

@sublime247
Copy link
Contributor Author

@respp Please kindly close this issue, so I can get my point for this

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