Compare commits

..

12 Commits

Author SHA1 Message Date
cd08444c5f upgrading noahspan-components 2025-03-05 09:25:11 -06:00
c3af2ec8ce Feature/56 add endorsements to pilot form (#63)
* adding endorsements to pilot form

* upgrading noahspan-components

* updating verison number
2025-03-05 09:08:34 -06:00
393364feb6 adding endorsements to pilot form (#58) 2025-03-02 11:43:33 -06:00
8f1dc5cb61 adding certificates to pilot form (#57)
* adding certificates to pilot form

* adding certificates to pilot form
2025-03-02 10:39:37 -06:00
032cd4665f Feature/49 add medical certificate to pilot form (#55)
* adding medical certificate to pilot form

* adding medical certificate to pilot form
2025-02-28 20:56:36 -06:00
99019ddeef fixing logbook entry form pilot name 2025-02-25 11:33:16 -06:00
80f0e5437c fixing logbook non authenticated 2025-02-24 19:53:18 -06:00
80cfa52413 fixing logbook date sort (#54) 2025-02-24 18:51:22 -06:00
07575302cc fixing logbook non authenticated (#53) 2025-02-24 12:55:49 -06:00
c765b06404 fixing logbook entry form title (#52) 2025-02-24 12:18:53 -06:00
280067648f fixing NaN in logbook entry table (#51) 2025-02-24 12:15:32 -06:00
0ff30e9761 Updating terraform modules 2025-02-24 09:07:33 -06:00
40 changed files with 922 additions and 961 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1,6 +1,6 @@
{ {
"name": "api", "name": "api",
"version": "1.0.0", "version": "1.1.0",
"description": "", "description": "",
"author": "", "author": "",
"private": true, "private": true,

View File

@@ -20,6 +20,7 @@ import { Public } from '@noahspan/noahspan-modules';
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,

View File

@@ -9,6 +9,7 @@ async function bootstrap() {
const httpService = new HttpService(); const httpService = new HttpService();
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors();
app.setGlobalPrefix('api'); app.setGlobalPrefix('api');
app.useGlobalFilters(new HttpExceptionFilter()); app.useGlobalFilters(new HttpExceptionFilter());

View File

@@ -1,7 +1,5 @@
export class Certificate { export class Certificate {
partitionKey: string;
rowKey: string;
type: string; type: string;
issueDate: Date; issueDate: string;
number?: string; number: string;
} }

View File

@@ -1,37 +0,0 @@
import { Injectable } from '@nestjs/common';
import { Repository, InjectRepository } from '@noahspan/azure-database';
import { Certificate } from './certificate.entity';
@Injectable()
export class CertificateService {
private readonly partitionKey: string = 'certificate';
constructor(
@InjectRepository(Certificate)
private readonly certificateRepository: Repository<Certificate>
) {}
async find(rowKey: string): Promise<Certificate> {
return await this.certificateRepository.find(this.partitionKey, rowKey);
}
async findAll(): Promise<Certificate[]> {
return await this.certificateRepository.findAll();
}
async create(certificate: Certificate): Promise<Certificate> {
return await this.certificateRepository.create(certificate);
}
async update(rowKey: string, certificate: Certificate): Promise<Certificate> {
return await this.certificateRepository.update(
this.partitionKey,
rowKey,
certificate
);
}
async delete(rowKey: string): Promise<void> {
await this.certificateRepository.delete(this.partitionKey, rowKey);
}
}

View File

@@ -1,6 +1,4 @@
export class Endorsement { export class Endorsement {
partitionkey: string;
rowKey: string;
type: string; type: string;
issueDate: Date; issueDate: Date;
} }

View File

@@ -1,37 +0,0 @@
import { InjectRepository, Repository } from '@noahspan/azure-database';
import { Injectable } from '@nestjs/common';
import { Endorsement } from './endorsement.entity';
@Injectable()
export class EndosementService {
private readonly partitionKey: string = 'endorsement';
constructor(
@InjectRepository(Endorsement)
private readonly endorsementRepository: Repository<Endorsement>
) {}
async find(rowKey: string): Promise<Endorsement> {
return await this.endorsementRepository.find(this.partitionKey, rowKey);
}
async findAll(): Promise<Endorsement[]> {
return await this.endorsementRepository.findAll();
}
async create(endorsement: Endorsement): Promise<Endorsement> {
return await this.endorsementRepository.create(endorsement);
}
async update(rowKey: string, endorsement: Endorsement): Promise<Endorsement> {
return await this.endorsementRepository.update(
this.partitionKey,
rowKey,
endorsement
);
}
async delete(rowKey: string): Promise<void> {
await this.endorsementRepository.delete(this.partitionKey, rowKey);
}
}

View File

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

View File

@@ -1,6 +0,0 @@
export class Medical {
partitionKey: string;
rowKey: string;
certificateClass: string;
certificateExpiration: Date;
}

View File

@@ -1,33 +0,0 @@
// import { Injectable } from '@nestjs/common';
// import { Repository, InjectRepository } from '@noahspan/azure-database';
// import { Medical } from './medical.entity';
// @Injectable()
// export class MedicalService {
// private readonly partitionKey: string = 'medical';
// constructor(
// @InjectRepository(Medical)
// private readonly profileRepository: Repository<Medical>
// ) {}
// async find(rowKey: string): Promise<Medical> {
// return this.profileRepository.find(this.partitionKey, rowKey);
// }
// async findAll(): Promise<Medical[]> {
// return this.profileRepository.findAll();
// }
// async create(profile: Medical): Promise<Medical> {
// return this.profileRepository.create(profile);
// }
// async update(rowKey: string, profile: Medical): Promise<Medical> {
// return this.profileRepository.update(this.partitionKey, rowKey, profile);
// }
// async delete(rowKey: string) {
// return this.profileRepository.delete(this.partitionKey, rowKey);
// }
// }

View File

@@ -7,18 +7,21 @@ import {
Param, Param,
Post, Post,
Put, Put,
UseGuards, 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 { AuthGuard } from '@nestjs/passport' import { Public } from '@noahspan/noahspan-modules'
import { PilotInterceptor } from './interceptors/pilot.interceptor';
@Controller('pilots') @Controller('pilots')
@UseInterceptors(new PilotInterceptor())
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,
@@ -33,6 +36,7 @@ export class PilotController {
} }
} }
@Public()
@Get() @Get()
async findAll() { async findAll() {
try { try {
@@ -47,9 +51,24 @@ export class PilotController {
@Post() @Post()
async create(@Body() pilotDto: PilotDto) { async create(@Body() pilotDto: PilotDto) {
try { try {
const pilot = new Pilot(); let pilot = new Pilot();
Object.assign(pilot, pilotDto); pilot = {
partitionKey: pilotDto.partitionKey,
rowKey: pilotDto.rowKey,
id: pilotDto.id,
name: pilotDto.name,
address: pilotDto.address,
city: pilotDto.city,
state: pilotDto.state,
postalCode: pilotDto.postalCode,
email: pilotDto.email,
phone: pilotDto.phone,
medicalClass: pilotDto.medicalClass,
medicalExpiration: pilotDto.medicalExpiration,
certificates: JSON.stringify(pilotDto.certificates),
endorsements: JSON.stringify(pilotDto.endorsements)
}
return await this.pilotService.create(pilot); return await this.pilotService.create(pilot);
} catch (error) { } catch (error) {
@@ -66,9 +85,24 @@ export class PilotController {
@Body() pilotDto: PilotDto @Body() pilotDto: PilotDto
) { ) {
try { try {
const pilot = new Pilot(); let pilot = new Pilot();
Object.assign(pilot, pilotDto); pilot = {
partitionKey: pilotDto.partitionKey,
rowKey: pilotDto.rowKey,
id: pilotDto.id,
name: pilotDto.name,
address: pilotDto.address,
city: pilotDto.city,
state: pilotDto.state,
postalCode: pilotDto.postalCode,
email: pilotDto.email,
phone: pilotDto.phone,
medicalClass: pilotDto.medicalClass,
medicalExpiration: pilotDto.medicalExpiration,
certificates: JSON.stringify(pilotDto.certificates),
endorsements: JSON.stringify(pilotDto.endorsements)
}
return await this.pilotService.update(partitionKey, rowKey, pilot); return await this.pilotService.update(partitionKey, rowKey, pilot);
} catch (error) { } catch (error) {

View File

@@ -1,3 +1,6 @@
import { Certificate } from "./certificate/certificate.entity";
import { Endorsement } from "./endorsement/endorsement.entity";
export class PilotDto { export class PilotDto {
partitionKey: string; partitionKey: string;
rowKey: string; rowKey: string;
@@ -9,4 +12,8 @@ export class PilotDto {
postalCode: string; postalCode: string;
email?: string; email?: string;
phone?: string; phone?: string;
medicalClass?: string;
medicalExpiration?: string;
certificates: Certificate;
endorsements: Endorsement
} }

View File

@@ -11,4 +11,8 @@ export class Pilot {
@EntityString() postalCode?: string; @EntityString() postalCode?: string;
@EntityString() email?: string; @EntityString() email?: string;
@EntityString() phone?: string; @EntityString() phone?: string;
@EntityString() medicalClass?: string;
@EntityString() medicalExpiration: string;
@EntityString() certificates: string;
@EntityString() endorsements: string;
} }

View File

@@ -1,3 +0,0 @@
# Flying
A pilot's logbook for tracking flight hours.

View File

@@ -1,7 +1,7 @@
{ {
"name": "app", "name": "app",
"private": true, "private": true,
"version": "1.0.0", "version": "1.1.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": "^0.8.9", "@noahspan/noahspan-components": "^1.4.0",
"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

@@ -1,22 +1,22 @@
import { useState } from 'react'; import { useState } from 'react';
import { IActionMenuProps } from './IActionMenuProps'; import { IActionMenuProps } from './IActionMenuProps';
import { import {
EllipsisVerticalIcon,
EyeIcon,
IconButton, IconButton,
Icon,
IconName,
ListItemIcon, ListItemIcon,
ListItemText, ListItemText,
Menu, Menu,
MenuItem, MenuItem
PenIcon,
TrashIcon
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { FormMode } from '../../enums/formMode'; import { FormMode } from '../../enums/formMode';
import { useIsAuthenticated } from '@azure/msal-react';
const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => { const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => {
const [anchorElAction, setAnchorElAction] = useState<null | HTMLElement>( const [anchorElAction, setAnchorElAction] = useState<null | HTMLElement>(
null null
); );
const isAuthenticated = useIsAuthenticated();
const onOpenActionMenu = (event: React.MouseEvent<HTMLElement>) => { const onOpenActionMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorElAction(event.currentTarget); setAnchorElAction(event.currentTarget);
@@ -29,7 +29,7 @@ const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => {
return ( return (
<div> <div>
<IconButton onClick={onOpenActionMenu}> <IconButton onClick={onOpenActionMenu}>
<EllipsisVerticalIcon size="sm" /> <Icon iconName={IconName.ELLIPSIS_VERTICAL} size="sm" />
</IconButton> </IconButton>
<Menu <Menu
anchorEl={anchorElAction} anchorEl={anchorElAction}
@@ -37,25 +37,31 @@ const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => {
open={Boolean(anchorElAction)} open={Boolean(anchorElAction)}
onClose={onCloseActionMenu} onClose={onCloseActionMenu}
> >
<MenuItem onClick={() => onOpenCloseForm(FormMode.EDIT, id)}> {isAuthenticated &&
<ListItemIcon> <MenuItem onClick={() => onOpenCloseForm(FormMode.EDIT, id)}>
<PenIcon size="lg" /> <ListItemIcon>
</ListItemIcon> <Icon iconName={IconName.PEN} size="lg" />
<ListItemText>Edit</ListItemText> </ListItemIcon>
</MenuItem> <ListItemText>Edit</ListItemText>
</MenuItem>
}
<MenuItem onClick={() => onOpenCloseForm(FormMode.VIEW, id)}> <MenuItem onClick={() => onOpenCloseForm(FormMode.VIEW, id)}>
<ListItemIcon> <ListItemIcon>
<EyeIcon size="lg" /> <Icon iconName={IconName.EYE} size="lg" />
</ListItemIcon> </ListItemIcon>
<ListItemText>View</ListItemText> <ListItemText>View</ListItemText>
</MenuItem> </MenuItem>
<hr className="my-3" /> {isAuthenticated &&
<MenuItem onClick={() => onDelete(id)}> <>
<ListItemIcon> <hr className="my-3" />
<TrashIcon size="lg" /> <MenuItem onClick={() => onDelete(id)}>
</ListItemIcon> <ListItemIcon>
<ListItemText>Delete</ListItemText> <Icon iconName={IconName.TRASH} size="lg" />
</MenuItem> </ListItemIcon>
<ListItemText>Delete</ListItemText>
</MenuItem>
</>
}
</Menu> </Menu>
</div> </div>
); );

View File

@@ -1,14 +1,14 @@
import { import {
Box, Box,
Button, Button,
CircleCheckIcon,
Dialog, Dialog,
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogContentText, DialogContentText,
DialogTitle, DialogTitle,
Spinner, Icon,
XmarkIcon IconName,
Spinner
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { IDialogConfirmationProps } from './IConfirmationDialogProps'; import { IDialogConfirmationProps } from './IConfirmationDialogProps';
@@ -34,13 +34,13 @@ const ConfirmationDialog = ({
{isLoading && <Spinner />} {isLoading && <Spinner />}
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={onCancel} variant="outlined" startIcon={<XmarkIcon />}> <Button onClick={onCancel} variant="outlined" startIcon={<Icon iconName={IconName.XMARK} />}>
No No
</Button> </Button>
<Button <Button
onClick={onConfirm} onClick={onConfirm}
variant="contained" variant="contained"
startIcon={<CircleCheckIcon />} startIcon={<Icon iconName={IconName.CIRCLE_CHECK} />}
> >
Yes Yes
</Button> </Button>

View File

@@ -5,16 +5,15 @@ import {
AccordionSummary, AccordionSummary,
Alert, Alert,
Button, Button,
ChevronDownIcon,
DatePicker, DatePicker,
Drawer, Drawer,
Grid, Grid,
Icon,
IconButton, IconButton,
SaveIcon, IconName,
Select, Select,
TextField, TextField,
Typography, Typography,
XmarkIcon
} 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';
@@ -123,6 +122,15 @@ const LogForm: React.FC<ILogFormProps> = ({
); );
const entry = response.data; const entry = response.data;
// if (mode !== FormMode.ADD) {
// const pilot = pilots?.find((pilot) => pilot.id === entry.pilotId);
// console.log(pilot.name)
// dispatch({
// type: 'SET_SELECTED_ENTRY_PILOT_NAME',
// payload: pilot.name
// });
// }
methods.reset(entry); methods.reset(entry);
} catch (error) { } catch (error) {
const axiosError = error as AxiosError; const axiosError = error as AxiosError;
@@ -139,7 +147,7 @@ const LogForm: React.FC<ILogFormProps> = ({
}, [entryId]); }, [entryId]);
useEffect(() => { useEffect(() => {
if (pilots) { if (pilots && FormMode.ADD) {
const newPilotsOptions = pilots.map((pilot) => { const newPilotsOptions = pilots.map((pilot) => {
return { return {
label: pilot.name, label: pilot.name,
@@ -166,11 +174,11 @@ const LogForm: React.FC<ILogFormProps> = ({
<form onSubmit={methods.handleSubmit(onSubmit)}> <form onSubmit={methods.handleSubmit(onSubmit)}>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid size={11}> <Grid size={11}>
<Typography variant="h4">{`${mode.toString().toLowerCase().charAt(0).toUpperCase() + mode.toString().slice(1).toLowerCase()} Pilot`}</Typography> <Typography variant="h4">{`${mode.toString().toLowerCase().charAt(0).toUpperCase() + mode.toString().slice(1).toLowerCase()} Entry`}</Typography>
</Grid> </Grid>
<Grid display="flex" justifyContent="right" size={1}> <Grid display="flex" justifyContent="right" size={1}>
<IconButton onClick={onCancel}> <IconButton onClick={onCancel}>
<XmarkIcon /> <Icon iconName={IconName.XMARK} />
</IconButton> </IconButton>
</Grid> </Grid>
{state.alert && ( {state.alert && (
@@ -194,50 +202,29 @@ const LogForm: React.FC<ILogFormProps> = ({
name="pilotId" name="pilotId"
control={methods.control} control={methods.control}
render={({ field: { onChange, value } }) => { render={({ field: { onChange, value } }) => {
useEffect(() => { console.log(value)
if (value && mode !== FormMode.ADD) {
const pilot = pilots?.find((pilot) => pilot.id === value);
dispatch({
type: 'SET_SELECTED_ENTRY_PILOT_NAME',
payload: pilot.name
});
}
}, [value]);
return ( return (
<> <Select
{mode === FormMode.ADD && ( disabled={state.isDisabled}
<Select fullWidth
disabled={state.isDisabled} onChange={(event: any) => {
fullWidth const pilot = pilots?.find(
onChange={(event) => { (pilot) => (pilot.id = event.target.value)
const pilot = pilots?.find( );
(pilot) => (pilot.id = event.target.value)
);
if (pilot) { if (pilot) {
methods.setValue('pilotName', pilot.name); methods.setValue('pilotName', pilot.name);
} }
methods.setValue('pilotId', event.target.value); methods.setValue('pilotId', event.target.value);
}} }}
options={ options={
state.pilotOptions && state.pilotOptions.length > 0 state.pilotOptions && state.pilotOptions.length > 0
? state.pilotOptions ? state.pilotOptions
: [] : []
} }
value={value} value={value ? value : ''}
/> />
)}
{mode !== FormMode.ADD && (
<TextField
disabled={true}
fullWidth
value={state.selectedEntryPilotName}
/>
)}
</>
); );
}} }}
/> />
@@ -439,7 +426,7 @@ const LogForm: React.FC<ILogFormProps> = ({
</Grid> </Grid>
<Grid size={12}> <Grid size={12}>
<Accordion defaultExpanded> <Accordion defaultExpanded>
<AccordionSummary expandIcon={<ChevronDownIcon />}> <AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}>
<Typography variant="body1">Landings</Typography> <Typography variant="body1">Landings</Typography>
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
@@ -512,7 +499,7 @@ const LogForm: React.FC<ILogFormProps> = ({
</Grid> </Grid>
<Grid size={12}> <Grid size={12}>
<Accordion> <Accordion>
<AccordionSummary expandIcon={<ChevronDownIcon />}> <AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}>
Instrument Instrument
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
@@ -680,7 +667,7 @@ const LogForm: React.FC<ILogFormProps> = ({
</Grid> </Grid>
<Grid size={12}> <Grid size={12}>
<Accordion defaultExpanded> <Accordion defaultExpanded>
<AccordionSummary expandIcon={<ChevronDownIcon />}> <AccordionSummary expandIcon={<Icon iconName={IconName.CHEVRON_DOWN} />}>
Type of Pilot Experience or Training Type of Pilot Experience or Training
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
@@ -911,7 +898,7 @@ const LogForm: React.FC<ILogFormProps> = ({
? state.isDisabled ? state.isDisabled
: false : false
} }
startIcon={<XmarkIcon />} startIcon={<Icon iconName={IconName.XMARK} />}
variant="outlined" variant="outlined"
onClick={onCancel} onClick={onCancel}
size="small" size="small"
@@ -921,7 +908,7 @@ const LogForm: React.FC<ILogFormProps> = ({
{mode.toString() !== FormMode.VIEW && ( {mode.toString() !== FormMode.VIEW && (
<Button <Button
disabled={state.isDisabled} disabled={state.isDisabled}
startIcon={<SaveIcon />} startIcon={<Icon iconName={IconName.SAVE} />}
size="small" size="small"
type="submit" type="submit"
variant="contained" variant="contained"

View File

@@ -6,7 +6,8 @@ import {
Button, Button,
ColumnDef, ColumnDef,
Grid, Grid,
PlusIcon, Icon,
IconName,
Spinner, Spinner,
Table, Table,
Typography Typography
@@ -32,6 +33,9 @@ const Logbook: React.FC<unknown> = () => {
dispatch({ type: 'SET_IS_LOADING', payload: true }); dispatch({ type: 'SET_IS_LOADING', payload: true });
const response: AxiosResponse = await httpClient.get(`api/logs`); const response: AxiosResponse = await httpClient.get(`api/logs`);
const entries: ILogbookEntry[] = response.data;
entries.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
if (response.data.length > 0) { if (response.data.length > 0) {
dispatch({ type: 'SET_ENTRIES', payload: response.data }); dispatch({ type: 'SET_ENTRIES', payload: response.data });
@@ -167,9 +171,7 @@ const Logbook: React.FC<unknown> = () => {
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info: any) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'singleEngineLand', accessorKey: 'singleEngineLand',
@@ -179,9 +181,7 @@ const Logbook: React.FC<unknown> = () => {
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info: any) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
id: 'landings', id: 'landings',
@@ -222,10 +222,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'instrumentSimulated', accessorKey: 'instrumentSimulated',
@@ -234,10 +232,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'instrumentApproaches', accessorKey: 'instrumentApproaches',
@@ -279,10 +275,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'flightTrainingReceived', accessorKey: 'flightTrainingReceived',
@@ -291,10 +285,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'crossCountry', accessorKey: 'crossCountry',
@@ -303,10 +295,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'night', accessorKey: 'night',
@@ -315,10 +305,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'solo', accessorKey: 'solo',
@@ -327,10 +315,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
}, },
{ {
accessorKey: 'pilotInCommand', accessorKey: 'pilotInCommand',
@@ -339,10 +325,8 @@ const Logbook: React.FC<unknown> = () => {
align: 'right', align: 'right',
headerAlign: 'right' headerAlign: 'right'
}, },
cell: (info) => cell: (info: any) =>
info.getValue() !== null info.getValue() ? parseFloat(info.getValue()).toFixed(1) : ''
? parseFloat(info.getValue()).toFixed(1)
: ''
} }
] ]
}, },
@@ -356,7 +340,7 @@ const Logbook: React.FC<unknown> = () => {
align: 'center', align: 'center',
headerAlign: 'center' headerAlign: 'center'
}, },
cell: (info) => ( cell: (info: any) => (
<ActionMenu <ActionMenu
id={info.row.original.rowKey} id={info.row.original.rowKey}
onDelete={onDeleteEntry} onDelete={onDeleteEntry}
@@ -382,7 +366,7 @@ const Logbook: React.FC<unknown> = () => {
{isAuthenticated && {isAuthenticated &&
<Button <Button
onClick={() => onOpenCloseEntryForm(FormMode.ADD)} onClick={() => onOpenCloseEntryForm(FormMode.ADD)}
startIcon={<PlusIcon />} startIcon={<Icon iconName={IconName.PLUS} />}
variant="contained" variant="contained"
data-testid="pilot-add-button" data-testid="pilot-add-button"
> >

View File

@@ -1,16 +1,19 @@
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,
IconButton, IconButton,
IconName,
PeoplePicker, PeoplePicker,
SaveIcon, Select,
StateSelect, StateSelect,
TextField, TextField,
Typography, Typography
XmarkIcon
} 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';
@@ -19,6 +22,9 @@ import { useAccessToken } from '../../hooks/accessToken/UseAcessToken';
import { useIsAuthenticated } from '@azure/msal-react'; import { useIsAuthenticated } from '@azure/msal-react';
import { FormMode } from '../../enums/formMode'; import { FormMode } from '../../enums/formMode';
import { Person } from '@microsoft/microsoft-graph-types'; import { Person } from '@microsoft/microsoft-graph-types';
import PilotFormCertificates from '../pilotFormCertificates/PilotFormCertificates';
import PilotFormEndorsements from '../pilotFormEndorsements/PilotFormEndorsements';
import PilotFormMedical from '../pilotFormMedical/PilotFormMedical';
const PilotForm: React.FC<IPilotFormProps> = ({ const PilotForm: React.FC<IPilotFormProps> = ({
pilotId, pilotId,
@@ -47,7 +53,11 @@ const PilotForm: React.FC<IPilotFormProps> = ({
state: '', state: '',
postalCode: '', postalCode: '',
email: '', email: '',
phone: '' phone: '',
medicalClass: '',
medicalExpiration: '',
certificates: [],
endorsements: []
}; };
const methods = useForm({ const methods = useForm({
defaultValues: defaultValues defaultValues: defaultValues
@@ -103,6 +113,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
}; };
const onSubmit = async (data: unknown) => { const onSubmit = async (data: unknown) => {
console.log(data)
try { try {
setIsLoading(true); setIsLoading(true);
@@ -154,6 +165,9 @@ const PilotForm: React.FC<IPilotFormProps> = ({
); );
const pilot = response.data; const pilot = response.data;
pilot.certificates = JSON.parse(pilot.certificates);
pilot.endorsements = JSON.parse(pilot.endorsements)
console.log(pilot)
setSelectedPerson({ setSelectedPerson({
userPrincipalName: pilot.id, userPrincipalName: pilot.id,
displayName: pilot.name displayName: pilot.name
@@ -191,7 +205,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
</Grid> </Grid>
<Grid display="flex" justifyContent="right" size={1}> <Grid display="flex" justifyContent="right" size={1}>
<IconButton onClick={onCancel}> <IconButton onClick={onCancel}>
<XmarkIcon /> <Icon iconName={IconName.XMARK} />
</IconButton> </IconButton>
</Grid> </Grid>
<Grid size={3}> <Grid size={3}>
@@ -363,6 +377,17 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid size={12}>
<PilotFormMedical
isDisabled={isDisabled}
/>
</Grid>
<Grid size={12}>
<PilotFormCertificates isDisabled={isDisabled} />
</Grid>
<Grid size={12}>
<PilotFormEndorsements isDisabled={isDisabled} />
</Grid>
<Grid display="flex" gap={2} justifyContent="right" size={12}> <Grid display="flex" gap={2} justifyContent="right" size={12}>
<Button <Button
disabled={ disabled={
@@ -370,7 +395,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
? isDisabled ? isDisabled
: false : false
} }
startIcon={<XmarkIcon />} startIcon={<Icon iconName={IconName.XMARK} />}
variant="outlined" variant="outlined"
onClick={onCancel} onClick={onCancel}
data-testid="pilot-cancel-button" data-testid="pilot-cancel-button"
@@ -381,7 +406,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
{mode.toString() !== FormMode.VIEW && ( {mode.toString() !== FormMode.VIEW && (
<Button <Button
disabled={isDisabled} disabled={isDisabled}
startIcon={<SaveIcon />} startIcon={<Icon iconName={IconName.SAVE} />}
size="small" size="small"
type="submit" type="submit"
variant="contained" variant="contained"
@@ -392,111 +417,6 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
</Grid> </Grid>
</Grid> </Grid>
{/* {pilotId && (
<>
<div className="col-span-1">
<Typography variant="h6">Last Review</Typography>
</div>
<div className="col-span-3">
<Controller
name="lastReview"
control={methods.control}
render={({ field }) => {
return (
<DatePicker
handleDateChanged={(date: string) => {
methods.setValue('lastReview', date);
}}
inputProps={{
value: field.value
}}
/>
);
}}
/>
</div>
</>
)} */}
{/* {pilotId && (
<>
<div className="col-span-4">
<Typography variant="h5">Medical</Typography>
<hr className="my-3" />
</div>
<div className="col-span-1">
<Typography variant="h6">Class</Typography>
</div>
<div className="col-span-3">
<Controller
name="medicalClass"
control={methods.control}
render={({ field }) => {
return (
<Select
labelProps={{
className:
'before:content-none after:content-none'
}}
{...field}
>
<Option key="first" value="First">
First
</Option>
<Option key="second" value="Second">
Second
</Option>
<Option key="third" value="Third">
Third
</Option>
<Option key="basicMed" value="Basic Med">
Basic Med
</Option>
</Select>
);
}}
/>
</div>
<div className="col-span-1">
<Typography variant="h6">Expiration Date</Typography>
</div>
<div className="col-span-3">
<Controller
name="medicalExpiration"
control={methods.control}
render={({ field }) => {
return (
<DatePicker
handleDateChanged={(date: string) => {
methods.setValue('medicalExpiration', date);
}}
inputProps={{
value: field.value
}}
/>
);
}}
/>
</div>
</>
)}
{pilotId && (
<>
<div className="col-span-4">
<Typography variant="h5">Certificates</Typography>
<hr className="my-3" />
</div>
<PilotFormCertificates certificates={[]} />
</>
)}
{pilotId && (
<>
<div className="col-span-4">
<Typography variant="h5">Endorsements</Typography>
<hr className="my-3" />
</div>
<PilotFormEndorsements endorsements={[]} />
</>
)} */}
</form> </form>
</FormProvider> </FormProvider>
</Drawer> </Drawer>

View File

@@ -1,5 +0,0 @@
import { Certificate } from './certificate.type';
export interface IPilotFormCertificates {
certificates: Certificate[];
}

View File

@@ -1,134 +1,160 @@
// import { IPilotFormCertificates } from './IPilotFormCertificates'; import { PilotFormCertificatesProps } from './PilotFormCertificatesProps.interface';
// import { import {
// Button, Button,
// DatePicker, DatePicker,
// Input, Grid,
// Option, Icon,
// PlusIcon, IconButton,
// Select, IconName,
// TrashIcon, Select,
// Typography TextField,
// } from '@noahspan/noahspan-components'; Typography
// import { Controller, useFieldArray, useFormContext } from 'react-hook-form'; } from '@noahspan/noahspan-components';
import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
// const PilotFormCertificates: React.FC<IPilotFormCertificates> = ({ const PilotFormCertificates = ({
// certificates isDisabled
// }: IPilotFormCertificates) => { }: PilotFormCertificatesProps ) => {
// const { const {
// control, control,
// formState: { errors }, formState: { errors },
// setValue } = useFormContext();
// } = useFormContext();
// const { fields, append, remove } = useFieldArray({ const { fields, append, remove } = useFieldArray({
// name: 'certificates', name: 'certificates',
// control control
// }); });
// return ( return (
// <> <Grid
// {fields.length > 0 && ( container
// <> spacing={2}
// <div className="col-span-1"> >
// <Typography variant="h6">Type</Typography> <Grid size={12}>
// </div> <Typography variant="h5">Certificates</Typography>
// <div className="col-span-1"> </Grid>
// <Typography variant="h6">Number</Typography> {fields.length > 0 && (
// </div> <>
// <div className="col-span-1"> <Grid size={4}>
// <Typography variant="h6">Date of Issue</Typography> <Typography variant="h6">Type</Typography>
// </div> </Grid>
// <div className="col-span-1"></div> <Grid size={4}>
// </> <Typography variant="h6">Number</Typography>
// )} </Grid>
// {fields.map((field, index) => { <Grid size={3}>
// return ( <Typography variant="h6">Date of Issue</Typography>
// <> </Grid>
// <div className="col-span-1"> <Grid size={1}>
// <Controller </Grid>
// name={`certificates.${index}.type`} {fields.map((field, index) => {
// control={control} return (
// render={({ field }) => { <>
// return ( <Grid size={4}>
// <Select label="Type" {...field}> <Controller
// <Option key="student" value="Student"> name={`certificates.${index}.type`}
// Student control={control}
// </Option> render={({ field: { onChange, value } }) => {
// <Option key="private" value="Private"> return (
// Private <Select
// </Option> disabled={isDisabled}
// <Option key="instrument" value="Instrument"> fullWidth
// Instrument onChange={onChange}
// </Option> options={
// <Option key="recreational" value="Recreational"> [
// Recreational {
// </Option> label: 'Student',
// <Option key="sport" value="Sport"> value: 'student'
// Sport },
// </Option> {
// </Select> label: 'Private',
// ); value: 'private'
// }} },
// /> {
// </div> label: 'Instrument',
// <div className="col-span-1"> value: 'instrument'
// <Controller },
// name={`certificates.${index}.number`} {
// control={control} label: 'Recreational',
// render={({ field }) => { value: 'recreational'
// return <Input label="Number" {...field} />; },
// }} {
// /> label: 'Sport',
// </div> value: 'sport'
// <div className="col-span-1"> }
// <Controller ]
// name={`certificates.${index}.dateOfIssue`} }
// control={control} value={value}
// render={({ field }) => { />
// return ( );
// <DatePicker }}
// handleDateChanged={(date: string) => { />
// setValue(`certificates.${index}.dateOfIssue`, date); </Grid>
// }} <Grid size={4}>
// inputProps={{ <Controller
// value: field.value name={`certificates.${index}.number`}
// }} control={control}
// /> render={({ field: { onChange, value } }) => {
// ); return (
// }} <TextField
// /> disabled={isDisabled}
// </div> fullWidth
// <div className="col-span-1"> onChange={onChange}
// <Button value={value}
// className="flex items-center gap-3" />
// onClick={() => remove(index)} )
// variant="outlined" }}
// > />
// <TrashIcon size="lg" /> </Grid>
// Delete <Grid size={3}>
// </Button> <Controller
// </div> name={`certificates.${index}.dateOfIssue`}
// </> control={control}
// ); render={({ field: { onChange, value } }) => {
// })} return (
// <div className="col-span-4"> <DatePicker
// <Button disabled={isDisabled}
// className="flex items-center gap-3" onChange={onChange}
// onClick={() => { value={value}
// append({ />
// type: '', );
// number: '', }}
// dateOfIssue: null />
// }); </Grid>
// }} <Grid size={1}>
// variant="outlined" <IconButton
// > disabled={isDisabled}
// <PlusIcon size="lg" /> onClick={() => remove(index)}
// Add Certificate sx={{
// </Button> marginTop: '-5px'
// </div> }}
// </> >
// ); <Icon iconName={IconName.TRASH} size='sm' />
// }; </IconButton>
</Grid>
</>
);
})}
</>
)}
{!isDisabled &&
<Grid display="flex" justifyContent="right" size={12}>
<Button
onClick={() => {
append({
type: '',
number: '',
dateOfIssue: null
});
}}
startIcon={<Icon iconName={IconName.PLUS} />}
variant="contained"
>
Add Certificate
</Button>
</Grid>
}
</Grid>
);
};
// export default PilotFormCertificates; export default PilotFormCertificates;

View File

@@ -0,0 +1,3 @@
export interface PilotFormCertificatesProps {
isDisabled: boolean;
}

View File

@@ -1,5 +0,0 @@
export type Certificate = {
type: string;
number: string;
dateOfIssue: Date;
};

View File

@@ -1,5 +0,0 @@
import { Endorsement } from './endorsement.type';
export interface IPilotFormEndorsements {
endorsements: Endorsement[];
}

View File

@@ -1,120 +1,135 @@
// import { IPilotFormEndorsements } from './IPilotFormEndorsements'; import { PilotFormEndorsementsProps } from './PilotFormEndorsementsProps.interface';
// import { import {
// Button, Button,
// DatePicker, DatePicker,
// Input, Grid,
// Option, Icon,
// PlusIcon, IconButton,
// Select, IconName,
// TrashIcon, Select,
// 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';
// const PilotFormEndorsements: React.FC<IPilotFormEndorsements> = ({ const PilotFormEndorsements = ({
// endorsements isDisabled
// }: IPilotFormEndorsements) => { }: PilotFormEndorsementsProps) => {
// const { const {
// control, control,
// formState: { errors }, formState: { errors },
// setValue setValue
// } = useFormContext(); } = useFormContext();
// const { fields, append, remove } = useFieldArray({ const { fields, append, remove } = useFieldArray({
// name: 'endorsements', name: 'endorsements',
// control control
// }); });
// return ( return (
// <> <Grid
// {fields.length > 0 && ( container
// <> spacing={2}
// <div className="col-span-1"> >
// <Typography variant="h6">Type</Typography> <Grid size={12}>
// </div> <Typography variant="h5">Endorsements</Typography>
// <div className="col-span-1"> </Grid>
// <Typography variant="h6">Date of Issue</Typography> {fields.length > 0 && (
// </div> <>
// <div className="col-span-1"></div> <Grid size={8}>
// <div className="col-span-1"></div> <Typography variant="h6">Type</Typography>
// </> </Grid>
// )} <Grid size={3}>
// {fields.map((field, index) => { <Typography variant="h6">Date of Issue</Typography>
// return ( </Grid>
// <> <Grid size={1}></Grid>
// <div className="col-span-1"> {fields.map((field, index) => {
// <Controller return (
// name={`endorsements.${index}.type`} <>
// control={control} <Grid size={8}>
// render={({ field }) => { <Controller
// return ( name={`endorsements.${index}.type`}
// <Select label="Type" {...field}> control={control}
// <Option key="complex" value="Complex"> render={({ field: { onChange, value } }) => {
// Complex return (
// </Option> <Select
// <Option key="highPerformance" value="High Performance"> disabled={isDisabled}
// High Performance fullWidth
// </Option> onChange={onChange}
// <Option key="highAltitude" value="High Altitude"> options={
// High Altitude [
// </Option> {
// <Option key="tailwheel" value="Tailwheel"> label: 'Complex',
// Tailwheel value: 'complex'
// </Option> },
// </Select> {
// ); label: 'High Performance',
// }} value: 'highPerfomance'
// /> },
// </div> {
// <div className="col-span-1"> label: 'High Altitude',
// <Controller value: 'highAltitude'
// name={`endorsements.${index}.dateOfIssue`} },
// control={control} {
// render={({ field }) => { label: 'Tailwheel',
// return ( value: 'tailwheel'
// <DatePicker }
// handleDateChanged={(date: string) => { ]
// setValue(`endorsements.${index}.dateOfIssue`, date); }
// }} value={value ? value : ''}
// inputProps={{ />
// value: field.value );
// }} }}
// /> />
// ); </Grid>
// }} <Grid size={3}>
// /> <Controller
// </div> name={`endorsements.${index}.dateOfIssue`}
// <div className="col-span-1"> control={control}
// <Button render={({ field: { onChange, value } }) => {
// className="flex items-center gap-3" return (
// onClick={() => remove(index)} <DatePicker
// variant="outlined" disabled={isDisabled}
// > onChange={onChange}
// <TrashIcon size="lg" /> value={value}
// Delete />
// </Button> );
// </div> }}
// </> />
// ); </Grid>
// })} <Grid size={1}>
// <div className="col-span-4"> <IconButton
// <Button disabled={isDisabled}
// className="flex items-center gap-3" onClick={() => remove(index)}
// onClick={() => { sx={{
// append({ marginTop: '-5px'
// type: '', }}
// number: '', >
// dateOfIssue: null <Icon iconName={IconName.TRASH} size="sm" />
// }); </IconButton>
// }} </Grid>
// variant="outlined" </>
// > );
// <PlusIcon size="lg" /> })}
// Add Endorsement </>
// </Button> )}
// </div> {!isDisabled &&
// </> <Grid display="flex" justifyContent="right" size={12}>
// ); <Button
// }; onClick={() => {
append({
type: '',
dateOfIssue: null
});
}}
startIcon={<Icon iconName={IconName.PLUS} />}
variant="contained"
>
Add Endorsement
</Button>
</Grid>
}
</Grid>
);
};
// export default PilotFormEndorsements; export default PilotFormEndorsements;

View File

@@ -0,0 +1,3 @@
export interface PilotFormEndorsementsProps {
isDisabled: boolean;
}

View File

@@ -1,5 +0,0 @@
export type Endorsement = {
type: string;
number: string;
dateOfIssue: Date;
};

View File

@@ -0,0 +1,78 @@
import { DatePicker, Grid, Select, Typography } from '@noahspan/noahspan-components';
import { Controller, useFormContext } from "react-hook-form"
import { PilotFormMedicalProps } from "./PilotFormMedicalProps.interface";
const PilotFormMedical = ({ isDisabled }: PilotFormMedicalProps) => {
const {
control,
formState: { errors },
setValue
} = useFormContext()
return (
<Grid container spacing={2}>
<Grid size={12}>
<Typography variant="h5">Medical</Typography>
</Grid>
<Grid size={3}>
<Typography variant="h6">Class</Typography>
</Grid>
<Grid size={9}>
<Controller
name="medicalClass"
control={control}
render={({ field: { onChange, value } }) => {
return (
<Select
disabled={isDisabled}
fullWidth
onChange={onChange}
options={
[
{
label: 'First',
value: 'first'
},
{
label: 'Second',
value: 'second'
},
{
label: 'Third',
value: 'third'
},
{
label: 'Basic Med',
value: 'basicMed'
}
]
}
value={value ? value : ''}
/>
);
}}
/>
</Grid>
<Grid size={3}>
<Typography variant="h6">Expiration</Typography>
</Grid>
<Grid size={9}>
<Controller
name="medicalExpiration"
control={control}
render={({ field: { onChange, value } }) => {
return (
<DatePicker
disabled={isDisabled}
onChange={onChange}
value={value}
/>
);
}}
/>
</Grid>
</Grid>
)
}
export default PilotFormMedical

View File

@@ -0,0 +1,3 @@
export interface PilotFormMedicalProps {
isDisabled: boolean;
}

View File

@@ -5,18 +5,10 @@ import {
Box, Box,
Button, Button,
ColumnDef, ColumnDef,
EllipsisVerticalIcon,
EyeIcon,
Grid, Grid,
IconButton, Icon,
ListItemIcon, IconName,
ListItemText,
Menu,
MenuItem,
PenIcon,
PlusIcon,
Table, Table,
TrashIcon,
Typography Typography
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { useHttpClient } from '../../hooks/httpClient/UseHttpClient'; import { useHttpClient } from '../../hooks/httpClient/UseHttpClient';
@@ -44,7 +36,7 @@ const Pilots: React.FC<unknown> = () => {
`api/pilots`, `api/pilots`,
config config
); );
console.log(response.data)
if (response.data.length > 0) { if (response.data.length > 0) {
dispatch({ type: 'SET_PILOTS', payload: response.data }); dispatch({ type: 'SET_PILOTS', payload: response.data });
@@ -144,7 +136,7 @@ const Pilots: React.FC<unknown> = () => {
}, },
{ {
header: 'Actions', header: 'Actions',
cell: (info) => ( cell: (info: any) => (
<ActionMenu <ActionMenu
id={info.row.original.rowKey} id={info.row.original.rowKey}
onDelete={onDeleteEntry} onDelete={onDeleteEntry}
@@ -170,7 +162,7 @@ const Pilots: React.FC<unknown> = () => {
{isAuthenticated && {isAuthenticated &&
<Button <Button
onClick={() => onOpenClosePilotForm(FormMode.ADD)} onClick={() => onOpenClosePilotForm(FormMode.ADD)}
startIcon={<PlusIcon />} startIcon={<Icon iconName={IconName.PLUS} />}
variant="contained" variant="contained"
data-testid="pilot-add-button" data-testid="pilot-add-button"
> >

View File

@@ -1,30 +1,25 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { ISiteNavProps } from './ISiteNavProps';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { useAppContext } from '../../hooks/appContext/UseAppContext'; import { useAppContext } from '../../hooks/appContext/UseAppContext';
import { import {
Avatar, Avatar,
Button, Button,
Icon,
IconButton, IconButton,
IconName,
Menu, Menu,
MenuItem, MenuItem,
Navbar, Navbar,
PlaneIcon,
SignOutIcon,
Spinner, Spinner,
Typography Typography
} from '@noahspan/noahspan-components'; } from '@noahspan/noahspan-components';
import { useIsAuthenticated, useMsal } from '@azure/msal-react'; import { useIsAuthenticated, useMsal } from '@azure/msal-react';
import { InteractionStatus } from '@azure/msal-browser';
import { useAccessToken } from '../../hooks/accessToken/UseAcessToken'; import { useAccessToken } from '../../hooks/accessToken/UseAcessToken';
import { useHttpClient } from '../../hooks/httpClient/UseHttpClient'; import { useHttpClient } from '../../hooks/httpClient/UseHttpClient';
import { AxiosInstance, AxiosResponse } from 'axios'; import { AxiosInstance, AxiosResponse } from 'axios';
import { User } from '@microsoft/microsoft-graph-types'; import { User } from '@microsoft/microsoft-graph-types';
import { EventMessage, EventPayload, EventType } from '@azure/msal-browser';
type EventPayloadExtended = EventPayload & { accessToken: string }; const SiteNav = () => {
const SiteNav: React.FC<unknown> = () => {
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [userPhoto, setUserPhoto] = useState<string>(); const [userPhoto, setUserPhoto] = useState<string>();
const [pages, setPages] = useState<{ name: string; url: string; }[]>([]); const [pages, setPages] = useState<{ name: string; url: string; }[]>([]);
@@ -98,7 +93,7 @@ const SiteNav: React.FC<unknown> = () => {
const Settings = () => { const Settings = () => {
return ( return (
<MenuItem onClick={handleSignOut}> <MenuItem onClick={handleSignOut}>
<SignOutIcon /> <Icon iconName={IconName.SIGN_OUT} />
<Typography sx={{ marginLeft: '10px', textAlign: 'center' }}> <Typography sx={{ marginLeft: '10px', textAlign: 'center' }}>
Sign Out Sign Out
</Typography> </Typography>
@@ -146,7 +141,7 @@ const SiteNav: React.FC<unknown> = () => {
handlePageClick={handlePageClick} handlePageClick={handlePageClick}
handleSignIn={handleSignIn} handleSignIn={handleSignIn}
isAuthenticated={isAuthenticated} isAuthenticated={isAuthenticated}
logo={<PlaneIcon size="2x" />} logo={<Icon iconName={IconName.PLANE} size="2x" />}
pages={pages} pages={pages}
settings={<Settings />} settings={<Settings />}
userPhoto={userPhoto} userPhoto={userPhoto}

View File

@@ -1,10 +1,3 @@
@tailwind base; body {
@tailwind components; background-color: #f2f2f2;
@tailwind utilities;
@layer base {
body {
@apply bg-[#fafaf9];
@apply text-black;
}
} }

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title> <title>Flying</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@@ -3,11 +3,10 @@ import ReactDOM from 'react-dom/client';
import App from './App.tsx'; import App from './App.tsx';
import AppContextProvider from './context/appContext/AppContextProvider.tsx'; import AppContextProvider from './context/appContext/AppContextProvider.tsx';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import './index.css';
import '@noahspan/noahspan-components/noahspan-components.css';
import { AuthenticationResult, EventMessage, EventType, PublicClientApplication } from '@azure/msal-browser'; import { AuthenticationResult, EventMessage, EventType, PublicClientApplication } from '@azure/msal-browser';
import { MsalProvider } from '@azure/msal-react'; import { MsalProvider } from '@azure/msal-react';
import { msalConfig } from './auth/msalConfig'; import { msalConfig } from './auth/msalConfig';
import './index.css';
const msalInstance: PublicClientApplication = new PublicClientApplication(msalConfig); const msalInstance: PublicClientApplication = new PublicClientApplication(msalConfig);

View File

@@ -9,6 +9,8 @@ services:
- '10001:10001' - '10001:10001'
- '10002:10002' - '10002:10002'
command: 'azurite --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0 --loose' command: 'azurite --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0 --loose'
volumes:
- ./azurite-flying:/data
api: api:
container_name: flying-api container_name: flying-api
@@ -18,7 +20,7 @@ services:
ports: ports:
- '3000:3000' - '3000:3000'
env_file: env_file:
- ./api/.env - ./api/.env.compose
app: app:
container_name: flying-app container_name: flying-app
@@ -27,7 +29,6 @@ services:
target: app target: app
ports: ports:
- '8080:8080' - '8080:8080'
# env_file:
# - ./app/.env
volumes:
azurite-flying:

View File

@@ -1,3 +1,10 @@
module "storage" {
source = "github.com/noahspannbauer/noahspan-terraform/modules/storage"
resource_group_name = var.RESOURCE_GROUP_NAME
storage_account_name = module.environment.storage_account_name
storage_tables = module.environment.storage_tables
}
module "container_app" { module "container_app" {
source = "github.com/noahspannbauer/noahspan-terraform/modules/container_app" source = "github.com/noahspannbauer/noahspan-terraform/modules/container_app"
app_subdomain_name = var.APP_SUBDOMAIN_NAME app_subdomain_name = var.APP_SUBDOMAIN_NAME
@@ -17,7 +24,6 @@ module "container_app" {
domain_name = var.DOMAIN_NAME domain_name = var.DOMAIN_NAME
log_analytics_workspace_name = module.environment.log_analytics_workspace_name log_analytics_workspace_name = module.environment.log_analytics_workspace_name
resource_group_name = var.RESOURCE_GROUP_NAME resource_group_name = var.RESOURCE_GROUP_NAME
storage_account_name = module.environment.storage_account_name storage_account_primary_connection_string = module.storage.storage_account_primary_connection_string
storage_tables = module.environment.storage_tables
tenant_id = var.TENANT_ID tenant_id = var.TENANT_ID
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@noahspan/flying", "name": "@noahspan/flying",
"version": "1.0.0", "version": "1.1.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\"",

616
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff