-
Notifications
You must be signed in to change notification settings - Fork 1
Select other years in the department preview pages and focus area pages #586
base: master
Are you sure you want to change the base?
Conversation
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.
Only did a review for FilterDropdown
. As requested can you please do the FilterDropdown
as a separate PR into master
? This PR has SectionHeading
files in as well.
@@ -0,0 +1,49 @@ | |||
import React from 'react'; | |||
import { MenuItem, CssBaseline } from '@material-ui/core'; |
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.
Why are you importing CssBaseline
?
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.
I tried something and forgot to remove it at a later stage. Removed.
if (loading) { | ||
return ( | ||
<MenuItem value="boom" displayEmpty name="something"> | ||
{callSpinner()} |
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.
You can just inline the output here since you're only using it once.
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.
Prettier does not allow for it.
} | ||
|
||
return options.map(({ id: idVal, name }) => { | ||
const selectedKey = options.findIndex(({ id }) => id === idVal); |
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.
What does selectedKey do? Why not use the id
as the key?
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.
removed
|
||
const callOptions = (options, selected, eventHandler, greyTheme, disabled, loading) => ( | ||
<SelectPreview | ||
{...{ greyTheme }} |
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.
What does greyTheme
do? Perhaps just add a prop to a component called primary
which is a boolean. If primary
is true then apply the white styling.
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.
Swapped to primary
const callOptions = (options, selected, eventHandler, greyTheme, disabled, loading) => ( | ||
<SelectPreview | ||
{...{ greyTheme }} | ||
disabled={disabled} |
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.
Destructure this.
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.
Done
} | ||
|
||
eventHandler(e) { | ||
const { updateUrl, year } = this.props; |
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.
Why do you have updateUrl
and year
in here? FilterDropdown
should not know anything about the context outside of it.
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.
Removed
|
||
eventHandler(e) { | ||
const { updateUrl, year } = this.props; | ||
const { selected } = this.state; |
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.
Remove all the history state logic below.
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.
removed.
...props, | ||
eventHandler: events.eventHandler, | ||
selected: state.selected, | ||
year: props.year, |
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.
Same issue as above.
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.
Done
|
||
// Type: Tselected | ||
/** | ||
* This is the selected text for the menu item inside of the drop down. Being unique, it |
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.
Nice! 🚀
|
||
import styled from 'styled-components'; | ||
|
||
const FormContainer = styled.div` |
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.
This needs to be removed.
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.
Removed.
…nto filter-dropdown
const Markup = ({ items }) => ( | ||
<BarChartContainer> | ||
{items.map((props, index) => ( | ||
<Bar key={items[index].amount} {...{ index, items, ...props }} /> |
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.
this is scary - we're assuming amounts will be unique? what happens if they're not?
@@ -41,8 +67,14 @@ const callButtonExplore = (url, color, verb, subject) => { | |||
); | |||
}; | |||
|
|||
const callDetails = (selected, verb, subject) => { | |||
const { name, value, url, color } = selected; | |||
const callAmount = (value, loading) => ( |
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.
what do we mean when we call these functions call...
? It doesn't make sense to me as an old fart. You call a function - it's weird to call callFoo
. This function does call something (like most functions) - it calls the constructor of Amount - would it make more sense to call it createAmount
? constructAmount
might sound a bit like it's a factory for Amount
s.
In fact it creates Amount and decides what content should be inside it.
Is calling it call...
a common pattern? I'm not saying it has to be changed, it's just sounds like we're writing a function to call a function and we call it callfunction.
{callText(notices)} | ||
</Wrapper> | ||
); | ||
const Notices = ({ notices }) => <Wrapper>{callText(notices)}</Wrapper>; |
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.
This seems like overzealous one-liners because we can.
Surely it'd be easier to understand what markup we're building here with
const Notices = ({notices}) =>
<Wrapper>
notices.map(notice => <Text key={notice}>{notice}</Text>)
</Wrapper>;
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.
like...the way it's written, if you want to know what Notices does, you're like it's a wrapper, and now I need to go read that function over there
what's Notices actually? It's a list of notices...
const calcPrettyName = government => { | ||
if(government === 'south-africa') { | ||
const calcPrettyName = title => { | ||
if (title === 'south-africa') { |
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.
This doesn't make sense any more and is probably something the view should pass in rather than have such domain-specific knowledge in the component
@@ -0,0 +1,13 @@ | |||
const calcFineprint = year => { | |||
if (year === '2018-19') { |
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.
This needs to be data-driven
})) | ||
: []; | ||
|
||
console.log(departmentArray, '3333333333333333'); |
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.
oi
selectionDropdown, | ||
yearDropdown, | ||
}, | ||
// national, |
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.
what's this for?
import createFetchDataFn from './createFetchDataFn'; | ||
import calcValidYearsRange from './calcValidYearsRange'; | ||
|
||
const createEndpointUrl = year => `/json/${year}/focus.json`; |
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.
focus.json in DepartmentSummary?
@@ -0,0 +1,164 @@ | |||
import faker from 'faker'; |
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.
mock data generation in production namespaces is a very big warning sign
While the schemas are only used in test code, let's move all schemas to the test namespaces.
When we want to use types in production code, we can pull the types out to the prod namespace and import them form the test code
*/ | ||
export type TgetDepartmentsData = (TgetDepartmentsDataProps) => void; | ||
|
||
// Type: TconstructGetFocusAreaDataProps |
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.
Guys, I don't think these types.ts files is the way to go.
There's a reason why we tend to put types by the functions and methods where they're used. Code locality is a Big Thing.
I'm jumping around about 5 files trying to figure out where the missing piece is and the types are in their own file?
Is this the goal, or is this just a stopgap to start adding types but eventually they'll be located adjacent to the relevant function?
Still need to work on: