import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {Tab, Tabs, TabList, TabPanel} from 'react-tabs';
import CodeEditor from '../components/base/Editor'
import RequestBodyEditor from '../components/RequestBodyEditor'
import RequestUrlBar from '../components/RequestUrlBar'
import Sidebar from '../components/Sidebar'
import * as RequestActions from '../actions/requests'
import * as GlobalActions from '../actions/global'
// Don't inject component styles (use our own)
Tabs.setUseDefaultStyles(false);
class App extends Component {
renderPageBody (actions, activeRequest) {
if (!activeRequest) {
return
;
}
const updateRequestBody = actions.updateRequestBody.bind(null, activeRequest.id);
const updateRequestUrl = actions.updateRequestUrl.bind(null, activeRequest.id);
const updateRequestMethod = actions.updateRequestMethod.bind(null, activeRequest.id);
return (
Params
Basic Auth
Headers
200 SUCCESS
GET https://google.com
)
}
render () {
const {actions, loading, requests} = this.props;
const activeRequest = requests.all.find(r => r.id === requests.active);
return (
{this.renderPageBody(actions, activeRequest)}
)
}
}
App.propTypes = {
actions: PropTypes.shape({
activateRequest: PropTypes.func.isRequired,
updateRequestBody: PropTypes.func.isRequired,
updateRequestUrl: PropTypes.func.isRequired,
updateRequestMethod: PropTypes.func.isRequired
}).isRequired,
requests: PropTypes.shape({
all: PropTypes.array.isRequired,
active: PropTypes.string // "required" but can be null
}).isRequired,
loading: PropTypes.bool.isRequired
};
function mapStateToProps (state) {
return {
actions: state.actions,
requests: state.requests,
loading: state.loading
};
}
function mapDispatchToProps (dispatch) {
return {
actions: Object.assign(
{},
bindActionCreators(GlobalActions, dispatch),
bindActionCreators(RequestActions, dispatch)
)
}
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(App);