Skip to content

Commit

Permalink
basic
Browse files Browse the repository at this point in the history
  • Loading branch information
sohamkamani committed May 27, 2016
1 parent 3b63ee6 commit 22ee50f
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 733 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ module.exports = {
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
};
12 changes: 12 additions & 0 deletions data/todo-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"id" : 0,
"text" : "Make API calls simpler",
"completed" : false
},
{
"id" : 1,
"text" : "Profit",
"completed" : false
}
]
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<div id="app-node">

</div>
<div class="not-available" style="display:none">Kindly login via PC to view the dashboard</div>
<script src="bundle.js"></script>
</body>

Expand Down
6 changes: 2 additions & 4 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import todoApp from './reducers'
import App from './components/App'
import dataService from './services/data-service'

let store = createStore(todoApp, applyMiddleware(dataService), window.devToolsExtension
? window.devToolsExtension()
: undefined)
let store = createStore(todoApp,{}, applyMiddleware(dataService))

render(
<Provider store={store}>
<App/>
</Provider>, document.getElementById('root'))
</Provider>, document.getElementById('app-node'))

store.dispatch({type: 'GET_TODO_DATA'})
64 changes: 32 additions & 32 deletions src/reducers/todos.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
const todo = (state, action) => {
switch (action.type) {
case 'ADD_TODO':
return {
id: action.id,
text: action.text,
completed: false
}
case 'TOGGLE_TODO':
if (state.id !== action.id) {
return state
}
switch (action.type) {
case 'ADD_TODO':
return {
id: action.id,
text: action.text,
completed: false
}
case 'TOGGLE_TODO':
if (state.id !== action.id) {
return state
}

return Object.assign({}, state, {
completed: !state.completed
})
default:
return state
}
return Object.assign({}, state, {
completed: !state.completed
})
default:
return state
}
}

const todos = (state = [], action) => {
switch (action.type) {
case 'ADD_TODO':
return [
...state,
todo(undefined, action)
]
case 'TOGGLE_TODO':
return state.map(t =>
todo(t, action)
)
case 'GET_TODO_DATA_RECEIVED':
return action.data
default:
return state
}
switch (action.type) {
case 'ADD_TODO':
return [
...state,
todo(undefined, action)
]
case 'TOGGLE_TODO':
return state.map(t =>
todo(t, action)
)
case 'GET_TODO_DATA_RECEIVED':
return action.data
default:
return state
}
}

export default todos
45 changes: 22 additions & 23 deletions src/services/data-service.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import request from 'superagent'

const dataService = store => next => action => {

switch (action.type) {
case 'GET_TODO_DATA':
request
.get('/data/initial-todos.json')
.end((err, res) => {
if (err) {
return store.dispatch({
type: 'GET_TODO_DATA_ERROR',
err
})
}
const data = JSON.parse(res.text)
store.dispatch({
type: 'GET_TODO_DATA_RECEIVED',
data
})
})
break
default:
console.log(action)
break
}
switch (action.type) {
case 'GET_TODO_DATA':
request
.get('/data/todo-data.json')
.end((err, res) => {
if (err) {
return next({
type: 'GET_TODO_DATA_ERROR',
err
})
}
const data = JSON.parse(res.text)
next({
type: 'GET_TODO_DATA_RECEIVED',
data
})
})
break
default:
next(action)
break
}

};

Expand Down
57 changes: 0 additions & 57 deletions styles/base.scss

This file was deleted.

38 changes: 0 additions & 38 deletions styles/content.scss

This file was deleted.

39 changes: 0 additions & 39 deletions styles/data-table.scss

This file was deleted.

10 changes: 1 addition & 9 deletions styles/main.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
@import "mixins.scss";
@import "variables.scss";
@import "base.scss";
@import "sidebar.scss";
@import "content.scss";
@import "pipeline.scss";
@import "data-table.scss";
@import "utilization.scss";
@import "my-staffing.scss";

20 changes: 0 additions & 20 deletions styles/mixins.scss

This file was deleted.

49 changes: 0 additions & 49 deletions styles/my-staffing.scss

This file was deleted.

Loading

0 comments on commit 22ee50f

Please sign in to comment.