From fd26f0851ed0aeeb7ec0f504b65a537f72753ba2 Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Sun, 2 Feb 2025 20:51:05 -0600 Subject: [PATCH 1/2] enabling pilot edit --- app/src/components/pilotForm/PilotForm.tsx | 25 +++++++++++++++------- app/src/components/siteNav/SiteNav.tsx | 1 - 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/components/pilotForm/PilotForm.tsx b/app/src/components/pilotForm/PilotForm.tsx index fe4ddb0..cc44b7d 100644 --- a/app/src/components/pilotForm/PilotForm.tsx +++ b/app/src/components/pilotForm/PilotForm.tsx @@ -99,6 +99,7 @@ const PilotForm: React.FC = ({ methods.reset(defaultValues); onOpenClose(FormMode.CANCEL); setSelectedPerson({ userPrincipalName: '', displayName: '' }); + setIsDisabled(false) }; const onSubmit = async (data: unknown) => { @@ -107,12 +108,21 @@ const PilotForm: React.FC = ({ const accessToken: string = await getAccessToken(); - await httpClient.post(`api/pilots`, data, { - headers: { - Authorization: accessToken - } - }); + if (!pilotId) { + await httpClient.post(`api/pilots`, data, { + headers: { + Authorization: accessToken + } + }); + } else { + await httpClient.put(`api/pilots/pilot/${pilotId}`, data, { + headers: { + Authorization: accessToken + } + }) + } + methods.reset(defaultValues) onOpenClose(FormMode.CANCEL); } catch (error) { const axiosError = error as AxiosError; @@ -139,17 +149,16 @@ const PilotForm: React.FC = ({ ? { headers: { Authorization: await getAccessToken() } } : {}; const response: AxiosResponse = await httpClient.get( - `api/pilots/${pilotId}`, + `api/pilots/pilot/${pilotId}`, config ); const pilot = response.data; - console.log(pilot); + setSelectedPerson({ userPrincipalName: pilot.id, displayName: pilot.name }); methods.reset(pilot); - console.log(methods.getValues()); } catch (error) { console.log(error); } finally { diff --git a/app/src/components/siteNav/SiteNav.tsx b/app/src/components/siteNav/SiteNav.tsx index 6830110..448db82 100644 --- a/app/src/components/siteNav/SiteNav.tsx +++ b/app/src/components/siteNav/SiteNav.tsx @@ -52,7 +52,6 @@ const SiteNav: React.FC = () => { instance.logoutRedirect(); }; const getUserProfile = async (accessToken: string): Promise => { - console.log(accessToken) try { const response: AxiosResponse = await httpClient.get(`api/userProfile`, { headers: { -- 2.49.1 From 3dbe9f8917aae00966925ad87877fc31a331d4c0 Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Sun, 2 Feb 2025 20:52:29 -0600 Subject: [PATCH 2/2] enabling pilot edit --- app/src/components/logForm/LogForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/components/logForm/LogForm.tsx b/app/src/components/logForm/LogForm.tsx index 00b0b79..8e6c50c 100644 --- a/app/src/components/logForm/LogForm.tsx +++ b/app/src/components/logForm/LogForm.tsx @@ -84,7 +84,7 @@ const LogForm: React.FC = ({ } }); } else { - await httpClient.put(`api/logs/${entryId}`, data, { + await httpClient.put(`api/logs/log/${entryId}`, data, { headers: { Authorization: accessToken } -- 2.49.1