connect Dashboard to store

This commit is contained in:
Ruidy Nemausat 2020-05-14 16:49:57 +02:00
parent 07dd7c5624
commit 04e337bab0
5 changed files with 22 additions and 17 deletions

View file

@ -9,16 +9,16 @@ import {DevSummary} from '../models/Dev';
*/ */
const DevProfile: FC<DevSummary> = ({ const DevProfile: FC<DevSummary> = ({
id, id,
name, displayName,
picture, picture,
description, description,
location, location,
skills, skills,
}) => ( }) => (
<div className="profile bg-light"> <div className="profile bg-light">
<img src={picture} alt={name} className="round-img" /> <img src={picture} alt={displayName} className="round-img" />
<div> <div>
<h2>{name}</h2> <h2>{displayName}</h2>
<p>{description}</p> <p>{description}</p>
<p>{location}</p> <p>{location}</p>
<a href="profile.html" className="btn btn-primary"> <a href="profile.html" className="btn btn-primary">

View file

@ -5,7 +5,7 @@ import Repo from '../types/Repo';
/** Shorter dev interface */ /** Shorter dev interface */
export interface DevSummary { export interface DevSummary {
id: string; id: string;
name: string; displayName: string;
picture: string; picture: string;
description: string; description: string;
location: string; location: string;
@ -28,7 +28,7 @@ interface Dev extends DevSummary {
*/ */
export const dummyDev: Dev = { export const dummyDev: Dev = {
id: '0', id: '0',
name: 'John Doe', displayName: 'John Doe',
picture: picture:
'https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200', 'https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200',
description: 'Developer at Microsoft', description: 'Developer at Microsoft',

View file

@ -1,4 +1,8 @@
import React, {FC} from 'react'; import React, {FC} from 'react';
// Redux
import {connect} from 'react-redux';
import {selectProfile} from '../store/firebase';
// Style
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import { import {
faUserCircle, faUserCircle,
@ -7,7 +11,8 @@ import {
} from '@fortawesome/free-solid-svg-icons'; } from '@fortawesome/free-solid-svg-icons';
import {faBlackTie} from '@fortawesome/free-brands-svg-icons'; import {faBlackTie} from '@fortawesome/free-brands-svg-icons';
import Header from '../components/Header'; import Header from '../components/Header';
import Dev, {dummyDev as dev} from '../models/Dev'; // Types
import Dev from '../models/Dev';
import Experience from '../types/Experience'; import Experience from '../types/Experience';
import {getTimePeriod} from '../types/TimePeriod'; import {getTimePeriod} from '../types/TimePeriod';
import Education from '../types/Education'; import Education from '../types/Education';
@ -15,10 +20,10 @@ import Education from '../types/Education';
/** /**
* Main page from which a Dev can peek and edit its own profile. * Main page from which a Dev can peek and edit its own profile.
*/ */
const Dashboard: FC<Dev> = () => { const Dashboard: FC<Dev> = dev => {
return ( return (
<section className="container"> <section className="container">
<Header title="Dashboard" lead={`Welcome ${dev.name}`} /> <Header title="Dashboard" lead={`Welcome ${dev.displayName}`} />
<div className="dash-buttons"> <div className="dash-buttons">
<a href="create-profile.html" className="btn btn-light"> <a href="create-profile.html" className="btn btn-light">
<FontAwesomeIcon icon={faUserCircle} /> Edit Profile <FontAwesomeIcon icon={faUserCircle} /> Edit Profile
@ -42,7 +47,7 @@ const Dashboard: FC<Dev> = () => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{dev.experiences.map((exp: Experience, i: number) => ( {/* {dev.experiences.map((exp: Experience, i: number) => (
<tr key={i}> <tr key={i}>
<td>{exp.company}</td> <td>{exp.company}</td>
<td className="hide-sm">{exp.position}</td> <td className="hide-sm">{exp.position}</td>
@ -51,7 +56,7 @@ const Dashboard: FC<Dev> = () => {
<button className="btn btn-danger">Delete</button> <button className="btn btn-danger">Delete</button>
</td> </td>
</tr> </tr>
))} ))} */}
</tbody> </tbody>
</table> </table>
@ -66,7 +71,7 @@ const Dashboard: FC<Dev> = () => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{dev.educations.map((edu: Education, i: number) => ( {/* {dev.educations.map((edu: Education, i: number) => (
<tr key={i}> <tr key={i}>
<td>{edu.school}</td> <td>{edu.school}</td>
<td className="hide-sm">{edu.field}</td> <td className="hide-sm">{edu.field}</td>
@ -75,7 +80,7 @@ const Dashboard: FC<Dev> = () => {
<button className="btn btn-danger">Delete</button> <button className="btn btn-danger">Delete</button>
</td> </td>
</tr> </tr>
))} ))} */}
</tbody> </tbody>
</table> </table>
<div className="my-2"> <div className="my-2">
@ -87,4 +92,4 @@ const Dashboard: FC<Dev> = () => {
); );
}; };
export default Dashboard; export default connect(selectProfile)(Dashboard);

View file

@ -11,7 +11,7 @@ const Developers: FC = () => {
const developers: DevSummary[] = [ const developers: DevSummary[] = [
{ {
id: '0', id: '0',
name: 'John Doe', displayName: 'John Doe',
picture: picture:
'https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200', 'https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50?s=200',
description: 'Developer at Microsoft', description: 'Developer at Microsoft',
@ -20,7 +20,7 @@ const Developers: FC = () => {
}, },
{ {
id: '42', id: '42',
name: 'Ruidy Nemausat', displayName: 'Ruidy Nemausat',
picture: picture:
'https://lh3.googleusercontent.com/a-/AOh14GhncH95MWKwPR3TRKy4eVd4n6w0-fobe4dhiam2xA', 'https://lh3.googleusercontent.com/a-/AOh14GhncH95MWKwPR3TRKy4eVd4n6w0-fobe4dhiam2xA',
description: 'Fullstack Engineer at DESY', description: 'Fullstack Engineer at DESY',

View file

@ -56,7 +56,7 @@ const Profile: FC<Dev> = () => {
alt="Some guy" alt="Some guy"
className="round-img my-1" className="round-img my-1"
/> />
<h1 className="large">{dev.name}</h1> <h1 className="large">{dev.displayName}</h1>
<p className="lead">{dev.description}</p> <p className="lead">{dev.description}</p>
<p>{dev.location}</p> <p>{dev.location}</p>
<div className="icons my-1"> <div className="icons my-1">
@ -69,7 +69,7 @@ const Profile: FC<Dev> = () => {
</div> </div>
<div className="profile-about bg-light p-2"> <div className="profile-about bg-light p-2">
<h2 className="text-primary">{`${dev.name}'s Bio`}</h2> <h2 className="text-primary">{`${dev.displayName}'s Bio`}</h2>
<p>{dev.bio}</p> <p>{dev.bio}</p>
<div className="line"></div> <div className="line"></div>
<h2 className="text-primary">Skill Set</h2> <h2 className="text-primary">Skill Set</h2>