import React, { PropTypes } from 'react' import { connect, Provider } from 'react-redux' import linkState from 'boost/linkState' import store from 'boost/store' import AppSettingTab from './Preference/AppSettingTab' import HelpTab from './Preference/HelpTab' import FolderSettingTab from './Preference/FolderSettingTab' import ContactTab from './Preference/ContactTab' import { closeModal } from 'boost/modal' const APP = 'APP' const HELP = 'HELP' const FOLDER = 'FOLDER' const CONTACT = 'CONTACT' class Preferences extends React.Component { constructor (props) { super(props) this.state = { currentTab: APP } } switchTeam (teamId) { this.setState({currentTeamId: teamId}) } handleNavButtonClick (tab) { return e => { this.setState({currentTab: tab}) } } render () { let content = this.renderContent() let tabs = [ {target: APP, label: 'Preferences'}, {target: FOLDER, label: 'Manage folder'}, {target: CONTACT, label: 'Contact form'} ] let navButtons = tabs.map(tab => ( )) return (
Setting
{navButtons}
{content}
) } renderContent () { let { folders, dispatch } = this.props switch (this.state.currentTab) { case HELP: return () case FOLDER: return ( ) case CONTACT: return ( ) case APP: default: return () } } // handleProfileSaveButtonClick (e) { // let profileState = this.state.profile // profileState.userInfo.alert = { // type: 'info', // message: 'Sending...' // } // this.setState({profile: profileState}, () => { // let input = { // profileName: profileState.userInfo.profileName, // email: profileState.userInfo.email // } // api.updateUserInfo(input) // .then(res => { // let profileState = this.state.profile // profileState.userInfo.alert = { // type: 'success', // message: 'Successfully done!' // } // this.setState({profile: profileState}) // }) // .catch(err => { // var message // if (err.status != null) { // message = err.response.body.message // } else if (err.code === 'ECONNREFUSED') { // message = 'Can\'t connect to API server.' // } else throw err // let profileState = this.state.profile // profileState.userInfo.alert = { // type: 'error', // message: message // } // this.setState({profile: profileState}) // }) // }) // } // handlePasswordSaveButton (e) { // let profileState = this.state.profile // if (profileState.password.newPassword !== profileState.password.confirmation) { // profileState.password.alert = { // type: 'error', // message: 'Confirmation doesn\'t match' // } // this.setState({profile: profileState}) // return // } // profileState.password.alert = { // type: 'info', // message: 'Sending...' // } // this.setState({profile: profileState}, () => { // let input = { // password: profileState.password.currentPassword, // newPassword: profileState.password.newPassword // } // api.updatePassword(input) // .then(res => { // let profileState = this.state.profile // profileState.password.alert = { // type: 'success', // message: 'Successfully done!' // } // profileState.password.currentPassword = '' // profileState.password.newPassword = '' // profileState.password.confirmation = '' // this.setState({profile: profileState}) // }) // .catch(err => { // var message // if (err.status != null) { // message = err.response.body.message // } else if (err.code === 'ECONNREFUSED') { // message = 'Can\'t connect to API server.' // } else throw err // let profileState = this.state.profile // profileState.password.alert = { // type: 'error', // message: message // } // profileState.password.currentPassword = '' // profileState.password.newPassword = '' // profileState.password.confirmation = '' // this.setState({profile: profileState}, () => { // if (this.refs.currentPassword != null) findDOMNode(this.refs.currentPassword).focus() // }) // }) // }) // } // renderProfile () { // let profileState = this.state.profile // return ( //
//
//
User Info
//
// // //
//
// // //
//
// // {this.state.profile.userInfo.alert != null // ? ( //
{profileState.userInfo.alert.message}
// ) // : null} //
//
//
//
Password
//
// // //
//
// // //
//
// // //
//
// // {profileState.password.alert != null // ? ( //
{profileState.password.alert.message}
// ) // : null} //
//
//
// ) // } } Preferences.propTypes = { folders: PropTypes.array, dispatch: PropTypes.func } Preferences.prototype.linkState = linkState function remap (state) { let { folders, status } = state return { folders, status } } let RootComponent = connect(remap)(Preferences) export default class PreferencesModal extends React.Component { render () { return ( ) } }