) => {
+ e?.preventDefault()
+ try {
+ if (challengeInfo?.id) {
+ // Ensure the challenge details reflect the latest data (e.g., active phase)
+ await mutate(`challengeBaseUrl/challenges/${challengeInfo?.id}`)
+ }
+ } catch {
+ // no-op: navigation should still occur even if revalidation fails
+ }
+
+ const pastPrefix = '/past-challenges/'
+ // eslint-disable-next-line no-restricted-globals
+ const idx = location.pathname.indexOf(pastPrefix)
+ const url = idx > -1
+ ? `${rootRoute}/past-challenges/${challengeInfo?.id}/challenge-details`
+ : `${rootRoute}/active-challenges/${challengeInfo?.id}/challenge-details`
+ navigate(url, {
+ fallback: './../../../../challenge-details',
+ })
+ }, [challengeInfo?.id, mutate, navigate])
+
return (
@@ -74,6 +109,7 @@ const AiReviewViewer: FC = () => {
scorecard={scorecard}
aiFeedback={runItems}
setActionButtons={setActionButtons}
+ navigateBack={back}
/>
)}