ens-usernames/app/components/ens/DisplayBox.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-10-01 21:10:58 +00:00
import React from 'react';
import Typography from '@material-ui/core/Typography';
import { connect } from 'react-redux';
import { YOUR_CONTACT_CODE } from './constants';
import { checkAndDispatchStatusContactCode } from '../../actions/accounts';
2018-10-09 15:03:20 +00:00
import styled from "styled-components";
2018-10-01 21:10:58 +00:00
2018-10-09 15:03:20 +00:00
const DisplayLabel = styled.div`
font-size: 14px;
color: #939BA1;
margin: 0 1em;
`;
const DisplayBox = styled.div`
border: 1px solid #EEF2F5;
border-radius: 8px;
margin: 7px 12px 14px 12px;
display: flex;
flex-direction: column;
justifyContent: space-around;
min-height: 4em;
word-wrap: break-word;
`;
const WrappedDisplayBox = ({displayType, pubKey, getStatusContactCode}) => (
2018-10-09 16:39:37 +00:00
<div>
2018-10-09 15:03:20 +00:00
<DisplayLabel>
{displayType}
</DisplayLabel>
2018-10-09 16:39:37 +00:00
<DisplayBox onClick={() => getStatusContactCode(displayType, pubKey)}>
2018-10-09 15:03:20 +00:00
<div style={{margin: '16px'}}>
2018-10-04 20:46:05 +00:00
<Typography type='body1'>{pubKey}</Typography>
2018-10-01 21:10:58 +00:00
</div>
2018-10-09 15:03:20 +00:00
</DisplayBox>
2018-10-01 21:10:58 +00:00
</div>
);
const mapDispatchToDisplayBoxProps = dispatch => ({
getStatusContactCode(displayType, pubKey) {
if (displayType === YOUR_CONTACT_CODE && !pubKey) checkAndDispatchStatusContactCode(dispatch);
},
});
export default connect(null, mapDispatchToDisplayBoxProps)(WrappedDisplayBox);