Skip to content

Commit

Permalink
Moved the pulse responses up to the pie chart card, made them pageabl…
Browse files Browse the repository at this point in the history
…e, and removed the distribution bar chart.
  • Loading branch information
ocielliottc committed Jan 6, 2025
1 parent 98b2cb7 commit 302142f
Showing 1 changed file with 33 additions and 61 deletions.
94 changes: 33 additions & 61 deletions web-ui/src/pages/PulseReportPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import {
MenuItem,
Modal,
TextField,
Typography
Typography,
Link,
} from '@mui/material';
import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
Expand Down Expand Up @@ -79,6 +80,8 @@ const ScoreOptionLabel = {
'Combined': 'Both',
};

const pulsesPerPage = 15;

/*
// Returns a random, integer score between 1 and 5.
// We may want to uncomment this later for testing.
Expand Down Expand Up @@ -117,6 +120,7 @@ const PulseReportPage = () => {
const [expanded, setExpanded] = useState(false);
const [scoreChartData, setScoreChartData] = useState([]);
const [pulses, setPulses] = useState([]);
const [pulsesUpperBounds, setPulsesUpperBounds] = useState(pulsesPerPage);
const [scope, setScope] = useState('Individual');
const [scoreType, setScoreType] = useState(ScoreOption.COMBINED);
const [selectedPulse, setSelectedPulse] = useState(null);
Expand Down Expand Up @@ -329,6 +333,7 @@ const PulseReportPage = () => {
return compare;
});
setPulses(pulses);
setPulsesUpperBounds(pulsesPerPage);
};

useEffect(() => {
Expand Down Expand Up @@ -389,63 +394,6 @@ const PulseReportPage = () => {
</Card>
);

const scoreDistributionChart = () => (
<Card>
<CardHeader
title="Distribution of pulse scores for selected team members"
titleTypographyProps={{ variant: 'h5', component: 'h2' }}
/>
<CardContent>
<BarChart
width={500}
height={300}
data={barChartData}
margin={{
top: 5,
right: 30,
left: 20,
bottom: 5
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="score" />
<YAxis />
<Tooltip />
<Legend />
{(scoreType == ScoreOption.COMBINED || scoreType == ScoreOption.INTERNAL) &&
<Bar
dataKey="internal"
fill={ociDarkBlue}
name={ScoreOptionLabel[ScoreOption.INTERNAL]}
/>
}
{(scoreType == ScoreOption.COMBINED || scoreType == ScoreOption.EXTERNAL) &&
<Bar
dataKey="external"
fill={ociOrange}
name={ScoreOptionLabel[ScoreOption.EXTERNAL]}
/>
}
</BarChart>
<ExpandMore
expand={expanded}
onClick={() => setExpanded(!expanded)}
aria-expanded={expanded}
aria-label={expanded ? 'show less' : 'show more'}
size="large"
/>
<Collapse
className="bottom-row"
in={expanded}
timeout="auto"
unmountOnExit
>
{responseSummary()}
</Collapse>
</CardContent>
</Card>
);

const handleCommentClick = pulse => {
setSelectedPulse(pulse);
setShowComments(true);
Expand Down Expand Up @@ -725,16 +673,33 @@ const PulseReportPage = () => {
</div>
}
</div>
<ExpandMore
expand={expanded}
onClick={() => setExpanded(!expanded)}
aria-expanded={expanded}
aria-label={expanded ? 'show less' : 'show more'}
size="large"
/>
<Collapse
className="bottom-row"
in={expanded}
timeout="auto"
unmountOnExit
>
{responseSummary()}
</Collapse>
</CardContent>
</Card>
</>
);

const responseSummary = () => {
let filteredPulses = pulses;
const pulsesSlice = pulses.slice(0, pulsesUpperBounds);

let filteredPulses = pulsesSlice;
const teamMemberIds = teamMembers.map(member => member.id);
if (teamMemberIds.length) {
filteredPulses = pulses.filter(pulse =>
filteredPulses = pulsesSlice.filter(pulse =>
teamMemberIds.includes(pulse.teamMemberId)
);
}
Expand Down Expand Up @@ -773,6 +738,14 @@ const PulseReportPage = () => {
</div>
);
})}
{pulsesUpperBounds < pulses.length &&
<Link to="#" style={{ cursor: 'pointer' }} onClick={(event) => {
event.preventDefault();
setPulsesUpperBounds(pulsesUpperBounds + pulsesPerPage);
}}>
Load more...
</Link>
}
</>
);
};
Expand Down Expand Up @@ -840,7 +813,6 @@ const PulseReportPage = () => {
/>
{pulseScoresChart()}
{averageScores()}
{scoreDistributionChart()}
<Modal open={showComments} onClose={() => setShowComments(false)}>
<Card className="feedback-request-enable-edits-modal">
<CardHeader
Expand Down

0 comments on commit 302142f

Please sign in to comment.