Customer List & CRM
Customer List & CRM
Relevant source files
The following files were used as context for generating this wiki page:
The Customer List and CRM module provides the primary interface for managing customer entities and tracking sales pipelines. It leverages the EntityListTable architecture for high-performance data grids, featuring advanced server-side filtering, metadata-driven UI configuration, and robust state persistence.
Customer List Architecture
The /customers route is a specialized implementation of the entity list pattern. It manages the lifecycle of customer data from metadata retrieval to paginated row loading.
Lifecycle and Data Flow
The route follows a strict loading sequence: loadMeta (UI configuration) followed by loadRows (data).
- Metadata Caching: To prevent redundant API calls during navigation or HMR, customer metadata is cached in
globalThis.__pbCustomerMetaCachesrc/routes/(app)/customers/+page.svelte:149-163. - State Restoration: Upon mounting, the component restores
visibleKeys,sortKey, andsearchInKeysfromsessionStoragesrc/routes/(app)/customers/+page.svelte:107-111. - Connectivity Recovery: The route listens for
onConnectivityRestoredevents to automatically refresh data after a network outage src/routes/(app)/customers/+page.svelte:273-276.
Metadata and Row Lifecycle
The following diagram illustrates the initialization and data fetching sequence for the Customer List.
Customer List Initialization Sequence
Code
Sources: src/routes/(app)/customers/+page.svelte:165-244, src/routes/(app)/customers/+page.svelte:149-163, src/routes/(app)/customers/+page.svelte:107-111
Filtering and Search
The module supports three layers of data restriction: global search, standard filters, and advanced logical filters.
Search Implementation
- Search Syntax: Supports wildcard tokens and field-specific overrides.
- Debouncing: Search input is debounced via a
searchTimerto prevent excessive API requests while typing src/routes/(app)/customers/+page.svelte:73-73. - Search In Keys: Users can restrict the search to specific columns, persisted in
sessionStoragesrc/routes/(app)/customers/+page.svelte:99-109.
Advanced Filters
The FiltersPanel provides a UI for complex queries using AND/OR connectors and various operators (e.g., BETWEEN, contains, startsWith) src/lib/entity-list/types.ts:136-146.
| Operator | Applicable Types | Description |
|---|---|---|
= / != | All | Exact match or inequality |
contains | text | Substring search |
BETWEEN | date, datetime | Range selection |
> / < | date, datetime, number | Comparison operators |
Sources: src/lib/entity-list/sheets/panels/FiltersPanel.svelte:74-85, src/lib/entity-list/types.ts:157-170
Connectivity & Error Handling
The Customer List is designed for resilience, handling backend unavailability through the AppError system.
- RFC 7807 Handling: API errors are parsed into Problem Details objects. If a fetch fails due to a database being unavailable (
ApiDatabaseUnavailableError) or the server being unreachable (ApiUnreachableError), apushImpactErroris triggered with aHIGHimpact level src/routes/(app)/customers/+page.svelte:18-19. - Automatic Retry: When the
onConnectivityRestoredevent fires (managed by theAppShellhealth probe), the page automatically invokesloadRows()to refresh the UI src/routes/(app)/customers/+page.svelte:273-276.
Entity State to Code Mapping
Code
Sources: src/routes/(app)/customers/+page.svelte:18-20, src/lib/app-connectivity-events.ts, src/lib/errors/app-errors.ts
Date and Time Localization
The customer list handles complex timezone scenarios, particularly for datetime columns.
- IANA Toggling: Users can toggle between
browser(local) andrecord(stored IANA) timezones fordatetimecolumns src/routes/(app)/customers/+page.svelte:104-105. - Formatting Pipeline: Raw values are passed through
formatListCellValue, which utilizesIntl.DateTimeFormatcached by locale tag and timezone src/lib/i18n/date-format.ts:102-121. - UTC Normalization: When applying date filters, values are converted to UTC ISO strings before being sent to the API, ensuring server-side consistency src/lib/entity-list/sheets/panels/FiltersPanel.svelte:142-145.
Sources: src/lib/i18n/date-format.ts:4-7, src/lib/i18n/date-format.ts:102-121, src/lib/entity-list/sheets/panels/FiltersPanel.svelte:134-162
CRM Pipeline
The CRM Pipeline (/crm/pipeline) serves as a placeholder for the upcoming sales management features.
- Structure: Uses
AppPageScaffoldandAppPageBreadcrumbfor shell consistency src/routes/(app)/crm/pipeline/+page.svelte:10-24. - Navigation: Integrates with
shellNav.modulesvia thecrmModuleMenuSegmentto provide contextual breadcrumbs src/routes/(app)/crm/pipeline/+page.svelte:15-20. - Content: Currently displays static information regarding lead tracking and pipeline stages as defined in the i18n bundles src/routes/(app)/crm/pipeline/+page.svelte:26-40.
Sources: src/routes/(app)/crm/pipeline/+page.svelte:1-42, src/lib/breadcrumb/crm-breadcrumb.ts