Skip to content

Commit

Permalink
adjust path to user object propreties
Browse files Browse the repository at this point in the history
  • Loading branch information
corscheparrera committed Jun 22, 2018
1 parent f6b22fc commit e1128cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"react": "^16.3.2",
"react-bootstrap": "^0.32.1",
"react-dom": "^16.3.2",
"react-icons": "^2.2.7",
"react-moment": "^0.7.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
Expand Down
12 changes: 4 additions & 8 deletions src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Col, Grid, Row } from "react-bootstrap";
import React, { Component } from "react";

import Chat from "./Chat.js";
import SripeIcon from "react-icons/lib/fa/cc-stripe";
import fire from "./Firebase.js";
import styled from "styled-components";

Expand Down Expand Up @@ -81,13 +82,7 @@ class Main extends Component {
console.log(users);

for (var key in users) {
// skip loop if the property is from prototype
if (!users.hasOwnProperty(key)) continue;

var obj = users[key];
for (var prop in obj) {
arrayOfUsers.push(obj[prop]);
}
arrayOfUsers.push(users[key]);
}
console.log(arrayOfUsers);
this.setState({ users: arrayOfUsers }, () => this.startChat());
Expand All @@ -100,7 +95,7 @@ class Main extends Component {
.ref(`${this.state.chatPath}`)
.on("child_added", x => this.updateState(x.val()));
database.ref(`${this.state.userPath}`).once("value", result => {
let email = result.val()[Object.keys(result.val())[0]].email;
let email = result.val().email;
this.setState({ email });
});
} catch (e) {
Expand Down Expand Up @@ -136,6 +131,7 @@ class Main extends Component {
<UserRow>
<Bold>{"Email: "}</Bold>
<h5>{data.email}</h5>
<SripeIcon size={40} style={{ paddingLeft: 10 }} />
</UserRow>
{/* <UserRow>
<Bold>{"Dernière connexion: "}</Bold>
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5841,6 +5841,16 @@ react-error-overlay@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-4.0.0.tgz#d198408a85b4070937a98667f500c832f86bd5d4"

[email protected]:
version "2.1.0"
resolved "https://registry.yarnpkg.com/react-icon-base/-/react-icon-base-2.1.0.tgz#a196e33fdf1e7aaa1fda3aefbb68bdad9e82a79d"

react-icons@^2.2.7:
version "2.2.7"
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-2.2.7.tgz#d7860826b258557510dac10680abea5ca23cf650"
dependencies:
react-icon-base "2.1.0"

react-is@^16.3.1:
version "16.4.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.4.1.tgz#d624c4650d2c65dbd52c72622bbf389435d9776e"
Expand Down

0 comments on commit e1128cd

Please sign in to comment.