Updated Print Center & TemplateList Object IO-587
This commit is contained in:
@@ -1,23 +1,12 @@
|
||||
import { Button } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../../../firebase/firebase.utils";
|
||||
import { selectBodyshop } from "../../../../redux/user/user.selectors";
|
||||
import { GenerateDocument } from "../../../../utils/RenderTemplate";
|
||||
import JobIntakeTemplateItem from "../job-checklist-template-item/job-checklist-template-item.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
export function JobIntakeTemplateList({ bodyshop, templates }) {
|
||||
export default function JobIntakeTemplateList({ templates }) {
|
||||
const { jobId } = useParams();
|
||||
const { t } = useTranslation();
|
||||
const renderTemplate = async (templateKey) => {
|
||||
@@ -55,7 +44,3 @@ export function JobIntakeTemplateList({ bodyshop, templates }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(JobIntakeTemplateList);
|
||||
|
||||
@@ -89,7 +89,7 @@ export function JobsDetailHeaderCsi({
|
||||
replyTo: bodyshop.email,
|
||||
},
|
||||
template: {
|
||||
name: TemplateList().csi_invitation.key,
|
||||
name: TemplateList("job").csi_invitation.key,
|
||||
variables: {
|
||||
id: result.data.insert_csi.returning[0].id,
|
||||
},
|
||||
|
||||
@@ -129,8 +129,8 @@ export function PartsOrderListTableComponent({
|
||||
GenerateDocument(
|
||||
{
|
||||
name: record.isReturn
|
||||
? TemplateList().parts_return_confirmation.key
|
||||
: TemplateList().parts_order_confirmation.key,
|
||||
? TemplateList("partsorder").parts_return_confirmation.key
|
||||
: TemplateList("partsorder").parts_order_confirmation.key,
|
||||
variables: { id: record.id },
|
||||
},
|
||||
{},
|
||||
@@ -143,8 +143,8 @@ export function PartsOrderListTableComponent({
|
||||
GenerateDocument(
|
||||
{
|
||||
name: record.isReturn
|
||||
? TemplateList().parts_return_confirmation.key
|
||||
: TemplateList().parts_order_confirmation.key,
|
||||
? TemplateList("partsorder").parts_return_confirmation.key
|
||||
: TemplateList("partsorder").parts_order_confirmation.key,
|
||||
variables: { id: record.id },
|
||||
},
|
||||
{},
|
||||
|
||||
@@ -12,12 +12,12 @@ import { QUERY_ALL_VENDORS_FOR_ORDER } from "../../graphql/vendors.queries";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import {
|
||||
setModalContext,
|
||||
toggleModalVisible
|
||||
toggleModalVisible,
|
||||
} from "../../redux/modals/modals.actions";
|
||||
import { selectPartsOrder } from "../../redux/modals/modals.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
@@ -159,8 +159,8 @@ export function PartsOrderModalContainer({
|
||||
GenerateDocument(
|
||||
{
|
||||
name: isReturn
|
||||
? TemplateList().parts_return_confirmation.key
|
||||
: TemplateList().parts_order_confirmation.key,
|
||||
? TemplateList("partsorder").parts_return_confirmation.key
|
||||
: TemplateList("partsorder").parts_order_confirmation.key,
|
||||
variables: {
|
||||
id: insertResult.data.insert_parts_orders.returning[0].id,
|
||||
},
|
||||
@@ -168,8 +168,8 @@ export function PartsOrderModalContainer({
|
||||
{
|
||||
to: matchingVendor ? [matchingVendor.email] : null,
|
||||
replyTo: bodyshop.email,
|
||||
subject: TemplateList("job", bodyshop.shopname)
|
||||
.parts_order_confirmation.subject,
|
||||
subject: TemplateList("partsorder", {}).parts_order_confirmation
|
||||
.subject,
|
||||
},
|
||||
"e"
|
||||
);
|
||||
@@ -177,8 +177,8 @@ export function PartsOrderModalContainer({
|
||||
GenerateDocument(
|
||||
{
|
||||
name: isReturn
|
||||
? TemplateList().parts_return_confirmation.key
|
||||
: TemplateList().parts_order_confirmation.key,
|
||||
? TemplateList("partsorder").parts_return_confirmation.key
|
||||
: TemplateList("partsorder").parts_order_confirmation.key,
|
||||
variables: {
|
||||
id: insertResult.data.insert_parts_orders.returning[0].id,
|
||||
},
|
||||
|
||||
@@ -121,7 +121,7 @@ function BillEnterModalContainer({
|
||||
|
||||
GenerateDocument(
|
||||
{
|
||||
name: TemplateList().payment_receipt.key,
|
||||
name: TemplateList("payment").payment_receipt.key,
|
||||
variables: {
|
||||
id: newPayment.data.insert_payments.returning[0].id,
|
||||
},
|
||||
|
||||
@@ -1,40 +1,28 @@
|
||||
import { Collapse, Row, Col } from "antd";
|
||||
import { Col, Collapse, Row } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectPrintCenter } from "../../redux/modals/modals.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import PrintCenterItem from "../print-center-item/print-center-item.component";
|
||||
import PrintCenterSpeedPrint from "../print-center-speed-print/print-center-speed-print.component";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
bodyshop: selectBodyshop,
|
||||
printCenterModal: selectPrintCenter,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("printCenter")),
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
const colSpan = { md: { span: 24 }, lg: { span: 12 } };
|
||||
|
||||
export function PrintCenterJobsComponent({ bodyshop, printCenterModal }) {
|
||||
export function PrintCenterJobsComponent({ printCenterModal }) {
|
||||
const { t } = useTranslation();
|
||||
const { id: jobId } = printCenterModal.context;
|
||||
const tempList = TemplateList();
|
||||
const tempList = TemplateList("job", {});
|
||||
const JobsReportsList = Object.keys(tempList).map((key) => {
|
||||
return tempList[key];
|
||||
});
|
||||
console.log("PrintCenterJobsComponent -> JobsReportsList", JobsReportsList);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -45,17 +33,15 @@ export function PrintCenterJobsComponent({ bodyshop, printCenterModal }) {
|
||||
<Col {...colSpan}>
|
||||
<Collapse accordion>
|
||||
<Collapse.Panel header={t("printcenter.labels.repairorder")}>
|
||||
<ul style={{ columns: "2 auto" }}>
|
||||
{JobsReportsList.filter((t) => t.drivingId === "job").map(
|
||||
(item) => (
|
||||
<PrintCenterItem
|
||||
key={item.key}
|
||||
item={item}
|
||||
id={jobId}
|
||||
disabled={item.disabled}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
<ul style={{ columns: "3 auto" }}>
|
||||
{JobsReportsList.map((item) => (
|
||||
<PrintCenterItem
|
||||
key={item.key}
|
||||
item={item}
|
||||
id={jobId}
|
||||
disabled={item.disabled}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
|
||||
@@ -3,47 +3,37 @@ import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectPrintCenter } from "../../redux/modals/modals.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import PrintCenterModalComponent from "./print-center-modal.component";
|
||||
import "./print-center-modal.styles.scss";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
bodyshop: selectBodyshop,
|
||||
printCenterModal: selectPrintCenter,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("printCenter")),
|
||||
});
|
||||
|
||||
export function PrintCenterModalContainer({
|
||||
printCenterModal,
|
||||
toggleModalVisible,
|
||||
currentUser,
|
||||
bodyshop,
|
||||
setEmailOptions,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { visible, context } = printCenterModal;
|
||||
const { type, id } = context;
|
||||
const { type } = context;
|
||||
// const { refetch } = actions;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
onCancel={() => toggleModalVisible()}
|
||||
width='90%'
|
||||
title={` ${t("printcenter.labels.title")} ${type} - ${id}`}
|
||||
destroyOnClose>
|
||||
width="90%"
|
||||
title={` ${t("printcenter.labels.title")} - ${type}`}
|
||||
destroyOnClose
|
||||
>
|
||||
<PrintCenterModalComponent context={context} />
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@@ -66,14 +66,18 @@ export function PrintCenterSpeedPrint({ bodyshop, jobId }) {
|
||||
);
|
||||
}
|
||||
|
||||
const renderTemplateList = (templates) => (
|
||||
<span className="imex-flex-row__margin">
|
||||
{templates.map((template, idx) => {
|
||||
if (idx === templates.length - 1) return TemplateList()[template].title;
|
||||
return `${TemplateList()[template].title}, `;
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
const renderTemplateList = (templates) => {
|
||||
const TemplateListGenerated = TemplateList();
|
||||
return (
|
||||
<span className="imex-flex-row__margin">
|
||||
{templates.map((template, idx) => {
|
||||
if (idx === templates.length - 1)
|
||||
return TemplateListGenerated[template].title;
|
||||
return `${TemplateListGenerated[template].title}, `;
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
|
||||
@@ -139,10 +139,10 @@ export function ScheduleJobModalContainer({
|
||||
messageOptions: {
|
||||
to: [values.email],
|
||||
replyTo: bodyshop.email,
|
||||
subject: TemplateList().appointment_confirmation.subject,
|
||||
subject: TemplateList("appointment").appointment_confirmation.subject,
|
||||
},
|
||||
template: {
|
||||
name: TemplateList().appointment_confirmation.key,
|
||||
name: TemplateList("appointment").appointment_confirmation.key,
|
||||
variables: {
|
||||
id: appt.data.insert_appointments.returning[0].id,
|
||||
},
|
||||
|
||||
@@ -16,6 +16,7 @@ const SelectorDiv = styled.div`
|
||||
export default function ShopInfoIntakeChecklistComponent({ form }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const TemplateListGenerated = TemplateList();
|
||||
return (
|
||||
<div>
|
||||
<Form.List name={["intakechecklist", "form"]}>
|
||||
@@ -128,12 +129,12 @@ export default function ShopInfoIntakeChecklistComponent({ form }) {
|
||||
]}
|
||||
>
|
||||
<Select mode="multiple">
|
||||
{Object.keys(TemplateList()).map((i) => (
|
||||
{Object.keys(TemplateListGenerated).map((i) => (
|
||||
<Select.Option
|
||||
key={TemplateList()[i].key}
|
||||
value={TemplateList()[i].key}
|
||||
key={TemplateListGenerated[i].key}
|
||||
value={TemplateListGenerated[i].key}
|
||||
>
|
||||
{TemplateList()[i].title}
|
||||
{TemplateListGenerated[i].title}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
@@ -250,12 +251,12 @@ export default function ShopInfoIntakeChecklistComponent({ form }) {
|
||||
]}
|
||||
>
|
||||
<Select mode="multiple">
|
||||
{Object.keys(TemplateList()).map((i) => (
|
||||
{Object.keys(TemplateListGenerated).map((i) => (
|
||||
<Select.Option
|
||||
key={TemplateList()[i].key}
|
||||
value={TemplateList()[i].key}
|
||||
key={TemplateListGenerated[i].key}
|
||||
value={TemplateListGenerated[i].key}
|
||||
>
|
||||
{TemplateList()[i].title}
|
||||
{TemplateListGenerated[i].title}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
@@ -4,10 +4,12 @@ import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
|
||||
export default function ShopInfoSpeedPrint({ bodyshop, form }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const TemplateListGenerated = TemplateList();
|
||||
console.log("TemplateListGenerated", TemplateListGenerated);
|
||||
return (
|
||||
<div>
|
||||
<Form.List name={["speedprint"]}>
|
||||
@@ -16,7 +18,7 @@ export default function ShopInfoSpeedPrint({ bodyshop, form }) {
|
||||
<div>
|
||||
{fields.map((field, index) => (
|
||||
<Form.Item key={field.key} style={{ padding: 0, margin: 2 }}>
|
||||
<div className="imex-flex-row">
|
||||
<LayoutFormRow grow>
|
||||
<Form.Item
|
||||
className="imex-flex-row__margin"
|
||||
label={t("bodyshop.fields.speedprint.id")}
|
||||
@@ -59,14 +61,14 @@ export default function ShopInfoSpeedPrint({ bodyshop, form }) {
|
||||
]}
|
||||
>
|
||||
<Select mode="multiple">
|
||||
{Object.keys(TemplateList())
|
||||
.map((key) => TemplateList()[key])
|
||||
.filter((template) => template.drivingId === "job")
|
||||
.map((template, idx) => (
|
||||
<Select.Option key={idx} value={template.key}>
|
||||
{template.title}
|
||||
</Select.Option>
|
||||
))}
|
||||
{Object.keys(TemplateListGenerated).map((key, idx) => (
|
||||
<Select.Option
|
||||
key={idx}
|
||||
value={TemplateListGenerated[key].key}
|
||||
>
|
||||
{TemplateListGenerated[key].title}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
@@ -81,7 +83,7 @@ export default function ShopInfoSpeedPrint({ bodyshop, form }) {
|
||||
index={index}
|
||||
total={fields.length}
|
||||
/>
|
||||
</div>
|
||||
</LayoutFormRow>
|
||||
</Form.Item>
|
||||
))}
|
||||
<Form.Item>
|
||||
|
||||
@@ -7,14 +7,14 @@ import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useHistory, useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import {
|
||||
INSERT_TEMPLATE,
|
||||
QUERY_TEMPLATES_BY_NAME_FOR_DUPE,
|
||||
} from "../../graphql/templates.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
@@ -67,12 +67,12 @@ export function ShopTemplateAddComponent({
|
||||
history.push({ search: queryString.stringify(search) });
|
||||
if (!!refetch) refetch();
|
||||
};
|
||||
|
||||
const TemplateListGenerated = TemplateList();
|
||||
const menu = (
|
||||
<Menu onClick={handleAdd}>
|
||||
{availableTemplateKeys.length > 0 ? (
|
||||
availableTemplateKeys.map((tkey) => (
|
||||
<Menu.Item key={tkey}>{TemplateList()[tkey].title}</Menu.Item>
|
||||
<Menu.Item key={tkey}>{TemplateListGenerated[tkey].title}</Menu.Item>
|
||||
))
|
||||
) : (
|
||||
<div>{t("bodyshop.labels.notemplatesavailable")}</div>
|
||||
|
||||
@@ -68,6 +68,7 @@ export function TimeTicketsSummaryEmployees({
|
||||
});
|
||||
|
||||
const handlePrintEmployeeTicket = async (empId) => {
|
||||
alert("Missing Key!");
|
||||
const html = await RenderTemplate(
|
||||
{
|
||||
name: TemplateList().time_tickets_by_employee.key,
|
||||
|
||||
Reference in New Issue
Block a user