2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-06-23 08:52:45 +02:00
|
|
|
import {
|
|
|
|
ENVIRONMENT_TYPE_POPUP,
|
|
|
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
2021-04-28 21:53:59 +02:00
|
|
|
} from '../../../../../shared/constants/app';
|
|
|
|
import { getEnvironmentType } from '../../../../../app/scripts/lib/util';
|
2021-02-04 19:15:23 +01:00
|
|
|
import NetworkDisplay from '../../network-display';
|
|
|
|
import Identicon from '../../../ui/identicon';
|
2022-03-08 22:50:35 +01:00
|
|
|
import IconCaretLeft from '../../../ui/icon/icon-caret-left';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { shortenAddress } from '../../../../helpers/utils/util';
|
|
|
|
import AccountMismatchWarning from '../../../ui/account-mismatch-warning/account-mismatch-warning.component';
|
|
|
|
import { useI18nContext } from '../../../../hooks/useI18nContext';
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default function ConfirmPageContainerHeader({
|
2020-05-21 22:21:34 +02:00
|
|
|
onEdit,
|
|
|
|
showEdit,
|
|
|
|
accountAddress,
|
|
|
|
showAccountInHeader,
|
|
|
|
children,
|
|
|
|
}) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const t = useI18nContext();
|
|
|
|
const windowType = getEnvironmentType();
|
2020-11-03 00:41:28 +01:00
|
|
|
const isFullScreen =
|
|
|
|
windowType !== ENVIRONMENT_TYPE_NOTIFICATION &&
|
2021-02-04 19:15:23 +01:00
|
|
|
windowType !== ENVIRONMENT_TYPE_POPUP;
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-05-21 22:21:34 +02:00
|
|
|
if (!showEdit && isFullScreen) {
|
2021-02-17 03:06:54 +01:00
|
|
|
return children;
|
2020-05-21 22:21:34 +02:00
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className="confirm-page-container-header">
|
2018-06-23 08:52:45 +02:00
|
|
|
<div className="confirm-page-container-header__row">
|
2020-11-03 00:41:28 +01:00
|
|
|
{showAccountInHeader ? (
|
|
|
|
<div className="confirm-page-container-header__address-container">
|
|
|
|
<div className="confirm-page-container-header__address-identicon">
|
|
|
|
<Identicon address={accountAddress} diameter={24} />
|
2020-08-14 13:47:43 +02:00
|
|
|
</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="confirm-page-container-header__address">
|
|
|
|
{shortenAddress(accountAddress)}
|
2019-12-03 17:35:44 +01:00
|
|
|
</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<AccountMismatchWarning address={accountAddress} />
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div
|
|
|
|
className="confirm-page-container-header__back-button-container"
|
|
|
|
style={{
|
|
|
|
visibility: showEdit ? 'initial' : 'hidden',
|
|
|
|
}}
|
|
|
|
>
|
2022-03-08 22:50:35 +01:00
|
|
|
<IconCaretLeft />
|
2020-11-03 00:41:28 +01:00
|
|
|
<span
|
|
|
|
className="confirm-page-container-header__back-button"
|
|
|
|
onClick={() => onEdit()}
|
|
|
|
>
|
|
|
|
{t('edit')}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
)}
|
2021-10-21 18:11:31 +02:00
|
|
|
{isFullScreen ? null : <NetworkDisplay />}
|
2018-06-23 08:52:45 +02:00
|
|
|
</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
{children}
|
2020-05-21 22:21:34 +02:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-05-21 22:21:34 +02:00
|
|
|
}
|
2018-06-23 08:52:45 +02:00
|
|
|
|
2020-05-21 22:21:34 +02:00
|
|
|
ConfirmPageContainerHeader.propTypes = {
|
|
|
|
accountAddress: PropTypes.string,
|
|
|
|
showAccountInHeader: PropTypes.bool,
|
|
|
|
showEdit: PropTypes.bool,
|
|
|
|
onEdit: PropTypes.func,
|
|
|
|
children: PropTypes.node,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|