import type { PlacesLibraryOrigin } from '@trek/shared'; import { Bookmark, Luggage } from 'lucide-react'; import React from 'react'; import type { TranslationFn } from '../../types'; /** How many origins a row names before it counts the rest. */ const SHOWN = 2; /** The name an origin goes by: the list's or the trip's. */ export function originName(origin: PlacesLibraryOrigin): string { return origin.kind === 'list' ? origin.collection_name : origin.trip_title; } /** * Where an entry of "All places" comes from (PLC-07): a chip per list and per trip, * trips first because they are what was actually planned, the rest counted. */ export default function LibraryOrigins({ origins, t, }: { origins: PlacesLibraryOrigin[]; t: TranslationFn; }): React.ReactElement { const ordered = [...origins].sort((a, b) => (a.kind === b.kind ? 0 : a.kind === 'trip' ? -1 : 1)); const rest = ordered.length - SHOWN; return (