Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Select other years in the department preview pages and focus area pages #586

Open
wants to merge 116 commits into
base: master
Choose a base branch
from

Conversation

ZeeshaanMaudar
Copy link
Contributor

Still need to work on:

  • Styling of dropdown
  • Disabled state
  • Loading State

Copy link
Contributor

@schalkventer schalkventer left a 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';
Copy link
Contributor

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?

Copy link
Contributor Author

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()}
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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 }}
Copy link
Contributor

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.

Copy link
Contributor Author

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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure this.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above.

Copy link
Contributor Author

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
Copy link
Contributor

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`
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

const Markup = ({ items }) => (
<BarChartContainer>
{items.map((props, index) => (
<Bar key={items[index].amount} {...{ index, items, ...props }} />
Copy link
Contributor

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) => (
Copy link
Contributor

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 Amounts.

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>;
Copy link
Contributor

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>;

Copy link
Contributor

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') {
Copy link
Contributor

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') {
Copy link
Contributor

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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oi

selectionDropdown,
yearDropdown,
},
// national,
Copy link
Contributor

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`;
Copy link
Contributor

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';
Copy link
Contributor

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

@jbothma jbothma changed the title Filter dropdown Select previous years' data in the department preview pages and focus are pages Jun 14, 2019
@jbothma jbothma changed the title Select previous years' data in the department preview pages and focus are pages Select previous years in the department preview pages and focus are pages Jun 14, 2019
@jbothma jbothma changed the title Select previous years in the department preview pages and focus are pages Select other years in the department preview pages and focus area pages Jun 14, 2019
*/
export type TgetDepartmentsData = (TgetDepartmentsDataProps) => void;

// Type: TconstructGetFocusAreaDataProps
Copy link
Contributor

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants