Skip to content

Commit

Permalink
version 10: css changes and fixed console errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumar authored and Kumar committed Apr 19, 2020
1 parent 6934ec4 commit 7e3017f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 44 deletions.
17 changes: 9 additions & 8 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ class App extends Component {
this.setState({
valuationPeriod: value
},
() => this.fetchServiceData());
() => this.fetchServiceData());

}

fetchServiceData(){
debugger
fetchServiceData() {
fetch('http://192.168.0.112:8080/assets?valuationPeriod=' + this.state.valuationPeriod)
.then(res => res.json())
.then((data) => {
Expand All @@ -51,12 +50,14 @@ class App extends Component {
render() {
const { portfolioName, data } = this.state;
return (
<div className="App">
<MyHeader data={data} />
<div className="container-fluid">
<div className="App container-fluid">
<div>
<div className="row">
<MyHeader data={data} />
</div>
<div className="row">
<MySidebar data={data} handlePortfolioChange={this.portfolioChange.bind(this)} />
<MainContent portfolioName={portfolioName} data={data} handlePeriodChange={this.handlePeriodChange.bind(this)}/>
<MySidebar portfolioName={portfolioName} data={data} handlePortfolioChange={this.portfolioChange.bind(this)} />
<MainContent portfolioName={portfolioName} data={data} handlePeriodChange={this.handlePeriodChange.bind(this)} />
</div>
</div>
<Footer />
Expand Down
10 changes: 0 additions & 10 deletions src/component/AssetsSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,9 @@ class AssetsSummary extends Component {
<div>
<h2 className="text-left">Assets Summary</h2>
<BootstrapTable wrapperClasses="table-responsive" keyField='assetType' data={details} columns={columns} />

</div>
);
}
}

// isGainOrLoss = (amount) => {
// let icon;
// if(changePercentage < 0){
// icon = <FontAwesomeIcon icon="arrow-alt-circle-down" color="red"/>
// }else if(this.props.changePercentage > 0){
// icon = <FontAwesomeIcon icon="arrow-alt-circle-up" color="green"/>
// }
// }

export default AssetsSummary;
11 changes: 3 additions & 8 deletions src/component/MainContent.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import React, { Component } from 'react';
import InfoCard from './InfoCard';
import AssetsSummary from './AssetsSummary';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'

class MainContent extends Component {
constructor(props) {
super(props);
}

handlePeriodChange(valuationPeriod) {
debugger
this.props.handlePeriodChange(valuationPeriod);
Expand All @@ -34,16 +29,16 @@ class MainContent extends Component {
}

return (
<main role="main" className="col-md-9 ml-sm-auto col-lg-10 pt-auto px-auto">
<main role="main" className="col-md-10 ml-sm-auto col-lg-10 pt-auto px-auto">
<div className="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
<h1 className="h2">{this.props.portfolioName}</h1>
<div className="btn-toolbar mb-2 mb-md-0">
<div className="btn-group mr-2">
<button className="btn btn-sm btn-outline-secondary">Share</button>
<button className="btn btn-sm btn-outline-secondary">Export</button>
</div>
<select onChange={(val) => this.handlePeriodChange(val.target.value)} className="btn btn-sm btn-outline-primary dropdown-toggle">
<option selected value="TODAY">Today</option>
<select defaultValue="TODAY" onChange={(val) => this.handlePeriodChange(val.target.value)} className="btn btn-sm btn-outline-primary dropdown-toggle">
<option value="TODAY">Today</option>
<option value="_7Days" >Last 7 Days</option>
<option value="_15Days">Last 15 Days</option>
<option value="_30Days">Last 30 Days</option>
Expand Down
12 changes: 6 additions & 6 deletions src/component/MyHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ class MyHeader extends Component {
const formattedTotalNetworthChange = utils.formatMoney(totalNetworthChange)

return (
<nav className="navbar navbar-dark sticky-top bg-dark">
<nav className="navbar navbar-dark sticky-top bg-dark col-md-12">
<div className="row">
<div className="col">
<FontAwesomeIcon icon="hand-holding-usd" color="yellow" size="3x" />
<a className="navbar-brand " href="#">My Assetz</a>
<span className="navbar-brand ">My Assetz</span >
</div>
<div className="col">
<a className="navbar-brand text-white" href="#">
<span className="navbar-brand text-white">
My Networth: <FontAwesomeIcon icon="rupee-sign" color="white" size="1x" />
<span className="label label-default ml-1">{formattedTotalNetworth}</span>
</a>
</span>
</div>
<div className="col">
<a className="navbar-brand text-white" href="#">
<span className="navbar-brand text-white">
Today's Change: <FontAwesomeIcon icon="rupee-sign" color="white" size="1x" />
<span className="label label-default ml-1">{formattedTotalNetworthChange}</span>
{icon}
</a>
</span>
</div>
</div>

Expand Down
23 changes: 15 additions & 8 deletions src/component/MySidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@ class MySidebar extends Component {
constructor(props) {
super(props);
this.state = {
links : []
links: []
}
}

static getDerivedStateFromProps(props, state) {
debugger
const links = [];
if (props && props.data && props.data.data && props.data.data.length > 0) {
for (let i = 0; i < props.data.data.length; i++) {
links.push({ key: i, text: props.data.data[i].portfolioName, isActive: false });
var active = false;
if (props.portfolioName && props.portfolioName === props.data.data[i].portfolioName) {
active = true;
}
links.push({ index: i, text: props.data.data[i].portfolioName, isActive: active });
}
}
return { links: links };
}

handleClick(i) {
debugger
const links = this.state.links.slice();
let portfolioName = "";
for (const j in links) {
if (i == j) {
for (var j = 0; j < links.length; j++) {
if (i === j) {
links[j].isActive = true;
portfolioName = links[j].text;
} else {
Expand All @@ -38,16 +44,17 @@ class MySidebar extends Component {
}

render() {

const { links } = this.state;
debugger
return (
<nav className="col-md-2 d-none d-md-block bg-light sidebar">
<nav className="col-md-2 bg-light sidebar">
<div className="sidebar-sticky">
<ul className="nav flex-column">
{this.state.links.map((link, i) =>
{links.map((link, i) =>
<NavLink
text={link.text}
isActive={link.isActive}
key={link.key}
key={link.index}
onClick={() => this.handleClick(i)}
/>
)}
Expand Down
10 changes: 7 additions & 3 deletions src/component/NavLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ class NavLink extends Component {
render() {
let { onClick } = this.props;
return (
<li key={this.props.key} onClick={onClick} className={"nav-item " + (this.props.isActive ? "active" : "")}>
<a className="nav-link text-left" href={this.props.key}>{this.props.text}</a>
<li key={this.props.index} onClick={onClick}>
<span className={"nav-link text-left cursor-pointer " + (this.props.isActive ? "active" : "")}>
{this.props.text}
</span>
</li>
);
}
}
export default NavLink;
export default NavLink;


2 changes: 1 addition & 1 deletion src/component/Utils.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
//add imports here if needed

export function formatMoney(money) {
return new Intl.NumberFormat('en-IN').format(money);
Expand Down
4 changes: 4 additions & 0 deletions src/css/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@
text-transform: uppercase;
}

.cursor-pointer{
cursor: pointer;
}

0 comments on commit 7e3017f

Please sign in to comment.