Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/apps/review/src/lib/components/Tabs/Tabs.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
}
.blockItem {
position: relative;
display: flex;
align-items: flex-start;
justify-content: flex-start;
&.selected {
background-color: var(--Actived);
color: var(--invertButtonColor);
Expand Down
4 changes: 4 additions & 0 deletions src/apps/review/src/lib/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ $icons: review appeal submission warning error event timer upload reopen 1st 2nd
flex-shrink: 0;
height: 20px;
width: 20px;
@include ltemd {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Ensure that the ltemd mixin is defined and behaves as expected. If it's not defined in this file, verify its definition elsewhere to confirm it applies the intended styles correctly.

height: 30px;
width: 30px;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@
color: var(--FontColor);
font-weight: normal;
margin-left: 4px;
@include ltemd {
&.selected {
color: var(--invertButtonColor);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { FC, useMemo, useState } from 'react'
import { FC, useCallback, useMemo, useState } from 'react'
import { mutate } from 'swr'
import classNames from 'classnames'

import { Tabs } from '~/apps/review/src/lib'
import { Tabs, useChallengeDetailsContext } from '~/apps/review/src/lib'
import { ScorecardViewer } from '~/apps/review/src/lib/components/Scorecard'
import { ScorecardAttachments } from '~/apps/review/src/lib/components/Scorecard/ScorecardAttachments'
import {
AiWorkflowRunAttachmentsResponse,
AiWorkflowRunItemsResponse,
AiWorkflowRunStatusEnum,
useAppNavigate,
useFetchAiWorkflowsRunAttachments,
useFetchAiWorkflowsRunItems,
} from '~/apps/review/src/lib/hooks'
import { ReviewsContextModel, SelectOption } from '~/apps/review/src/lib/models'
import { ChallengeDetailContextModel, ReviewsContextModel, SelectOption } from '~/apps/review/src/lib/models'
import { AiWorkflowRunStatus } from '~/apps/review/src/lib/components/AiReviewsTable'
import { rootRoute } from '~/apps/review/src/config/routes.config'

import { ScorecardHeader } from '../ScorecardHeader'
import { useReviewsContext } from '../../ReviewsContext'
Expand All @@ -28,12 +32,21 @@ const AiReviewViewer: FC = () => {
)
const { totalCount }: AiWorkflowRunAttachmentsResponse
= useFetchAiWorkflowsRunAttachments(workflowId, workflowRun?.id)
const {
challengeInfo,
}: ChallengeDetailContextModel = useChallengeDetailsContext()
const navigate = useAppNavigate()

const tabItems: SelectOption[] = [
{
indicator: workflowRun && (
<>
<span className={styles.tabScore}>{workflowRun?.score ?? ''}</span>
<span className={classNames(styles.tabScore, {
[styles.selected]: selectedTab === 'scorecard',
})}
>
{workflowRun?.score ?? ''}
</span>
<AiWorkflowRunStatus
run={workflowRun}
hideLabel
Expand All @@ -52,6 +65,28 @@ const AiReviewViewer: FC = () => {
].includes(workflowRun.status)
), [workflowRun])

const back = useCallback(async (e?: React.MouseEvent<HTMLAnchorElement>) => {
e?.preventDefault()
try {
if (challengeInfo?.id) {
// Ensure the challenge details reflect the latest data (e.g., active phase)
await mutate(`challengeBaseUrl/challenges/${challengeInfo?.id}`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The mutate function is called with a hardcoded string challengeBaseUrl/challenges/${challengeInfo?.id}. Ensure that challengeBaseUrl is defined and correctly imported or used here, as it is not shown in the diff. If it's a typo or missing import, it could lead to runtime errors.

}
} 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Using location.pathname directly can be problematic in environments where location is not defined, such as during server-side rendering. Consider using a safer method to access the current path that is compatible with both client and server environments.

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 (
<div className={styles.wrap}>

Expand All @@ -74,6 +109,7 @@ const AiReviewViewer: FC = () => {
scorecard={scorecard}
aiFeedback={runItems}
setActionButtons={setActionButtons}
navigateBack={back}
/>
)}

Expand Down
Loading