Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(containers): add Links container
Browse files Browse the repository at this point in the history
feat(containers): add Links container
  • Loading branch information
Metnew committed Sep 30, 2017
1 parent d9867bd commit e813450
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 63 deletions.
60 changes: 60 additions & 0 deletions src/common/containers/Links/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @flow
*/
import React, {Component} from 'react'
import {connect} from 'react-redux'
import Helmet from 'react-helmet'
import {Loader} from 'semantic-ui-react'
import {GET_LINKS} from 'actions/links'
import LinksComponent from './components'
import {getEntitiesLinksState} from 'selectors'
import type {GlobalState} from 'reducers'

type Props = {
links: Object,
getLinks: () => void,
isLinksLoaded: boolean,
isLinksLoading: boolean,
}

class Links extends Component {
props: Props
componentDidMount () {
this.getLinks()
}

getLinks () {
this.props.getLinks()
}

render () {
const {links, isLinksLoaded} = this.props
return (
<div>
<Helmet>
<title>Noir:Links</title>
</Helmet>
{isLinksLoaded
? <LinksComponent links={links} />
: <Loader active>Loading...</Loader>}
</div>
)
}
}

function mapStateToProps (state: GlobalState) {
const linksState = getEntitiesLinksState(state)
const links = linksState.entities
const isLinksLoaded = linksState.isLoaded
const isLinksLoading = linksState.isLoading

return {links, isLinksLoaded, isLinksLoading}
}

const mapDispatchToProps = dispatch => ({
getLinks () {
dispatch(GET_LINKS())
}
})

export default connect(mapStateToProps, mapDispatchToProps)(Links)
63 changes: 0 additions & 63 deletions src/common/containers/Users/index.jsx

This file was deleted.

0 comments on commit e813450

Please sign in to comment.