Skip to content

Commit

Permalink
Merge pull request #1909 from MetaPhase-Consulting/update/available-b…
Browse files Browse the repository at this point in the history
…idders-chart-stats

updating ab chart stats TM-2409
  • Loading branch information
SidelineCory24 committed Jan 21, 2022
2 parents e337b27 + ec797ea commit c46e4e8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import FA from 'react-fontawesome';
import { Cell, Pie, PieChart, Tooltip } from 'recharts';
import InteractiveElement from 'Components/InteractiveElement';
import LoadingText from 'Components/LoadingText';
import { getAvatarColor } from 'utilities';
import { getAvatarColor, sortGrades } from 'utilities';
import Picky from 'react-picky';
import { Row } from '../../Layout';

Expand All @@ -15,19 +15,26 @@ const AvailableBidderStats = () => {

const statOptions = [
'Bureau',
'CDO',
'Grade',
'OC Bureau',
'Post',
'Skill',
'Status',
'TED',
];

// App state
const biddersData = useSelector(state => state.availableBiddersFetchDataSuccess);
const availableBiddersIsLoading = useSelector(state => state.availableBiddersFetchDataLoading);

const stats = get(biddersData.stats, selectedStat) || [];
const statsSum = get(biddersData.stats, 'Sum', {})[selectedStat];
let stats = get(biddersData, 'stats', {})[selectedStat] || [];
const statsSum = get(biddersData, 'stats.Sum', {})[selectedStat] || 0;

// sorting grades to maintain consistency across the site
if (selectedStat === 'Grade') {
stats = stats.map(grade => ({ ...grade, code: grade.name }));
stats.sort(sortGrades);
}

// adding colors
const stats$ = stats.map(m => {
Expand Down Expand Up @@ -92,7 +99,12 @@ const AvailableBidderStats = () => {
className="legend-square"
style={{ backgroundColor: m.color }}
/>
<div className="legend-text">{`(${m.value}) ${m.name} ${m.percent}`}</div>
<div className="legend-text">
{`(${m.value}) ${m.name}`}
<span className="percent-text">
{`${m.percent}`}
</span>
</div>
</div>
))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import TestUtils from 'react-dom/test-utils';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import AvailableBidderStats from './AvailableBidderStats';

const middlewares = [thunk];
const mockStore = configureStore(middlewares);

describe('AvailableBidderStats', () => {
it('is defined', () => {
const wrapper = TestUtils.renderIntoDocument(<Provider store={mockStore({})}><MemoryRouter>
<AvailableBidderStats isCDO />
</MemoryRouter></Provider>);
expect(wrapper).toBeDefined();
});
});
5 changes: 5 additions & 0 deletions src/sass/_availableBidders.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
margin: auto .8em;
}

.percent-text {
font-weight: bold;
margin-left: .4em;
}

.chart-container {
margin-right: auto;

Expand Down

0 comments on commit c46e4e8

Please sign in to comment.