Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Mali" rel="stylesheet">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -19,15 +22,16 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<base href="/" />
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
<title>React App</title>
<base href="/" />
</head>

<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

Expand All @@ -37,5 +41,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
5 changes: 4 additions & 1 deletion src/actions/actionTypes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export const LOG_IN_SUCCESS = 'LOG_IN_SUCCESS';
export const LOG_OUT = 'LOG_OUT';
export const REQUEST_AUTHENTICATION = 'REQUEST_AUTHENTICATION';
export const REQUEST_AUTHENTICATION = 'REQUEST_AUTHENTICATION';

export const ADD_NOTES = "ADD_NOTES";
export const REMOVE_NOTES = "REMOVE_NOTES";
11 changes: 11 additions & 0 deletions src/actions/notesAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as types from "./actionTypes";

export const addNotes = data => ({
type: types.ADD_NOTES,
payload: data
});

export const removeNotes = index => ({
type: types.REMOVE_NOTES,
payload: index
});
41 changes: 20 additions & 21 deletions src/containers/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import React, { Component } from 'react';
import {
Switch,
Route
} from 'react-router-dom';
import '../styles/App.css';
import React, { Component } from "react";
import { Switch, Route } from "react-router-dom";
import "../styles/App.css";

import Landing from "./LandingPage";
import Login from "./LoginPage";
Expand All @@ -13,19 +10,21 @@ import Dashboard from "./Dashboard";
import Footer from "../components/Footer";

export default class App extends Component {
render() {
console.log(this.props)
return (
<div className="App">
<Switch>
<Route exact path="/" component={Landing} />
<Route path="/login" component={Login} />
<Route path="/signup" component={Signup} />
<Route path="/reset" component={Reset} />
<Route exact path="/dashboard" component={Dashboard} />
</Switch>
<Footer />
</div>
);
}
render() {
console.log(this.props);
return (
<div className="App">
<div className="content">
<Switch>
<Route exact path="/" component={Landing} />
<Route path="/login" component={Login} />
<Route path="/signup" component={Signup} />
<Route path="/reset" component={Reset} />
<Route exact path="/dashboard" component={Dashboard} />
</Switch>
</div>
<Footer />
</div>
);
}
}
130 changes: 99 additions & 31 deletions src/containers/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,106 @@
import React from "react";
import { connect } from 'react-redux';
import { logOutUser } from '../actions/sessionAction';

import { connect } from "react-redux";
import { logOutUser } from "../actions/sessionAction";
import { addNotes, removeNotes } from "../actions/notesAction";
import { Link } from "react-router-dom";
import "../styles/Dashboard.css";
class Dashboard extends React.Component {
handleLogout() {
const { dispatch } = this.props;
dispatch(logOutUser())
}
componentWillMount() {
const { history, session } = this.props;
if (!session) {
history.push('/');
}
}
componentWillReceiveProps(nextProps) {
if (!nextProps.session) {
const { history } = nextProps;
history.push('/');
}
state = {
note: undefined
};
handleLogout() {
this.props.logOutUser();
}
componentWillMount() {
const { history, session } = this.props;
if (!session) {
history.push("/");
}
render() {
return (
<div>
<button onClick={this.handleLogout.bind(this)}>Logout</button>

</div>
);
}
componentWillReceiveProps(nextProps) {
if (!nextProps.session) {
const { history } = nextProps;
history.push("/");
}
}
onChange = e => {
this.setState({
note: e.target.value
});
};
onAdd = () => {
if (!this.state.note) return;
this.props.addNotes(this.state.note);
this.setState({
note: ""
});
};
onRemove = id => {
this.props.removeNotes(id);
};
render() {
const { notes } = this.props;
return (
<div className="brime-layout">
<div className="header">
<div className="left">
<Link to="/dashboard">
<img
src="https://github.com/BrimeNotes/android/raw/master/Logo-branding/logo_0.5x.png?raw=true"
style={{ height: 50 }}
alt="logo"
/>
</Link>
<h1 style={{ color: "#fb6737" }}>Brime Notes</h1>
</div>
<div className="right">
<button onClick={this.handleLogout.bind(this)}>Logout</button>
</div>
</div>
<div className="content flex flex--center">
<div className="notes-input">
<input
value={this.state.note}
onChange={this.onChange}
placeholder="Add Note"
required={true}
/>
<button onClick={this.onAdd}>+ Add</button>
</div>
<div className="notes-list">
{notes.map((note, index) => (
<div key={index} className="note-card">
<div className="value">{note}</div>
<div className="action">
<i
className="material-icons"
onClick={() => this.onRemove(index)}
>
close
</i>
</div>
</div>
))}
</div>
</div>
</div>
);
}
}

const mapStateToProps = state => {
const { session } = state;
return {
session
}
}
export default connect(mapStateToProps)(Dashboard);
const { session, notes } = state;
return {
session,
notes
};
};
const mapDispatchToProps = dispatch => ({
addNotes: data => dispatch(addNotes(data)),
removeNotes: index => dispatch(removeNotes(index)),
logOutUser: () => dispatch(logOutUser())
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(Dashboard);
28 changes: 17 additions & 11 deletions src/containers/LandingPage.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import React from "react";
import { Link } from 'react-router-dom';
import { Link } from "react-router-dom";

export default class Landing extends React.Component {
render() {
return (
<div style={{ textAllign: "center" , marginTop: "2em"}}>
<Link to="/" ><img src="https://github.com/BrimeNotes/android/raw/master/Logo-branding/logo_0.5x.png?raw=true" style={{maxWidth:"10%"}} alt="logo"/></Link>
<h1 style={{color: "#fb6737"}}>Brime Notes</h1>
<p>Notes Like Never Before</p>
<Link to="/login">Login</Link>
</div>
);
}
render() {
return (
<div style={{ textAllign: "center" }}>
<Link to="/">
<img
src="https://github.com/BrimeNotes/android/raw/master/Logo-branding/logo_0.5x.png?raw=true"
style={{ maxWidth: "10%" }}
alt="logo"
/>
</Link>
<h1 style={{ color: "#fb6737" }}>Brime Notes</h1>
<p>Notes Like Never Before</p>
<Link to="/login">Login</Link>
</div>
);
}
}
Loading