Skip to content

Commit c4ba5a2

Browse files
Merge pull request #5203 from OneCommunityGlobal/Sayali_Fix_PRGrading_ReviewerCount
Sayali : pass reviewerCount and reviewerNames to PR grading screen for DB…
2 parents dace937 + a71472d commit c4ba5a2

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

src/components/PRGradingScreen/PRGradingTest.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const PRGradingTest = () => {
3333
cfg.testDataType
3434
}${cfg.notes ? ` — ${cfg.notes}` : ''}`,
3535
fromDB: true,
36+
reviewerCount: cfg.reviewerCount,
37+
reviewerNames: cfg.reviewerNames || [],
3638
}));
3739
setDynamicTeams(fetched);
3840
} catch {
@@ -47,7 +49,8 @@ const PRGradingTest = () => {
4749
const allTeams = [...STATIC_TEAMS, ...dynamicTeams];
4850

4951
const handleTeamSelect = teamId => {
50-
history.push('/pr-grading-screen', { teamId });
52+
const team = allTeams.find(t => t.id === teamId);
53+
history.push('/pr-grading-screen', { teamId, config: team });
5154
};
5255

5356
const handleDeleteConfig = async (e, teamId) => {

src/components/PRGradingScreen/index.jsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
1-
import React from 'react';
21
import { useLocation } from 'react-router-dom';
2+
import { v4 as uuidv4 } from 'uuid';
33
import { getDataByTeamId } from './mockData';
44
import PRGradingScreen from './PRGradingScreen';
55

6+
const STATIC_IDS = ['team1', 'team2', 'team3'];
7+
68
const PRGradingScreenContainer = () => {
79
const location = useLocation();
8-
9-
// Get teamId from router state, fallback to default
1010
const teamId = location.state?.teamId || 'team1';
11-
const data = getDataByTeamId(teamId);
11+
const config = location.state?.config || null;
12+
13+
if (!STATIC_IDS.includes(teamId) && config) {
14+
const reviewers = Array.from({ length: config.reviewerCount }, (_, i) => ({
15+
id: uuidv4(),
16+
reviewer: config.reviewerNames?.[i] || `Reviewer ${i + 1}`,
17+
prsNeeded: 10,
18+
prsReviewed: 0,
19+
gradedPrs: [],
20+
}));
1221

22+
const teamData = {
23+
teamName: config.teamName,
24+
dateRange: {
25+
start: new Date().toLocaleDateString(),
26+
end: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toLocaleDateString(),
27+
},
28+
};
29+
30+
return <PRGradingScreen teamData={teamData} reviewers={reviewers} />;
31+
}
32+
33+
const data = getDataByTeamId(teamId);
1334
return <PRGradingScreen teamData={data.teamData} reviewers={data.reviewers} />;
1435
};
1536

0 commit comments

Comments
 (0)