Skip to content

Component Name: fellowsSearch

Last Updated: 2025-09-29 Source Code: https://bitbucket.org/i2cinc/i2c.salesforce.metadata/src/STAGING/force-app/main/default/lwc/fellowsSearch

API Name: c-fellowsSearch Type: Page Component Target: lightningCommunity__Page, lightningCommunity__Default

Business Purpose

Displays searchable, sortable, paginated list of AANP Fellows. Users can search by name/title/year/city/state, sort by induction year/city/state, and click fellow names to view full profiles. Implements client-side filtering/sorting with URL parameter persistence for shareable links.

User Interface

  • Layout: Search box + table + pagination
  • Key UI Elements: Search input, sortable table headers, fellow links, pagination controls
  • Responsive: Stacks on mobile

Component Structure

Files

  • fellowsSearch.html - Template (156 lines)
  • fellowsSearch.js - Controller (190 lines)
  • fellowsSearch.js-meta.xml - Community page target

JavaScript Controller

Properties (API)

None - loads all fellows automatically

Tracked Properties

  • fellowsList: All fellows from wire
  • searchTerm: Current search query
  • pageNumber: Current page (1-indexed)
  • sortDirection: 'asc', 'desc', or ''
  • sortField: 'inductionYear', 'city', 'state', or ''

Wire Adapters

@wire(CurrentPageReference)

  • Reads URL parameters (pageNumber, sortDirection, sortField, searchTerm)
  • Initializes state from URL on load

@wire(getFellowsList)

  • Loads all AANP Fellows
  • Maps to { id, name, title, inductionYear, city, state, url }

Event Handlers

  • handleSearchTermChange: Updates searchTerm, resets pageNumber, updates URL
  • handleSort: Cycles through desc → asc → none for clicked column
  • handlePageChange: Updates pageNumber from pagination component

Computed Properties

filteredFellowsList

  • Filters by searchTerm across all fields
  • Sorts by sortField/sortDirection
  • Paginates to current page (10 per page)

isEmpty, notFound, totalItems

  • UI state helpers

Private Methods

mapFellowFields(data)

  • Maps Account to display object

updateQueryParams(params)

  • Updates browser URL with current state

Events

Handles pagechange from c-pagination child component

Dependencies

  • Apex: AccountController.getFellowsList()
  • Child components: c-form-input, c-pagination
  • Objects: Account (Name, Fellow_Title__c, Fellow_Induction_Year__c, PersonMailingCity, PersonMailingStateCode)

Usage Examples

<!-- On Fellows search page -->
<c-fellows-search></c-fellows-search>

⚠️ Pre-Go-Live Concerns

CRITICAL

  • Loads ALL fellows client-side: No server-side pagination - could be thousands of records

HIGH

  • No loading state: Users see blank table while loading
  • No error handling: Wire error just logs to console
  • Client-side filtering inefficient: Should use server-side search for performance

MEDIUM

  • URL manipulation: Uses window.history.replaceState (works but not standard LWC pattern)
  • Sort logic complex: Empty string handling for "no sort" (lines 63-73)

Maintenance Notes

Complexity: Medium Key Notes: - CRITICAL: Client-side filtering/sorting - doesn't scale beyond ~1000 fellows - URL persistence allows shareable search/sort/page states - Uses c-pagination for page controls - Sorting cycles: none → desc → asc → none - Search is case-insensitive across 5 fields - 10 items per page (ITEMS_PER_PAGE constant)