Compare commits

...

4 Commits

Author SHA1 Message Date
70fde43801 Feature/62 limit pilot data for non auth users (#69)
* limiting pilot data for unauthenticated users

* limiting pilot data for unauthenticated users

* limiting pilot data for unauthenticated users
2025-03-18 10:08:50 -05:00
adb8e51adf limiting pilot data for unauthenticated users (#68)
* limiting pilot data for unauthenticated users

* limiting pilot data for unauthenticated users
2025-03-18 09:56:24 -05:00
09f19b178f making logbook responsive (#65)
* making logbook responsive

* making logbook responsive
2025-03-17 19:32:53 -05:00
98cfe69afb limiting log data returned for unauthenticated users (#64) 2025-03-16 19:47:43 -05:00
26 changed files with 1501 additions and 881 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "api", "name": "api",
"version": "1.1.0", "version": "1.2.0",
"description": "", "description": "",
"author": "", "author": "",
"private": true, "private": true,
@@ -27,7 +27,7 @@
"@nestjs/passport": "^10.0.3", "@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.0.0", "@nestjs/platform-express": "^10.0.0",
"@noahspan/azure-database": "^3.1.2", "@noahspan/azure-database": "^3.1.2",
"@noahspan/noahspan-modules": "^1.0.0", "@noahspan/noahspan-modules": "^1.1.5",
"@schematics/angular": "^17.3.7", "@schematics/angular": "^17.3.7",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"reflect-metadata": "^0.2.2", "reflect-metadata": "^0.2.2",

View File

@@ -44,11 +44,11 @@ import configuration from './config/configuration';
provide: APP_FILTER, provide: APP_FILTER,
useClass: HttpExceptionFilter useClass: HttpExceptionFilter
}, },
{ // {
provide: APP_GUARD, // provide: APP_GUARD,
useClass: AuthGuard // useClass: AuthGuard
}, // },
Reflector // Reflector
] ]
}) })
export class AppModule {} export class AppModule {}

View File

@@ -0,0 +1,39 @@
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
import { Observable, map } from 'rxjs';
export class LogInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, handler: CallHandler): Observable<any> {
const req = context.switchToHttp().getRequest();
const authHeader = req.headers.authorization;
const token = authHeader && authHeader.split(' ')[1];
if (!token) {
return handler.handle().pipe(
map((data) => {
if (data.length) {
const logs = data.map((log) => {
return {
partitionKey: log.partitionKey,
rowKey: log.rowKey,
pilotId: log.pilotId,
pilotName: log.pilotName,
date: log.date,
aircraftMakeModel: log.aircraftMakeModel,
routeFrom: log.routeFrom,
routeTo: log.routeTo,
durationOfFlight: log.durationOfFlight,
notes: log.notes
};
});
return logs;
} else {
return data;
}
})
);
}
return handler.handle().pipe(map((data) => data));
}
}

View File

