'use strict' import React from 'react' import ReactDOM from 'react-dom' import { BrowserRouter as Router, Route, NavLink, Switch, Redirect } from 'react-router-dom' import Progress from './components/Progress' import appReducer from './reducers' import adminReducer from './reducers/admin' import { fetchAdminData, patchUser, patchPublisher } from './actions/admin' import { toggleMenu } from './actions' import Util from './lib/Util' import Icon from './components/Icon' import IconButton from './components/IconButton' import '../styles/admin.scss' import './containers/listitem.scss' const reducer = Util.combineReducers(appReducer, adminReducer) class App extends React.Component { constructor () { super() this.state = { error: '', user: { id: '', email: '', password: '', currentPassword: '' }, users: [], publishers: [], working: false, navMenu: false } this.dispatch = this.dispatch.bind(this) this.getRegisteredUsers = this.getRegisteredUsers.bind(this) this.getRegisteredPublishers = this.getRegisteredPublishers.bind(this) /* this.state.user = { ...this.state.user, 'created_at': 1551151466802, 'updated_at': 1551151520134, 'id': 1, 'email': 'admin@tkluge.net', 'admin': true } */ } dispatch (action) { if (!action) throw new Error('dispatch: missing action') if (action instanceof Function) { action(this.dispatch, () => this.state) } else { const changes = reducer(this.state, action) if (!changes || !Object.keys(changes).length) return this.setState({ ...changes }) } } componentDidMount () { this.dispatch(fetchAdminData()) } getRegisteredUsers () { return this.state.users.map(user => { return (