-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from City-of-Helsinki/develop
Develop
- Loading branch information
Showing
49 changed files
with
2,973 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// @flow | ||
import React, {PureComponent} from 'react'; | ||
import {connect} from 'react-redux'; | ||
import flowRight from 'lodash/flowRight'; | ||
|
||
import {fetchAttributes as fetchPlotApplicationsAttributes} from '$src/plotApplications/actions'; | ||
import { | ||
getAttributes as getPlotApplicationsAttributes, | ||
getIsFetchingAttributes as getIsFetchingPlotApplicationsAttributes, | ||
getPlotApplicationsMethods, | ||
} from '$src/plotApplications/selectors'; | ||
|
||
import type {Attributes, Methods} from '$src/types'; | ||
|
||
function PlotApplicationsAttributes(WrappedComponent: any) { | ||
type Props = { | ||
fetchPlotApplicationsAttributes: Function, | ||
isFetchingPlotApplicationsAttributes: boolean, | ||
plotApplicationsAttributes: Attributes, | ||
plotApplicationsMethods: Methods, | ||
} | ||
|
||
return class PlotApplicationsAttributes extends PureComponent<Props> { | ||
componentDidMount() { | ||
const { | ||
fetchPlotApplicationsAttributes, | ||
isFetchingPlotApplicationsAttributes, | ||
plotApplicationsAttributes, | ||
} = this.props; | ||
|
||
if(!isFetchingPlotApplicationsAttributes && !plotApplicationsAttributes) { | ||
fetchPlotApplicationsAttributes(); | ||
} | ||
} | ||
|
||
render() { | ||
return <WrappedComponent {...this.props} />; | ||
} | ||
}; | ||
} | ||
|
||
const withPlotApplicationsAttributes = flowRight( | ||
connect( | ||
(state) => { | ||
return{ | ||
plotApplicationsAttributes: getPlotApplicationsAttributes(state), | ||
isFetchingPlotApplicationsAttributes: getIsFetchingPlotApplicationsAttributes(state), | ||
plotApplicationsMethods: getPlotApplicationsMethods(state), | ||
}; | ||
}, | ||
{ | ||
fetchPlotApplicationsAttributes, | ||
}, | ||
), | ||
PlotApplicationsAttributes, | ||
); | ||
|
||
export {withPlotApplicationsAttributes}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.