-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updating ab chart stats TM-2409 #1909
Changes from 30 commits
d924a68
888458a
c86eb13
182e925
8e64990
9774600
61125b1
b2bbded
2e3d065
df7e512
6069fd7
240c0b7
1ada685
19a5b5f
eb21929
9cbae29
4a80705
4ef70af
95af851
21d22b9
40515d4
f7a3988
749471b
bd7a8e9
15f559c
74c413d
a678fe8
4419029
1eb0e2d
0392a93
049385b
5daa884
ba0b9f8
442394d
ec797ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
||
|
@@ -15,22 +15,29 @@ 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]; | ||
const stats = get(biddersData, 'stats', {})[selectedStat] || []; | ||
const statsSum = get(biddersData, 'stats.Sum', {})[selectedStat] || 0; | ||
const grades = get(biddersData, 'stats.Grade', []) || []; | ||
|
||
const grades$ = grades.map(grade => ({ ...grade, code: grade.name })); | ||
grades$.sort(sortGrades); | ||
|
||
const stat = selectedStat === 'Grade' ? grades$ : stats; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be cleaner, and easier to understand that
@mjoyce91 or is modifying stats a big no-no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
// adding colors | ||
const stats$ = stats.map(m => { | ||
const stats$ = stat.map(m => { | ||
const color = getAvatarColor((m.name), 6000).backgroundColor; | ||
return { | ||
...m, | ||
|
@@ -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> | ||
)) | ||
} | ||
|
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(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