Skip to content
Snippets Groups Projects
Commit ef28ab26 authored by Martin Wighus Holtmon's avatar Martin Wighus Holtmon
Browse files

projectSecondPart/Problem1 - Added link from userDetail to the users photos (userPhotos)

parent a420cd81
No related branches found
No related tags found
No related merge requests found
import React from 'react'; import React from 'react';
import './userDetail.css'; import './userDetail.css';
import {Link} from "react-router-dom";
import {Typography} from "@material-ui/core";
/** /**
...@@ -14,14 +16,15 @@ class UserDetail extends React.Component { ...@@ -14,14 +16,15 @@ class UserDetail extends React.Component {
generateUserPreview() { generateUserPreview() {
let user = window.cs142models.userListModel().find(e => e._id === this.props.match.params.userId) let user = window.cs142models.userListModel().find(e => e._id === this.props.match.params.userId)
console.log(user) console.log(user)
return (<div id="DivUserPreview"> return (
<Typography variant="body1">
<h2>{user.first_name} {user.last_name}</h2> <h2>{user.first_name} {user.last_name}</h2>
<p> <p>
Occupation: {user.occupation} <br /> Occupation: {user.occupation} <br />
From: {user.location} <br /> From: {user.location} <br />
Description: {user.description} Description: {user.description}
</p> </p>
</div> </Typography>
) )
} }
...@@ -30,6 +33,7 @@ class UserDetail extends React.Component { ...@@ -30,6 +33,7 @@ class UserDetail extends React.Component {
return ( return (
<div id="divUserDetail"> <div id="divUserDetail">
{this.generateUserPreview()} {this.generateUserPreview()}
<Link to={"/photos/" + this.props.match.params.userId}>See photos!</Link>
</div> </div>
); );
} }
......
...@@ -11,7 +11,7 @@ import './userPhotos.css'; ...@@ -11,7 +11,7 @@ import './userPhotos.css';
class UserPhotos extends React.Component { class UserPhotos extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
console.log(window.cs142models.photoOfUserModel(this.props.match.params.userId))
} }
render() { render() {
......
...@@ -4,7 +4,7 @@ import { ...@@ -4,7 +4,7 @@ import {
HashRouter, Route, Switch HashRouter, Route, Switch
} from 'react-router-dom'; } from 'react-router-dom';
import { import {
Grid, Typography, Paper Grid, Paper
} from '@material-ui/core'; } from '@material-ui/core';
import './styles/main.css'; import './styles/main.css';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment