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';
|
|
|
|
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',
|
|
|
|
}}
|
|
|
|
>
|
2021-05-25 02:20:09 +02:00
|
|
|
<img src="./images/caret-left.svg" alt="" />
|
2020-11-03 00:41:28 +01:00
|
|
|
<span
|
|
|
|
className="confirm-page-container-header__back-button"
|
|
|
|
onClick={() => onEdit()}
|
|
|
|
>
|
|
|
|
{t('edit')}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{!isFullScreen && <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
|
|
|
};
|