Merged in release/2025-03-14 (pull request #2192)

Release/2025-03-14 into test-AIO - IO-3172 IO-3166
This commit is contained in:
Dave Richer
2025-03-12 16:09:26 +00:00
7 changed files with 427 additions and 708 deletions

View File

@@ -208,28 +208,32 @@ function Header({
key: "allpayments", key: "allpayments",
id: "header-accounting-allpayments", id: "header-accounting-allpayments",
icon: <BankFilled />, icon: <BankFilled />,
label: ( label: <Link to="/manage/payments">{t("menus.header.allpayments")}</Link>
<Link to="/manage/payments">
<LockWrapper featureName="payments" bodyshop={bodyshop}>
{t("menus.header.allpayments")}
</LockWrapper>
</Link>
)
}, },
{ {
key: "enterpayments", key: "enterpayments",
id: "header-accounting-enterpayments", id: "header-accounting-enterpayments",
icon: <FaCreditCard />, icon: <Icon component={FaCreditCard} />,
label: ( label: t("menus.header.enterpayment"),
<LockWrapper featureName="payments" bodyshop={bodyshop}> onClick: () => {
{t("menus.header.enterpayment")}
</LockWrapper>
),
onClick: () =>
HasFeatureAccess({ featureName: "payments", bodyshop }) &&
setPaymentContext({ setPaymentContext({
actions: {}, actions: {},
context: null context: null
});
}
}
);
if (ImEXPay.treatment === "on") {
accountingChildren.push({
key: "entercardpayments",
id: "header-accounting-entercardpayments",
icon: <Icon component={FaCreditCard} />,
label: t("menus.header.entercardpayment"),
onClick: () => {
setCardPaymentContext({
actions: {},
context: null
}) })
}, },
...(ImEXPay.treatment === "on" ...(ImEXPay.treatment === "on"

View File

@@ -28,11 +28,10 @@ import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
import FormDateTimePickerComponent from "../form-date-time-picker/form-date-time-picker.component"; import FormDateTimePickerComponent from "../form-date-time-picker/form-date-time-picker.component";
import LockerWrapperComponent from "../lock-wrapper/lock-wrapper.component"; import LockerWrapperComponent from "../lock-wrapper/lock-wrapper.component";
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component"; import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx";
import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util"; import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util";
import DuplicateJob from "./jobs-detail-header-actions.duplicate.util"; import DuplicateJob from "./jobs-detail-header-actions.duplicate.util";
import JobsDetailHeaderActionsToggleProduction from "./jobs-detail-header-actions.toggle-production"; import JobsDetailHeaderActionsToggleProduction from "./jobs-detail-header-actions.toggle-production";
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
@@ -775,15 +774,14 @@ export function JobsDetailHeaderActions({
key: "enterpayments", key: "enterpayments",
id: "job-actions-enterpayments", id: "job-actions-enterpayments",
disabled: !job.converted, disabled: !job.converted,
label: <LockerWrapperComponent featureName="payments">{t("menus.header.enterpayment")}</LockerWrapperComponent>, label: t("menus.header.enterpayment"),
onClick: () => { onClick: () => {
logImEXEvent("job_header_enter_payment"); logImEXEvent("job_header_enter_payment");
HasFeatureAccess({ featureName: "payments", bodyshop }) && setPaymentContext({
setPaymentContext({ actions: {},
actions: {}, context: { jobid: job.id }
context: { jobid: job.id } });
});
} }
}); });

View File

@@ -1,6 +1,6 @@
import { useQuery } from "@apollo/client"; import { useQuery } from "@apollo/client";
import queryString from "query-string"; import queryString from "query-string";
import React, { useEffect } from "react"; import { useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
@@ -10,23 +10,17 @@ import PaymentsListPaginated from "../../components/payments-list-paginated/paym
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component"; import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
import { QUERY_ALL_PAYMENTS_PAGINATED } from "../../graphql/payments.queries"; import { QUERY_ALL_PAYMENTS_PAGINATED } from "../../graphql/payments.queries";
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions"; import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { pageLimit } from "../../utils/config"; import { pageLimit } from "../../utils/config";
import FeatureWrapperComponent from "../../components/feature-wrapper/feature-wrapper.component";
import InstanceRenderManager from "../../utils/instanceRenderMgr"; import InstanceRenderManager from "../../utils/instanceRenderMgr";
import UpsellComponent, { upsellEnum } from "../../components/upsell/upsell.component";
import { Card } from "antd";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({});
bodyshop: selectBodyshop
});
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)), setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)) setSelectedHeader: (key) => dispatch(setSelectedHeader(key))
}); });
export function AllJobs({ bodyshop, setBreadcrumbs, setSelectedHeader }) { export function AllJobs({ setBreadcrumbs, setSelectedHeader }) {
const searchParams = queryString.parse(useLocation().search); const searchParams = queryString.parse(useLocation().search);
const { page, sortcolumn, sortorder, searchObj } = searchParams; const { page, sortcolumn, sortorder, searchObj } = searchParams;
@@ -60,25 +54,15 @@ export function AllJobs({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
if (error) return <AlertComponent message={error.message} type="error" />; if (error) return <AlertComponent message={error.message} type="error" />;
return ( return (
<FeatureWrapperComponent <RbacWrapper action="payments:list">
featureName="payments" <PaymentsListPaginated
noauth={ refetch={refetch}
<Card> loading={loading}
<UpsellComponent upsell={upsellEnum().payments.general} /> searchParams={searchParams}
</Card> total={data ? data.payments_aggregate.aggregate.count : 0}
} payments={data ? data.payments : []}
z />
> </RbacWrapper>
<RbacWrapper action="payments:list">
<PaymentsListPaginated
refetch={refetch}
loading={loading}
searchParams={searchParams}
total={data ? data.payments_aggregate.aggregate.count : 0}
payments={data ? data.payments : []}
/>
</RbacWrapper>
</FeatureWrapperComponent>
); );
} }

View File

@@ -1,10 +1,13 @@
/** Notification Scenarios
* @description This file contains the scenarios for job notifications.
* @type {string[]}
*/
const notificationScenarios = [ const notificationScenarios = [
"job-assigned-to-me", "job-assigned-to-me",
"bill-posted", "bill-posted",
"critical-parts-status-changed", "critical-parts-status-changed",
"part-marked-back-ordered", "part-marked-back-ordered",
"new-note-added", "new-note-added",
"supplement-imported",
"schedule-dates-changed", "schedule-dates-changed",
"tasks-updated-created", "tasks-updated-created",
"new-media-added-reassigned", "new-media-added-reassigned",
@@ -14,6 +17,7 @@ const notificationScenarios = [
"job-status-change", "job-status-change",
"payment-collected-completed", "payment-collected-completed",
"alternate-transport-changed" "alternate-transport-changed"
// "supplement-imported", // Disabled for now
]; ];
export { notificationScenarios }; export { notificationScenarios };

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
const { const {
jobAssignedToMeBuilder, jobAssignedToMeBuilder,
billPostedHandler, billPostedBuilder,
newNoteAddedBuilder, newNoteAddedBuilder,
scheduledDatesChangedBuilder, scheduledDatesChangedBuilder,
tasksUpdatedCreatedBuilder, tasksUpdatedCreatedBuilder,
@@ -30,10 +30,12 @@ const { isFunction } = require("lodash");
* - builder {Function}: A function to handle the scenario. * - builder {Function}: A function to handle the scenario.
* - onlyTruthyValues {boolean|Array<string>}: Specifies fields that must have truthy values for the scenario to match. * - onlyTruthyValues {boolean|Array<string>}: Specifies fields that must have truthy values for the scenario to match.
* - filterCallback {Function}: Optional callback (sync or async) to further filter the scenario based on event data (returns boolean). * - filterCallback {Function}: Optional callback (sync or async) to further filter the scenario based on event data (returns boolean).
* - enabled {boolean}: If true, the scenario is active; if false or omitted, the scenario is skipped.
*/ */
const notificationScenarios = [ const notificationScenarios = [
{ {
key: "job-assigned-to-me", key: "job-assigned-to-me",
enabled: true,
table: "jobs", table: "jobs",
fields: ["employee_prep", "employee_body", "employee_csr", "employee_refinish"], fields: ["employee_prep", "employee_body", "employee_csr", "employee_refinish"],
matchToUserFields: ["employee_prep", "employee_body", "employee_csr", "employee_refinish"], matchToUserFields: ["employee_prep", "employee_body", "employee_csr", "employee_refinish"],
@@ -41,24 +43,28 @@ const notificationScenarios = [
}, },
{ {
key: "bill-posted", key: "bill-posted",
enabled: true,
table: "bills", table: "bills",
builder: billPostedHandler, builder: billPostedBuilder,
onNew: true onNew: true
}, },
{ {
key: "new-note-added", key: "new-note-added",
enabled: true,
table: "notes", table: "notes",
builder: newNoteAddedBuilder, builder: newNoteAddedBuilder,
onNew: true onNew: true
}, },
{ {
key: "schedule-dates-changed", key: "schedule-dates-changed",
enabled: true,
table: "jobs", table: "jobs",
fields: ["scheduled_in", "scheduled_completion", "scheduled_delivery"], fields: ["scheduled_in", "scheduled_completion", "scheduled_delivery"],
builder: scheduledDatesChangedBuilder builder: scheduledDatesChangedBuilder
}, },
{ {
key: "tasks-updated-created", key: "tasks-updated-created",
enabled: true,
table: "tasks", table: "tasks",
fields: ["updated_at"], fields: ["updated_at"],
// onNew: true, // onNew: true,
@@ -66,12 +72,14 @@ const notificationScenarios = [
}, },
{ {
key: "job-status-change", key: "job-status-change",
enabled: true,
table: "jobs", table: "jobs",
fields: ["status"], fields: ["status"],
builder: jobStatusChangeBuilder builder: jobStatusChangeBuilder
}, },
{ {
key: "job-added-to-production", key: "job-added-to-production",
enabled: true,
table: "jobs", table: "jobs",
fields: ["inproduction"], fields: ["inproduction"],
onlyTruthyValues: ["inproduction"], onlyTruthyValues: ["inproduction"],
@@ -79,36 +87,42 @@ const notificationScenarios = [
}, },
{ {
key: "alternate-transport-changed", key: "alternate-transport-changed",
enabled: true,
table: "jobs", table: "jobs",
fields: ["alt_transport"], fields: ["alt_transport"],
builder: alternateTransportChangedBuilder builder: alternateTransportChangedBuilder
}, },
{ {
key: "new-time-ticket-posted", key: "new-time-ticket-posted",
enabled: true,
table: "timetickets", table: "timetickets",
builder: newTimeTicketPostedBuilder builder: newTimeTicketPostedBuilder
}, },
{ {
key: "intake-delivery-checklist-completed", key: "intake-delivery-checklist-completed",
enabled: true,
table: "jobs", table: "jobs",
fields: ["intakechecklist", "deliverchecklist"], fields: ["intakechecklist", "deliverchecklist"],
builder: intakeDeliveryChecklistCompletedBuilder builder: intakeDeliveryChecklistCompletedBuilder
}, },
{ {
key: "payment-collected-completed", key: "payment-collected-completed",
enabled: true,
table: "payments", table: "payments",
onNew: true, onNew: true,
builder: paymentCollectedCompletedBuilder builder: paymentCollectedCompletedBuilder
}, },
{ {
// MAKE SURE YOU ARE NOT ON A LMS ENVIRONMENT // Only works on a non LMS ENV
key: "new-media-added-reassigned", key: "new-media-added-reassigned",
enabled: true,
table: "documents", table: "documents",
fields: ["jobid"], fields: ["jobid"],
builder: newMediaAddedReassignedBuilder builder: newMediaAddedReassignedBuilder
}, },
{ {
key: "critical-parts-status-changed", key: "critical-parts-status-changed",
enabled: true,
table: "joblines", table: "joblines",
fields: ["status"], fields: ["status"],
onlyTruthyValues: ["status"], onlyTruthyValues: ["status"],
@@ -117,6 +131,7 @@ const notificationScenarios = [
}, },
{ {
key: "part-marked-back-ordered", key: "part-marked-back-ordered",
enabled: true,
table: "joblines", table: "joblines",
fields: ["status"], fields: ["status"],
builder: partMarkedBackOrderedBuilder, builder: partMarkedBackOrderedBuilder,
@@ -133,12 +148,11 @@ const notificationScenarios = [
} }
} }
}, },
// -------------- Difficult --------------- // Holding off on this one for now, spans multiple tables
// Holding off on this one for now
{ {
key: "supplement-imported", key: "supplement-imported",
enabled: false,
builder: supplementImportedBuilder builder: supplementImportedBuilder
// spans multiple tables,
} }
]; ];
@@ -159,6 +173,11 @@ const notificationScenarios = [
const getMatchingScenarios = async (eventData, getBodyshopFromRedis) => { const getMatchingScenarios = async (eventData, getBodyshopFromRedis) => {
const matches = []; const matches = [];
for (const scenario of notificationScenarios) { for (const scenario of notificationScenarios) {
// Check if the scenario is enabled; skip if not explicitly true
if (scenario.enabled !== true) {
continue;
}
// If eventData has a table, then only scenarios with a table property that matches should be considered. // If eventData has a table, then only scenarios with a table property that matches should be considered.
if (eventData.table) { if (eventData.table) {
if (!scenario.table || eventData.table.name !== scenario.table) { if (!scenario.table || eventData.table.name !== scenario.table) {

View File

@@ -35,7 +35,6 @@ const scenarioParser = async (req, jobIdField) => {
} = req; } = req;
// Step 1: Validate we know what user committed the action that fired the parser // Step 1: Validate we know what user committed the action that fired the parser
// console.log("Step 1");
const hasuraUserRole = event?.session_variables?.["x-hasura-role"]; const hasuraUserRole = event?.session_variables?.["x-hasura-role"];
const hasuraUserId = event?.session_variables?.["x-hasura-user-id"]; const hasuraUserId = event?.session_variables?.["x-hasura-user-id"];
@@ -52,7 +51,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 2: Extract just the jobId using the provided jobIdField // Step 2: Extract just the jobId using the provided jobIdField
// console.log("Step 2");
let jobId = null; let jobId = null;
if (jobIdField) { if (jobIdField) {
@@ -70,7 +68,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 3: Query job watchers associated with the job ID using GraphQL // Step 3: Query job watchers associated with the job ID using GraphQL
// console.log("Step 3");
const watcherData = await gqlClient.request(queries.GET_JOB_WATCHERS, { const watcherData = await gqlClient.request(queries.GET_JOB_WATCHERS, {
jobid: jobId jobid: jobId
@@ -96,7 +93,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 5: Perform the full event diff now that we know there are watchers // Step 5: Perform the full event diff now that we know there are watchers
// console.log("Step 5");
const eventData = await eventParser({ const eventData = await eventParser({
newData: event.data.new, newData: event.data.new,
@@ -107,7 +103,6 @@ const scenarioParser = async (req, jobIdField) => {
}); });
// Step 6: Extract body shop information from the job data // Step 6: Extract body shop information from the job data
// console.log("Step 6");
const bodyShopId = watcherData?.job?.bodyshop?.id; const bodyShopId = watcherData?.job?.bodyshop?.id;
const bodyShopName = watcherData?.job?.bodyshop?.shopname; const bodyShopName = watcherData?.job?.bodyshop?.shopname;
@@ -122,7 +117,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 7: Identify scenarios that match the event data and job context // Step 7: Identify scenarios that match the event data and job context
// console.log("Step 7");
const matchingScenarios = await getMatchingScenarios( const matchingScenarios = await getMatchingScenarios(
{ {
@@ -155,7 +149,6 @@ const scenarioParser = async (req, jobIdField) => {
}; };
// Step 8: Query notification settings for the job watchers // Step 8: Query notification settings for the job watchers
// console.log("Step 8");
const associationsData = await gqlClient.request(queries.GET_NOTIFICATION_ASSOCIATIONS, { const associationsData = await gqlClient.request(queries.GET_NOTIFICATION_ASSOCIATIONS, {
emails: jobWatchers.map((x) => x.email), emails: jobWatchers.map((x) => x.email),
@@ -173,7 +166,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 9: Filter scenario watchers based on their enabled notification methods // Step 9: Filter scenario watchers based on their enabled notification methods
// console.log("Step 9");
finalScenarioData.matchingScenarios = finalScenarioData.matchingScenarios.map((scenario) => ({ finalScenarioData.matchingScenarios = finalScenarioData.matchingScenarios.map((scenario) => ({
...scenario, ...scenario,
@@ -213,7 +205,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 10: Build and collect scenarios to dispatch notifications for // Step 10: Build and collect scenarios to dispatch notifications for
// console.log("Step 10");
const scenariosToDispatch = []; const scenariosToDispatch = [];
@@ -240,7 +231,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 11: Filter scenario fields to include only those that changed // Step 11: Filter scenario fields to include only those that changed
// console.log("Step 11");
const filteredScenarioFields = const filteredScenarioFields =
scenario.fields?.filter((field) => eventData.changedFieldNames.includes(field)) || []; scenario.fields?.filter((field) => eventData.changedFieldNames.includes(field)) || [];
@@ -274,7 +264,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 12: Dispatch email notifications to the email queue // Step 12: Dispatch email notifications to the email queue
// console.log("Step 12");
const emailsToDispatch = scenariosToDispatch.map((scenario) => scenario?.email); const emailsToDispatch = scenariosToDispatch.map((scenario) => scenario?.email);
if (!isEmpty(emailsToDispatch)) { if (!isEmpty(emailsToDispatch)) {
@@ -287,7 +276,6 @@ const scenarioParser = async (req, jobIdField) => {
} }
// Step 13: Dispatch app notifications to the app queue // Step 13: Dispatch app notifications to the app queue
// console.log("Step 13");
const appsToDispatch = scenariosToDispatch.map((scenario) => scenario?.app); const appsToDispatch = scenariosToDispatch.map((scenario) => scenario?.app);
if (!isEmpty(appsToDispatch)) { if (!isEmpty(appsToDispatch)) {