aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/PasswordModal.js
blob: 4b37dfe3e5e0c2a2bd9521ddd1082f47c195aea0 (plain) (blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import React from 'react';
import Modal from 'react-modal';
import styled from 'styled-components'
import { PassInput } from './Inputs'
import Error from './Err';

const modalStyles = {
    content: {
        top: '50%',
        left: '50%',
        transform: 'translate(-50%, -50%)',
        width: '400px',
        height: '250px',
        border: '1px solid #11111188'
    }
};

const PassProtected = styled.h3`
    font-weight: 700
`

const RightPad = styled.div`
    margin-right: 3em;
`

const LeftPad = styled.div`
    margin-left: 2em;
`

class PasswordModal extends React.Component {

    componentWillMount() {
        Modal.setAppElement('body');
    }

    constructor(props) {
        super(props);

        this.submitPassword = this.submitPassword.bind(this);
    }

    submitPassword(event) {
        const password = this.props.value
        this.props.validateCallback(password)
        event.preventDefault();
    }

    render() {
        return(
            <Modal
                isOpen={this.props.hasPass && !this.props.validPass}
                style={modalStyles}
                contentLabel="enter paste password"
                classNames
            >
                <form onSubmit={this.submitPassword}>
                    <LeftPad>
                        <PassProtected><span role="img" aria-label="warning">🚧&nbsp;</span>err: password protected</PassProtected>
                    </LeftPad>
                    <RightPad>
                        <PassInput
                            value={this.props.value}
                            onChange={this.props.onChange} />
                    </RightPad>
                    <LeftPad>
                        <input className="lt-button lt-shadow lt-hover" type="submit" value="continue" />
                        <Error msg={this.props.error} />
                    </LeftPad>
                </form>
            </Modal>
        );
    }
}

export default PasswordModal