mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
b2fd0ae5aa
useAddPlaceToCollection holds the maps search, the pick and the save that AddPlaceToCollectionModal and MCollAddSheet each carried, with the pure helpers in addPlaceModel. The differences stay as variants. The desktop resets and stays open after an add, sends links and typed coordinates and shows the error's own text. The phone closes, takes coordinates only from the picked hit, ignores a second search or save while one is running and shows the fallback text.
10 lines
539 B
TypeScript
10 lines
539 B
TypeScript
/** A place as the maps search hands it back: loosely typed, every field optional. */
|
|
export type MapsPlace = Record<string, unknown>;
|
|
|
|
/** A non-empty string field of a maps place, or undefined. */
|
|
export const str = (v: unknown): string | undefined => (typeof v === 'string' && v ? v : undefined);
|
|
|
|
/** A numeric field of a maps place, whether it came as a number or as text, or undefined. */
|
|
export const num = (v: unknown): number | undefined =>
|
|
typeof v === 'number' ? v : typeof v === 'string' && v !== '' ? Number(v) : undefined;
|