feat(trucks): site_id column and site/truck helpers
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
export function trucksForSite<T extends { site_id: string | null }>(trucks: T[], siteId: string): T[] {
|
||||
if (!siteId) return trucks
|
||||
return trucks.filter(t => t.site_id === null || t.site_id === siteId)
|
||||
}
|
||||
|
||||
export function siteForTruck(
|
||||
trucks: { id: string; site_id: string | null }[],
|
||||
truckId: string | null | undefined,
|
||||
): string | null {
|
||||
if (!truckId) return null
|
||||
return trucks.find(t => t.id === truckId)?.site_id ?? null
|
||||
}
|
||||
Reference in New Issue
Block a user