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
1,092 changes: 189 additions & 903 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^4.8.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-redux-firebase": "^2.0.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.17",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0"
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.17"
},
"scripts": {
"start": "PORT=3006 react-scripts start",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
Expand Down
11 changes: 10 additions & 1 deletion src/ActionsTYPES/TYPES.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
export const RUN_THE_APP = 'RUN_THE_APP';
export const RUN_THE_APP = 'RUN_THE_APP';

export const GET_ALL_GROUPS_PENDING = 'GET_ALL_GROUPS_PENDING';
export const GET_ALL_GROUPS_SUCCESS = 'GET_ALL_GROUPS_SUCCESS';
export const GET_ALL_GROUPS_REJECTED = 'GET_ALL_GROUPS_REJECTED';

export const CREATE_ACCOUNT_PENDING = 'CREATE_ACCOUNT_PENDING';
export const CREATE_ACCOUT_SUCCESS = 'CREATE_ACCOUT_SUCCESS';
export const CREATE_ACCOUNT_REJECTED = 'CREATE_ACCOUNT_REJECTED';
export const CREATE_ACCOUNT_TO_INITIAL = 'CREATE_ACCOUNT_TO_INITIAL';
64 changes: 64 additions & 0 deletions src/actions/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import {
CREATE_ACCOUNT_PENDING,
CREATE_ACCOUT_SUCCESS,
CREATE_ACCOUNT_REJECTED,
CREATE_ACCOUNT_TO_INITIAL
} from '../ActionsTYPES/TYPES';

// https://rnfirebase.io/
export const LoginViaFirebaseCustom = (email, password) =>
(dispatch, getState, getFirebase) => {
const firebase = getFirebase();

dispatch({ type: CREATE_ACCOUNT_PENDING });

firebase.auth().createUserWithEmailAndPassword(email, password)
.then((userData) => {
dispatch({ type: CREATE_ACCOUT_SUCCESS, payload: userData });

})
.catch((error) => {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
dispatch({ type: CREATE_ACCOUNT_REJECTED, payload: errorMessage });
});
}


export const createAccount = (email, password) =>
(dispatch, getState, getFirebase) => {
const firebase = getFirebase();

dispatch({ type: CREATE_ACCOUNT_PENDING });

firebase.auth().createUserWithEmailAndPassword(email, password)
.then((userData) => {
// localStorage.setItem() < KTO
// iS VERIFIED
// FIRST TIME USER?????????

dispatch({ type: CREATE_ACCOUT_SUCCESS, payload: userData });

})
.catch((error) => {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
dispatch({ type: CREATE_ACCOUNT_REJECTED, payload: errorMessage });
});
}


export const createAccountToInitial = () => {
(dispatch) => {
dispatch({ type: CREATE_ACCOUNT_TO_INITIAL });
}
}



export default {
createAccount,
createAccountToInitial
}
Empty file added src/actions/events.js
Empty file.
2 changes: 1 addition & 1 deletion src/actions/globalActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as TYPES from '../ActionsTypes/TYPES';
import * as TYPES from '../ActionsTYPES/TYPES';

export function runTheApp() {
return {
Expand Down
26 changes: 26 additions & 0 deletions src/actions/senders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
GET_ALL_GROUPS_PENDING,
GET_ALL_GROUPS_REJECTED,
GET_ALL_GROUPS_SUCCESS
} from '../ActionsTYPES/TYPES';

export const getAllGroups = () =>
(dispatch, getState, getFirebase) => {
const firebase = getFirebase();

dispatch({ type: GET_ALL_GROUPS_PENDING });

const groups = firebase.database().ref('groups');

groups.once("value")
.then((snapshot) => {
dispatch({ type: GET_ALL_GROUPS_SUCCESS, payload: snapshot.val() });
})
.catch((error) => {
dispatch({ type: GET_ALL_GROUPS_REJECTED, payload: error });
})
}

export default {
getAllGroups
}
4 changes: 1 addition & 3 deletions src/components/Chat/Chat.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { Component } from 'react';

class Chat extends Component {
constructor(){
super();
}

render(){
return(
<div>Someday I will be the chat!</div>
Expand Down
47 changes: 45 additions & 2 deletions src/components/Home/Home.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,57 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { getAllGroups } from '../../actions/senders';
import { createAccount, createAccountToInitial } from '../../actions/auth';
import Group from './components/group';
import group from './components/group';

class Home extends Component {
constructor(){
super();
}

componentWillMount() {
this.props.getAllGroups();
}

createAccount = () => {
this.props.createAccount('asdsadasdasdsa@gmail.com', '123123123');
}

render(){
console.log('[Home Component][render]');
console.log(this.props);
const groups = this.props.groupStatus && this.props.groupStatus.groups ? this.props.groupStatus.groups.map(item => (
<Group
key={item.nameUS}
title={item.nameUS}
/>
)
) : [];
return(
<div>Hello, I am Home!</div>
<div>
<div>
{this.props.groupStatus.pending ? 'Loading' : groups }
<button onClick={this.createAccount}>CREATE ACCOUNT</button>
</div>
</div>
);
}
}

export default Home;
const mapStateToProps = (state) => {
return {
groupStatus: state.groupReducer
}
}

const mapDispatchToProps = (dispatch) => {
return {
getAllGroups: bindActionCreators(getAllGroups, dispatch),
createAccount: bindActionCreators(createAccount, dispatch)
}
}


export default connect(mapStateToProps, mapDispatchToProps)(Home);
Empty file.
18 changes: 18 additions & 0 deletions src/components/Home/components/group.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { Component } from 'react';
import { NavLink } from 'react-router-dom';


class Group extends Component {
constructor(){
super();
}
render(){
return(
<div>
<NavLink to={`/${this.props.title}`}>{this.props.title}</NavLink>
</div>
);
}
}

export default Group;
12 changes: 9 additions & 3 deletions src/components/Programs/Programs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import React, { Component } from 'react';

class Programs extends Component {
constructor(){
super();

componentWillMount() {
// GETALL_POSTS_BY_GROUP_NAME
// this.props.getPostsByGroupName(this.props.ActiveRouteName);
}

// cherry-pick YOYO

render(){
console.log(this.props);
return(
<div>I contain all programs!</div>
<div>{this.props.location.pathname}</div>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
// import registerServiceWorker from './registerServiceWorker';
import { BrowserRouter } from 'react-router-dom';

import { Provider } from 'react-redux'
Expand Down
56 changes: 56 additions & 0 deletions src/reducers/authReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as TYPES from '../ActionsTYPES/TYPES';

const initialState = {
pending: false,
success: false,
rejected: false,
userData: null,
error: null
}

function authReducer(state = initialState, action) {
switch(action.type) {
case TYPES.CREATE_ACCOUNT_PENDING: {
return {
...state,
pending: true
}
}
case TYPES.CREATE_ACCOUT_SUCCESS: {
return {
...state,
pending: false,
success: true,
rejected: false,
userData: action.payload
}
}
case TYPES.CREATE_ACCOUNT_REJECTED: {
return {
...state,
pending: false,
success: false,
rejected: true,
error: action.payload
}
}
case TYPES.CREATE_ACCOUNT_TO_INITIAL: {
return {
...state,
pending: false,
success: false,
rejected: false,
userData: null,
error: null
}
}

default: {
return state;
}

}
}

export default authReducer;

52 changes: 52 additions & 0 deletions src/reducers/groupReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
GET_ALL_GROUPS_PENDING,
GET_ALL_GROUPS_SUCCESS,
GET_ALL_GROUPS_REJECTED
} from '../ActionsTYPES/TYPES';

const initialState = {
pending: false,
success: false,
rejected: false,
groups: [],
error: null
}


function groupReducer(state = initialState, action) {
switch(action.type) {
case GET_ALL_GROUPS_PENDING: {
return {
...state,
pending: true
}
}
case GET_ALL_GROUPS_SUCCESS: {
return {
...state,
success: true,
pending: false,
rejected: false,
groups: action.payload
}
}
case GET_ALL_GROUPS_REJECTED: {
return {
...state,
pending: false,
error: action.payload,
success: false,
rejected: true
}
}

default: {
return state;
}

}


}

export default groupReducer;
8 changes: 7 additions & 1 deletion src/reducers/rootReducer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { combineReducers } from 'redux';
import { firebaseReducer } from 'react-redux-firebase'

// @REDUCERS
import testReducer from './testReducer';
import groupReducer from './groupReducer';
import authReducer from './authReducer';

// @ROOT REDUCER
const rootRecuer = combineReducers({
testReducer
testReducer: testReducer,
groupReducer: groupReducer,
firebase: firebaseReducer,
authReducer: authReducer
});

export default rootRecuer;
Loading