Skip to content

Commit

Permalink
revert: Re-add finalizeSession function
Browse files Browse the repository at this point in the history
  • Loading branch information
drikusroor committed Dec 19, 2023
1 parent 05c103c commit d29bcee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions frontend/src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ export const getNextRound = async ({ session }) => {
}
};

// Tell the backend that the session is finished
export const finalizeSession = async ({ session, participant }) => {
try {
const response = await axios.post(
API_BASE_URL + URLS.session.finalize(session.current.id),
qs.stringify({
csrfmiddlewaretoken: participant.csrf_token,
})
);
return response.data;
} catch (err) {
console.error(err);
return null;
}
}

// Share participant
export const shareParticipant = async ({ email, participant }) => {
try {
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/Final/Final.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Rank from "../Rank/Rank";
import Social from "../Social/Social";

import { URLS } from "../../config";
import { finalizeSession } from "../../API";
import ParticipantLink from "../ParticipantLink/ParticipantLink";
import UserFeedback from "../UserFeedback/UserFeedback";

Expand Down Expand Up @@ -45,6 +46,10 @@ const Final= ({ experiment, participant, session, score, final_text, action_text
};
}, [score, showScore]);

const finalize = () => {
finalizeSession({ session, participant });
}

return (
<div className="aha__final d-flex flex-column justify-content-center">
{rank && (
Expand Down

0 comments on commit d29bcee

Please sign in to comment.