From 8fb18ae000550bd274c720422a744521191d1b29 Mon Sep 17 00:00:00 2001 From: toqvist Date: Mon, 26 Feb 2024 11:40:27 +0100 Subject: [PATCH] Remove geopicker for now --- src/collections/Makers.ts | 7 ++++++- src/customFields/geoPicker/GeoPicker.tsx | 13 +++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/collections/Makers.ts b/src/collections/Makers.ts index 0feebe2..9289fba 100644 --- a/src/collections/Makers.ts +++ b/src/collections/Makers.ts @@ -15,7 +15,12 @@ const Makers: CollectionConfig = { type: 'text', // required required: true, }, - geoPickerField, + //geoPickerField, is a bit broken right now + { + name: 'location', + type: 'point', + label: 'Location', + }, { name: 'products', // required type: 'relationship', // required diff --git a/src/customFields/geoPicker/GeoPicker.tsx b/src/customFields/geoPicker/GeoPicker.tsx index db5a2a9..3654b0f 100644 --- a/src/customFields/geoPicker/GeoPicker.tsx +++ b/src/customFields/geoPicker/GeoPicker.tsx @@ -3,8 +3,9 @@ import { useField } from 'payload/components/forms'; export const GeoPicker: React.FC<{ path: string }> = ({ path }) => { const { value, setValue } = useField({ path }); - const [longitude, setLongitude] = React.useState(value[0]); - const [latitude, setLatitude] = React.useState(value[1]); + const [longitude, setLongitude] = React.useState(value[0] || 0); + const [latitude, setLatitude] = React.useState(value[1] || 0); + const [error, setError] = React.useState("") const handleCityEnter = async (e) => { if (e.key === 'Enter') { @@ -19,8 +20,9 @@ export const GeoPicker: React.FC<{ path: string }> = ({ path }) => { setLongitude(lon); setValue([lon, lat]); } - } catch (error) { - console.error('Error fetching geolocation:', error); + } catch (err) { + setError(e) + console.error('Error fetching geolocation:', e); } } }; @@ -46,6 +48,9 @@ export const GeoPicker: React.FC<{ path: string }> = ({ path }) => { placeholder="Enter city to get coordinates" /> + {error != "" && +

{error}

+ }