mirror of https://gitlab.com/ecentrics/concordia
Ezerous
6 years ago
56 changed files with 12421 additions and 4324 deletions
@ -0,0 +1,15 @@ |
|||
{ |
|||
"rules": { |
|||
"comma-dangle": ["error", "never"], |
|||
"no-console": "off", |
|||
"no-unused-vars": "warn", |
|||
"object-curly-newline": ["error", { |
|||
"ObjectExpression": "always", |
|||
"ObjectPattern": { "multiline": true }, |
|||
"ImportDeclaration": "never", |
|||
"ExportDeclaration": "never" |
|||
}], |
|||
"object-curly-spacing": ["error", "always"] |
|||
}, |
|||
"extends": "airbnb" |
|||
} |
@ -0,0 +1 @@ |
|||
# node_modules in the project root is ignored by default |
@ -0,0 +1,3 @@ |
|||
{ |
|||
"extends": "plugin:react/recommended" |
|||
} |
@ -0,0 +1 @@ |
|||
node_modules/* |
File diff suppressed because one or more lines are too long
@ -1,14 +1,12 @@ |
|||
import React from 'react'; |
|||
import { Button, Icon } from 'semantic-ui-react' |
|||
import { Button, Icon } from 'semantic-ui-react'; |
|||
|
|||
const FloatingButton = (props) => { |
|||
return ( |
|||
const FloatingButton = props => ( |
|||
<div className="action-button" onClick={props.onClick}> |
|||
<Button icon color='teal' size='large'> |
|||
<Icon name='add'/> |
|||
<Button icon color="teal" size="large"> |
|||
<Icon name="add" /> |
|||
</Button> |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
export default FloatingButton; |
@ -1,16 +1,17 @@ |
|||
import React from 'react'; |
|||
|
|||
const LoadingSpinner = (props) => { |
|||
return( |
|||
const LoadingSpinner = props => ( |
|||
<div className="vertical-center-children"> |
|||
<div className={"center-in-parent " + (props.className ? props.className : "")} |
|||
style={props.style ? props.style : []}> |
|||
<div |
|||
className={`center-in-parent ${ |
|||
props.className ? props.className : ''}`}
|
|||
style={props.style ? props.style : []} |
|||
> |
|||
<p> |
|||
<i className="fas fa-spinner fa-3x fa-spin"></i> |
|||
<i className="fas fa-spinner fa-3x fa-spin" /> |
|||
</p> |
|||
</div> |
|||
</div> |
|||
); |
|||
} |
|||
|
|||
export default LoadingSpinner; |
@ -1,12 +1,13 @@ |
|||
import React from 'react'; |
|||
import pageNotFound from '../assets/images/PageNotFound.jpg'; |
|||
|
|||
const NotFound = () => { |
|||
return ( |
|||
<div style={{textAlign: "center"}}> |
|||
const NotFound = () => ( |
|||
<div style={{ |
|||
textAlign: 'center' |
|||
}} |
|||
> |
|||
<img src={pageNotFound} alt="Page not found!" /> |
|||
</div> |
|||
); |
|||
}; |
|||
|
|||
export default NotFound; |
@ -1,43 +1,46 @@ |
|||
import React, { Component } from 'react'; |
|||
|
|||
import { Header } from 'semantic-ui-react'; |
|||
import {connect} from "react-redux"; |
|||
import { connect } from 'react-redux'; |
|||
import UsernameFormContainer from './UsernameFormContainer'; |
|||
|
|||
class SignUpContainer extends Component { |
|||
componentDidUpdate(prevProps) { |
|||
if (this.props.user.hasSignedUp && !prevProps.user.hasSignedUp) |
|||
this.props.history.push("/"); |
|||
if (this.props.user.hasSignedUp && !prevProps.user.hasSignedUp) this.props.history.push('/'); |
|||
} |
|||
|
|||
render() { |
|||
return ( |
|||
this.props.user.hasSignedUp |
|||
?(<div className="vertical-center-in-parent"> |
|||
<Header color='teal' textAlign='center' as='h2'> |
|||
? ( |
|||
<div className="vertical-center-in-parent"> |
|||
<Header color="teal" textAlign="center" as="h2"> |
|||
There is already an account for this addresss. |
|||
</Header> |
|||
<Header color='teal' textAlign='center' as='h4'> |
|||
<Header color="teal" textAlign="center" as="h4"> |
|||
If you want to create another account please change your address. |
|||
</Header> |
|||
</div>) |
|||
:(<div className="sign-up-container"> |
|||
</div> |
|||
) |
|||
: ( |
|||
<div className="sign-up-container"> |
|||
<div> |
|||
<h1>Sign Up</h1> |
|||
<p className="no-margin"> |
|||
<strong>Account address:</strong> {this.props.user.address} |
|||
<strong>Account address:</strong> |
|||
{' '} |
|||
{this.props.user.address} |
|||
</p> |
|||
<UsernameFormContainer /> |
|||
</div> |
|||
</div>) |
|||
</div> |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
const mapStateToProps = state => { |
|||
return { |
|||
const mapStateToProps = state => ({ |
|||
user: state.user |
|||
} |
|||
}; |
|||
}); |
|||
|
|||
export default connect(mapStateToProps)(SignUpContainer); |
|||
|
@ -1,12 +1,12 @@ |
|||
const epochTimeConverter = (timestamp) => { |
|||
var timestampDate = new Date(0); |
|||
const timestampDate = new Date(0); |
|||
timestampDate.setUTCSeconds(timestamp); |
|||
return ((timestampDate.getMonth() + 1) + " " |
|||
+ timestampDate.getDate() + ", " |
|||
+ timestampDate.getFullYear() + ", " |
|||
+ timestampDate.getHours() + ":" |
|||
+ timestampDate.getMinutes() + ":" |
|||
+ timestampDate.getSeconds()) |
|||
} |
|||
return (`${timestampDate.getMonth() + 1} ${ |
|||
timestampDate.getDate()}, ${ |
|||
timestampDate.getFullYear()}, ${ |
|||
timestampDate.getHours()}:${ |
|||
timestampDate.getMinutes()}:${ |
|||
timestampDate.getSeconds()}`);
|
|||
}; |
|||
|
|||
export default epochTimeConverter; |
@ -1,14 +1,14 @@ |
|||
import { combineReducers } from 'redux'; |
|||
import { drizzleReducers } from 'drizzle'; |
|||
import { connectRouter } from 'connected-react-router' |
|||
import { connectRouter } from 'connected-react-router'; |
|||
import userReducer from './userReducer'; |
|||
import orbitReducer from './orbitReducer'; |
|||
import userInterfaceReducer from './userInterfaceReducer'; |
|||
|
|||
export default (history) => combineReducers({ |
|||
export default history => combineReducers({ |
|||
router: connectRouter(history), |
|||
user: userReducer, |
|||
orbit: orbitReducer, |
|||
interface: userInterfaceReducer, |
|||
...drizzleReducers |
|||
}) |
|||
}); |
|||
|
@ -1,13 +1,18 @@ |
|||
import { all, fork } from 'redux-saga/effects' |
|||
import { drizzleSagas } from 'drizzle' |
|||
import drizzleUtilsSaga from './drizzleUtilsSaga' |
|||
import { all, fork } from 'redux-saga/effects'; |
|||
import { drizzleSagas } from 'drizzle'; |
|||
import drizzleUtilsSaga from './drizzleUtilsSaga'; |
|||
import userSaga from './userSaga'; |
|||
import orbitSaga from "./orbitSaga"; |
|||
import transactionsSaga from "./transactionsSaga"; |
|||
import orbitSaga from './orbitSaga'; |
|||
import transactionsSaga from './transactionsSaga'; |
|||
|
|||
export default function* root() { |
|||
let sagas = [...drizzleSagas, drizzleUtilsSaga, orbitSaga, userSaga, transactionsSaga]; |
|||
const sagas = [ |
|||
...drizzleSagas, |
|||
drizzleUtilsSaga, |
|||
orbitSaga, |
|||
userSaga, |
|||
transactionsSaga]; |
|||
yield all( |
|||
sagas.map(saga => fork(saga)) |
|||
) |
|||
sagas.map(saga => fork(saga)), |
|||
); |
|||
} |
@ -1,73 +1,81 @@ |
|||
import {call, select, take, takeEvery} from 'redux-saga/effects' |
|||
import { call, select, take, takeEvery } from 'redux-saga/effects'; |
|||
|
|||
import { drizzle } from '../../index' |
|||
import { orbitSagaPut } from '../../utils/orbitUtils' |
|||
import { drizzle } from '../../index'; |
|||
import { orbitSagaPut } from '../../utils/orbitUtils'; |
|||
import { DRIZZLE_UTILS_SAGA_INITIALIZED } from '../actions/drizzleUtilsActions'; |
|||
|
|||
let transactionsHistory = Object.create(null); |
|||
const transactionsHistory = Object.create(null); |
|||
|
|||
function* initTransaction(action) { |
|||
var dataKey = drizzle.contracts[action.transactionDescriptor.contract] |
|||
.methods[action.transactionDescriptor['method']] |
|||
.cacheSend(...(action.transactionDescriptor.params)); |
|||
const dataKey = drizzle.contracts[action.transactionDescriptor.contract].methods[action.transactionDescriptor.method].cacheSend( |
|||
...(action.transactionDescriptor.params), |
|||
); |
|||
|
|||
transactionsHistory[dataKey] = action; |
|||
transactionsHistory[dataKey].state = 'initialized'; |
|||
} |
|||
|
|||
function* handleEvent(action) { |
|||
var transactionStack = yield select((state) => state.transactionStack); |
|||
var dataKey = transactionStack.indexOf(action.event.transactionHash); |
|||
const transactionStack = yield select(state => state.transactionStack); |
|||
const dataKey = transactionStack.indexOf(action.event.transactionHash); |
|||
|
|||
switch (action.event.event) { |
|||
case 'TopicCreated': |
|||
if (dataKey !== -1 && |
|||
transactionsHistory[dataKey] && |
|||
transactionsHistory[dataKey].state === 'initialized') { |
|||
if (dataKey !== -1 |
|||
&& transactionsHistory[dataKey] |
|||
&& transactionsHistory[dataKey].state === 'initialized') { |
|||
transactionsHistory[dataKey].state = 'success'; |
|||
// Gets orbit
|
|||
const orbit = yield select((state) => state.orbit); |
|||
const orbit = yield select(state => state.orbit); |
|||
// And saves the topic
|
|||
yield call(orbitSagaPut, orbit.topicsDB, action.event.returnValues.topicID, |
|||
{ subject: transactionsHistory[dataKey].userInputs.topicSubject }); |
|||
yield call(orbitSagaPut, orbit.postsDB, action.event.returnValues.postID, |
|||
{ subject: transactionsHistory[dataKey].userInputs.topicSubject, |
|||
content: transactionsHistory[dataKey].userInputs.topicMessage }); |
|||
yield call(orbitSagaPut, orbit.topicsDB, |
|||
action.event.returnValues.topicID, |
|||
{ |
|||
subject: transactionsHistory[dataKey].userInputs.topicSubject |
|||
}); |
|||
yield call(orbitSagaPut, orbit.postsDB, |
|||
action.event.returnValues.postID, |
|||
{ |
|||
subject: transactionsHistory[dataKey].userInputs.topicSubject, |
|||
content: transactionsHistory[dataKey].userInputs.topicMessage |
|||
}); |
|||
} |
|||
break; |
|||
case 'PostCreated': |
|||
if (dataKey !== -1 && |
|||
transactionsHistory[dataKey] && |
|||
transactionsHistory[dataKey].state === 'initialized') { |
|||
if (dataKey !== -1 |
|||
&& transactionsHistory[dataKey] |
|||
&& transactionsHistory[dataKey].state === 'initialized') { |
|||
transactionsHistory[dataKey].state = 'success'; |
|||
// Gets orbit
|
|||
const orbit = yield select((state) => state.orbit); |
|||
const orbit = yield select(state => state.orbit); |
|||
// And saves the topic
|
|||
yield call(orbitSagaPut, orbit.postsDB, action.event.returnValues.postID, |
|||
{subject: transactionsHistory[dataKey].userInputs.postSubject, |
|||
content: transactionsHistory[dataKey].userInputs.postMessage }); |
|||
yield call(orbitSagaPut, orbit.postsDB, |
|||
action.event.returnValues.postID, |
|||
{ |
|||
subject: transactionsHistory[dataKey].userInputs.postSubject, |
|||
content: transactionsHistory[dataKey].userInputs.postMessage |
|||
}); |
|||
} |
|||
break; |
|||
default: |
|||
// Nothing to do here
|
|||
return; |
|||
} |
|||
} |
|||
|
|||
function* handleError() { |
|||
var transactionStack = yield select((state) => state.transactionStack); |
|||
const transactionStack = yield select(state => state.transactionStack); |
|||
transactionStack.forEach((transaction, index) => { |
|||
if (transaction.startsWith('TEMP_')) { |
|||
transactionsHistory[index].state = 'error'; |
|||
} |
|||
}) |
|||
}); |
|||
} |
|||
|
|||
function* transactionsSaga() { |
|||
yield take(DRIZZLE_UTILS_SAGA_INITIALIZED); |
|||
yield takeEvery("INIT_TRANSACTION", initTransaction); |
|||
yield takeEvery("EVENT_FIRED", handleEvent); |
|||
yield takeEvery("TX_ERROR", handleError); |
|||
yield takeEvery('INIT_TRANSACTION', initTransaction); |
|||
yield takeEvery('EVENT_FIRED', handleEvent); |
|||
yield takeEvery('TX_ERROR', handleError); |
|||
} |
|||
|
|||
export default transactionsSaga; |
|||
|
@ -1,28 +1,27 @@ |
|||
import React from 'react' |
|||
import React from 'react'; |
|||
import { connect } from 'react-redux'; |
|||
import { Route, Redirect } from 'react-router-dom' |
|||
import { Redirect, Route } from 'react-router-dom'; |
|||
|
|||
const PrivateRoute = ({ component: Component, ...rest }) => ( |
|||
<Route |
|||
{...rest} |
|||
render={props => |
|||
props.hasSignedUp ? ( |
|||
render={props => (props.hasSignedUp ? ( |
|||
<Component {...props} /> |
|||
) : ( |
|||
<Redirect to={{ |
|||
pathname: "/signup", |
|||
state: { from: props.location } |
|||
pathname: '/signup', |
|||
state: { |
|||
from: props.location |
|||
} |
|||
}} |
|||
/> |
|||
) |
|||
)) |
|||
} |
|||
/> |
|||
); |
|||
|
|||
const mapStateToProps = state => { |
|||
return { |
|||
hasSignedUp: state.user.hasSignedUp, |
|||
} |
|||
}; |
|||
const mapStateToProps = state => ({ |
|||
hasSignedUp: state.user.hasSignedUp |
|||
}); |
|||
|
|||
export default connect(mapStateToProps)(PrivateRoute); |
|||
|
@ -1,28 +1,31 @@ |
|||
import React from 'react' |
|||
import { Route, Redirect, Switch } from 'react-router-dom' |
|||
import React from 'react'; |
|||
import { Redirect, Route, Switch } from 'react-router-dom'; |
|||
import CoreLayoutContainer from '../containers/CoreLayoutContainer'; |
|||
import HomeContainer from '../containers/HomeContainer' |
|||
import SignUpContainer from '../containers/SignUpContainer' |
|||
import StartTopicContainer from '../containers/StartTopicContainer' |
|||
import TopicContainer from '../containers/TopicContainer' |
|||
import ProfileContainer from '../containers/ProfileContainer' |
|||
import NotFound from '../components/NotFound' |
|||
import HomeContainer from '../containers/HomeContainer'; |
|||
import SignUpContainer from '../containers/SignUpContainer'; |
|||
import StartTopicContainer from '../containers/StartTopicContainer'; |
|||
import TopicContainer from '../containers/TopicContainer'; |
|||
import ProfileContainer from '../containers/ProfileContainer'; |
|||
import NotFound from '../components/NotFound'; |
|||
|
|||
const routes = ( |
|||
<div> |
|||
<CoreLayoutContainer> |
|||
<Switch> |
|||
<Route exact path="/" component={HomeContainer} /> |
|||
<Redirect from='/home' to="/" /> |
|||
<Redirect from="/home" to="/" /> |
|||
<Route path="/signup" component={SignUpContainer} /> |
|||
<Route path="/startTopic" component={StartTopicContainer} /> |
|||
<Route path="/topic/:topicId/:postId?" component={TopicContainer} /> |
|||
<Route path='/profile/:address?/:username?' component={ProfileContainer} /> |
|||
<Route path='/404' component={NotFound} /> |
|||
<Route |
|||
path="/profile/:address?/:username?" |
|||
component={ProfileContainer} |
|||
/> |
|||
<Route path="/404" component={NotFound} /> |
|||
<Route component={NotFound} /> |
|||
</Switch> |
|||
</CoreLayoutContainer> |
|||
</div> |
|||
); |
|||
|
|||
export default routes |
|||
export default routes; |
|||
|
Loading…
Reference in new issue