Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
move from react-redux to reatty, clear commit history
Browse files Browse the repository at this point in the history
  • Loading branch information
Metnew committed Feb 13, 2017
0 parents commit 311efc9
Show file tree
Hide file tree
Showing 71 changed files with 2,694 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["lodash", "transform-regenerator", "transform-decorators-legacy"],
"presets": ["es2015", "react", "stage-0"]
}
33 changes: 33 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": ["eslint:recommended", "plugin:react/recommended"],
"parser": "babel-eslint",
"plugins": [
"react"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"env": {
"browser": true,
"amd": true,
"es6": true,
"node": true
},
"rules": {
"comma-dangle": 1,
"quotes": [ 1, "single" ],
"no-undef": 1,
"global-strict": 0,
"no-extra-semi": 1,
"no-underscore-dangle": 0,
"no-console": 0,
"no-unused-vars": 1,
"no-trailing-spaces": [1, { "skipBlankLines": true }],
"no-unreachable": 1,
"no-alert": 0,
"react/jsx-uses-react": 1
}
}
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
# Python venv
venv

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Vladimir Metnev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Usage
DEV Run:
```
npm i
npm start
```
20 changes: 20 additions & 0 deletions common/Root.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, {Component} from 'react';
import {Provider} from 'react-redux'
import routes from './routing';
import {Router} from 'react-router';

export default class Root extends Component {
static propTypes = {
store: React.PropTypes.object,
history: React.PropTypes.object
}

render() {
const {store, history} = this.props;
return (
<Provider store={store}>
<Router routes={routes} history={history}/>
</Provider>
);
}
}
55 changes: 55 additions & 0 deletions common/actions/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
login_API,
register_API,
recoverPassword_API,
setLocalToken,
resetLocalToken
} from 'api/AuthSvc';
import {resultOK} from 'api/utils';

export const LOGIN_AUTH_SUCCESS = 'LOGIN_AUTH_SUCCESS'
export const LOGIN_AUTH_FAIL = 'LOGIN_AUTH_FAIL'

export const LOGOUT_AUTH_SUCCESS = 'LOGOUT_AUTH_SUCCESS'

export const RECOVER_PASSWORD_AUTH_SUCCESS = 'RECOVER_PASSWORD_AUTH_SUCCESS'
export const RECOVER_PASSWORD_AUTH_FAIL = 'RECOVER_PASSWORD_AUTH_FAIL'

export const REGISTER_AUTH_SUCCESS = 'REGISTER_AUTH_SUCCESS'
export const REGISTER_AUTH_FAIL = 'REGISTER_AUTH_FAIL'

export function LOGIN_AUTH(data) {
return async() => {
let result = await login_API(data)
if (!resultOK(result)) {
return {type: LOGIN_AUTH_FAIL, error: result}
}
setLocalToken(result.token)
return {type: LOGIN_AUTH_SUCCESS, result: result}
}
}

export function LOGOUT_AUTH(data) {
resetLocalToken();
return {type: LOGOUT_AUTH_SUCCESS}
}

export function RECOVER_PASSWORD(data) {
return async() => {
let result = await recoverPassword_API(data)
if (!resultOK(result)) {
return {type: RECOVER_PASSWORD_AUTH_FAIL, error: result}
}
return {type: RECOVER_PASSWORD_AUTH_SUCCESS, result: result}
}
}

export function REGISTER_AUTH(data) {
return async() => {
let result = await register_API(data)
if (!resultOK(result)) {
return {type: REGISTER_AUTH_FAIL, error: result}
}
return {type: REGISTER_AUTH_SUCCESS, result: result}
}
}
1 change: 1 addition & 0 deletions common/actions/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
26 changes: 26 additions & 0 deletions common/actions/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//import api service
import {getStatistics_API} from 'api/StatisticsSvc';
//import request management utils
import {resultOK} from 'api/utils';


//define action types
export const GET_STATISTICS_SUCCESS = 'GET_STATISTICS_SUCCESS';
export const GET_STATISTICS_FAIL = 'GET_STATISTICS_FAIL';

