Added redux based email overlay to parts order modal + built out barebones parts order email template.
This commit is contained in:
@@ -14,21 +14,33 @@ import {
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import PartsOrderModalComponent from "./parts-order-modal.component";
|
||||
import {
|
||||
setEmailOptions,
|
||||
toggleEmailOverlayVisible
|
||||
} from "../../redux/email/email.actions";
|
||||
import PartsOrderEmailTemplate from "../../emails/parts-order/parts-order.email";
|
||||
import { REPORT_QUERY_PARTS_ORDER_BY_PK } from "../../emails/parts-order/parts-order.query";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setEmailOptions: e => dispatch(setEmailOptions(e)),
|
||||
toggleEmailOverlayVisible: () => dispatch(toggleEmailOverlayVisible())
|
||||
});
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
mapDispatchToProps
|
||||
)(function PartsOrderModalContainer({
|
||||
partsOrderModalVisible,
|
||||
linesToOrder,
|
||||
jobId,
|
||||
currentUser,
|
||||
bodyshop,
|
||||
refetch
|
||||
refetch,
|
||||
setEmailOptions,
|
||||
toggleEmailOverlayVisible
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [modalVisible, setModalVisible] = partsOrderModalVisible;
|
||||
@@ -51,6 +63,7 @@ export default connect(
|
||||
const orderLines = orderLinesState[0];
|
||||
|
||||
const sendTypeState = useState("e");
|
||||
const sendType = sendTypeState[0];
|
||||
const partsOrderState = useState({
|
||||
vendorid: null,
|
||||
jobid: jobId,
|
||||
@@ -92,6 +105,32 @@ export default connect(
|
||||
});
|
||||
if (refetch) refetch();
|
||||
setModalVisible(false);
|
||||
|
||||
if (sendType === "e") {
|
||||
//Show the email modal and set the data.
|
||||
|
||||
//TODO Remove some of the options below.
|
||||
setEmailOptions({
|
||||
messageOptions: {
|
||||
from: {
|
||||
name: "Kavia Autobdoy",
|
||||
address: "noreply@bodyshop.app"
|
||||
},
|
||||
to: "patrickwf@gmail.com",
|
||||
replyTo: "snaptsoft@gmail.com"
|
||||
},
|
||||
template: PartsOrderEmailTemplate,
|
||||
queryConfig: [
|
||||
REPORT_QUERY_PARTS_ORDER_BY_PK,
|
||||
{
|
||||
variables: {
|
||||
id: r.data.insert_parts_orders.returning[0].id
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
toggleEmailOverlayVisible();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
notification["error"]({
|
||||
|
||||
Reference in New Issue
Block a user