2022-06-24 02:58:32 +02:00
|
|
|
import { connect } from 'react-redux';
|
2022-06-24 15:08:46 +02:00
|
|
|
import { selectClaimForUri, selectPreorderTagForUri } from 'redux/selectors/claims';
|
2022-06-24 02:58:32 +02:00
|
|
|
import { doHideModal } from 'redux/actions/app';
|
|
|
|
import { preOrderPurchase } from 'redux/actions/wallet';
|
|
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
|
|
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
import { getChannelIdFromClaim, getChannelNameFromClaim } from 'util/claim';
|
2022-06-24 15:08:46 +02:00
|
|
|
import PreorderContent from './view';
|
2022-06-24 02:58:32 +02:00
|
|
|
|
|
|
|
const select = (state, props) => {
|
|
|
|
const { uri } = props;
|
|
|
|
|
|
|
|
const claim = selectClaimForUri(state, uri, false);
|
|
|
|
const { claim_id: claimId, value_type: claimType } = claim || {};
|
|
|
|
|
|
|
|
// setup variables for backend tip API
|
|
|
|
const channelClaimId = getChannelIdFromClaim(claim);
|
|
|
|
const tipChannelName = getChannelNameFromClaim(claim);
|
|
|
|
|
|
|
|
const activeChannelClaim = selectActiveChannelClaim(state);
|
|
|
|
const { name: activeChannelName, claim_id: activeChannelId } = activeChannelClaim || {};
|
|
|
|
|
|
|
|
return {
|
|
|
|
activeChannelName,
|
|
|
|
activeChannelId,
|
|
|
|
claimId,
|
|
|
|
claimType,
|
|
|
|
channelClaimId,
|
|
|
|
tipChannelName,
|
|
|
|
preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY),
|
2022-06-24 15:08:46 +02:00
|
|
|
preorderTag: selectPreorderTagForUri(state, props.uri),
|
2022-06-24 02:58:32 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const perform = {
|
|
|
|
doHideModal,
|
|
|
|
preOrderPurchase,
|
|
|
|
};
|
|
|
|
|
2022-06-24 15:08:46 +02:00
|
|
|
export default withRouter(connect(select, perform)(PreorderContent));
|