export const GET_STATISTICS = () => {
return async function() {
let result = await getStatistics_API();
if (!resultOK(result)) {
return {
type: GET_STATISTICS_FAIL,
error: result.data
}
}
return {
type: GET_STATISTICS_SUCCESS,
result: result.data
}

}
}
11 changes: 11 additions & 0 deletions common/actions/error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// export const THROW_ERROR_SERVER_REQUEST = 'SERVER_REQUEST_ERROR';
export const SEND_ERROR_TO_SERVER_FAIL = 'SEND_ERROR_TO_SERVER_FAIL';
export const SEND_ERROR_TO_SERVER_SUCCESS = 'SEND_ERROR_TO_SERVER_SUCCESS';

export const THROW_ERROR = (error) => {
console.error(error)
}

export const SEND_ERROR_TO_SERVER = (error) => {

}
23 changes: 23 additions & 0 deletions common/actions/inbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {getInbox_API} from 'api/InboxSvc';
import {resultOK} from 'api/utils';

export const GET_INBOX_SUCCESS = 'GET_INBOX_SUCCESS';
export const GET_INBOX_FAIL = 'GET_INBOX_FAIL';


export const GET_INBOX = () => {
return async function() {
let result = await getInbox_API()
if (!resultOK(result)) {
return {
type: GET_INBOX_FAIL,
error: result
}
}
return {
type: GET_INBOX_SUCCESS,
result: result
}

}
}
25 changes: 25 additions & 0 deletions common/actions/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const UI_OPEN_SIDEBAR = 'UI_OPEN_SIDEBAR';
export const UI_CLOSE_SIDEBAR = 'UI_CLOSE_SIDEBAR';
export const UI_ACTIVATE_OBFUSCATOR = 'UI_ACTIVATE_OBFUSCATOR';
export const UI_DEACTIVATE_OBFUSCATOR = 'UI_DEACTIVATE_OBFUSCATOR';
export const UI_WINDOW_RESIZE = 'UI_WINDOW_RESIZE';

export const CLOSE_SIDEBAR = () => ({
type: UI_CLOSE_SIDEBAR
})

export const OPEN_SIDEBAR = () => ({
type: UI_OPEN_SIDEBAR
})

export const ACTIVATE_OBFUSCATOR = () => ({
type: UI_ACTIVATE_OBFUSCATOR
})

export const DEACTIVATE_OBFUSCATOR = () => ({
type: UI_DEACTIVATE_OBFUSCATOR
})

export const WINDOW_RESIZE = () => ({
type: UI_WINDOW_RESIZE
})
43 changes: 43 additions & 0 deletions common/api/AuthSvc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {post, get} from './utils';
import * as store from 'store2'

export function getLocalToken() {
return store.get('auth_token')
}

export function resetLocalToken() {
console.log('remove local token')
store.remove('auth_token')
}
export function setLocalToken(token) {
console.log('set new local token')
store.set('auth_token', token)
}

export function isLoggedIn() {
console.log('local token is null:', getLocalToken() === null)
let localToken = getLocalToken()
if (localToken === null) {
return false
}
return true
}

export async function verifyToken() {
return await get('/auth/verify')
}
export async function refreshToken() {
return await get('/auth/refresh')
}

export async function login_API(data) {
return await post('/auth', data)
}

export async function recoverPassword_API(data) {
return await post('/auth/recover', data)
}

export async function register_API(data) {
return await post('/auth/register', data)
}
18 changes: 18 additions & 0 deletions common/api/InboxSvc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {get, post} from './utils';
// import * as store from 'store2'

export async function getInbox_API() {
return await get('/inbox/')
}

export async function getConversation_API(id) {
return await get(`/inbox/${id}/`)
}

export async function sendConversationMessage_API(id, data) {
return await post(`/inbox/${id}/message/`, data)
}

export async function acceptConversationQuote_API(id, data) {
return await post(`/quotes/${id}/`, data)
}
5 changes: 5 additions & 0 deletions common/api/StatisticsSvc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {get, post} from './utils'

export async function getStatistics_API() {
return await get('/statistics')
}
Loading

0 comments on commit 311efc9

Please sign in to comment.