mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
feat(mobile): add a place shared from Google Maps or Amap to a trip
A place shared from a maps app to TREK could only be kept among a trip's links or read as a booking. A map link is now first offered as a place: after the trip is picked, its new place sheet opens with the link in the search, which looks it up at once through the existing resolver, so name, address and position are filled in and only need saving. Other links are offered as before. Addresses discussion #2582.
This commit is contained in:
@@ -60,6 +60,8 @@ export interface PlaceSearchOptions {
|
||||
* search ends the billing session, and a pick clears the typed-ahead list too.
|
||||
*/
|
||||
variant: 'dialog' | 'sheet';
|
||||
/** What the field starts with, such as a map link shared to the app (#2582). */
|
||||
initialQuery?: string;
|
||||
/** Where the trip is happening: autocomplete is biased to the box, the full search to its centre. */
|
||||
locationBias: LocationBiasBox | undefined;
|
||||
t: ReturnType<typeof useTranslation>['t'];
|
||||
@@ -101,6 +103,7 @@ export function usePlaceSearch({
|
||||
onMapLink,
|
||||
onCoordinates,
|
||||
onResolvingChange,
|
||||
initialQuery,
|
||||
}: PlaceSearchOptions) {
|
||||
const sheet = variant === 'sheet';
|
||||
// Place names in the language the user picked for them, the app's otherwise (#1799).
|
||||
@@ -110,7 +113,7 @@ export function usePlaceSearch({
|
||||
// The same hint autocomplete gets, as a point instead of a box.
|
||||
const biasPoint = pointFromBox(locationBias);
|
||||
|
||||
const [query, setQuery] = useState('');
|
||||
const [query, setQuery] = useState(initialQuery ?? '');
|
||||
const [results, setResults] = useState<MapsSearchRow[]>([]);
|
||||
/** What answered the last full search. Only a fallback: a merged list carries the source per place. */
|
||||
const [searchSource, setSearchSource] = useState('');
|
||||
|
||||
Reference in New Issue
Block a user