2021-06-23 23:35:25 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { useHistory } from 'react-router-dom';
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2021-02-04 19:15:23 +01:00
|
|
|
import PageContainerHeader from '../../../components/ui/page-container/page-container-header';
|
2021-06-23 23:35:25 +02:00
|
|
|
import { getMostRecentOverviewPage } from '../../../ducks/history/history';
|
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
|
|
import {
|
|
|
|
ASSET_TYPES,
|
|
|
|
getSendAsset,
|
|
|
|
getSendStage,
|
|
|
|
resetSendState,
|
|
|
|
SEND_STAGES,
|
|
|
|
} from '../../../ducks/send';
|
2018-04-07 00:29:51 +02:00
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
export default function SendHeader() {
|
|
|
|
const history = useHistory();
|
|
|
|
const mostRecentOverviewPage = useSelector(getMostRecentOverviewPage);
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const stage = useSelector(getSendStage);
|
|
|
|
const asset = useSelector(getSendAsset);
|
|
|
|
const t = useI18nContext();
|
2018-04-07 00:29:51 +02:00
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
const onClose = () => {
|
|
|
|
dispatch(resetSendState());
|
|
|
|
history.push(mostRecentOverviewPage);
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-07-02 04:09:28 +02:00
|
|
|
|
2021-06-23 23:35:25 +02:00
|
|
|
let title = asset.type === ASSET_TYPES.NATIVE ? t('send') : t('sendTokens');
|
2018-04-07 00:29:51 +02:00
|
|
|
|
2021-07-31 02:45:18 +02:00
|
|
|
if (stage === SEND_STAGES.ADD_RECIPIENT || stage === SEND_STAGES.INACTIVE) {
|
2021-08-20 17:44:41 +02:00
|
|
|
title = t('sendTo');
|
2021-06-23 23:35:25 +02:00
|
|
|
} else if (stage === SEND_STAGES.EDIT) {
|
|
|
|
title = t('edit');
|
2018-04-07 00:29:51 +02:00
|
|
|
}
|
2021-06-23 23:35:25 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PageContainerHeader
|
|
|
|
className="send__header"
|
|
|
|
onClose={onClose}
|
|
|
|
title={title}
|
|
|
|
headerCloseText={t('cancel')}
|
|
|
|
/>
|
|
|
|
);
|
2018-04-07 00:29:51 +02:00
|
|
|
}
|