@@ -7,20 +7,22 @@ import {
Param, Param,
Post, Post,
Put, Put,
UseGuards UseGuards,
UseInterceptors
} from '@nestjs/common'; } from '@nestjs/common';
import { LogDto } from './log.dto'; import { LogDto } from './log.dto';
import { Log } from './log.entity'; import { Log } from './log.entity';
import { LogService } from './log.service'; import { LogService } from './log.service';
import { CustomError } from '../error/customError'; import { CustomError } from '../error/customError';
import { Public } from '@noahspan/noahspan-modules'; import { AuthGuard } from '@noahspan/noahspan-modules';
import { LogInterceptor } from './interceptors/log.interceptor';
@Controller('logs') @Controller('logs')
@UseInterceptors(new LogInterceptor())
export class LogController { export class LogController {
constructor(private readonly logService: LogService) {} constructor(private readonly logService: LogService) {}
@Public()
@Get(':partitionKey/:rowKey') @Get(':partitionKey/:rowKey')
async find( async find(
@Param('partitionKey') partitionKey: string, @Param('partitionKey') partitionKey: string,
@@ -35,7 +37,6 @@ export class LogController {
} }
} }
@Public()
@Get() @Get()
async findAll(): Promise<Log[]> { async findAll(): Promise<Log[]> {
try { try {
@@ -47,6 +48,7 @@ export class LogController {
} }
} }
@UseGuards(AuthGuard)
@Post() @Post()
async create(@Body() logDto: LogDto): Promise<Log> { async create(@Body() logDto: LogDto): Promise<Log> {
try { try {
@@ -62,6 +64,7 @@ export class LogController {
} }
} }
@UseGuards(AuthGuard)
@Put(':partitionKey/:rowKey') @Put(':partitionKey/:rowKey')
async update( async update(
@Param('partitionKey') partitionKey: string, @Param('partitionKey') partitionKey: string,
@@ -81,6 +84,7 @@ export class LogController {
} }
} }
@UseGuards(AuthGuard)
@Delete(':partitionKey/:rowKey') @Delete(':partitionKey/:rowKey')
async delete( async delete(
@Param('partitionKey') partitionKey: string, @Param('partitionKey') partitionKey: string,

View File

@@ -16,10 +16,12 @@ export class PilotInterceptor implements NestInterceptor {
partitionKey: pilot.partitionKey, partitionKey: pilot.partitionKey,
rowKey: pilot.rowKey, rowKey: pilot.rowKey,
id: pilot.id, id: pilot.id,
name: pilot.name name: pilot.name,
certificates: pilot.certificates,
endorsements: pilot.endorsements
}; };
}); });
console.log(pilots)
return pilots; return pilots;
} else { } else {
return data; return data;

View File

@@ -7,13 +7,14 @@ import {
Param, Param,
Post, Post,
Put, Put,
UseGuards,
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { PilotDto } from './pilot.dto'; import { PilotDto } from './pilot.dto';
import { Pilot } from './pilot.entity'; import { Pilot } from './pilot.entity';
import { PilotService } from './pilot.service'; import { PilotService } from './pilot.service';
import { CustomError } from '../error/customError'; import { CustomError } from '../error/customError';
import { Public } from '@noahspan/noahspan-modules' import { AuthGuard } from '@noahspan/noahspan-modules'
import { PilotInterceptor } from './interceptors/pilot.interceptor'; import { PilotInterceptor } from './interceptors/pilot.interceptor';
@Controller('pilots') @Controller('pilots')
@@ -21,7 +22,6 @@ import { PilotInterceptor } from './interceptors/pilot.interceptor';
export class PilotController { export class PilotController {
constructor(private readonly pilotService: PilotService) {} constructor(private readonly pilotService: PilotService) {}
@Public()
@Get(':partitionKey/:rowKey') @Get(':partitionKey/:rowKey')
async find( async find(
@Param('partitionKey') partitionKey: string, @Param('partitionKey') partitionKey: string,
@@ -36,7 +36,6 @@ export class PilotController {
} }
} }
@Public()
@Get() @Get()
async findAll() { async findAll() {
try { try {
@@ -48,6 +47,7 @@ export class PilotController {
} }
} }
@UseGuards(AuthGuard)
@Post() @Post()
async create(@Body() pilotDto: PilotDto) { async create(@Body() pilotDto: PilotDto) {
try { try {
@@ -78,6 +78,7 @@ export class PilotController {
} }
} }
@UseGuards(AuthGuard)
@Put(':partitionKey/:rowKey') @Put(':partitionKey/:rowKey')
async update( async update(
@Param('partitionKey') partitionKey: string, @Param('partitionKey') partitionKey: string,
@@ -112,6 +113,7 @@ export class PilotController {
} }
} }
@UseGuards(AuthGuard)
@Delete(':partitionKey/:rowKey') @Delete(':partitionKey/:rowKey')
async delete( async delete(
@Param('partitionKey') partitionKey: string, @Param('partitionKey') partitionKey: string,

View File

@@ -1,7 +1,7 @@
{ {
"name": "app", "name": "app",
"private": true, "private": true,
"version": "1.1.0", "version": "1.2.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
@@ -13,7 +13,7 @@
"dependencies": { "dependencies": {
"@azure/msal-browser": "^4.0.1", "@azure/msal-browser": "^4.0.1",
"@azure/msal-react": "^3.0.1", "@azure/msal-react": "^3.0.1",
"@noahspan/noahspan-components": "^1.4.0", "@noahspan/noahspan-components": "^1.5.1",
"axios": "^1.7.2", "axios": "^1.7.2",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"react": "^18.3.1", "react": "^18.3.1",

View File

@@ -19,11 +19,7 @@ const App = () => {
<> <>
<SiteNav /> <SiteNav />
<Routes> <Routes>
<Route path="/pilots" element={ <Route path="/pilots" element={<Pilots />} />
<ProtectedRoute>
<Pilots />
</ProtectedRoute>
} />
<Route path="/" element={<Logbook />} /> <Route path="/" element={<Logbook />} />
</Routes> </Routes>
</> </>

View File

@@ -13,7 +13,9 @@ import {
IconName, IconName,
Select, Select,
TextField, TextField,
theme,
Typography, Typography,
useMediaQuery
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { useForm, Controller, FormProvider } from 'react-hook-form'; import { useForm, Controller, FormProvider } from 'react-hook-form';
import { ILogFormProps } from './ILogFormProps'; import { ILogFormProps } from './ILogFormProps';
@@ -63,6 +65,7 @@ const LogForm: React.FC<ILogFormProps> = ({
}; };
const methods = useForm(); const methods = useForm();
const { pilots } = usePilots(); const { pilots } = usePilots();
const isMedium = useMediaQuery(theme.breakpoints.up('md'));
const onCancel = () => { const onCancel = () => {
methods.reset(defaultValues); methods.reset(defaultValues);
@@ -166,7 +169,7 @@ const LogForm: React.FC<ILogFormProps> = ({
PaperProps={{ PaperProps={{
sx: { sx: {
padding: '30px', padding: '30px',
width: '33%' width: isMedium ? '33%' : '75%'
} }
}} }}
> >
@@ -194,15 +197,14 @@ const LogForm: React.FC<ILogFormProps> = ({
</Alert> </Alert>
</Grid> </Grid>
)} )}
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Pilot *</Typography> <Typography variant="body1">Pilot *</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="pilotId" name="pilotId"
control={methods.control} control={methods.control}
render={({ field: { onChange, value } }) => { render={({ field: { onChange, value } }) => {
console.log(value)
return ( return (
<Select <Select
disabled={state.isDisabled} disabled={state.isDisabled}
@@ -229,10 +231,10 @@ const LogForm: React.FC<ILogFormProps> = ({
}} }}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Date *</Typography> <Typography variant="body1">Date *</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="date" name="date"
control={methods.control} control={methods.control}
@@ -245,10 +247,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Aircraft Make and Model *</Typography> <Typography variant="body1">Aircraft Make and Model *</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="aircraftMakeModel" name="aircraftMakeModel"
control={methods.control} control={methods.control}
@@ -268,10 +270,12 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> {isAuthenticated &&
<>
<Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Aircraft Identity *</Typography> <Typography variant="body1">Aircraft Identity *</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="aircraftIdentity" name="aircraftIdentity"
control={methods.control} control={methods.control}
@@ -291,10 +295,12 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> </>
}
<Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Route From</Typography> <Typography variant="body1">Route From</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="routeFrom" name="routeFrom"
control={methods.control} control={methods.control}
@@ -314,10 +320,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Route To</Typography> <Typography variant="body1">Route To</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="routeTo" name="routeTo"
control={methods.control} control={methods.control}
@@ -337,10 +343,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Duration Of Flight</Typography> <Typography variant="body1">Duration Of Flight</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="durationOfFlight" name="durationOfFlight"
control={methods.control} control={methods.control}
@@ -366,10 +372,12 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> {isAuthenticated &&
<>
<Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Single Engine Land</Typography> <Typography variant="body1">Single Engine Land</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="singleEngineLand" name="singleEngineLand"
control={methods.control} control={methods.control}
@@ -395,10 +403,14 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> </>
}
{isAuthenticated &&
<>
<Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Simulator or ATD</Typography> <Typography variant="body1">Simulator or ATD</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="simulatorAtd" name="simulatorAtd"
control={methods.control} control={methods.control}
@@ -424,6 +436,9 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
</>
}
{isAuthenticated &&
<Grid size={12}> <Grid size={12}>
<Accordion defaultExpanded> <Accordion defaultExpanded>
<AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}> <AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}>
@@ -431,10 +446,10 @@ const LogForm: React.FC<ILogFormProps> = ({
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Day</Typography> <Typography variant="body1">Day</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="landingsDay" name="landingsDay"
control={methods.control} control={methods.control}
@@ -462,10 +477,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Night</Typography> <Typography variant="body1">Night</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="landingsNight" name="landingsNight"
control={methods.control} control={methods.control}
@@ -497,6 +512,8 @@ const LogForm: React.FC<ILogFormProps> = ({
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
</Grid> </Grid>
}
{isAuthenticated &&
<Grid size={12}> <Grid size={12}>
<Accordion> <Accordion>
<AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}> <AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}>
@@ -504,10 +521,10 @@ const LogForm: React.FC<ILogFormProps> = ({
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Actual</Typography> <Typography variant="body1">Actual</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="instrumentActual" name="instrumentActual"
control={methods.control} control={methods.control}
@@ -535,10 +552,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Simulated</Typography> <Typography variant="body1">Simulated</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="instrumentSimulated" name="instrumentSimulated"
control={methods.control} control={methods.control}
@@ -566,12 +583,12 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1"> <Typography variant="body1">
Instrument Approaches Instrument Approaches
</Typography> </Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="instrumentApproaches" name="instrumentApproaches"
control={methods.control} control={methods.control}
@@ -602,7 +619,7 @@ const LogForm: React.FC<ILogFormProps> = ({
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={4}>
<Typography variant="body1">Holds</Typography> <Typography variant="body1">Holds</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="instrumentHolds" name="instrumentHolds"
control={methods.control} control={methods.control}
@@ -630,10 +647,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Nav / Track</Typography> <Typography variant="body1">Nav / Track</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="instrumentNavTrack" name="instrumentNavTrack"
control={methods.control} control={methods.control}
@@ -665,6 +682,8 @@ const LogForm: React.FC<ILogFormProps> = ({
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
</Grid> </Grid>
}
{isAuthenticated &&
<Grid size={12}> <Grid size={12}>
<Accordion defaultExpanded> <Accordion defaultExpanded>
<AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}> <AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}>
@@ -672,12 +691,12 @@ const LogForm: React.FC<ILogFormProps> = ({
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1"> <Typography variant="body1">
Ground Training Received Ground Training Received
</Typography> </Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="groundTrainingReceived" name="groundTrainingReceived"
control={methods.control} control={methods.control}
@@ -705,12 +724,12 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1"> <Typography variant="body1">
Flight Training Received Flight Training Received
</Typography> </Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="flightTrainingReceived" name="flightTrainingReceived"
control={methods.control} control={methods.control}
@@ -738,10 +757,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Cross Country</Typography> <Typography variant="body1">Cross Country</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="crossCountry" name="crossCountry"
control={methods.control} control={methods.control}
@@ -769,10 +788,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Night</Typography> <Typography variant="body1">Night</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="night" name="night"
control={methods.control} control={methods.control}
@@ -800,10 +819,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Solo</Typography> <Typography variant="body1">Solo</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="solo" name="solo"
control={methods.control} control={methods.control}
@@ -831,10 +850,10 @@ const LogForm: React.FC<ILogFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid alignItems="center" display="flex" size={4}> <Grid alignItems="center" display="flex" size={isMedium ? 4 : 12}>
<Typography variant="body1">Pilot in Command</Typography> <Typography variant="body1">Pilot in Command</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="pilotInCommand" name="pilotInCommand"
control={methods.control} control={methods.control}
@@ -866,10 +885,11 @@ const LogForm: React.FC<ILogFormProps> = ({
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
</Grid> </Grid>
<Grid size={4}> }
<Grid size={isMedium ? 4 : 12}>
<Typography variant="body1">Notes</Typography> <Typography variant="body1">Notes</Typography>
</Grid> </Grid>
<Grid size={8}> <Grid size={isMedium ? 8 : 12}>
<Controller <Controller
name="notes" name="notes"
control={methods.control} control={methods.control}

View File

@@ -3,6 +3,7 @@ export interface ILogbookEntry {
rowKey: string; rowKey: string;
id: string; id: string;
pilotId: string; pilotId: string;
pilotName: string;
date: string; date: string;
aircraftMakeModel: string; aircraftMakeModel: string;
aircraftIdentity: string; aircraftIdentity: string;
@@ -24,4 +25,5 @@ export interface ILogbookEntry {
night: number | null; night: number | null;
solo: number | null; solo: number | null;
pilotInCommand: number | null; pilotInCommand: number | null;
notes: string;
} }

View File

@@ -10,7 +10,9 @@ import {
IconName, IconName,
Spinner, Spinner,
Table, Table,
Typography theme,
Typography,
useMediaQuery
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { initialState, reducer } from './reducer'; import { initialState, reducer } from './reducer';
import { useHttpClient } from '../../hooks/httpClient/UseHttpClient'; import { useHttpClient } from '../../hooks/httpClient/UseHttpClient';
@@ -21,12 +23,14 @@ import { FormMode } from '../../enums/formMode';
import ActionMenu from '../actionMenu/ActionMenu'; import ActionMenu from '../actionMenu/ActionMenu';
import ConfirmationDialog from '../confirmationDialog/ConfirmationDialog'; import ConfirmationDialog from '../confirmationDialog/ConfirmationDialog';
import { ILogbookEntry } from './ILogbookEntry'; import { ILogbookEntry } from './ILogbookEntry';
import LogbookCard from '../logbookCard/LogbookCard';
const Logbook: React.FC<unknown> = () => { const Logbook: React.FC<unknown> = () => {
const [state, dispatch] = useReducer(reducer, initialState); const [state, dispatch] = useReducer(reducer, initialState);
const httpClient: AxiosInstance = useHttpClient(); const httpClient: AxiosInstance = useHttpClient();
const isAuthenticated = useIsAuthenticated(); const isAuthenticated = useIsAuthenticated();
const { getAccessToken } = useAccessToken(); const { getAccessToken } = useAccessToken();
const isMedium = useMediaQuery(theme.breakpoints.up('md'));
const getLogbookEntries = async () => { const getLogbookEntries = async () => {
try { try {
@@ -129,10 +133,70 @@ const Logbook: React.FC<unknown> = () => {
}); });
}; };
const columns: ColumnDef<ILogbookEntry>[] = [ const unauthColumns: ColumnDef<ILogbookEntry>[] = [
{ {
accessorKey: 'pilotName', accessorKey: 'pilotName',
header: 'Pilot' header: 'Pilot',
},
{
accessorKey: 'date',
header: 'Date'
},
{
accessorKey: 'aircraftMakeModel',
header: 'Aircraft Make & Model'
},
{
id: 'route',
header: 'Route of Flight',
meta: {
headerAlign: 'center'
},
columns: [
{
accessorKey: 'routeFrom',
header: 'From'
},
{
accessorKey: 'routeTo',
header: 'To'
}
]
},
{
accessorKey: 'durationOfFlight',
header: 'Duration Of Flight',
meta: {
align: 'right',
headerAlign: 'right'
},
cell: (info: any) =>
info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
},
{
accessorKey: 'notes',
header: 'Notes'
},
{
header: 'Actions',
meta: {
align: 'center',
headerAlign: 'center'
},
cell: (info: any) => (
<ActionMenu
id={info.row.original.rowKey}
onDelete={onDeleteEntry}
onOpenCloseForm={onOpenCloseEntryForm}
/>
)
}
]
const authColumns: ColumnDef<ILogbookEntry>[] = [
{
accessorKey: 'pilotName',
header: 'Pilot',
}, },
{ {
accessorKey: 'date', accessorKey: 'date',
@@ -144,7 +208,7 @@ const Logbook: React.FC<unknown> = () => {
}, },
{ {
accessorKey: 'aircraftIdentity', accessorKey: 'aircraftIdentity',
header: 'Aircraft Identity' header: 'Aircraft Identity',
}, },
{ {
id: 'route', id: 'route',
@@ -359,10 +423,10 @@ const Logbook: React.FC<unknown> = () => {
return ( return (
<Box sx={{ margin: '20px' }}> <Box sx={{ margin: '20px' }}>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid size={11}> <Grid size={isMedium ? 11 : 6}>
<Typography variant="h4">Logbook</Typography> <Typography variant="h4">Logbook</Typography>
</Grid> </Grid>
<Grid display="flex" justifyContent="right" size={1}> <Grid display="flex" justifyContent="right" size={isMedium ? 1 : 6}>
{isAuthenticated && {isAuthenticated &&
<Button <Button
onClick={() => onOpenCloseEntryForm(FormMode.ADD)} onClick={() => onOpenCloseEntryForm(FormMode.ADD)}
@@ -389,9 +453,12 @@ const Logbook: React.FC<unknown> = () => {
)} )}
{!state.isLoading && ( {!state.isLoading && (
<Grid size={12}> <Grid size={12}>
{state.entries.length > 0 && ( {isMedium && state.entries.length > 0 && (
<Table columns={columns} data={state.entries} /> <Table columns={isAuthenticated ? authColumns : unauthColumns} data={state.entries} />
)} )}
{!isMedium && state.entries.length > 0 &&
<LogbookCard logs={state.entries} onDelete={onDeleteEntry} onOpenCloseForm={onOpenCloseEntryForm} />
}
</Grid> </Grid>
)} )}
{state.isLoading && !state.alert && ( {state.isLoading && !state.alert && (

View File

@@ -0,0 +1,74 @@
import { Card, CardContent, CardHeader, Grid, Typography } from "@noahspan/noahspan-components";
import { LogbookCardProps } from "./LogbookCardProps.interface";
import { useEffect } from "react";
import ActionMenu from "../actionMenu/ActionMenu";
const LogbookCard = ({ logs, onDelete, onOpenCloseForm }: LogbookCardProps) => {
return (
<Grid container spacing={2}>
{logs.map((log) => {
return (
<Grid size={12}>
<Card key={log.rowKey}>
<CardHeader
action={<ActionMenu id={log.rowKey} onDelete={onDelete} onOpenCloseForm={onOpenCloseForm} />}
subheader={log.pilotName}
title={log.date}
slotProps={{
subheader: {
fontSize: '16px'
},
title: {
fontSize: '24px',
}
}}
/>
<CardContent>
<Grid container spacing={1}>
<Grid size={12}>
<Typography variant="subtitle2">Aircraft Make and Model</Typography>
</Grid>
<Grid size={12}>
<Typography variant="body1">{log.aircraftMakeModel}</Typography>
</Grid>
<Grid size={12}>
<Typography variant="subtitle2">Route From</Typography>
</Grid>
<Grid size={12}>
<Typography variant="body1">{log.routeFrom}</Typography>
</Grid>
<Grid size={12}>
<Typography variant="subtitle2">Route To</Typography>
</Grid>
<Grid size={12}>
<Typography variant="body1">{log.routeTo}</Typography>
</Grid>
<Grid size={12}>
<Typography variant="subtitle2">Duration Of Flight</Typography>
</Grid>
<Grid size={12}>
<Typography variant="body1">{log.durationOfFlight}</Typography>
</Grid>
{log.notes &&
<>
<Grid size={12}>
<Typography variant="subtitle2">Notes</Typography>
</Grid>
<Grid size={12}>
<Typography variant="body1">{log.notes}</Typography>
</Grid>
</>
}
</Grid>
</CardContent>
</Card>
</Grid>
)
})}
</Grid>
)
}
export default LogbookCard;

View File

@@ -0,0 +1,8 @@
import { FormMode } from "../../enums/formMode";
import { ILogbookEntry } from "../logbook/ILogbookEntry";
export interface LogbookCardProps {
logs: ILogbookEntry[];
onDelete: (entryId: string) => void;
onOpenCloseForm: (formMode: FormMode, id: string) => void;
}

View File

@@ -0,0 +1,29 @@
import { Card, CardContent, CardHeader, Grid, Typography } from "@noahspan/noahspan-components"
import { PilotCardProps } from "./PilotCardProps.interface"
import ActionMenu from "../actionMenu/ActionMenu"
const PilotCard = ({ pilots, onDelete, onOpenCloseForm }: PilotCardProps) => {
return (
<Grid container spacing={2}>
{pilots.map((pilot) => {
return (
<Grid size={12}>
<Card key={pilot.rowKey}>
<CardHeader
action={<ActionMenu id={pilot.rowKey} onDelete={onDelete} onOpenCloseForm={onOpenCloseForm} />}
title={pilot.name}
slotProps={{
title: {
fontSize: '24px',
}
}}
/>
</Card>
</Grid>
)
})}
</Grid>
)
}
export default PilotCard;

View File

@@ -0,0 +1,8 @@
import { FormMode } from "../../enums/formMode";
import { Pilot } from "../pilots/Pilot.interface";
export interface PilotCardProps {
pilots: Pilot[];
onDelete: (entryId: string) => void;
onOpenCloseForm: (formMode: FormMode, id: string) => void;
}

View File

@@ -1,19 +1,18 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { useForm, Controller, FormProvider } from 'react-hook-form'; import { useForm, Controller, FormProvider } from 'react-hook-form';
import { import {
Accordion,
Button, Button,
DatePicker,
Drawer, Drawer,
Grid, Grid,
Icon, Icon,
IconButton, IconButton,
IconName, IconName,
PeoplePicker, PeoplePicker,
Select,
StateSelect, StateSelect,
TextField, TextField,
Typography theme,
Typography,
useMediaQuery
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { IPilotFormProps } from './IPilotFormProps'; import { IPilotFormProps } from './IPilotFormProps';
import { AxiosError, AxiosInstance, AxiosResponse } from 'axios'; import { AxiosError, AxiosInstance, AxiosResponse } from 'axios';
@@ -64,6 +63,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
}); });
const [isDisabled, setIsDisabled] = useState<boolean>(false); const [isDisabled, setIsDisabled] = useState<boolean>(false);
const [isError, setIsError] = useState<boolean>(false); const [isError, setIsError] = useState<boolean>(false);
const isMedium = useMediaQuery(theme.breakpoints.up('md'));
const onPeoplePickerSearch = async ( const onPeoplePickerSearch = async (
_event: React.SyntheticEvent, _event: React.SyntheticEvent,
@@ -113,7 +113,6 @@ const PilotForm: React.FC<IPilotFormProps> = ({
}; };
const onSubmit = async (data: unknown) => { const onSubmit = async (data: unknown) => {
console.log(data)
try { try {
setIsLoading(true); setIsLoading(true);
@@ -167,7 +166,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
pilot.certificates = JSON.parse(pilot.certificates); pilot.certificates = JSON.parse(pilot.certificates);
pilot.endorsements = JSON.parse(pilot.endorsements) pilot.endorsements = JSON.parse(pilot.endorsements)
console.log(pilot)
setSelectedPerson({ setSelectedPerson({
userPrincipalName: pilot.id, userPrincipalName: pilot.id,
displayName: pilot.name displayName: pilot.name
@@ -193,7 +192,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
PaperProps={{ PaperProps={{
sx: { sx: {
padding: '30px', padding: '30px',
width: '33%' width: isMedium ? '33%' : '75%'
} }
}} }}
> >
@@ -208,10 +207,10 @@ const PilotForm: React.FC<IPilotFormProps> = ({
<Icon iconName={IconName.XMARK} /> <Icon iconName={IconName.XMARK} />
</IconButton> </IconButton>
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">Name *</Typography> <Typography variant="h6">Name *</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<PeoplePicker <PeoplePicker
disabled={isDisabled} disabled={isDisabled}
loading={isPeoplePickerLoading} loading={isPeoplePickerLoading}
@@ -221,10 +220,12 @@ const PilotForm: React.FC<IPilotFormProps> = ({
value={selectedPerson} value={selectedPerson}
/> />
</Grid> </Grid>
<Grid size={3}> {isAuthenticated &&
<>
<Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">Address *</Typography> <Typography variant="h6">Address *</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="address" name="address"
control={methods.control} control={methods.control}
@@ -245,10 +246,10 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">City *</Typography> <Typography variant="h6">City *</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="city" name="city"
control={methods.control} control={methods.control}
@@ -269,10 +270,10 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">State *</Typography> <Typography variant="h6">State *</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="state" name="state"
control={methods.control} control={methods.control}
@@ -295,10 +296,10 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">Postal Code *</Typography> <Typography variant="h6">Postal Code *</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="postalCode" name="postalCode"
control={methods.control} control={methods.control}
@@ -319,10 +320,10 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">Email</Typography> <Typography variant="h6">Email</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="email" name="email"
control={methods.control} control={methods.control}
@@ -348,10 +349,10 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">Phone Number</Typography> <Typography variant="h6">Phone Number</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="phone" name="phone"
control={methods.control} control={methods.control}
@@ -377,16 +378,20 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
</>
}
{isAuthenticated &&
<Grid size={12}> <Grid size={12}>
<PilotFormMedical <PilotFormMedical
isDisabled={isDisabled} isDisabled={isDisabled}
/> />
</Grid> </Grid>
}
<Grid size={12}> <Grid size={12}>
<PilotFormCertificates isDisabled={isDisabled} /> <PilotFormCertificates isDisabled={isDisabled} mode={mode} />
</Grid> </Grid>
<Grid size={12}> <Grid size={12}>
<PilotFormEndorsements isDisabled={isDisabled} /> <PilotFormEndorsements isDisabled={isDisabled} mode={mode} />
</Grid> </Grid>
<Grid display="flex" gap={2} justifyContent="right" size={12}> <Grid display="flex" gap={2} justifyContent="right" size={12}>
<Button <Button

View File

@@ -8,12 +8,14 @@ import {
IconName, IconName,
Select, Select,
TextField, TextField,
Typography Typography,
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { Controller, useFieldArray, useFormContext } from 'react-hook-form'; import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
import { FormMode } from '../../enums/formMode';
const PilotFormCertificates = ({ const PilotFormCertificates = ({
isDisabled isDisabled,
mode
}: PilotFormCertificatesProps ) => { }: PilotFormCertificatesProps ) => {
const { const {
control, control,
@@ -30,9 +32,11 @@ const PilotFormCertificates = ({
container container
spacing={2} spacing={2}
> >
{fields.length > 0 || mode !== FormMode.VIEW &&
<Grid size={12}> <Grid size={12}>
<Typography variant="h5">Certificates</Typography> <Typography variant="h5">Certificates</Typography>
</Grid> </Grid>
}
{fields.length > 0 && ( {fields.length > 0 && (
<> <>
<Grid size={4}> <Grid size={4}>

View File

@@ -1,3 +1,6 @@
import { FormMode } from "../../enums/formMode";
export interface PilotFormCertificatesProps { export interface PilotFormCertificatesProps {
isDisabled: boolean; isDisabled: boolean;
mode: FormMode;
} }

View File

@@ -10,8 +10,10 @@ import {
Typography Typography
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { Controller, useFieldArray, useFormContext } from 'react-hook-form'; import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
import { FormMode } from '../../enums/formMode';
const PilotFormEndorsements = ({ const PilotFormEndorsements = ({
mode,
isDisabled isDisabled
}: PilotFormEndorsementsProps) => { }: PilotFormEndorsementsProps) => {
const { const {
@@ -30,9 +32,11 @@ const PilotFormEndorsements = ({
container container
spacing={2} spacing={2}
> >
{fields.length > 0 || mode !== FormMode.VIEW &&
<Grid size={12}> <Grid size={12}>
<Typography variant="h5">Endorsements</Typography> <Typography variant="h5">Endorsements</Typography>
</Grid> </Grid>
}
{fields.length > 0 && ( {fields.length > 0 && (
<> <>
<Grid size={8}> <Grid size={8}>

View File

@@ -1,3 +1,6 @@
import { FormMode } from "../../enums/formMode";
export interface PilotFormEndorsementsProps { export interface PilotFormEndorsementsProps {
isDisabled: boolean; isDisabled: boolean;
mode: FormMode;
} }

View File

@@ -1,4 +1,4 @@
import { DatePicker, Grid, Select, Typography } from '@noahspan/noahspan-components'; import { DatePicker, Grid, Select, theme, Typography, useMediaQuery } from '@noahspan/noahspan-components';
import { Controller, useFormContext } from "react-hook-form" import { Controller, useFormContext } from "react-hook-form"
import { PilotFormMedicalProps } from "./PilotFormMedicalProps.interface"; import { PilotFormMedicalProps } from "./PilotFormMedicalProps.interface";
@@ -7,17 +7,18 @@ const PilotFormMedical = ({ isDisabled }: PilotFormMedicalProps) => {
control, control,
formState: { errors }, formState: { errors },
setValue setValue
} = useFormContext() } = useFormContext();
const isMedium = useMediaQuery(theme.breakpoints.up('md'));
return ( return (
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid size={12}> <Grid size={12}>
<Typography variant="h5">Medical</Typography> <Typography variant="h5">Medical</Typography>
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">Class</Typography> <Typography variant="h6">Class</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="medicalClass" name="medicalClass"
control={control} control={control}
@@ -53,10 +54,10 @@ const PilotFormMedical = ({ isDisabled }: PilotFormMedicalProps) => {
}} }}
/> />
</Grid> </Grid>
<Grid size={3}> <Grid size={isMedium ? 3 : 12}>
<Typography variant="h6">Expiration</Typography> <Typography variant="h6">Expiration</Typography>
</Grid> </Grid>
<Grid size={9}> <Grid size={isMedium ? 9 : 12}>
<Controller <Controller
name="medicalExpiration" name="medicalExpiration"
control={control} control={control}

View File

@@ -9,7 +9,9 @@ import {
Icon, Icon,
IconName, IconName,
Table, Table,
Typography theme,
Typography,
useMediaQuery
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { useHttpClient } from '../../hooks/httpClient/UseHttpClient'; import { useHttpClient } from '../../hooks/httpClient/UseHttpClient';
import { AxiosError, AxiosInstance, AxiosResponse } from 'axios'; import { AxiosError, AxiosInstance, AxiosResponse } from 'axios';
@@ -20,21 +22,19 @@ import { Pilot } from './Pilot.interface';
import { initialState, reducer } from './reducer'; import { initialState, reducer } from './reducer';
import ActionMenu from '../actionMenu/ActionMenu'; import ActionMenu from '../actionMenu/ActionMenu';
import ConfirmationDialog from '../confirmationDialog/ConfirmationDialog'; import ConfirmationDialog from '../confirmationDialog/ConfirmationDialog';
import PilotCard from '../pilotCard/PilotCard';
const Pilots: React.FC<unknown> = () => { const Pilots: React.FC<unknown> = () => {
const [state, dispatch] = useReducer(reducer, initialState); const [state, dispatch] = useReducer(reducer, initialState);
const httpClient: AxiosInstance = useHttpClient(); const httpClient: AxiosInstance = useHttpClient();
const isAuthenticated = useIsAuthenticated(); const isAuthenticated = useIsAuthenticated();
const { getAccessToken } = useAccessToken(); const { getAccessToken } = useAccessToken();
const isMedium = useMediaQuery(theme.breakpoints.up('md'));
const getPilots = async () => { const getPilots = async () => {
try { try {
const config = isAuthenticated
? { headers: { Authorization: await getAccessToken() } }
: {};
const response: AxiosResponse = await httpClient.get( const response: AxiosResponse = await httpClient.get(
`api/pilots`, `api/pilots`
config
); );
if (response.data.length > 0) { if (response.data.length > 0) {
@@ -147,18 +147,18 @@ const Pilots: React.FC<unknown> = () => {
]; ];
useEffect(() => { useEffect(() => {
if (isAuthenticated && !state.isFormOpen) { if (!state.isFormOpen) {
getPilots(); getPilots();
} }
}, [isAuthenticated, state.isFormOpen]); }, [state.isFormOpen]);
return ( return (
<Box sx={{ margin: '20px' }}> <Box sx={{ margin: '20px' }}>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid size={11}> <Grid size={isMedium ? 11 : 6}>
<Typography variant="h4">Pilots</Typography> <Typography variant="h4">Pilots</Typography>
</Grid> </Grid>
<Grid display="flex" justifyContent="right" size={1}> <Grid display="flex" justifyContent="right" size={isMedium ? 1 : 6}>
{isAuthenticated && {isAuthenticated &&
<Button <Button
onClick={() => onOpenClosePilotForm(FormMode.ADD)} onClick={() => onOpenClosePilotForm(FormMode.ADD)}
@@ -184,7 +184,12 @@ const Pilots: React.FC<unknown> = () => {
</Grid> </Grid>
)} )}
<Grid size={12}> <Grid size={12}>
{state.pilots.length > 0 && <Table columns={columns} data={state.pilots} />} {isMedium && state.pilots.length > 0 &&
<Table columns={columns} data={state.pilots} />
}
{!isMedium && state.pilots.length > 0 &&
<PilotCard pilots={state.pilots} onDelete={onDeleteEntry} onOpenCloseForm={onOpenClosePilotForm} />
}
</Grid> </Grid>
</Grid> </Grid>
{state.isFormOpen && ( {state.isFormOpen && (

View File

@@ -34,15 +34,12 @@ const SiteNav = () => {
{ {
name: 'Logbook', name: 'Logbook',
url: '/' url: '/'
} },
]; {
if (isAuthenticated) {
pages.push({
name: 'Pilots', name: 'Pilots',
url: '/pilots' url: '/pilots'
})
} }
];
setPages(pages) setPages(pages)
}; };

View File

@@ -2,7 +2,7 @@ version: '3.8'
services: services:
azurite: azurite:
container_name: azurite container_name: azurite-flying
image: mcr.microsoft.com/azure-storage/azurite image: mcr.microsoft.com/azure-storage/azurite
ports: ports:
- '10000:10000' - '10000:10000'

View File

@@ -1,6 +1,6 @@
{ {
"name": "@noahspan/flying", "name": "@noahspan/flying",
"version": "1.1.0", "version": "1.2.0",
"scripts": { "scripts": {
"start": "concurrently 'npm run start:azure -w api' 'wait-on tcp:0.0.0.0:7071 && npm run dev -w app'", "start": "concurrently 'npm run start:azure -w api' 'wait-on tcp:0.0.0.0:7071 && npm run dev -w app'",
"format": "prettier --write \"**/src/**/*.ts\" \"**/test/**/*.ts\"", "format": "prettier --write \"**/src/**/*.ts\" \"**/test/**/*.ts\"",

603
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff