expression reducer and stubbed out component

This commit is contained in:
Colin Megill
2017-11-26 23:19:49 -08:00
parent 4a412bb05c
commit 1e431c6a0a
3 changed files with 75 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import React from "react";
import _ from "lodash";
import { connect } from "react-redux";
import * as globals from "../../globals";
import styles from "./expression.css";
import SectionHeader from "../framework/sectionHeader"
@connect((state) => {
return {
expression: state.expression.data
}
})
class Expression extends React.Component {
constructor(props) {
super(props);
this.state = {
};
}
handleClick() {
}
render () {
if (!this.props.expression) return null
return (
<div style={{marginTop: 50}}>
<SectionHeader text="Expression"/>
{
_.map(this.props.expression.genes, (gene) => {
return (
<button
key={gene}
onClick={this.handleClick.bind(this)}
style={{marginRight: 10}}>
{gene}
</button>
)
})
}
</div>
)
}
};
export default Expression;
+29
View File
@@ -0,0 +1,29 @@
const Expression = (state = {
data: null,
loading: null,
error: null,
}, action) => {
switch (action.type) {
case "get expression started":
return Object.assign({}, state, {
loading: true,
error: null
});
case "get expression success":
return Object.assign({}, state, {
error: null,
loading: false,
data: action.data.data,
});
case "get expression error":
return Object.assign({}, state, {
data: null,
loading: false,
error: action.data
});
default:
return state;
}
};
export default Expression;