const ReactRouter = require('react-router'); const ReactRedux = require('react-redux'); const React = require('react'); const find = require('lodash.find'); const Loader = require('../components/loader'); const Printers = require('../components/printers'); const Changes = require('../components/changes'); const Change = require('../components/change'); const actions = require('../state/actions'); const { fetchChanges, lockPrinter, print, transitionTo } = actions; const { Match } = ReactRouter; const { connect } = ReactRedux; const Print = ({ pathname, printers = [], changes = [], lockPrinter, fetchChanges, onPrint, loaded, loading, locked, router }) => { const allChanges = () => { return (

Changes

); }; const singleChange = ({ params }) => { const change = find(changes, (change) => { return change.id === params.id; }); if (!change) { return (

Change not found

); } const _onPrint = (id) => { return () => { return onPrint(id); }; }; // TODO: don't load all changes return (

Change

); }; return (

Printers

); }; const mapStateToProps = (state) => { return { loaded: state.ui.changes.loaded, loading: state.ui.changes.loading, changes: state.data.changes, printers: state.data.printers, locked: state.ui.printers.locked }; }; const mapDispatchToProps = (dispatch) => { return { lockPrinter: (id) => { return dispatch(lockPrinter(id)); }, fetchChanges: () => { return dispatch(fetchChanges()); }, onPrint: (id) => { return dispatch(print(id)).then(() => { return dispatch(transitionTo('/print')); }); } }; }; module.exports = connect(mapStateToProps, mapDispatchToProps)(Print);