-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aircraft selection in homepage (#134)
- Loading branch information
Showing
4 changed files
with
126 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import GeneralLayout from '../src/layouts/GeneralLayout'; | ||
import Lead from '../src/components/Lead'; | ||
import SearchFlightsForm from '../src/components/SearchFlightsForm'; | ||
import { fetchCompanies } from '../src/services/fetch-companies'; | ||
import { fetchAirports } from '../src/services/fetch-airports'; | ||
import GeneralLayout from "../src/layouts/GeneralLayout"; | ||
import Lead from "../src/components/Lead"; | ||
import SearchFlightsForm from "../src/components/SearchFlightsForm"; | ||
import { fetchCompanies } from "../src/services/fetch-companies"; | ||
import { fetchAircraftIcaoCodes } from "../src/services/fetch-aircraft-icao-codes"; | ||
import { fetchAirports } from "../src/services/fetch-airports"; | ||
|
||
export const revalidate = 3600; | ||
|
||
export default async function Page() { | ||
const companies = await fetchCompanies() | ||
const airports = await fetchAirports(); | ||
const companies = await fetchCompanies(); | ||
const airports = await fetchAirports(); | ||
const aircraftIcaoCodes = await fetchAircraftIcaoCodes(); | ||
|
||
return <GeneralLayout> | ||
<Lead>To begin, fill at least one of the following fields.</Lead> | ||
<SearchFlightsForm airports={airports} companies={companies} /> | ||
return ( | ||
<GeneralLayout> | ||
<Lead>To begin, fill at least one of the following fields.</Lead> | ||
<SearchFlightsForm | ||
airports={airports} | ||
companies={companies} | ||
aircraftIcaoCodes={aircraftIcaoCodes} | ||
/> | ||
</GeneralLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { FlightModel } from "@mach/database"; | ||
import { QueryTypes } from "sequelize"; | ||
|
||
export async function fetchAircraftIcaoCodes() { | ||
const companies = await FlightModel.sequelize?.query( | ||
`SELECT DISTINCT(aircraft#>>'{icaoCode}') AS "aircraftIcaoCode" FROM "flights" AS "flight";`, | ||
{ type: QueryTypes.SELECT } | ||
); | ||
|
||
return companies?.map((v: any) => v.aircraftIcaoCode) ?? []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abbf54c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mach – ./
mach-five.vercel.app
mach-git-master-jpedroh.vercel.app
mach-jpedroh.vercel.app
mach.jpedroh.dev