Begin work on speed print menu. BOD-229
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import React from "react";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import RenderTemplate, {
|
||||
displayTemplateInWindow,
|
||||
} from "../../utils/RenderTemplate";
|
||||
import { Button } from "antd";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop, //currentUser: selectCurrentUser
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
export function PrintCenterSpeedPrint({ bodyshop, job }) {
|
||||
const { speedprint } = bodyshop;
|
||||
|
||||
const renderTemplate = async (templateKey) => {
|
||||
logImEXEvent("speed_print_template_render");
|
||||
|
||||
const html = await RenderTemplate(
|
||||
{
|
||||
name: templateKey,
|
||||
variables: { id: job.id },
|
||||
},
|
||||
bodyshop
|
||||
);
|
||||
displayTemplateInWindow(html);
|
||||
};
|
||||
|
||||
const renderAllTemplates = (templateKeys) => {
|
||||
logImEXEvent("speed_print_render_all_templates");
|
||||
|
||||
templateKeys.forEach((templateKey) => renderTemplate(templateKey));
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{speedprint.map((sp) => (
|
||||
<div>
|
||||
{JSON.stringify(sp)}
|
||||
<Button onClick={() => renderAllTemplates(sp.templates)}>
|
||||
Print All
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(PrintCenterSpeedPrint);
|
||||
Reference in New Issue
Block a user