File size: 1,138 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import styled from 'styled-components';
import MemberCardPopupWrapper from './MemberCardPopupWrapper';

const StyledMemberCardPopup = styled.div`
  position: absolute;
  top: 0;
  left: 0;
`;

export default class MemberCardPopup extends React.Component {
  state = { isPopupVisible: false };

  static instance;
  static show(config) {
    this.instance && this.instance.showPopup(config);
  }

  showPopup = ({ direction, position, member }) => {
    this.setState({
      isPopupVisible: true,
      direction,
      position,
      member
    });
  };

  closePopup = () => {
    this.setState({ isPopupVisible: false });
  };

  render() {
    const { isPopupVisible, direction, position, member } = this.state;
    const { guildRolesList } = this.props;

    return (
      <StyledMemberCardPopup>
        {isPopupVisible && (
          <MemberCardPopupWrapper
            direction={direction}
            position={position}
            member={member}
            guildRolesList={guildRolesList}
            onClose={this.closePopup}
          />
        )}
      </StyledMemberCardPopup>
    );
  }
}