adding flights page
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||
import Pilots from './components/pilots/Pilots';
|
||||
import Flights from './components/flights/Flights';
|
||||
import Logbook from './components/logbook/Logbook';
|
||||
import Pilots from './components/pilots/Pilots';
|
||||
import SiteNav from './components/siteNav/SiteNav';
|
||||
import { useIsAuthenticated } from '@azure/msal-react';
|
||||
|
||||
@@ -19,8 +20,10 @@ const App = () => {
|
||||
<>
|
||||
<SiteNav />
|
||||
<Routes>
|
||||
<Route path='/' element={<Flights />} />
|
||||
<Route path="/logbook" element={<Logbook />} />
|
||||
<Route path="/pilots" element={<Pilots />} />
|
||||
<Route path="/" element={<Logbook />} />
|
||||
|
||||
</Routes>
|
||||
</>
|
||||
);
|
||||
|
||||
32
app/src/components/flights/Flights.tsx
Normal file
32
app/src/components/flights/Flights.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Box, Container } from "@noahspan/noahspan-components";
|
||||
import LogbookCard from "../logbookCard/LogbookCard";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useLogs } from "../../hooks/logs/UseLogs";
|
||||
import { ILogbookEntry } from "../logbook/ILogbookEntry";
|
||||
|
||||
const Flights = () => {
|
||||
const [flights, setFlights] = useState<any[]>([])
|
||||
const { logs } = useLogs();
|
||||
|
||||
useEffect(() => {
|
||||
const flights = logs?.filter((log) => {
|
||||
if (log.tracks && JSON.parse(log.tracks).length > 0) {
|
||||
return log;
|
||||
}
|
||||
})
|
||||
console.log(flights)
|
||||
if (flights && flights.length > 0) {
|
||||
setFlights(flights)
|
||||
}
|
||||
}, [logs])
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Box sx={{ margin: '20px' }}>
|
||||
<LogbookCard logs={flights} mode='flights' />
|
||||
</Box>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
export default Flights;
|
||||
@@ -35,9 +35,6 @@ const LogTrackMaps = ({ rowKey, trackUrls }: LogTrackMapsProps) => {
|
||||
config
|
||||
);
|
||||
const kml = new DOMParser().parseFromString(response.data, 'text/xml')
|
||||
// const converted = toGeoJSON.kml(dom);
|
||||
|
||||
// rewind(converted, false);
|
||||
|
||||
convertedTracks.push(kml);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ const Logbook: React.FC<unknown> = () => {
|
||||
<Table columns={state.columns} data={state.entries} />
|
||||
)}
|
||||
{!isMedium && state.entries.length > 0 &&
|
||||
<LogbookCard logs={state.entries} onDelete={onDeleteEntry} onOpenCloseForm={onOpenCloseEntryForm} />
|
||||
<LogbookCard logs={state.entries} onDelete={onDeleteEntry} mode='logbook' onOpenCloseForm={onOpenCloseEntryForm} />
|
||||
}
|
||||
</Grid>
|
||||
)}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { Card, CardContent, CardHeader, Grid, Typography } from "@noahspan/noahspan-components";
|
||||
import { LogbookCardProps } from "./LogbookCardProps.interface";
|
||||
import { useEffect } from "react";
|
||||
import ActionMenu from "../actionMenu/ActionMenu";
|
||||
import LogTrackMaps from "../logTrackMaps/LogTrackMaps";
|
||||
|
||||
|
||||
const LogbookCard = ({ logs, onDelete, onOpenCloseForm }: LogbookCardProps) => {
|
||||
const LogbookCard = ({ logs, mode, onDelete, onOpenCloseForm }: LogbookCardProps) => {
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
{logs.map((log) => {
|
||||
console.log(log)
|
||||
return (
|
||||
<Grid size={12}>
|
||||
<Card key={log.rowKey}>
|
||||
<CardHeader
|
||||
action={<ActionMenu id={log.rowKey} onDelete={onDelete} onOpenCloseForm={onOpenCloseForm} />}
|
||||
action={mode === 'logbook' ? <ActionMenu id={log.rowKey} onDelete={onDelete!} onOpenCloseForm={onOpenCloseForm!} /> : null}
|
||||
subheader={log.pilotName}
|
||||
title={log.date}
|
||||
slotProps={{
|
||||
@@ -26,6 +27,14 @@ const LogbookCard = ({ logs, onDelete, onOpenCloseForm }: LogbookCardProps) => {
|
||||
/>
|
||||
<CardContent>
|
||||
<Grid container spacing={1}>
|
||||
{mode === 'flights' && log.tracks && JSON.parse(log.tracks).length > 0 &&
|
||||
<Grid size={12}>
|
||||
<LogTrackMaps
|
||||
rowKey={log.rowKey}
|
||||
trackUrls={JSON.parse(log.tracks)}
|
||||
/>
|
||||
</Grid>
|
||||
}
|
||||
<Grid size={12}>
|
||||
<Typography variant="subtitle2">Aircraft Make and Model</Typography>
|
||||
</Grid>
|
||||
@@ -50,6 +59,24 @@ const LogbookCard = ({ logs, onDelete, onOpenCloseForm }: LogbookCardProps) => {
|
||||
<Grid size={12}>
|
||||
<Typography variant="body1">{log.durationOfFlight}</Typography>
|
||||
</Grid>
|
||||
{mode === 'logbook' && log.tracks && JSON.parse(log.tracks).length > 0 &&
|
||||
<>
|
||||
<Grid size={12}>
|
||||
<Typography variant="subtitle2">Tracks</Typography>
|
||||
</Grid>
|
||||
{JSON.parse(log.tracks).map((track: string) => {
|
||||
const trackSplit = track.split('/')
|
||||
const filename = trackSplit[trackSplit.length - 1];
|
||||
|
||||
return (
|
||||
<Grid size={12}>
|
||||
<Typography variant="body1">{filename}</Typography>
|
||||
</Grid>
|
||||
)
|
||||
|
||||
})}
|
||||
</>
|
||||
}
|
||||
{log.notes &&
|
||||
<>
|
||||
<Grid size={12}>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ILogbookEntry } from "../logbook/ILogbookEntry";
|
||||
|
||||
export interface LogbookCardProps {
|
||||
logs: ILogbookEntry[];
|
||||
onDelete: (entryId: string) => void;
|
||||
onOpenCloseForm: (formMode: FormMode, id: string) => void;
|
||||
mode: 'flights' | 'logbook';
|
||||
onDelete?: (entryId: string) => void;
|
||||
onOpenCloseForm?: (formMode: FormMode, id: string) => void;
|
||||
}
|
||||
@@ -32,9 +32,13 @@ const SiteNav = () => {
|
||||
const getPages = () => {
|
||||
const pages = [
|
||||
{
|
||||
name: 'Logbook',
|
||||
name: 'Flights',
|
||||
url: '/'
|
||||
},
|
||||
{
|
||||
name: 'Logbook',
|
||||
url: '/logbook'
|
||||
},
|
||||
{
|
||||
name: 'Pilots',
|
||||
url: '/pilots'
|
||||
@@ -79,7 +83,6 @@ const SiteNav = () => {
|
||||
|
||||
return imageUrl;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
body {
|
||||
background-color: #f2f2f2;
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user