forked from USStateDept/State-TalentMAP
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #447 from MetaPhase-Consulting/dev
dev -> staging
- Loading branch information
Showing
56 changed files
with
1,685 additions
and
468 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import numeral from 'numeral'; | ||
import ProfileSectionTitle from '../../ProfileSectionTitle'; | ||
import Spinner from '../../Spinner'; | ||
import { EMPTY_FUNCTION } from '../../../Constants/PropTypes'; | ||
import { getLoginStats } from '../../../actions/stats'; | ||
import BidStatCard from '../../BidStatistics/BidStatCard'; | ||
|
||
export const formatNum = n => numeral(n).format('0,0'); | ||
|
||
class Stats extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
selected: '', | ||
}; | ||
} | ||
|
||
componentWillMount() { | ||
const { getStats } = this.props; | ||
getStats(); | ||
} | ||
|
||
render() { | ||
const { | ||
stats, | ||
statsIsLoading, | ||
statsHasErrored, | ||
} = this.props; | ||
|
||
const statsSuccess = !statsIsLoading && !statsHasErrored; | ||
|
||
return ( | ||
<div | ||
className={`usa-grid-full profile-content-inner-container administrator-page | ||
${(statsIsLoading) ? 'results-loading' : ''}`} | ||
> | ||
{ | ||
statsIsLoading && !statsHasErrored && | ||
<Spinner type="homepage-position-results" size="big" /> | ||
} | ||
<div className="usa-grid-full"> | ||
<ProfileSectionTitle title="Login Statistics" icon="sitemap" /> | ||
</div> | ||
{ | ||
statsSuccess && | ||
<div className="usa-grid-full bid-stat-card-list"> | ||
<div className="usa-grid-full"> | ||
<h3>Total Logins</h3> | ||
{stats.filter(f => f.type === 'total').map(m => ( | ||
<BidStatCard title={m.title} number={formatNum(m.count)} /> | ||
))} | ||
</div> | ||
<div className="usa-grid-full"> | ||
<h3>Unique Logins</h3> | ||
{stats.filter(f => f.type === 'unique').map(m => ( | ||
<BidStatCard title={m.title} number={formatNum(m.count)} /> | ||
))} | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Stats.propTypes = { | ||
stats: PropTypes.shape({}), | ||
statsIsLoading: PropTypes.bool, | ||
statsHasErrored: PropTypes.bool, | ||
getStats: PropTypes.func, | ||
}; | ||
|
||
Stats.defaultProps = { | ||
stats: [], | ||
statsIsLoading: false, | ||
statsHasErrored: false, | ||
getStats: EMPTY_FUNCTION, | ||
}; | ||
|
||
const mapStateToProps = state => ({ | ||
stats: state.stats, | ||
statsIsLoading: state.statsIsLoading, | ||
statsHasErrored: state.statsHasErrored, | ||
}); | ||
|
||
export const mapDispatchToProps = dispatch => ({ | ||
getStats: (options = {}) => dispatch(getLoginStats({ options })), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(Stats); |
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 @@ | ||
export { default } from './Stats'; |
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
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.