BOD-34 Added jobs items and conditional rendering for print center.
This commit is contained in:
@@ -11360,6 +11360,58 @@
|
|||||||
<folder_node>
|
<folder_node>
|
||||||
<name>printcenter</name>
|
<name>printcenter</name>
|
||||||
<children>
|
<children>
|
||||||
|
<folder_node>
|
||||||
|
<name>errors</name>
|
||||||
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>nocontexttype</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
|
</children>
|
||||||
|
</folder_node>
|
||||||
|
<folder_node>
|
||||||
|
<name>jobs</name>
|
||||||
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>repairorder</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
|
</children>
|
||||||
|
</folder_node>
|
||||||
<folder_node>
|
<folder_node>
|
||||||
<name>labels</name>
|
<name>labels</name>
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
load: () => dispatch(startLoading()),
|
load: () => dispatch(startLoading()),
|
||||||
endload: () => dispatch(endLoading()),
|
endload: () => dispatch(endLoading()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
@@ -48,13 +49,12 @@ export default connect(
|
|||||||
);
|
);
|
||||||
newWin.document.write(r.data);
|
newWin.document.write(r.data);
|
||||||
});
|
});
|
||||||
}}
|
}}>
|
||||||
>
|
|
||||||
TinyMCE
|
TinyMCE
|
||||||
</button>
|
</button>
|
||||||
<Editor
|
<Editor
|
||||||
value={state}
|
value={state}
|
||||||
apiKey="f3s2mjsd77ya5qvqkee9vgh612cm6h41e85efqakn2d0kknk"
|
apiKey='f3s2mjsd77ya5qvqkee9vgh612cm6h41e85efqakn2d0kknk'
|
||||||
init={{
|
init={{
|
||||||
height: 500,
|
height: 500,
|
||||||
//menubar: false,
|
//menubar: false,
|
||||||
@@ -76,12 +76,7 @@ export default connect(
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
setEmailOptions({
|
setEmailOptions({
|
||||||
messageOptions: {
|
messageOptions: {
|
||||||
from: {
|
|
||||||
name: bodyshop.shopname || EmailSettings.fromNameDefault,
|
|
||||||
address: EmailSettings.fromAddress,
|
|
||||||
},
|
|
||||||
to: "patrickwf@gmail.com",
|
to: "patrickwf@gmail.com",
|
||||||
replyTo: bodyshop.email,
|
|
||||||
Subject: "TODO FIX ME",
|
Subject: "TODO FIX ME",
|
||||||
},
|
},
|
||||||
template: {
|
template: {
|
||||||
@@ -89,8 +84,7 @@ export default connect(
|
|||||||
variables: { id: "2b42336f-b8de-4f04-a053-d6bff034d384" },
|
variables: { id: "2b42336f-b8de-4f04-a053-d6bff034d384" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}>
|
||||||
>
|
|
||||||
Set email config.
|
Set email config.
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@@ -110,8 +104,7 @@ export default connect(
|
|||||||
variables: { id: "6fea31e9-ea85-4c89-ac56-6f9cc84531fe" },
|
variables: { id: "6fea31e9-ea85-4c89-ac56-6f9cc84531fe" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}>
|
||||||
>
|
|
||||||
Parts Order
|
Parts Order
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||||
import EmailOverlayComponent from "./email-overlay.component";
|
import EmailOverlayComponent from "./email-overlay.component";
|
||||||
|
import { EmailSettings } from "../../emails/constants";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
modalVisible: selectEmailVisible,
|
modalVisible: selectEmailVisible,
|
||||||
@@ -31,10 +32,16 @@ export function EmailOverlayContainer({
|
|||||||
bodyshop,
|
bodyshop,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const defaultEmailFrom = {
|
||||||
const [messageOptions, setMessageOptions] = useState(
|
from: {
|
||||||
emailConfig.messageOptions
|
name: bodyshop.shopname || EmailSettings.fromNameDefault,
|
||||||
);
|
address: EmailSettings.fromAddress,
|
||||||
|
},
|
||||||
|
replyTo: bodyshop.email,
|
||||||
|
};
|
||||||
|
const [messageOptions, setMessageOptions] = useState({
|
||||||
|
...defaultEmailFrom,
|
||||||
|
});
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
|
|
||||||
const renderEmail = () => {
|
const renderEmail = () => {
|
||||||
@@ -78,7 +85,11 @@ export function EmailOverlayContainer({
|
|||||||
context: { ...contextData, bodyshop: bodyshop },
|
context: { ...contextData, bodyshop: bodyshop },
|
||||||
})
|
})
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
setMessageOptions({ ...messageOptions, html: r.data });
|
setMessageOptions({
|
||||||
|
...emailConfig.messageOptions,
|
||||||
|
...defaultEmailFrom,
|
||||||
|
html: r.data,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -119,8 +130,7 @@ export function EmailOverlayContainer({
|
|||||||
onOk={handleOk}
|
onOk={handleOk}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
toggleEmailOverlayVisible();
|
toggleEmailOverlayVisible();
|
||||||
}}
|
}}>
|
||||||
>
|
|
||||||
<LoadingSpinner loading={false}>
|
<LoadingSpinner loading={false}>
|
||||||
<EmailOverlayComponent
|
<EmailOverlayComponent
|
||||||
handleConfigChange={handleConfigChange}
|
handleConfigChange={handleConfigChange}
|
||||||
@@ -131,8 +141,7 @@ export function EmailOverlayContainer({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log(messageOptions.html);
|
console.log(messageOptions.html);
|
||||||
navigator.clipboard.writeText(messageOptions.html);
|
navigator.clipboard.writeText(messageOptions.html);
|
||||||
}}
|
}}>
|
||||||
>
|
|
||||||
Get HTML
|
Get HTML
|
||||||
</button>
|
</button>
|
||||||
</LoadingSpinner>
|
</LoadingSpinner>
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||||
|
import { selectPrintCenter } from "../../redux/modals/modals.selectors";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
printCenterModal: selectPrintCenter,
|
||||||
|
});
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||||
|
});
|
||||||
|
|
||||||
|
export function PrintCenterItemComponent({
|
||||||
|
printCenterModal,
|
||||||
|
setEmailOptions,
|
||||||
|
item,
|
||||||
|
}) {
|
||||||
|
return <li>{item.title}</li>;
|
||||||
|
}
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(PrintCenterItemComponent);
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { Collapse } 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 JobsReports from "./print-center-jobs.list";
|
||||||
|
import PrintCenterItem from "../print-center-item/print-center-item.component";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
currentUser: selectCurrentUser,
|
||||||
|
bodyshop: selectBodyshop,
|
||||||
|
printCenterModal: selectPrintCenter,
|
||||||
|
});
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||||
|
toggleModalVisible: () => dispatch(toggleModalVisible("printCenter")),
|
||||||
|
});
|
||||||
|
export function PrintCenterJobsComponent({ printCenterModal }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { id: jobid } = printCenterModal.context;
|
||||||
|
|
||||||
|
const JobsReportsList = JobsReports(null);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
Print Center Jobs COmponetn
|
||||||
|
<Collapse accordion>
|
||||||
|
{JobsReportsList.map((section) => (
|
||||||
|
<Collapse.Panel key={section.key} header={section.title}>
|
||||||
|
<ul style={{ columns: "2 auto" }}>
|
||||||
|
{section.items.map((item) => (
|
||||||
|
<PrintCenterItem key={item.key} item={item} />
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</Collapse.Panel>
|
||||||
|
))}
|
||||||
|
</Collapse>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(PrintCenterJobsComponent);
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import i18n from "i18next";
|
||||||
|
|
||||||
|
export default function JobsReports(job) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: i18n.t("printcenter.jobs.repairorder"),
|
||||||
|
key: "printcenter.jobs.repairorder",
|
||||||
|
disabled: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: "appointment_reminder",
|
||||||
|
title: "Appointment Reminder",
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "appointment_reminder2",
|
||||||
|
title: "Appointment Reminder2",
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "appointment_reminder3",
|
||||||
|
title: "Appointment Reminder3",
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "appointment_reminder4",
|
||||||
|
title: "Appointment Reminder4",
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "appointment_reminder5",
|
||||||
|
title: "Appointment Reminder5",
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Section 2",
|
||||||
|
key: "Section2",
|
||||||
|
disabled: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
key: "appointment_reminder12",
|
||||||
|
title: "Appointment Reminder12",
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,8 +1,23 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import PrintCenterJobs from "../print-center-jobs/print-center-jobs.component";
|
||||||
|
|
||||||
export default function PrintCenterModalComponent({ context }) {
|
export default function PrintCenterModalComponent({ context }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { type, id } = context;
|
const { type } = context;
|
||||||
return <div>{`${type} - ${id}`}</div>;
|
|
||||||
|
let ModalContent;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "job":
|
||||||
|
ModalContent = PrintCenterJobs;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{ModalContent ? <ModalContent /> : t("printcenter.errors.nocontexttype")}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ export function PrintCenterModalContainer({
|
|||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { visible, context, actions } = printCenterModal;
|
const { visible, context } = printCenterModal;
|
||||||
// const { jobId, linesToOrder } = context;
|
const { type, id } = context;
|
||||||
// const { refetch } = actions;
|
// const { refetch } = actions;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -41,7 +41,7 @@ export function PrintCenterModalContainer({
|
|||||||
visible={visible}
|
visible={visible}
|
||||||
onCancel={() => toggleModalVisible()}
|
onCancel={() => toggleModalVisible()}
|
||||||
width='90%'
|
width='90%'
|
||||||
title={t("printcenter.labels.title")}
|
title={` ${t("printcenter.labels.title")} ${type} - ${id}`}
|
||||||
destroyOnClose>
|
destroyOnClose>
|
||||||
<PrintCenterModalComponent context={context} />
|
<PrintCenterModalComponent context={context} />
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
51
client/src/redux/application/application.sagas.js
Normal file
51
client/src/redux/application/application.sagas.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { all, call, put, takeLatest } from "redux-saga/effects";
|
||||||
|
// import { sendEmailFailure, sendEmailSuccess } from "./email.actions";
|
||||||
|
// import EmailActionTypes from "./email.types";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
// export function* onSendEmail() {
|
||||||
|
// yield takeLatest(EmailActionTypes.SEND_EMAIL, sendEmail);
|
||||||
|
// }
|
||||||
|
// export function* sendEmail(payload) {
|
||||||
|
// try {
|
||||||
|
// console.log("Sending thta email", payload);
|
||||||
|
// axios.post("/sendemail", payload).then(response => {
|
||||||
|
// console.log(JSON.stringify(response));
|
||||||
|
// put(sendEmailSuccess());
|
||||||
|
// });
|
||||||
|
// } catch (error) {
|
||||||
|
// console.log("Error in sendEmail saga.");
|
||||||
|
// yield put(sendEmailFailure(error.message));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export function* onSendEmailSuccess() {
|
||||||
|
// yield takeLatest(EmailActionTypes.SEND_EMAIL_SUCCESS, sendEmailSuccessSaga);
|
||||||
|
// }
|
||||||
|
// export function* sendEmailSuccessSaga() {
|
||||||
|
// try {
|
||||||
|
// console.log("Send email success.");
|
||||||
|
// } catch (error) {
|
||||||
|
// console.log("Error in sendEmailSuccess saga.");
|
||||||
|
// yield put(sendEmailFailure(error.message));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export function* onSendEmailFailure() {
|
||||||
|
// yield takeLatest(EmailActionTypes.SEND_EMAIL_FAILURE, sendEmailFailureSaga);
|
||||||
|
// }
|
||||||
|
// export function* sendEmailFailureSaga(error) {
|
||||||
|
// try {
|
||||||
|
// yield console.log(error);
|
||||||
|
// } catch (error) {
|
||||||
|
// console.log("Error in sendEmailFailure saga.", error.message);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
export function* applicationSagas() {
|
||||||
|
yield all([
|
||||||
|
// call(onSendEmail),
|
||||||
|
// call(onSendEmailFailure),
|
||||||
|
// call(onSendEmailSuccess)
|
||||||
|
]);
|
||||||
|
}
|
||||||
@@ -4,7 +4,13 @@ import { userSagas } from "./user/user.sagas";
|
|||||||
import { messagingSagas } from "./messaging/messaging.sagas";
|
import { messagingSagas } from "./messaging/messaging.sagas";
|
||||||
import { emailSagas } from "./email/email.sagas";
|
import { emailSagas } from "./email/email.sagas";
|
||||||
import { modalsSagas } from "./modals/modals.sagas";
|
import { modalsSagas } from "./modals/modals.sagas";
|
||||||
|
import { applicationSagas } from "./application/application.sagas";
|
||||||
export default function* rootSaga() {
|
export default function* rootSaga() {
|
||||||
yield all([call(userSagas), call(messagingSagas), call(emailSagas),
|
yield all([
|
||||||
call(modalsSagas)]);
|
call(userSagas),
|
||||||
|
call(messagingSagas),
|
||||||
|
call(emailSagas),
|
||||||
|
call(modalsSagas),
|
||||||
|
call(applicationSagas),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,6 +733,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"printcenter": {
|
"printcenter": {
|
||||||
|
"errors": {
|
||||||
|
"nocontexttype": "No context type set."
|
||||||
|
},
|
||||||
|
"jobs": {
|
||||||
|
"repairorder": "Repair Order Related"
|
||||||
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"title": "Print Center"
|
"title": "Print Center"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,6 +733,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"printcenter": {
|
"printcenter": {
|
||||||
|
"errors": {
|
||||||
|
"nocontexttype": ""
|
||||||
|
},
|
||||||
|
"jobs": {
|
||||||
|
"repairorder": ""
|
||||||
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"title": ""
|
"title": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,6 +733,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"printcenter": {
|
"printcenter": {
|
||||||
|
"errors": {
|
||||||
|
"nocontexttype": ""
|
||||||
|
},
|
||||||
|
"jobs": {
|
||||||
|
"repairorder": ""
|
||||||
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"title": ""
|
"title": ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user