fixing logbook non authenticated (#53)
This commit was merged in pull request #53.
This commit is contained in:
@@ -20,6 +20,7 @@ import { Public } from '@noahspan/noahspan-modules';
|
||||
export class LogController {
|
||||
constructor(private readonly logService: LogService) {}
|
||||
|
||||
@Public()
|
||||
@Get(':partitionKey/:rowKey')
|
||||
async find(
|
||||
@Param('partitionKey') partitionKey: string,
|
||||
|
||||
@@ -9,6 +9,7 @@ async function bootstrap() {
|
||||
const httpService = new HttpService();
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
app.enableCors();
|
||||
app.setGlobalPrefix('api');
|
||||
app.useGlobalFilters(new HttpExceptionFilter());
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@ import {
|
||||
TrashIcon
|
||||
} from '@noahspan/noahspan-components';
|
||||
import { FormMode } from '../../enums/formMode';
|
||||
import { useIsAuthenticated } from '@azure/msal-react';
|
||||
|
||||
const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => {
|
||||
const [anchorElAction, setAnchorElAction] = useState<null | HTMLElement>(
|
||||
null
|
||||
);
|
||||
const isAuthenticated = useIsAuthenticated();
|
||||
|
||||
const onOpenActionMenu = (event: React.MouseEvent<HTMLElement>) => {
|
||||
setAnchorElAction(event.currentTarget);
|
||||
@@ -37,18 +39,22 @@ const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => {
|
||||
open={Boolean(anchorElAction)}
|
||||
onClose={onCloseActionMenu}
|
||||
>
|
||||
{isAuthenticated &&
|
||||
<MenuItem onClick={() => onOpenCloseForm(FormMode.EDIT, id)}>
|
||||
<ListItemIcon>
|
||||
<PenIcon size="lg" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>Edit</ListItemText>
|
||||
</MenuItem>
|
||||
}
|
||||
<MenuItem onClick={() => onOpenCloseForm(FormMode.VIEW, id)}>
|
||||
<ListItemIcon>
|
||||
<EyeIcon size="lg" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>View</ListItemText>
|
||||
</MenuItem>
|
||||
{isAuthenticated &&
|
||||
<>
|
||||
<hr className="my-3" />
|
||||
<MenuItem onClick={() => onDelete(id)}>
|
||||
<ListItemIcon>
|
||||
@@ -56,6 +62,8 @@ const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => {
|
||||
</ListItemIcon>
|
||||
<ListItemText>Delete</ListItemText>
|
||||
</MenuItem>
|
||||
</>
|
||||
}
|
||||
</Menu>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -122,7 +122,7 @@ const LogForm: React.FC<ILogFormProps> = ({
|
||||
config
|
||||
);
|
||||
const entry = response.data;
|
||||
|
||||
console.log(entry)
|
||||
methods.reset(entry);
|
||||
} catch (error) {
|
||||
const axiosError = error as AxiosError;
|
||||
@@ -186,6 +186,8 @@ const LogForm: React.FC<ILogFormProps> = ({
|
||||
</Alert>
|
||||
</Grid>
|
||||
)}
|
||||
{!FormMode.VIEW &&
|
||||
<>
|
||||
<Grid alignItems="center" display="flex" size={4}>
|
||||
<Typography variant="body1">Pilot *</Typography>
|
||||
</Grid>
|
||||
@@ -195,7 +197,7 @@ const LogForm: React.FC<ILogFormProps> = ({
|
||||
control={methods.control}
|
||||
render={({ field: { onChange, value } }) => {
|
||||
useEffect(() => {
|
||||
if (value && mode !== FormMode.ADD) {
|
||||
if (value) {
|
||||
const pilot = pilots?.find((pilot) => pilot.id === value);
|
||||
|
||||
dispatch({
|
||||
@@ -230,18 +232,35 @@ const LogForm: React.FC<ILogFormProps> = ({
|
||||
value={value}
|
||||
/>
|
||||
)}
|
||||
{mode !== FormMode.ADD && (
|
||||
<TextField
|
||||
disabled={true}
|
||||
fullWidth
|
||||
value={state.selectedEntryPilotName}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
</>
|
||||
}
|
||||
{FormMode.VIEW &&
|
||||
<>
|
||||
<Grid alignItems="center" display="flex" size={4}>
|
||||
<Typography variant="body1">Pilot *</Typography>
|
||||
</Grid>
|
||||
<Grid size={8}>
|
||||
<Controller
|
||||
name="pilotName"
|
||||
control={methods.control}
|
||||
render={({ field: { value } }) => {
|
||||
return (
|
||||
<TextField
|
||||
disabled={true}
|
||||
fullWidth
|
||||
value={value}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
</>
|
||||
}
|
||||
<Grid alignItems="center" display="flex" size={4}>
|
||||
<Typography variant="body1">Date *</Typography>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user