aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/Settings.js
blob: bf42180aaea1a05bf1e00127674bf40ee3aa947d (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import React from 'react';

import update from 'immutability-helper';

import { me } from '../api';

import { UserType } from './Types';

import Button from './Button';
import Icon from './Icon';

export default class Settings extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            settings: {},
            me: {}
        };
    }
    componentDidMount() {
        me().then(visitor => {
            this.setState({
                me: visitor
            });
        });
    }
    onSubmitAvatar = (event) => {
        if (event.preventDefault) {
            event.preventDefault();
        }
        console.log('avatar update');
    }
    passwordChanged = (event) => {
        this.setState({
            settings: { password: event.target.value }
        });
    }
    onSubmitPassword = (event) => {
        if (event.preventDefault) {
            event.preventDefault();
        }
        console.log('password update');
    }
    emailChanged = (event) => {
        let newState = update(this.state, {
            me: { activeEmail: { $set: event.target.value } }
        });
        this.setState(newState);
        console.log('email update');
    }
    disableTelegram = () => {
        console.log('telegram disable');
    }
    disableFacebook = (event) => {
        if (event.preventDefault) {
            event.preventDefault();
        }
        console.log('facebook disable');
    }
    enableFacebook = (event) => {
        if (event.preventDefault) {
            event.preventDefault();
        }
        console.log('facebook enable');
    }
    disableTwitter = () => {
        console.log('twitter disable');
    }
    render() {
        const { me } = this.state;
        return (
            <div className="msg-cont">
                <fieldset>
                    <legend><Icon name="ei-user" size="m" />Changing your avatar</legend>
                    <form>
                        <p>Avatar: <input type="file" name="avatar" /><br />
                            <small>Recommendations: PNG, 96x96, &lt;50Kb. Also, JPG and GIF supported.</small></p>
                        <p><input type="hidden" name="page" value="about" />
                            <Button onClick={this.onSubmitAvatar}>Update</Button>
                        </p>
                    </form>
                </fieldset>
                <fieldset>
                    <legend><Icon name="ei-unlock" size="m" />Changing your password</legend>
                    <form>
                        <p>Change password: <input type="password" name="password" size="8" onChange={this.passwordChanged} />
                            <Button onClick={this.onSubmitPassword}>Update</Button><br />
                            <i>(max. length - 16 symbols)</i></p>
                    </form>
                </fieldset>
                <fieldset>
                    <legend><Icon name="ei-sc-telegram" size="m" />Telegram</legend>
                    {me.telegramName ? (
                        <form>
                            <div>Telegram: <b> {me.telegramName} </b>&mdash;
                                <Button onClick={this.disableTelegram}>Disable</Button>
                            </div>
                        </form>
                    ) : (
                            <p>To connect Telegram account: send any text message to <a href="https://telegram.me/Juick_bot">@Juick_bot</a>
                            </p>
                        )}
                </fieldset>
                {me.jids && (
                    <form>
                        <fieldset>
                            <legend>XMPP accounts
                                </legend>
                            <p>Your accounts:</p>
                            <p>
                                {
                                    me.jids.map(jid =>
                                        <React.Fragment key="jid">
                                            <label><input type="radio" name="delete" value={jid} />{jid}</label><br />
                                        </React.Fragment>
                                    )
                                }
                            </p>
                            {
                                me.jids && me.jids.length > 1 &&
                                <p><input type="hidden" name="page" value="jid-del" /><input type="submit" value="  Delete  " /></p>
                            }
                            <p>To add new jabber account: send any text message to <a href="xmpp:juick@juick.com?message;body=login">juick@juick.com</a>
                            </p>
                        </fieldset>
                    </form>
                )}
                <fieldset>
                    <legend><Icon name="ei-envelope" size="m" />E-mail</legend>
                    <form>
                        <p>Add account:<br />
                            <input type="text" name="account" />
                            <input type="hidden" name="page" value="email-add" />
                            <input type="submit" value="  Add  " />
                        </p>
                    </form>
                    <form>
                        <p>Your accounts:</p>
                        <p>
                            {
                                me.emails ? me.emails.map(email =>
                                    <React.Fragment key={email}>
                                        <label>
                                            <input type="radio" name="account" value={email} />{email}
                                        </label>
                                        <br />
                                        {me.emails.length > 1 &&
                                            <p><input type="hidden" name="page" value="email-del" /><input type="submit" value="  Delete  " /></p>
                                        }
                                    </React.Fragment>
                                ) : '-'
                            }
                        </p>
                    </form>
                    {
                        me.emails &&
                        <>
                            {/** email_off **/}
                            <form>
                                You can receive notifications to email:<br />
                                Sent to <select name="account" value={me.activeEmail || 'Disabled'} onChange={this.emailChanged}>
                                    <option value="">Disabled</option>
                                    {
                                        me.emails.map(email =>
                                            <option key={email} value={email}>
                                                {email}
                                            </option>
                                        )
                                    }
                                </select>
                            </form>
                            {/** /email_off **/}
                            <p>&nbsp;</p>
                            <p>You can post to Juick via e-mail. Send your <u>plain text</u> messages to <span><a href="mailto:juick@juick.com">juick@juick.com</a></span>. You can attach one photo or video file.</p>
                        </>
                    }
                </fieldset>
                <fieldset>
                    <legend><Icon name="ei-sc-facebook" size="m" />Facebook</legend>
                    {me.facebookStatus && me.facebookStatus.connected ? (
                        me.facebookStatus.crosspostEnabled ?
                            <form>
                                <div>
                                    Facebook: <b>Enabled</b> &mdash;
                                    <Button onClick={this.disableFacebook}>Disable</Button>
                                </div>
                            </form>
                            :
                            <form>
                                <div>
                                    Facebook: <b>Disabled</b> &mdash;
                                    <Button onClick={this.enableFacebook}>Enable</Button>
                                </div>
                            </form>
                    ) : (
                            <p>Cross-posting to Facebook:
                                <a href="/_fblogin">
                                    <img src="//static.juick.com/facebook-connect.png" alt="Connect to Facebook" />
                                </a>
                            </p>
                        )}
                </fieldset>
                <fieldset>
                    <legend><Icon name="ei-sc-twitter" size="m" />Twitter</legend>
                    {me.twitterName ?
                        <form action="/settings" method="post">
                            <div>Twitter: <b>{me.twitterName}</b> &mdash;
            <input type="hidden" name="page" value="twitter-del" />
                                <Button onClick={this.disableTwitter}>Disable</Button>
                            </div>
                        </form>
                        :
                        <p>Cross-posting to Twitter: <a href="/_twitter"><img src="//static.juick.com/twitter-connect.png"
                            alt="Connect to Twitter" /></a></p>
                    }
                </fieldset>

            </div>
        );
    }
}

Settings.propTypes = {
    visitor: UserType.isRequired
};