2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2021-01-15 20:00:20 +00:00
|
|
|
import { connect } from 'react-redux'
|
2020-04-29 23:32:49 +01:00
|
|
|
import { injectIntl, defineMessages } from 'react-intl'
|
2020-07-02 02:38:10 +01:00
|
|
|
import {
|
|
|
|
URL_DISSENTER_SHOP,
|
|
|
|
URL_DISSENTER_SHOP_DONATIONS,
|
|
|
|
} from '../../constants'
|
2021-01-15 20:00:20 +00:00
|
|
|
import { fetchExpenses } from '../../actions/expenses'
|
2020-02-05 22:45:48 +00:00
|
|
|
import PanelLayout from './panel_layout';
|
|
|
|
import ProgressBar from '../progress_bar'
|
2020-07-02 02:38:10 +01:00
|
|
|
import Button from '../button'
|
|
|
|
import Text from '../text'
|
2020-12-30 17:21:43 +00:00
|
|
|
import Icon from '../icon'
|
2020-02-05 22:45:48 +00:00
|
|
|
|
2020-08-17 21:07:16 +01:00
|
|
|
class ProgressPanel extends React.PureComponent {
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2021-01-15 20:00:20 +00:00
|
|
|
componentDidMount() {
|
|
|
|
if (!this.props.isFetched) {
|
|
|
|
this.props.onFetchExpenses()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-05 22:45:48 +00:00
|
|
|
render() {
|
2021-01-15 20:00:20 +00:00
|
|
|
const { intl, value, isFetched } = this.props
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2021-01-15 20:00:20 +00:00
|
|
|
if (value === 0 && !isFetched) return null
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2020-12-30 17:21:43 +00:00
|
|
|
const subtitle = (
|
|
|
|
<div className={[_s.d, _s.flexRow, _s.aiCenter, _s.jcCenter].join(' ')}>
|
|
|
|
<Text color='secondary' size='small' weight='bold' className={_s.mrAuto}>
|
|
|
|
{intl.formatMessage(messages.operationsSubtitle)}
|
|
|
|
</Text>
|
2020-07-02 02:38:10 +01:00
|
|
|
<Button
|
2020-12-30 17:21:43 +00:00
|
|
|
noClasses
|
2020-07-02 02:38:10 +01:00
|
|
|
href={URL_DISSENTER_SHOP_DONATIONS}
|
2020-12-30 17:21:43 +00:00
|
|
|
className={[_s.d, _s.flexRow, _s.aiCenter, _s.jcCenter, _s.outlineNone, _s.bgTransparent, _s.noUnderline].join(' ')}
|
2020-07-02 02:38:10 +01:00
|
|
|
>
|
2020-12-30 17:21:43 +00:00
|
|
|
<Text align='center' color='brand' weight='medium' className={_s.mr5}>
|
|
|
|
Donate
|
2020-07-02 02:38:10 +01:00
|
|
|
</Text>
|
2020-12-30 17:21:43 +00:00
|
|
|
<Icon id='arrow-right' className={_s.cBrand} size='14px' />
|
2020-07-02 02:38:10 +01:00
|
|
|
</Button>
|
2020-12-30 17:21:43 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PanelLayout
|
|
|
|
noPadding
|
|
|
|
title={intl.formatMessage(messages.operationsTitle)}
|
|
|
|
subtitle={subtitle}
|
|
|
|
>
|
|
|
|
<div className={[_s.d, _s.px15, _s.pb15, _s.pt5].join(' ')}>
|
|
|
|
<ProgressBar
|
2021-01-15 20:00:20 +00:00
|
|
|
progress={value}
|
2020-12-30 17:21:43 +00:00
|
|
|
title={intl.formatMessage(messages.progressTitle, { value })}
|
|
|
|
href={URL_DISSENTER_SHOP}
|
|
|
|
/>
|
|
|
|
</div>
|
2020-02-05 22:45:48 +00:00
|
|
|
</PanelLayout>
|
|
|
|
)
|
|
|
|
}
|
2020-04-29 23:32:49 +01:00
|
|
|
|
2020-08-19 01:22:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
progressTitle: { id: 'progress_title', defaultMessage: '{value}% covered this month' },
|
2021-01-16 20:23:33 +00:00
|
|
|
operationsTitle: { id: 'operations_title', defaultMessage: "Help keep Gab online" },
|
2020-12-30 17:21:43 +00:00
|
|
|
operationsSubtitle: { id: 'operations_subtitle', defaultMessage: "We're 100% funded by you." },
|
2020-08-19 01:22:15 +01:00
|
|
|
donationTitle: { id: 'make_donation', defaultMessage: 'Make a Donation' },
|
|
|
|
})
|
|
|
|
|
2021-01-15 20:00:20 +00:00
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
isFetched: state.getIn(['expenses', 'fetched'], false),
|
|
|
|
value: state.getIn(['expenses', 'value'], 0),
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
onFetchExpenses() {
|
|
|
|
dispatch(fetchExpenses())
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2020-08-19 01:22:15 +01:00
|
|
|
ProgressPanel.propTypes = {
|
|
|
|
intl: PropTypes.object.isRequired,
|
2021-01-15 20:00:20 +00:00
|
|
|
isFetched: PropTypes.bool.isRequired,
|
|
|
|
value: PropTypes.number.isRequired,
|
|
|
|
onFetchExpenses: PropTypes.func.isRequired,
|
2020-08-19 01:22:15 +01:00
|
|
|
}
|
|
|
|
|
2021-01-16 20:23:33 +00:00
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ProgressPanel))
|