Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyt committed Nov 28, 2016
1 parent 6acc0d2 commit 8b9bcb2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 49 deletions.
28 changes: 9 additions & 19 deletions src/client/components/Profile/Activity.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import * as _ from 'lodash';
import * as React from "react";
import * as ReactDOM from "react-dom";

interface IActivityItemProps {
messageId: number;
date: string;
description: string;
};
}

class ActivityItem extends React.Component<IActivityItemProps, {}> {
constructor(props: IActivityItemProps) {
super(props);
}

render() {
return(
<li key={"active" + this.props.messageId.toString()} className="ui segment" style={{margin:"10px"}}>
<li className="ui segment" style={{margin:"10px"}}>
<div className="contetnt">
<div className="header">
<h5>{"Date: " + this.props.date}</h5>
Expand All @@ -30,30 +26,24 @@ class ActivityItem extends React.Component<IActivityItemProps, {}> {

export interface IActivity {
data: IActivityItemProps[];
};
}

export class Activity extends React.Component<IActivity, {}> {
constructor(props: IActivity) {
super(props);
}

getListItem() {
const items = this.props.data;
const listItem = items.map((item) =>
<ActivityItem
renderItems() {
return _.map(this.props.data, (item, i) => (
<ActivityItem key={i}
messageId={item.messageId}
date={item.date}
description={item.description}/>
);
return listItem;
));
}

render() {
return(
<div id="Activity" className="ui vertical stripe quote segment">
<h3>Activity</h3>
<ul type = "none" className="ui container">
{this.getListItem()}
{this.renderItems()}
</ul>
</div>
);
Expand Down
15 changes: 7 additions & 8 deletions src/client/components/Profile/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as React from "react";
import * as ReactDOM from "react-dom";
import API from '../../api';
import {User} from '../../../lib/model';

interface FrontCardProps {
username: string;
role: string;
imageSrc: string;
};
}

class FrontCard extends React.Component<FrontCardProps, {}> {
render() {
Expand Down Expand Up @@ -46,7 +45,7 @@ interface BackCardProps {
position: string;
place: string;
description: string;
};
}

class BackCard extends React.Component<BackCardProps, {}> {
render() {
Expand Down Expand Up @@ -81,25 +80,25 @@ interface CardProps {
position: string;
place: string;
description: string;
};
}

///////////////////////////////////////////////////////////////////////////////////////
interface ICardState {
user?: User;
};
}

const otherImg = "http://i1.kym-cdn.com/entries/icons/original/000/004/349/Minecraft_Creeper_Wallpaper_by_LynchMob10_09_1_.jpg";

export class Card extends React.Component<{}, ICardState> {
constructor() {
super();
constructor(props: {}) {
super(props);
this.state = {user: null};
}

componentDidMount() {
API.me().then(user => {
this.setState({user: user });
});
});
}

render() {
Expand Down
31 changes: 9 additions & 22 deletions src/client/components/Profile/TeamList.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import * as _ from 'lodash';
import * as React from "react";
import * as ReactDOM from "react-dom";


interface ListItemProps {
teamId: string;
teamName: string;
imageSrc: string;
};

}

class TeamItem extends React.Component<ListItemProps, {}> {
constructor(props: any) {
super(props);
}
render() {
const teamId = this.props.teamId;
// console.log(teamId);
// console.log(this.props);
return (
<li id={teamId.toString()} className="content">
<li className="content">
<div >
<span>
<img className="ui avatar image" src={this.props.imageSrc} alt="Avatar"/>
Expand All @@ -32,28 +27,20 @@ class TeamItem extends React.Component<ListItemProps, {}> {

export interface TeamListProps {
data: ListItemProps[];
};
}

export class TeamList extends React.Component<TeamListProps, {}> {
constructor(props: TeamListProps) {
super(props);
}

getListItem() {
console.log(this.props);
const items = this.props.data;
const listItem = items.map((item) =>
<TeamItem teamId={item.teamId} teamName={item.teamName} imageSrc={item.imageSrc} />
);
console.log(listItem);
return listItem;
renderItems() {
return _.map(this.props.data, (item, i) => (
<TeamItem key={i} teamId={item.teamId} teamName={item.teamName} imageSrc={item.imageSrc} />
));
}

render() {
return(
<div className="ui card">
<ul type = "none">
{this.getListItem()}
{this.renderItems()}
</ul>
</div>
);
Expand Down

0 comments on commit 8b9bcb2

Please sign in to comment.