Feature/49 add medical certificate to pilot form (#55)

* adding medical certificate to pilot form

* adding medical certificate to pilot form
This commit was merged in pull request #55.
This commit is contained in:
2025-03-01 02:56:36 +00:00
committed by GitHub
parent 99019ddeef
commit 032cd4665f
4 changed files with 100 additions and 65 deletions

View File

@@ -1,12 +1,15 @@
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,
IconButton, IconButton,
PeoplePicker, PeoplePicker,
SaveIcon, SaveIcon,
Select,
StateSelect, StateSelect,
TextField, TextField,
Typography, Typography,
@@ -19,6 +22,7 @@ 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 PilotFormMedical from '../pilotFormMedical/PilotFormMedical';
const PilotForm: React.FC<IPilotFormProps> = ({ const PilotForm: React.FC<IPilotFormProps> = ({
pilotId, pilotId,
@@ -47,7 +51,9 @@ const PilotForm: React.FC<IPilotFormProps> = ({
state: '', state: '',
postalCode: '', postalCode: '',
email: '', email: '',
phone: '' phone: '',
medicalClass: '',
medicalExpiration: ''
}; };
const methods = useForm({ const methods = useForm({
defaultValues: defaultValues defaultValues: defaultValues
@@ -103,6 +109,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);
@@ -363,6 +370,11 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
/> />
</Grid> </Grid>
<Grid size={12}>
<PilotFormMedical
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={
@@ -392,6 +404,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
)} )}
</Grid> </Grid>
</Grid> </Grid>
{/* {pilotId && ( {/* {pilotId && (
<> <>
<div className="col-span-1"> <div className="col-span-1">
@@ -417,69 +430,8 @@ const PilotForm: React.FC<IPilotFormProps> = ({
</div> </div>
</> </>
)} */} )} */}
{/* {pilotId && (
<> {/* {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"> <div className="col-span-4">
<Typography variant="h5">Certificates</Typography> <Typography variant="h5">Certificates</Typography>

View File

@@ -0,0 +1,77 @@
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'
}
]
}
/>
);
}}
/>
</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

@@ -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
@@ -28,4 +30,5 @@ services:
ports: ports:
- '8080:8080' - '8080:8080'
volumes:
azurite-flying: