|
@@ -0,0 +1,99 @@
|
|
|
+import React from 'react';
|
|
|
+import { connect } from 'react-redux';
|
|
|
+import { bindActionCreators } from 'redux'
|
|
|
+ import ChangeLoginForm from './ChangeLoginForm/index';
|
|
|
+
|
|
|
+const user = {
|
|
|
+ "data": {
|
|
|
+ "_id": "5c48461c40ca670017ba5974",
|
|
|
+ "name": "Debil",
|
|
|
+ "email": "superus@lol.com",
|
|
|
+ "password": "$2a$10$qoxrQ2Sp3BDTLa9Xdc0ZPuLVHamipMQRWxeWxw1RwthICnbPoFLvC",
|
|
|
+ "profilePhoto": "",
|
|
|
+ "role": 0
|
|
|
+ },
|
|
|
+ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjNDg0NjFjNDBjYTY3MDAxN2JhNTk3NCIsInJvbGUiOjAsImlhdCI6MTU0ODI1NTczMiwiZXhwIjoxNTQ4MzQyMTMyfQ.RAIiCLjBJ2u1VEQWy1oUgPjHj0dZRG27l0J3c8FDss0"
|
|
|
+}
|
|
|
+
|
|
|
+class ProfilePage extends React.Component {
|
|
|
+ state={
|
|
|
+ clicked:false
|
|
|
+ }
|
|
|
+
|
|
|
+ handleClick = () => {
|
|
|
+ this.setState((prevState) => ({ clicked: !prevState.clicked }));
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ const { users, userChangeRequest, passwordChangeRequest } = this.props;
|
|
|
+ const { data } = user;
|
|
|
+ const {clicked} =this.state;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className="page page--bottom-only profile-page">
|
|
|
+ <section className="border bg-autumn-foliage m-5 rounded d-flex">
|
|
|
+ <div>
|
|
|
+ <img className="m-4 " src=" https://cdn.iconscout.com/icon/free/png-256/avatar-373-456325.png" ></img>
|
|
|
+ </div>
|
|
|
+ <div className="border-left bg-autumn-foliage m-5 rounded w-75 ">
|
|
|
+ {!clicked
|
|
|
+ ?
|
|
|
+ <div className ="d-flex mb-3" >
|
|
|
+ <h3 className = " p-2 flex-fill bd-highlight">Name</h3>
|
|
|
+ <h5 className="p-2 font-po-bold flex-fill bd-highlight align-self-end">{data.name}</h5>
|
|
|
+ <button type="button" onClick ={this.handleClick} className=" flex-fill bg-shadow btn btn-outline-light col-3">Change</button>
|
|
|
+ </div>
|
|
|
+ :
|
|
|
+ <div>
|
|
|
+ <h3 className = " p-2 flex-fill bd-highlight">Name</h3>
|
|
|
+ <h5 className="p-2 font-po-bold flex-fill bd-highlight align-self-end">{data.name}</h5>
|
|
|
+ <ChangeLoginForm> </ChangeLoginForm>
|
|
|
+ </div>
|
|
|
+ }
|
|
|
+ <div className ="d-flex mb-3" >
|
|
|
+ <h3 className = "p-2 flex-fill bd-highlight">Email</h3>
|
|
|
+ <h5 className="p-2 flex-fill font-po-bold bd-highlight align-self-end">{data.email}</h5>
|
|
|
+ <button type="button" className=" flex-fill bg-shadow btn btn-outline-light col-3">Change</button>
|
|
|
+ </div>
|
|
|
+ <div className ="d-flex mb-3" >
|
|
|
+ <h3 className = "p-2 flex-fill bd-highlight">Password</h3>
|
|
|
+ <button type="button" className=" flex-fill bg-shadow btn btn-outline-light col-3">Change</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section className="container section section--stats">
|
|
|
+ <div className="section__element section__element--">
|
|
|
+ <h3>Member Since</h3>
|
|
|
+ <p>{new Date(data.createdAt).toLocaleString()}</p>
|
|
|
+ </div>
|
|
|
+ <div className="section__element section__element--comments border-right-0">
|
|
|
+ <h3>Last comments</h3>
|
|
|
+ <p className="comments-block">
|
|
|
+ {
|
|
|
+ data.comments && data.comments
|
|
|
+ .slice(0, 60)
|
|
|
+ .map(el =>
|
|
|
+ <p>
|
|
|
+ <h4>{new Date(el.createdAt).toLocaleString()}</h4>
|
|
|
+ {el.text}
|
|
|
+ </p>)
|
|
|
+ }
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const
|
|
|
+ mapStateToProps = state => ({
|
|
|
+ user: state.user,
|
|
|
+ users: state.users
|
|
|
+ });
|
|
|
+
|
|
|
+const mapDispatchToProps = dispatch => bindActionCreators({}, dispatch);
|
|
|
+
|
|
|
+export default connect(mapStateToProps, mapDispatchToProps)(ProfilePage);
|