mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 02:34:21 +00:00
refactor(collections): share the add place to list logic between desktop and phone
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.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
/** 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;
|
||||
Reference in New Issue
Block a user