diff --git a/modules/web-home/src/views/index.tsx b/modules/web-home/src/views/index.tsx index 68ed0173..58ef51dd 100644 --- a/modules/web-home/src/views/index.tsx +++ b/modules/web-home/src/views/index.tsx @@ -4,10 +4,10 @@ import { Checkbox } from '@mach/web-shared-ui/checkbox' import { Layout } from '@mach/web-shared-ui/layout' import { Lead } from '@mach/web-shared-ui/lead' import { Select } from '@mach/web-shared-ui/select' -import { LoaderFunctionArgs } from 'react-router' +import { Await, LoaderFunctionArgs } from 'react-router' import { Form, useLoaderData } from 'react-router' -import { useState } from 'react' +import { Suspense, useState } from 'react' import { serverOnly$ } from 'vite-env-only/macros' import { fetchAircraftIcaoCodes } from '../services/fetch-aircraft-icao-codes' @@ -20,16 +20,16 @@ import { formatAirport } from '../utils/format-airport' export const loader = serverOnly$(({ context }: LoaderFunctionArgs) => { const db = makeDatabaseConnection(context) - return Promise.all([ - fetchCycles(db), - fetchCompanies(db), - fetchAirports(db), - fetchAircraftIcaoCodes(db), - ]) + return { + cycles: fetchCycles(db), + companies: fetchCompanies(db), + airports: fetchAirports(db), + aircraftIcaoCodes: fetchAircraftIcaoCodes(db), + } }) export function HomePage() { - const [cycles, companies, airports, aircraftIcaoCodes] = + const { cycles, companies, airports, aircraftIcaoCodes } = useLoaderData() const [errorMessage, setErrorMessage] = useState('') @@ -47,67 +47,90 @@ export function HomePage() { return ( - To begin, fill at least one of the following fields. + Loading...}> + To begin, fill at least one of the following fields. -
- ({ + id: cycle, + name: cycle, + }))} + defaultSelectedKey={cycles[0]} + /> + )} + - ({ + id: airport.id, + name: formatAirport(airport), + }))} + /> - ({ + id: airport.id, + name: formatAirport(airport), + }))} + /> + + )} + - ({ + id: company, + name: company, + }))} + /> + )} + - ({ + id: aircraftIcaoCode, + name: aircraftIcaoCode, + }))} + /> + )} + - + - {errorMessage && ( -

- {errorMessage} -

- )} + {errorMessage && ( +

+ {errorMessage} +

+ )} - - + + +
) }