Skip to content

Commit

Permalink
fixed a todo
Browse files Browse the repository at this point in the history
  • Loading branch information
fhennig committed Sep 30, 2024
1 parent 9ba53e3 commit c9e7d8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions website/src/hooks/useGroupOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,17 @@ function callCreateGroup(accessToken: string, zodios: ZodiosInstance<typeof grou
};
}

type EditGroupSuccess = {
succeeded: true;
group: Group;
};
type EditGroupError = {
succeeded: false;
errorMessage: string;
};
export type EditGroupResult = EditGroupSuccess | EditGroupError;

function callEditGroup(accessToken: string, zodios: ZodiosInstance<typeof groupManagementApi>) {
// TODO
return async (groupId: number, group: NewGroup) => {
try {
const groupResult = await zodios.editGroup(group, {
Expand All @@ -141,13 +150,13 @@ function callEditGroup(accessToken: string, zodios: ZodiosInstance<typeof groupM
return {
succeeded: true,
group: groupResult,
} as CreateGroupSuccess; // TODO change type
} as EditGroupSuccess;
} catch (error) {
const message = `Failed to create group: ${stringifyMaybeAxiosError(error)}`;
return {
succeeded: false,
errorMessage: message,
} as CreateGroupError;
} as EditGroupError;
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions website/src/services/groupManagementApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createGroupEndpoint = makeEndpoint({
const editGroupEndpoint = makeEndpoint({
method: 'put',
path: '/groups/:groupId',
alias: 'editGroup', // TODO what does this do?
alias: 'editGroup',
parameters: [
authorizationHeader,
{
Expand All @@ -31,7 +31,7 @@ const editGroupEndpoint = makeEndpoint({
},
],
response: group,
errors: [notAuthorizedError],
errors: [notAuthorizedError], // TODO not sure which errors the API can throw
});
const addUserToGroupEndpoint = makeEndpoint({
method: 'put',
Expand Down

0 comments on commit c9e7d8c

Please sign in to comment.