OpenTripPlanner/client/src/components/SearchBar/DepartureArrivalSelect.tsx
a-limyr f1cf602c53 Fixes to address feedback on pull request.
Moves styling to CSS.
Minor renaming of input option.
Minor layout change for input.
Minor layout change for reset button.
2025-09-09 14:13:09 +02:00

41 lines
1.2 KiB
TypeScript

import { Form } from 'react-bootstrap';
import { TripQueryVariables } from '../../gql/graphql.ts';
export function DepartureArrivalSelect({
tripQueryVariables,
setTripQueryVariables,
}: {
tripQueryVariables: TripQueryVariables;
setTripQueryVariables: (tripQueryVariables: TripQueryVariables) => void;
}) {
const onChange = (arriveBy: boolean | undefined) => {
if (arriveBy === undefined) {
const updatedVariables = { ...tripQueryVariables };
delete updatedVariables.arriveBy;
setTripQueryVariables(updatedVariables);
} else {
setTripQueryVariables({
...tripQueryVariables,
arriveBy,
});
}
};
return (
<Form.Group>
<Form.Label column="sm" htmlFor="departureArrivalSelect">
Depart/Arrive
</Form.Label>
<Form.Select
size="sm"
className="input-medium"
onChange={(e) => (e.target.value === 'arrival' ? onChange(true) : onChange(undefined))}
value={tripQueryVariables.arriveBy ? 'arrival' : 'departure'}
style={{ verticalAlign: 'bottom' }}
>
<option value="arrival">Arrive by</option>
<option value="departure">Depart after</option>
</Form.Select>
</Form.Group>
);
}