-
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 possibility to filter results by company (#99)
- Loading branch information
Showing
5 changed files
with
50 additions
and
19 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,10 +1,13 @@ | ||
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'; | ||
|
||
export default async function Page() { | ||
const companies = await fetchCompanies() | ||
|
||
export default function Page() { | ||
return <GeneralLayout> | ||
<Lead>To begin, fill at least one of the following fields.</Lead> | ||
<SearchFlightsForm /> | ||
<SearchFlightsForm companies={companies} /> | ||
</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
39 changes: 22 additions & 17 deletions
39
packages/front/src/components/SearchFlightsForm/index.tsx
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,13 @@ | ||
import { FlightModel } from "@mach/database"; | ||
import { Sequelize } from "sequelize"; | ||
|
||
export async function fetchCompanies() { | ||
const companies = await FlightModel.findAll({ | ||
attributes: [ | ||
[Sequelize.fn("DISTINCT", Sequelize.col("company")), "company"], | ||
], | ||
raw: true, | ||
}); | ||
|
||
return companies.map((v) => v.company); | ||
} |
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
c38bf85
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-jpedroh.vercel.app
mach.jpedroh.dev
mach-git-master-jpedroh.vercel.app
mach-five.vercel.app