From 59af8a28a0f4b808cf44fbb22fd900bd98e23f0e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 27 Aug 2018 14:35:38 +0300 Subject: /settings updates --- vnext/src/api/index.js | 4 ++ vnext/src/components/Settings.js | 128 ++++++++++++++++++++------------------- 2 files changed, 69 insertions(+), 63 deletions(-) (limited to 'vnext') diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index efa57cf1..90c8b15e 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -31,6 +31,10 @@ export function me(username = '', password = '') { }); } +export function info(username) { + return client.get(`/info/${username}`); +} + export function getChats() { return client.get('/groups_pms'); } diff --git a/vnext/src/components/Settings.js b/vnext/src/components/Settings.js index d4947e5a..d3eced63 100644 --- a/vnext/src/components/Settings.js +++ b/vnext/src/components/Settings.js @@ -1,66 +1,71 @@ import React from 'react'; +import { me } from '../api'; + +import { UserType } from './Types'; + +import Button from './Button'; + export default class Settings extends React.Component { constructor(props) { super(props); this.state = { settings: {}, - userinfo: {}, - facebook: {} + 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'); + } render() { - const { settings, userinfo, facebook } = this.state; + const { me } = this.state; return (

Settings

+
+ Changing your avatar

Avatar:
Recommendations: PNG, 96x96, <50Kb. Also, JPG and GIF supported.

-

-

Full name:

-

Country:

-

URL:
- Please, start with "http://"

-

About:
-
- Max. 255 symbols

+

+ +

+
Changing your password -
- -

Change password: -
+ +

Change password: +
(max. length - 16 symbols)

- - -
-
- Notification options -

- -  Reply notifications ("Message posted") -

-

-  Subscriptions notifications ("@user subscribed...") -

-

-  Posts recommendations ("Recommended by @user") -

-

-
-
- Telegram - {settings.telegramName ? ( + Telegram + {me.telegramName ? (
-
Telegram: telegram_name — +
Telegram: {me.telegramName}
@@ -70,7 +75,7 @@ export default class Settings extends React.Component {

)}
- {settings.jids && ( + {me.jids && (
Your accounts:

{ - settings.jids.map(jid => + me.jids.map(jid => -
+
) } - {settings.auths.map(auth => - - - — Confirm
-
- )}

- {settings.jids && settings.jids.length > 1( + { + me.jids && me.jids.length > 1 &&

- )} + }

To add new jabber account: send any text message to juick@juick.com

@@ -121,13 +119,13 @@ export default class Settings extends React.Component {

Your accounts:

{ - settings.emails ? settings.emails.map(email => + me.emails ? me.emails.map(email =>
- {settings.emails.length > 1 && + {me.emails.length > 1 &&

} @@ -135,15 +133,15 @@ export default class Settings extends React.Component { }

- {settings.emails && + {me.emails && {/** email_off **/}
You can receive notifications to email:
Sent to @@ -213,3 +210,8 @@ export default class Settings extends React.Component { ); } } + +Settings.propTypes = { + visitor: UserType.isRequired +}; + -- cgit v1.2.3