Compare commits
5 Commits
f152476d8f
...
main
Author | SHA1 | Date | |
---|---|---|---|
8fb18ae000 | |||
0e1d640a42 | |||
ac9b63a33a | |||
ac387d41ad | |||
2654b4a9c4 |
@ -10,10 +10,35 @@ const Couriers: CollectionConfig = {
|
|||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'name', // required
|
name: 'name',
|
||||||
type: 'text', // required
|
type: 'text',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'startingPoint',
|
||||||
|
label: 'Traveling from',
|
||||||
|
type: 'text', // TODO use geopicker here
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'destination',
|
||||||
|
label: 'Traveling to',
|
||||||
|
type: 'text' // TODO user geopicker here
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'departureDate',
|
||||||
|
label: 'Departure date',
|
||||||
|
type: 'date'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'arrivalDate',
|
||||||
|
label: 'Arrival date',
|
||||||
|
type: 'date'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'weightAllowance',
|
||||||
|
label: 'Weight Allowance (KG)',
|
||||||
|
type: 'number'
|
||||||
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,11 +32,35 @@ const Dispatches: CollectionConfig = {
|
|||||||
relationTo: 'retailers',
|
relationTo: 'retailers',
|
||||||
hasMany: false,
|
hasMany: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'typeOfTransportation',
|
||||||
|
type: 'select',
|
||||||
|
hasMany: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Air',
|
||||||
|
value: 'air'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Car',
|
||||||
|
value: 'car'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Train',
|
||||||
|
value: 'train'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Boat',
|
||||||
|
value: 'boat'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'courier',
|
name: 'courier',
|
||||||
type: 'relationship',
|
type: 'relationship',
|
||||||
relationTo: 'couriers',
|
relationTo: 'couriers',
|
||||||
hasMany: false,
|
hasMany: false,
|
||||||
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'timeSensitive',
|
name: 'timeSensitive',
|
||||||
@ -68,4 +92,4 @@ const Dispatches: CollectionConfig = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Dispatches;
|
export default Dispatches;
|
||||||
|
@ -15,7 +15,12 @@ const Makers: CollectionConfig = {
|
|||||||
type: 'text', // required
|
type: 'text', // required
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
geoPickerField,
|
//geoPickerField, is a bit broken right now
|
||||||
|
{
|
||||||
|
name: 'location',
|
||||||
|
type: 'point',
|
||||||
|
label: 'Location',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'products', // required
|
name: 'products', // required
|
||||||
type: 'relationship', // required
|
type: 'relationship', // required
|
||||||
|
@ -24,6 +24,11 @@ const Retailers: CollectionConfig = {
|
|||||||
type: 'relationship', // required
|
type: 'relationship', // required
|
||||||
relationTo: 'products', // required
|
relationTo: 'products', // required
|
||||||
hasMany: true,
|
hasMany: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'salesPoint',
|
||||||
|
type: 'text',
|
||||||
|
label: 'Where do you plan to sell/exhibit products?'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@ -3,8 +3,9 @@ import { useField } from 'payload/components/forms';
|
|||||||
|
|
||||||
export const GeoPicker: React.FC<{ path: string }> = ({ path }) => {
|
export const GeoPicker: React.FC<{ path: string }> = ({ path }) => {
|
||||||
const { value, setValue } = useField<string>({ path });
|
const { value, setValue } = useField<string>({ path });
|
||||||
const [longitude, setLongitude] = React.useState(value[0]);
|
const [longitude, setLongitude] = React.useState(value[0] || 0);
|
||||||
const [latitude, setLatitude] = React.useState(value[1]);
|
const [latitude, setLatitude] = React.useState(value[1] || 0);
|
||||||
|
const [error, setError] = React.useState("")
|
||||||
|
|
||||||
const handleCityEnter = async (e) => {
|
const handleCityEnter = async (e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
@ -19,8 +20,9 @@ export const GeoPicker: React.FC<{ path: string }> = ({ path }) => {
|
|||||||
setLongitude(lon);
|
setLongitude(lon);
|
||||||
setValue([lon, lat]);
|
setValue([lon, lat]);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
console.error('Error fetching geolocation:', error);
|
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"
|
placeholder="Enter city to get coordinates"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{error != "" &&
|
||||||
|
<p>{error}</p>
|
||||||
|
}
|
||||||
<div className="field-type point">
|
<div className="field-type point">
|
||||||
<ul className='point__wrap'>
|
<ul className='point__wrap'>
|
||||||
<li>
|
<li>
|
||||||
|
Reference in New Issue
Block a user