Compare commits

..

3 Commits

Author SHA1 Message Date
8fb18ae000 Remove geopicker for now
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-26 11:40:27 +01:00
0e1d640a42 make courier field required for dispatches
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-26 00:26:04 +05:00
ac9b63a33a add sales point / exhibition place to retailers (#7)
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-25 19:58:24 +05:00
4 changed files with 22 additions and 6 deletions

View File

@ -60,6 +60,7 @@ const Dispatches: CollectionConfig = {
type: 'relationship',
relationTo: 'couriers',
hasMany: false,
required: true
},
{
name: 'timeSensitive',
@ -91,4 +92,4 @@ const Dispatches: CollectionConfig = {
],
};
export default Dispatches;
export default Dispatches;

View File

@ -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

View File

@ -24,6 +24,11 @@ const Retailers: CollectionConfig = {
type: 'relationship', // required
relationTo: 'products', // required
hasMany: true,
},
{
name: 'salesPoint',
type: 'text',
label: 'Where do you plan to sell/exhibit products?'
}
],
};

View File

@ -3,8 +3,9 @@ import { useField } from 'payload/components/forms';
export const GeoPicker: React.FC<{ path: string }> = ({ path }) => {
const { value, setValue } = useField<string>({ 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"
/>
</div>
{error != "" &&
<p>{error}</p>
}
<div className="field-type point">
<ul className='point__wrap'>
<li>