Skip to content

Commit ff77f1c

Browse files
authored
Merge pull request #1347 from topcoder-platform/pm-3065
fix(PM-3065, PM-3074, PM-3076): added back button, ui issues
2 parents fe11f1b + eaf1b23 commit ff77f1c

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

src/apps/review/src/lib/components/Tabs/Tabs.module.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@
138138
}
139139
.blockItem {
140140
position: relative;
141+
display: flex;
142+
align-items: flex-start;
143+
justify-content: flex-start;
141144
&.selected {
142145
background-color: var(--Actived);
143146
color: var(--invertButtonColor);

src/apps/review/src/lib/styles/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ $icons: review appeal submission warning error event timer upload reopen 1st 2nd
3737
flex-shrink: 0;
3838
height: 20px;
3939
width: 20px;
40+
@include ltemd {
41+
height: 30px;
42+
width: 30px;
43+
}
4044
}
4145
}
4246

src/apps/review/src/pages/reviews/components/AiReviewViewer/AiReviewViewer.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@
1515
color: var(--FontColor);
1616
font-weight: normal;
1717
margin-left: 4px;
18+
@include ltemd {
19+
&.selected {
20+
color: var(--invertButtonColor);
21+
}
22+
}
1823
}

src/apps/review/src/pages/reviews/components/AiReviewViewer/AiReviewViewer.tsx

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import { FC, useMemo, useState } from 'react'
1+
import { FC, useCallback, useMemo, useState } from 'react'
2+
import { mutate } from 'swr'
3+
import classNames from 'classnames'
24

3-
import { Tabs } from '~/apps/review/src/lib'
5+
import { Tabs, useChallengeDetailsContext } from '~/apps/review/src/lib'
46
import { ScorecardViewer } from '~/apps/review/src/lib/components/Scorecard'
57
import { ScorecardAttachments } from '~/apps/review/src/lib/components/Scorecard/ScorecardAttachments'
68
import {
79
AiWorkflowRunAttachmentsResponse,
810
AiWorkflowRunItemsResponse,
911
AiWorkflowRunStatusEnum,
12+
useAppNavigate,
1013
useFetchAiWorkflowsRunAttachments,
1114
useFetchAiWorkflowsRunItems,
1215
} from '~/apps/review/src/lib/hooks'
13-
import { ReviewsContextModel, SelectOption } from '~/apps/review/src/lib/models'
16+
import { ChallengeDetailContextModel, ReviewsContextModel, SelectOption } from '~/apps/review/src/lib/models'
1417
import { AiWorkflowRunStatus } from '~/apps/review/src/lib/components/AiReviewsTable'
18+
import { rootRoute } from '~/apps/review/src/config/routes.config'
1519

1620
import { ScorecardHeader } from '../ScorecardHeader'
1721
import { useReviewsContext } from '../../ReviewsContext'
@@ -28,12 +32,21 @@ const AiReviewViewer: FC = () => {
2832
)
2933
const { totalCount }: AiWorkflowRunAttachmentsResponse
3034
= useFetchAiWorkflowsRunAttachments(workflowId, workflowRun?.id)
35+
const {
36+
challengeInfo,
37+
}: ChallengeDetailContextModel = useChallengeDetailsContext()
38+
const navigate = useAppNavigate()
3139

3240
const tabItems: SelectOption[] = [
3341
{
3442
indicator: workflowRun && (
3543
<>
36-
<span className={styles.tabScore}>{workflowRun?.score ?? ''}</span>
44+
<span className={classNames(styles.tabScore, {
45+
[styles.selected]: selectedTab === 'scorecard',
46+
})}
47+
>
48+
{workflowRun?.score ?? ''}
49+
</span>
3750
<AiWorkflowRunStatus
3851
run={workflowRun}
3952
hideLabel
@@ -52,6 +65,28 @@ const AiReviewViewer: FC = () => {
5265
].includes(workflowRun.status)
5366
), [workflowRun])
5467

68+
const back = useCallback(async (e?: React.MouseEvent<HTMLAnchorElement>) => {
69+
e?.preventDefault()
70+
try {
71+
if (challengeInfo?.id) {
72+
// Ensure the challenge details reflect the latest data (e.g., active phase)
73+
await mutate(`challengeBaseUrl/challenges/${challengeInfo?.id}`)
74+
}
75+
} catch {
76+
// no-op: navigation should still occur even if revalidation fails
77+
}
78+
79+
const pastPrefix = '/past-challenges/'
80+
// eslint-disable-next-line no-restricted-globals
81+
const idx = location.pathname.indexOf(pastPrefix)
82+
const url = idx > -1
83+
? `${rootRoute}/past-challenges/${challengeInfo?.id}/challenge-details`
84+
: `${rootRoute}/active-challenges/${challengeInfo?.id}/challenge-details`
85+
navigate(url, {
86+
fallback: './../../../../challenge-details',
87+
})
88+
}, [challengeInfo?.id, mutate, navigate])
89+
5590
return (
5691
<div className={styles.wrap}>
5792

@@ -74,6 +109,7 @@ const AiReviewViewer: FC = () => {
74109
scorecard={scorecard}
75110
aiFeedback={runItems}
76111
setActionButtons={setActionButtons}
112+
navigateBack={back}
77113
/>
78114
)}
79115

0 commit comments

Comments
 (0)