mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
add confirmed button
This commit is contained in:
parent
11272ce41a
commit
a7b70a31e7
|
@ -21,6 +21,7 @@ export default function Event({
|
|||
const [needRideBack, setNeedRideBack] = useState(false);
|
||||
const [rideTherePickupPlaceID, setRideTherePickupPlaceID] = useState('');
|
||||
const [rideBackDropoffPlaceID, setRideBackDropoffPlaceID] = useState('');
|
||||
const [confirmed, setConfirmed] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
console.log({ rideTherePickupPlaceID, rideBackDropoffPlaceID });
|
||||
|
@ -131,9 +132,10 @@ export default function Event({
|
|||
</span>
|
||||
<UIPlacesAutocomplete
|
||||
placeholder="Pickup location"
|
||||
onSelected={(address, placeID) =>
|
||||
setRideTherePickupPlaceID(placeID)
|
||||
}
|
||||
onSelected={(address, placeID) => {
|
||||
setRideTherePickupPlaceID(placeID);
|
||||
setConfirmed(false);
|
||||
}}
|
||||
/>
|
||||
<UITimeInput />
|
||||
</>
|
||||
|
@ -152,13 +154,35 @@ export default function Event({
|
|||
</span>
|
||||
<UIPlacesAutocomplete
|
||||
placeholder="Dropoff location"
|
||||
onSelected={(address, placeID) =>
|
||||
setRideBackDropoffPlaceID(placeID)
|
||||
}
|
||||
onSelected={(address, placeID) => {
|
||||
setRideBackDropoffPlaceID(placeID);
|
||||
setConfirmed(false);
|
||||
}}
|
||||
/>
|
||||
<UITimeInput />
|
||||
</>
|
||||
)}
|
||||
{(needRideThere || needRideBack) &&
|
||||
(rideTherePickupPlaceID || rideBackDropoffPlaceID) && (
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: confirmed ? green : lightgrey,
|
||||
color: confirmed ? 'white' : 'black',
|
||||
padding: '1rem',
|
||||
borderRadius: '0.5em',
|
||||
textTransform: 'uppercase',
|
||||
fontWeight: 500,
|
||||
marginTop: '0.5em',
|
||||
cursor: 'pointer',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
onClick={() => {
|
||||
setConfirmed((confirmed) => !confirmed);
|
||||
}}
|
||||
>
|
||||
{confirmed ? 'Confirmed' : 'Confirm'}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,12 @@ export default function UIPlacesAutocomplete({
|
|||
const suggestionsRef = useRef<readonly Suggestion[]>([]);
|
||||
return (
|
||||
<PlacesAutocomplete
|
||||
onChange={setLocation}
|
||||
onChange={(location) => {
|
||||
setLocation(location);
|
||||
if (onSelected) {
|
||||
onSelected(null!, null!);
|
||||
}
|
||||
}}
|
||||
onSelect={(address, placeID) => {
|
||||
setLocation(address);
|
||||
if (onSelected) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user