feat: Add street address to locations

Adds a street_address column to the locations table and updates the LocationSearch component to capture, store, and display full street addresses. This includes database migration, interface updates, and formatter logic.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-06 13:51:40 +00:00
parent c1683f9b02
commit 98fbc94476
5 changed files with 128 additions and 9 deletions

View File

@@ -0,0 +1,64 @@
/**
* Location Formatting Utilities
*
* Centralized utilities for formatting location data consistently across the app.
*/
export interface LocationData {
street_address?: string | null;
city?: string | null;
state_province?: string | null;
country?: string | null;
postal_code?: string | null;
}
/**
* Format location for display
* @param location - Location data object
* @param includeStreet - Whether to include street address in the output
* @returns Formatted location string or null if no location data
*/
export function formatLocationDisplay(
location: LocationData | null | undefined,
includeStreet: boolean = false
): string | null {
if (!location) return null;
const parts: string[] = [];
if (includeStreet && location.street_address) {
parts.push(location.street_address);
}
if (location.city) {
parts.push(location.city);
}
if (location.state_province) {
parts.push(location.state_province);
}
if (location.country) {
parts.push(location.country);
}
return parts.length > 0 ? parts.join(', ') : null;
}
/**
* Format full address including street
* @param location - Location data object
* @returns Formatted full address or null if no location data
*/
export function formatFullAddress(location: LocationData | null | undefined): string | null {
return formatLocationDisplay(location, true);
}
/**
* Format location without street address (city, state, country only)
* @param location - Location data object
* @returns Formatted location without street or null if no location data
*/
export function formatLocationShort(location: LocationData | null | undefined): string | null {
return formatLocationDisplay(location, false);
}