diff --git a/api/src/log/log.controller.ts b/api/src/log/log.controller.ts index 55aea0a..a8d9927 100644 --- a/api/src/log/log.controller.ts +++ b/api/src/log/log.controller.ts @@ -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, diff --git a/api/src/main.ts b/api/src/main.ts index cfa9d95..3b8b89f 100644 --- a/api/src/main.ts +++ b/api/src/main.ts @@ -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()); diff --git a/app/src/components/actionMenu/ActionMenu.tsx b/app/src/components/actionMenu/ActionMenu.tsx index 6bf8df3..e6ad4d7 100644 --- a/app/src/components/actionMenu/ActionMenu.tsx +++ b/app/src/components/actionMenu/ActionMenu.tsx @@ -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 ); + const isAuthenticated = useIsAuthenticated(); const onOpenActionMenu = (event: React.MouseEvent) => { setAnchorElAction(event.currentTarget); @@ -37,25 +39,31 @@ const ActionMenu = ({ id, onDelete, onOpenCloseForm }: IActionMenuProps) => { open={Boolean(anchorElAction)} onClose={onCloseActionMenu} > - onOpenCloseForm(FormMode.EDIT, id)}> - - - - Edit - + {isAuthenticated && + onOpenCloseForm(FormMode.EDIT, id)}> + + + + Edit + + } onOpenCloseForm(FormMode.VIEW, id)}> View -
- onDelete(id)}> - - - - Delete - + {isAuthenticated && + <> +
+ onDelete(id)}> + + + + Delete + + + } ); diff --git a/app/src/components/logForm/LogForm.tsx b/app/src/components/logForm/LogForm.tsx index 56fb90d..9244600 100644 --- a/app/src/components/logForm/LogForm.tsx +++ b/app/src/components/logForm/LogForm.tsx @@ -122,7 +122,7 @@ const LogForm: React.FC = ({ config ); const entry = response.data; - + console.log(entry) methods.reset(entry); } catch (error) { const axiosError = error as AxiosError; @@ -186,62 +186,81 @@ const LogForm: React.FC = ({ )} - - Pilot * - - - { - useEffect(() => { - if (value && mode !== FormMode.ADD) { - const pilot = pilots?.find((pilot) => pilot.id === value); + {!FormMode.VIEW && + <> + + Pilot * + + + { + useEffect(() => { + if (value) { + const pilot = pilots?.find((pilot) => pilot.id === value); - dispatch({ - type: 'SET_SELECTED_ENTRY_PILOT_NAME', - payload: pilot.name - }); - } - }, [value]); + dispatch({ + type: 'SET_SELECTED_ENTRY_PILOT_NAME', + payload: pilot.name + }); + } + }, [value]); - return ( - <> - {mode === FormMode.ADD && ( - { + const pilot = pilots?.find( + (pilot) => (pilot.id = event.target.value) + ); - if (pilot) { - methods.setValue('pilotName', pilot.name); - } + if (pilot) { + methods.setValue('pilotName', pilot.name); + } - methods.setValue('pilotId', event.target.value); - }} - options={ - state.pilotOptions && state.pilotOptions.length > 0 - ? state.pilotOptions - : [] - } - value={value} - /> - )} - {mode !== FormMode.ADD && ( + methods.setValue('pilotId', event.target.value); + }} + options={ + state.pilotOptions && state.pilotOptions.length > 0 + ? state.pilotOptions + : [] + } + value={value} + /> + )} + + ); + }} + /> + + + } + {FormMode.VIEW && + <> + + Pilot * + + + { + return ( - )} - - ); - }} - /> - + ) + }} + /> + + + } Date *