Feature/5 pilots edit (#40)

* enabling pilot edit

* enabling pilot edit
This commit was merged in pull request #40.
This commit is contained in:
2025-02-03 02:55:09 +00:00
committed by GitHub
parent c71af4a793
commit fd28bbfd20
3 changed files with 18 additions and 10 deletions

View File

@@ -84,7 +84,7 @@ const LogForm: React.FC<ILogFormProps> = ({
}
});
} else {
await httpClient.put(`api/logs/${entryId}`, data, {
await httpClient.put(`api/logs/log/${entryId}`, data, {
headers: {
Authorization: accessToken
}

View File

@@ -99,6 +99,7 @@ const PilotForm: React.FC<IPilotFormProps> = ({
methods.reset(defaultValues);
onOpenClose(FormMode.CANCEL);
setSelectedPerson({ userPrincipalName: '', displayName: '' });
setIsDisabled(false)
};
const onSubmit = async (data: unknown) => {
@@ -107,12 +108,21 @@ const PilotForm: React.FC<IPilotFormProps> = ({
const accessToken: string = await getAccessToken();
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<IPilotFormProps> = ({
? { 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 {

View File

@@ -52,7 +52,6 @@ const SiteNav: React.FC<unknown> = () => {
instance.logoutRedirect();
};
const getUserProfile = async (accessToken: string): Promise<User> => {
console.log(accessToken)
try {
const response: AxiosResponse = await httpClient.get(`api/userProfile`, {
headers: {