mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
add react-places-autocomplete to the new design
This commit is contained in:
parent
fcaaf44457
commit
479ce77c82
|
@ -1,4 +1,5 @@
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import PlacesAutocomplete from 'react-places-autocomplete';
|
||||||
|
|
||||||
const green = '#60f760';
|
const green = '#60f760';
|
||||||
const lightgrey = '#e0e0e0';
|
const lightgrey = '#e0e0e0';
|
||||||
|
@ -16,6 +17,8 @@ export default function Event({
|
||||||
}) {
|
}) {
|
||||||
const [needRideThere, setNeedRideThere] = useState(false);
|
const [needRideThere, setNeedRideThere] = useState(false);
|
||||||
const [needRideBack, setNeedRideBack] = useState(false);
|
const [needRideBack, setNeedRideBack] = useState(false);
|
||||||
|
const [rideThereLocation, setRideThereLocation] = useState('');
|
||||||
|
const [rideBackLocation, setRideBackLocation] = useState('');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -118,17 +121,67 @@ export default function Event({
|
||||||
</div>
|
</div>
|
||||||
{needRideThere && (
|
{needRideThere && (
|
||||||
<>
|
<>
|
||||||
<input
|
<PlacesAutocomplete
|
||||||
type="text"
|
onChange={(address) => setRideThereLocation(address)}
|
||||||
style={{
|
value={rideThereLocation}
|
||||||
marginTop: '0.5em',
|
>
|
||||||
padding: '0.5em',
|
{({
|
||||||
fontSize: '1.25rem',
|
getInputProps,
|
||||||
borderRadius: '0.5em',
|
getSuggestionItemProps,
|
||||||
border: '0px',
|
suggestions,
|
||||||
}}
|
loading,
|
||||||
placeholder="Where would you be picked up?"
|
}) => (
|
||||||
/>
|
<div
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
{...getInputProps({
|
||||||
|
style: {
|
||||||
|
marginTop: '0.5em',
|
||||||
|
padding: '0.5em',
|
||||||
|
fontSize: '1.25rem',
|
||||||
|
borderRadius: '0.5em',
|
||||||
|
border: '0px',
|
||||||
|
zIndex: 1,
|
||||||
|
},
|
||||||
|
placeholder: 'Where would you be picked up?',
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
{loading
|
||||||
|
? 'Loading'
|
||||||
|
: suggestions.length > 0 && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: '-1em',
|
||||||
|
paddingTop: '2em',
|
||||||
|
paddingBottom: '1em',
|
||||||
|
paddingLeft: '1em',
|
||||||
|
paddingRight: '1em',
|
||||||
|
borderBottomLeftRadius: '0.5em',
|
||||||
|
borderBottomRightRadius: '0.5em',
|
||||||
|
backgroundColor: 'white',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{suggestions.map((suggestion) => (
|
||||||
|
<div
|
||||||
|
{...getSuggestionItemProps(suggestion)}
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
key={suggestion.placeId}
|
||||||
|
>
|
||||||
|
{suggestion.description}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</PlacesAutocomplete>
|
||||||
<input
|
<input
|
||||||
type="time"
|
type="time"
|
||||||
style={{
|
style={{
|
||||||
|
@ -144,17 +197,67 @@ export default function Event({
|
||||||
)}
|
)}
|
||||||
{needRideBack && (
|
{needRideBack && (
|
||||||
<>
|
<>
|
||||||
<input
|
<PlacesAutocomplete
|
||||||
type="text"
|
onChange={(address) => setRideBackLocation(address)}
|
||||||
style={{
|
value={rideBackLocation}
|
||||||
marginTop: '0.5em',
|
>
|
||||||
padding: '0.5em',
|
{({
|
||||||
fontSize: '1.25rem',
|
getInputProps,
|
||||||
borderRadius: '0.5em',
|
getSuggestionItemProps,
|
||||||
border: '0px',
|
suggestions,
|
||||||
}}
|
loading,
|
||||||
placeholder="Where would you be dropped off?"
|
}) => (
|
||||||
/>
|
<div
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
{...getInputProps({
|
||||||
|
style: {
|
||||||
|
marginTop: '0.5em',
|
||||||
|
padding: '0.5em',
|
||||||
|
fontSize: '1.25rem',
|
||||||
|
borderRadius: '0.5em',
|
||||||
|
border: '0px',
|
||||||
|
zIndex: 1,
|
||||||
|
},
|
||||||
|
placeholder: 'Where would you be dropped off?',
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
{loading
|
||||||
|
? 'Loading'
|
||||||
|
: suggestions.length > 0 && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: '-1em',
|
||||||
|
paddingTop: '2em',
|
||||||
|
paddingBottom: '1em',
|
||||||
|
paddingLeft: '1em',
|
||||||
|
paddingRight: '1em',
|
||||||
|
borderBottomLeftRadius: '0.5em',
|
||||||
|
borderBottomRightRadius: '0.5em',
|
||||||
|
backgroundColor: 'white',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{suggestions.map((suggestion) => (
|
||||||
|
<div
|
||||||
|
{...getSuggestionItemProps(suggestion)}
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
}}
|
||||||
|
key={suggestion.placeId}
|
||||||
|
>
|
||||||
|
{suggestion.description}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</PlacesAutocomplete>
|
||||||
<input
|
<input
|
||||||
type="time"
|
type="time"
|
||||||
style={{
|
style={{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user