Skip to content

Commit

Permalink
fixes up the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarsh-scottlogic committed Mar 26, 2024
1 parent 5f4a99b commit 9979e81
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
11 changes: 2 additions & 9 deletions frontend/src/components/MainComponent/MainComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,11 @@ function MainComponent({
}
}

// for clearing single level progress
async function resetLevel() {
// reset on the backend
const resultingChatInfoMessage = await resetService.resetLevelProgress(
currentLevel
);
const chatInfoMessage = await resetService.resetLevelProgress(currentLevel);

resetFrontendState();
setMessages((messages: ChatMessage[]) => [
resultingChatInfoMessage,
...messages,
]);
setMessages((messages: ChatMessage[]) => [chatInfoMessage, ...messages]);
}

// for going switching level without clearing progress
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/models/apiResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type LoadLevelResponse = {
};

type ResetLevelResponse = {
resultingChatInfoMessage: ChatMessageDTO;
chatInfoMessage: ChatMessageDTO;
};

export type { StartResponse, LoadLevelResponse, ResetLevelResponse };
7 changes: 3 additions & 4 deletions frontend/src/service/resetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ async function resetAllProgress(level: number) {
}

async function resetLevelProgress(level: number) {
const response = await sendRequest(`resetlevel?level=${level}`, {
const response = await sendRequest(`${PATH}/${level}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
});
const { resultingChatInfoMessage } =
(await response.json()) as ResetLevelResponse;
const { chatInfoMessage } = (await response.json()) as ResetLevelResponse;

return makeChatMessageFromDTO(resultingChatInfoMessage);
return makeChatMessageFromDTO(chatInfoMessage);
}

export { resetAllProgress, resetLevelProgress };

0 comments on commit 9979e81

Please sign in to comment.