Skip to content
This repository has been archived by the owner on Mar 3, 2025. It is now read-only.

Commit

Permalink
Implement searchWindow search parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
testower committed Oct 3, 2023
1 parent 4d8805c commit e2512ce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client-next/src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LocationInputField } from './LocationInputField.tsx';
import { DepartureArrivalSelect } from './DepartureArrivalSelect.tsx';
import { TimeInputField } from './TimeInputField.tsx';
import { DateInputField } from './DateInputField.tsx';
import { SearchWindowInput } from './SearchWindowInput.tsx';

export function SearchBar({
onRoute,
Expand All @@ -22,6 +23,7 @@ export function SearchBar({
<DepartureArrivalSelect tripQueryVariables={tripQueryVariables} setTripQueryVariables={setTripQueryVariables} />
<TimeInputField tripQueryVariables={tripQueryVariables} setTripQueryVariables={setTripQueryVariables} />
<DateInputField tripQueryVariables={tripQueryVariables} setTripQueryVariables={setTripQueryVariables} />
<SearchWindowInput tripQueryVariables={tripQueryVariables} setTripQueryVariables={setTripQueryVariables} />
<Button variant="primary" onClick={onRoute}>
Route
</Button>
Expand Down
29 changes: 29 additions & 0 deletions client-next/src/components/SearchBar/SearchWindowInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Form } from 'react-bootstrap';
import { TripQueryVariables } from '../../gql/graphql.ts';

export function SearchWindowInput({
tripQueryVariables,
setTripQueryVariables,
}: {
tripQueryVariables: TripQueryVariables;
setTripQueryVariables: (tripQueryVariables: TripQueryVariables) => void;
}) {
return (
<Form.Group>
<Form.Label htmlFor="searchWindowInput">Search window (seconds)</Form.Label>
<Form.Control
type="number"
id="searchWindowInput"
size="sm"
placeholder="3600"
value={tripQueryVariables.searchWindow || undefined}
onChange={(event) =>
setTripQueryVariables({
...tripQueryVariables,
searchWindow: Number(event.target.value),
})
}
/>
</Form.Group>
);
}
4 changes: 2 additions & 2 deletions client-next/src/hooks/useTripQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const endpoint = `https://api.entur.io/journey-planner/v3/graphql`;
TODO: should live in a separate file, and split into fragments for readability
*/
const query = graphql(`
query trip($from: Location!, $to: Location!, $arriveBy: Boolean, $dateTime: DateTime) {
trip(from: $from, to: $to, arriveBy: $arriveBy, dateTime: $dateTime) {
query trip($from: Location!, $to: Location!, $arriveBy: Boolean, $dateTime: DateTime, $searchWindow: Int) {
trip(from: $from, to: $to, arriveBy: $arriveBy, dateTime: $dateTime, searchWindow: $searchWindow) {
tripPatterns {
aimedStartTime
aimedEndTime
Expand Down

0 comments on commit e2512ce

Please sign in to comment.