Skip to content

Commit

Permalink
Fixed: Update final_action_with_optional_button and Final component (#…
Browse files Browse the repository at this point in the history
…1000)

* chore: Update final_action_with_optional_button to handle and add participant_id_url in redirect URL if participant has participant_id_url

* refactor: Update Final component to use Link instead of anchor tag for button navigation
  • Loading branch information
drikusroor authored May 6, 2024
1 parent afedd03 commit 36412aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion backend/experiment/actions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ def final_action_with_optional_button(session, final_text='', title=_('End'), bu
return a Final.action, which has a button to continue to the next experiment if series is defined
"""
collection_slug = session.load_json_data().get(COLLECTION_KEY)

if session.participant.participant_id_url:
participant_id_url = session.participant.participant_id_url
redirect_url = f'/collection/{collection_slug}?participant_id_url={participant_id_url}'
else:
redirect_url = f'/collection/{collection_slug}'

if collection_slug:
return Final(
title=title,
session=session,
final_text=final_text,
button={
'text': button_text,
'link': f'/collection/{collection_slug}'
'link': redirect_url
}
)
else:
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Final/Final.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useRef } from "react";
import { withRouter } from "react-router-dom";
import { Link, withRouter } from "react-router-dom";

import Rank from "../Rank/Rank";
import Social from "../Social/Social";
Expand Down Expand Up @@ -65,9 +65,9 @@ const Final = ({ experiment, participant, score, final_text, action_texts, butto
</div>
{button && (
<div className="text-center pt-4">
<a className='btn btn-primary btn-lg' href={button.link} onClick={button.link ? undefined : onNext}>
<Link className='btn btn-primary btn-lg' to={button.link} onClick={button.link ? undefined : onNext}>
{button.text}
</a>
</Link>
</div>
)}
{logo && (
Expand Down

0 comments on commit 36412aa

Please sign in to comment.