diff --git a/client/public/index.html b/client/public/index.html index f92ac3b35..c24a163ad 100644 --- a/client/public/index.html +++ b/client/public/index.html @@ -5,10 +5,7 @@ - + diff --git a/client/public/kavia.png b/client/public/kavia.png deleted file mode 100644 index be947430a..000000000 Binary files a/client/public/kavia.png and /dev/null differ diff --git a/client/src/App/registerServiceWorker.component.jsx b/client/src/App/registerServiceWorker.component.jsx index 7136574f8..e2909bb00 100644 --- a/client/src/App/registerServiceWorker.component.jsx +++ b/client/src/App/registerServiceWorker.component.jsx @@ -5,7 +5,7 @@ import React from "react"; import * as serviceWorker from "../serviceWorker"; const onServiceWorkerUpdate = (registration) => { - console.log("[RSW] onServiceWorkerUpdate", registration); + console.log("onServiceWorkerUpdate", registration); const key = `open${Date.now()}`; const btn = ( @@ -37,6 +37,5 @@ const onServiceWorkerUpdate = (registration) => { // if (process.env.NODE_ENV === "production") { // console.log("SWR Registering SW..."); -console.log("Registering Service Worker..."); serviceWorker.register({ onUpdate: onServiceWorkerUpdate }); // } diff --git a/client/src/components/job-checklist/components/job-checklist-template-list/job-checklist-template-list.component.jsx b/client/src/components/job-checklist/components/job-checklist-template-list/job-checklist-template-list.component.jsx index 28ecc01bb..382a2781d 100644 --- a/client/src/components/job-checklist/components/job-checklist-template-list/job-checklist-template-list.component.jsx +++ b/client/src/components/job-checklist/components/job-checklist-template-list/job-checklist-template-list.component.jsx @@ -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 }) { ); } -export default connect( - mapStateToProps, - mapDispatchToProps -)(JobIntakeTemplateList); diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx index 82cbc4a49..103948668 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.csi.component.jsx @@ -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, }, diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx index ca238bff1..8d10749bc 100644 --- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx +++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx @@ -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 }, }, {}, diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx index 513c7ca91..2729a89a2 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx @@ -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, }, diff --git a/client/src/components/payment-modal/payment-modal.container.jsx b/client/src/components/payment-modal/payment-modal.container.jsx index a480b4415..b73310c4b 100644 --- a/client/src/components/payment-modal/payment-modal.container.jsx +++ b/client/src/components/payment-modal/payment-modal.container.jsx @@ -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, }, diff --git a/client/src/components/print-center-jobs/print-center-jobs.component.jsx b/client/src/components/print-center-jobs/print-center-jobs.component.jsx index 7fe518540..5b4d7ecc3 100644 --- a/client/src/components/print-center-jobs/print-center-jobs.component.jsx +++ b/client/src/components/print-center-jobs/print-center-jobs.component.jsx @@ -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 (
@@ -45,17 +33,15 @@ export function PrintCenterJobsComponent({ bodyshop, printCenterModal }) { -
    - {JobsReportsList.filter((t) => t.drivingId === "job").map( - (item) => ( - - ) - )} +
      + {JobsReportsList.map((item) => ( + + ))}
    diff --git a/client/src/components/print-center-modal/print-center-modal.container.jsx b/client/src/components/print-center-modal/print-center-modal.container.jsx index 0d53b1e65..b812e62ef 100644 --- a/client/src/components/print-center-modal/print-center-modal.container.jsx +++ b/client/src/components/print-center-modal/print-center-modal.container.jsx @@ -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 ( toggleModalVisible()} - width='90%' - title={` ${t("printcenter.labels.title")} ${type} - ${id}`} - destroyOnClose> + width="90%" + title={` ${t("printcenter.labels.title")} - ${type}`} + destroyOnClose + > ); diff --git a/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx b/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx index 7319e4f3e..ac12718f0 100644 --- a/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx +++ b/client/src/components/print-center-speed-print/print-center-speed-print.component.jsx @@ -66,14 +66,18 @@ export function PrintCenterSpeedPrint({ bodyshop, jobId }) { ); } -const renderTemplateList = (templates) => ( - - {templates.map((template, idx) => { - if (idx === templates.length - 1) return TemplateList()[template].title; - return `${TemplateList()[template].title}, `; - })} - -); +const renderTemplateList = (templates) => { + const TemplateListGenerated = TemplateList(); + return ( + + {templates.map((template, idx) => { + if (idx === templates.length - 1) + return TemplateListGenerated[template].title; + return `${TemplateListGenerated[template].title}, `; + })} + + ); +}; export default connect( mapStateToProps, diff --git a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx index 97fca225d..ff051e291 100644 --- a/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx +++ b/client/src/components/schedule-job-modal/schedule-job-modal.container.jsx @@ -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, }, diff --git a/client/src/components/shop-info/shop-info.intake.component.jsx b/client/src/components/shop-info/shop-info.intake.component.jsx index d53907020..ef38f181c 100644 --- a/client/src/components/shop-info/shop-info.intake.component.jsx +++ b/client/src/components/shop-info/shop-info.intake.component.jsx @@ -16,6 +16,7 @@ const SelectorDiv = styled.div` export default function ShopInfoIntakeChecklistComponent({ form }) { const { t } = useTranslation(); + const TemplateListGenerated = TemplateList(); return (
    @@ -128,12 +129,12 @@ export default function ShopInfoIntakeChecklistComponent({ form }) { ]} > @@ -250,12 +251,12 @@ export default function ShopInfoIntakeChecklistComponent({ form }) { ]} > diff --git a/client/src/components/shop-info/shop-info.speedprint.component.jsx b/client/src/components/shop-info/shop-info.speedprint.component.jsx index df3bf9201..c754f3abe 100644 --- a/client/src/components/shop-info/shop-info.speedprint.component.jsx +++ b/client/src/components/shop-info/shop-info.speedprint.component.jsx @@ -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 (
    @@ -16,7 +18,7 @@ export default function ShopInfoSpeedPrint({ bodyshop, form }) {
    {fields.map((field, index) => ( -
    + @@ -81,7 +83,7 @@ export default function ShopInfoSpeedPrint({ bodyshop, form }) { index={index} total={fields.length} /> -
    +
    ))} diff --git a/client/src/components/shop-template-add/shop-template-add.component.jsx b/client/src/components/shop-template-add/shop-template-add.component.jsx index 47a071652..619e70f4e 100644 --- a/client/src/components/shop-template-add/shop-template-add.component.jsx +++ b/client/src/components/shop-template-add/shop-template-add.component.jsx @@ -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 = ( {availableTemplateKeys.length > 0 ? ( availableTemplateKeys.map((tkey) => ( - {TemplateList()[tkey].title} + {TemplateListGenerated[tkey].title} )) ) : (
    {t("bodyshop.labels.notemplatesavailable")}
    diff --git a/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx b/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx index d9a39caa8..e6322f862 100644 --- a/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx +++ b/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx @@ -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, diff --git a/client/src/index.js b/client/src/index.js index 4584a4b5a..5a4a2b851 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -1,16 +1,16 @@ +import Dinero from "dinero.js"; import React from "react"; import ReactDOM from "react-dom"; -import { BrowserRouter } from "react-router-dom"; -import "./translations/i18n"; -//import * as serviceWorker from "./serviceWorker"; import { Provider } from "react-redux"; +import { BrowserRouter } from "react-router-dom"; import { PersistGate } from "redux-persist/integration/react"; -import { store, persistor } from "./redux/store"; import AppContainer from "./App/App.container"; -import "./index.css"; -import LoadingSpinner from "./components/loading-spinner/loading-spinner.component"; import "./App/registerServiceWorker.component"; -import Dinero from "dinero.js"; +import LoadingSpinner from "./components/loading-spinner/loading-spinner.component"; +import "./index.css"; +import { persistor, store } from "./redux/store"; +//import * as serviceWorker from "./serviceWorker"; //This is registered in a separate component to track notifications. +import "./translations/i18n"; require("dotenv").config(); diff --git a/client/src/utils/TemplateConstants.js b/client/src/utils/TemplateConstants.js index 68f6afc81..3fa1436bc 100644 --- a/client/src/utils/TemplateConstants.js +++ b/client/src/utils/TemplateConstants.js @@ -1,38 +1,75 @@ import i18n from "i18next"; - +import { store } from "../redux/store"; export const EmailSettings = { fromNameDefault: "ImEX Online", fromAddress: "noreply@imex.online", }; -export const TemplateList = (type, object) => { +export const TemplateList = (type, context) => { + const { bodyshop } = store.getState().user; + return { - appointment_confirmation: { - title: i18n.t("printcenter.appointments.appointment_confirmation"), - description: "Appointment Confirmation", - drivingId: "appointment", - key: "appointment_confirmation", - subject: "Appointment Confirmation", - }, - //Verified Completed items - estimate_detail: { - title: i18n.t("printcenter.jobs.estimate_detail"), - description: "Est Detail", - drivingId: "job", - key: "estimate_detail", - }, - parts_order_confirmation: { - title: i18n.t("printcenter.jobs.parts_order_confirmation"), - description: "Parts Order", - drivingId: "job", - key: "parts_order_confirmation", - subject: "Parts Order", - }, - parts_return_confirmation: { - title: i18n.t("printcenter.jobs.parts_return_confirmation"), - description: "Parts Return", - drivingId: "job", - key: "parts_return_confirmation", - }, + //If there's no type or the type is job, send it back. + ...(!type || type === "job" + ? { + estimate_detail: { + title: i18n.t("printcenter.jobs.estimate_detail"), + description: "Est Detail", + key: "estimate_detail", + disabled: false, + }, + } + : {}), + ...(!type || type === "appointment" + ? { + appointment_confirmation: { + title: i18n.t("printcenter.appointments.appointment_confirmation"), + description: "Appointment Confirmation", + key: "appointment_confirmation", + subject: "Appointment Confirmation", + disabled: false, + }, + } + : {}), + ...(!type || type === "partsorder" + ? { + parts_order_confirmation: { + title: i18n.t("printcenter.jobs.parts_order_confirmation"), + description: "Parts Order", + key: "parts_order_confirmation", + subject: `${bodyshop.shopname} Parts Order ${ + (context && context.job && context.job.ro_number) || "" + }`, + disabled: false, + }, + parts_return_confirmation: { + title: i18n.t("printcenter.jobs.parts_return_confirmation"), + description: "Parts Return", + key: "parts_return_confirmation", + disabled: false, + }, + } + : {}), + ...(!type || type === "payment" + ? { + payment_confirmation: { + title: i18n.t("printcenter.jobs.payment_confirmation"), + description: "Est Detail", + key: "payment_confirmation", + disabled: false, + }, + } + : {}), + ...(!type || type === "csi" + ? { + csi_invitation: { + title: i18n.t("printcenter.jobs.csi_invitation"), + description: "CSI invite", + key: "csi_invitation", + disabled: false, + }, + } + : {}), + ...(!type || type === "job" ? {} : {}), }; }; diff --git a/package.json b/package.json index 4213f4e12..b21d7cad5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "npm": "6.11.3" }, "scripts": { - "setup": "npm i && cd firebase && npm i && cd .. && cd client && npm i && cd .. && cd admin && npm i", + "setup": "npm i && cd client && npm i", "admin": "cd admin && npm start", "client": "cd client && npm start", "server": "nodemon server.js",