Compare commits
59 Commits
feature/IO
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
633d5668f0 | ||
|
|
00cc47553b | ||
|
|
3c360130a3 | ||
|
|
13e4143eeb | ||
|
|
68c7b184d2 | ||
|
|
9b85d15ff1 | ||
|
|
e7cf49a2ec | ||
|
|
04b29b6970 | ||
|
|
f5bc79cba7 | ||
|
|
2ae18681cb | ||
|
|
fda763476a | ||
|
|
999cbd80f4 | ||
|
|
ad2a5fe95b | ||
|
|
d835021069 | ||
|
|
c4b303aee1 | ||
|
|
e2c5a4cba4 | ||
|
|
fd04125ed1 | ||
|
|
a0566e76ab | ||
|
|
87e8b2ce27 | ||
|
|
5e24404e82 | ||
|
|
64a280b111 | ||
|
|
cf393e8f9e | ||
|
|
909a21023a | ||
|
|
0402156b4d | ||
|
|
94bdc6c43f | ||
|
|
9466d36e69 | ||
|
|
412efb06e5 | ||
|
|
da7e637183 | ||
|
|
2e95fa25af | ||
|
|
f6c63bbd74 | ||
|
|
0a654082c2 | ||
|
|
2c20b731d2 | ||
|
|
8a22897cdd | ||
|
|
677da61b52 | ||
|
|
6513434bd7 | ||
|
|
fe2600029f | ||
|
|
c5b4efedfb | ||
|
|
310321d0ab | ||
|
|
7e884c42ea | ||
|
|
e279bf41a4 | ||
|
|
4a060ab51c | ||
|
|
62c1c77a18 | ||
|
|
db19ecb28c | ||
|
|
51748ce28d | ||
|
|
4bbfd8a9da | ||
|
|
d4d2db2cac | ||
|
|
23483144e1 | ||
|
|
67d5dcb062 | ||
|
|
901a49e571 | ||
|
|
49ae107fde | ||
|
|
0135281bcd | ||
|
|
99cf95daf0 | ||
|
|
8c1758ae49 | ||
|
|
2d764921ff | ||
|
|
858a11f8b4 | ||
|
|
4859239f55 | ||
|
|
5c64d7185e | ||
|
|
152479bc08 | ||
|
|
3fe0e3a33c |
@@ -12791,27 +12791,6 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>allow_text_message</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>
|
||||
<concept_node>
|
||||
<name>checklist</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -42614,27 +42593,6 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>allow_text_message</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>
|
||||
<concept_node>
|
||||
<name>name</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
511
client/package-lock.json
generated
511
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -13,18 +13,18 @@
|
||||
"@emotion/is-prop-valid": "^1.3.1",
|
||||
"@fingerprintjs/fingerprintjs": "^4.6.1",
|
||||
"@firebase/analytics": "^0.10.16",
|
||||
"@firebase/app": "^0.13.0",
|
||||
"@firebase/auth": "^1.10.5",
|
||||
"@firebase/firestore": "^4.7.15",
|
||||
"@firebase/app": "^0.13.1",
|
||||
"@firebase/auth": "^1.10.6",
|
||||
"@firebase/firestore": "^4.7.17",
|
||||
"@firebase/messaging": "^0.12.21",
|
||||
"@jsreport/browser-client": "^3.1.0",
|
||||
"@reduxjs/toolkit": "^2.8.2",
|
||||
"@sentry/cli": "^2.45.0",
|
||||
"@sentry/react": "^9.22.0",
|
||||
"@sentry/cli": "^2.46.0",
|
||||
"@sentry/react": "^9.27.0",
|
||||
"@sentry/vite-plugin": "^3.5.0",
|
||||
"@splitsoftware/splitio-react": "^2.1.1",
|
||||
"@splitsoftware/splitio-react": "^2.3.1",
|
||||
"@tanem/react-nprogress": "^5.0.53",
|
||||
"antd": "^5.25.2",
|
||||
"antd": "^5.25.4",
|
||||
"apollo-link-logger": "^2.0.1",
|
||||
"apollo-link-sentry": "^4.3.0",
|
||||
"autosize": "^6.0.1",
|
||||
@@ -41,24 +41,25 @@
|
||||
"i18next": "^24.2.3",
|
||||
"i18next-browser-languagedetector": "^8.1.0",
|
||||
"immutability-helper": "^3.1.1",
|
||||
"libphonenumber-js": "^1.12.8",
|
||||
"libphonenumber-js": "^1.12.9",
|
||||
"logrocket": "^9.0.2",
|
||||
"markerjs2": "^2.32.4",
|
||||
"memoize-one": "^6.0.0",
|
||||
"normalize-url": "^8.0.1",
|
||||
"normalize-url": "^8.0.2",
|
||||
"object-hash": "^3.0.0",
|
||||
"phone": "^3.1.59",
|
||||
"prop-types": "^15.8.1",
|
||||
"query-string": "^9.2.0",
|
||||
"raf-schd": "^4.0.3",
|
||||
"react": "^18.3.1",
|
||||
"react-big-calendar": "^1.18.0",
|
||||
"react-big-calendar": "^1.19.2",
|
||||
"react-color": "^2.19.3",
|
||||
"react-cookie": "^8.0.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-drag-listview": "^2.0.0",
|
||||
"react-grid-gallery": "^1.0.1",
|
||||
"react-grid-layout": "1.3.4",
|
||||
"react-i18next": "^15.4.1",
|
||||
"react-i18next": "^15.5.2",
|
||||
"react-icons": "^5.5.0",
|
||||
"react-image-lightbox": "^5.1.4",
|
||||
"react-markdown": "^10.1.0",
|
||||
@@ -69,7 +70,7 @@
|
||||
"react-resizable": "^3.0.5",
|
||||
"react-router-dom": "^6.30.0",
|
||||
"react-sticky": "^6.0.3",
|
||||
"react-virtuoso": "^4.12.7",
|
||||
"react-virtuoso": "^4.12.8",
|
||||
"recharts": "^2.15.2",
|
||||
"redux": "^5.0.1",
|
||||
"redux-actions": "^3.0.3",
|
||||
@@ -77,7 +78,7 @@
|
||||
"redux-saga": "^1.3.0",
|
||||
"redux-state-sync": "^3.1.4",
|
||||
"reselect": "^5.1.1",
|
||||
"sass": "^1.89.0",
|
||||
"sass": "^1.89.1",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"styled-components": "^6.1.18",
|
||||
"subscriptions-transport-ws": "^0.11.0",
|
||||
@@ -133,14 +134,14 @@
|
||||
"@dotenvx/dotenvx": "^1.44.1",
|
||||
"@emotion/babel-plugin": "^11.13.5",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@eslint/js": "^9.27.0",
|
||||
"@eslint/js": "^9.28.0",
|
||||
"@playwright/test": "^1.51.1",
|
||||
"@sentry/webpack-plugin": "^3.5.0",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"browserslist": "^4.24.5",
|
||||
"@vitejs/plugin-react": "^4.5.1",
|
||||
"browserslist": "^4.25.0",
|
||||
"browserslist-to-esbuild": "^2.1.1",
|
||||
"chalk": "^5.4.1",
|
||||
"eslint": "^8.57.1",
|
||||
@@ -160,7 +161,7 @@
|
||||
"vite-plugin-node-polyfills": "^0.23.0",
|
||||
"vite-plugin-pwa": "^1.0.0",
|
||||
"vite-plugin-style-import": "^2.0.0",
|
||||
"vitest": "^3.1.4",
|
||||
"vitest": "^3.2.3",
|
||||
"workbox-window": "^7.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ import { useApolloClient, useMutation } from "@apollo/client";
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Button, Checkbox, Form, Modal, Space } from "antd";
|
||||
import _ from "lodash";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { INSERT_NEW_BILL } from "../../graphql/bills.queries";
|
||||
import { UPDATE_INVENTORY_LINES } from "../../graphql/inventory.queries";
|
||||
import { UPDATE_JOB_LINE } from "../../graphql/jobs-lines.queries";
|
||||
@@ -24,7 +25,6 @@ import BillFormContainer from "../bill-form/bill-form.container";
|
||||
import { CalculateBillTotal } from "../bill-form/bill-form.totals.utility";
|
||||
import { handleUpload as handleLocalUpload } from "../documents-local-upload/documents-local-upload.utility";
|
||||
import { handleUpload } from "../documents-upload/documents-upload.utility";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
billEnterModal: selectBillEnterModal,
|
||||
@@ -196,7 +196,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
||||
job: { lbr_adjustments: newAdjustments }
|
||||
}
|
||||
});
|
||||
if (!!jobUpdate.errors) {
|
||||
if (jobUpdate.errors) {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.saving", {
|
||||
message: JSON.stringify(jobUpdate.errors)
|
||||
@@ -213,7 +213,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
||||
variables: { partsLineIds: markPolReceived.map((p) => p.id) },
|
||||
refetchQueries: ["QUERY_PARTS_BILLS_BY_JOBID"]
|
||||
});
|
||||
if (!!r2.errors) {
|
||||
if (r2.errors) {
|
||||
setLoading(false);
|
||||
setEnterAgain(false);
|
||||
notification["error"]({
|
||||
@@ -224,7 +224,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
||||
}
|
||||
}
|
||||
|
||||
if (!!r1.errors) {
|
||||
if (r1.errors) {
|
||||
setLoading(false);
|
||||
setEnterAgain(false);
|
||||
notification["error"]({
|
||||
@@ -244,7 +244,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
||||
consumedbybillid: billId
|
||||
}
|
||||
});
|
||||
if (!!r2.errors) {
|
||||
if (r2.errors) {
|
||||
setLoading(false);
|
||||
setEnterAgain(false);
|
||||
notification["error"]({
|
||||
@@ -396,7 +396,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
||||
{t("bills.labels.generatepartslabel")}
|
||||
</Checkbox>
|
||||
<Button onClick={handleCancel}>{t("general.actions.cancel")}</Button>
|
||||
<Button loading={loading} onClick={() => form.submit()}>
|
||||
<Button loading={loading} onClick={() => form.submit()} id="save-bill-enter-modal">
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
{billEnterModal.context && billEnterModal.context.id ? null : (
|
||||
@@ -406,6 +406,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
||||
onClick={() => {
|
||||
setEnterAgain(true);
|
||||
}}
|
||||
id="save-and-new-bill-enter-modal"
|
||||
>
|
||||
{t("general.actions.saveandnew")}
|
||||
</Button>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EditFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Card, Checkbox, Input, Space, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FaTasks } from "react-icons/fa";
|
||||
import { connect } from "react-redux";
|
||||
@@ -209,6 +209,7 @@ export function BillsListTableComponent({
|
||||
}
|
||||
});
|
||||
}}
|
||||
id="reconcile-bills-button"
|
||||
>
|
||||
<LockerWrapperComponent featureName="bills"> {t("jobs.actions.reconcile")}</LockerWrapperComponent>
|
||||
</Button>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Button, Form, InputNumber, Popover, Space } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
|
||||
export default function CABCpvrtCalculator({ disabled, form }) {
|
||||
const [visibility, setVisibility] = useState(false);
|
||||
|
||||
@@ -39,7 +40,7 @@ export default function CABCpvrtCalculator({ disabled, form }) {
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover destroyTooltipOnHide content={popContent} open={visibility} disabled={disabled}>
|
||||
<Popover destroyOnHidden content={popContent} open={visibility} disabled={disabled}>
|
||||
<Button disabled={disabled} onClick={() => setVisibility(true)}>
|
||||
<CalculatorFilled />
|
||||
</Button>
|
||||
|
||||
@@ -202,8 +202,6 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
||||
text: message.text
|
||||
};
|
||||
|
||||
// Add cases for other known message types as needed
|
||||
|
||||
default:
|
||||
// Log a warning for unhandled message types
|
||||
logLocal("handleMessageChanged - Unhandled message type", { type: message.type });
|
||||
@@ -211,7 +209,7 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
||||
}
|
||||
}
|
||||
|
||||
return messageRef; // Keep other messages unchanged
|
||||
return messageRef;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -245,11 +243,8 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
||||
});
|
||||
|
||||
const updatedList = existingList?.conversations
|
||||
? [
|
||||
newConversation,
|
||||
...existingList.conversations.filter((conv) => conv.id !== newConversation.id) // Prevent duplicates
|
||||
]
|
||||
: [newConversation];
|
||||
? [newConversation, ...existingList.conversations.filter((conv) => conv.id !== newConversation.id)]
|
||||
: [newConversation]; // Prevent duplicates
|
||||
|
||||
client.cache.writeQuery({
|
||||
query: CONVERSATION_LIST_QUERY,
|
||||
@@ -403,6 +398,7 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
logLocal("handleConversationChanged - Unhandled type", { type });
|
||||
client.cache.modify({
|
||||
@@ -419,10 +415,95 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Existing handler for phone number opt-out
|
||||
const handlePhoneNumberOptedOut = async (data) => {
|
||||
const { bodyshopid, phone_number } = data;
|
||||
logLocal("handlePhoneNumberOptedOut - Start", data);
|
||||
|
||||
try {
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
phone_number_opt_out(existing = [], { readField }) {
|
||||
const phoneNumberExists = existing.some(
|
||||
(ref) => readField("phone_number", ref) === phone_number && readField("bodyshopid", ref) === bodyshopid
|
||||
);
|
||||
|
||||
if (phoneNumberExists) {
|
||||
logLocal("handlePhoneNumberOptedOut - Phone number already in cache", { phone_number, bodyshopid });
|
||||
return existing;
|
||||
}
|
||||
|
||||
const newOptOut = {
|
||||
__typename: "phone_number_opt_out",
|
||||
id: `temporary-${phone_number}-${Date.now()}`,
|
||||
bodyshopid,
|
||||
phone_number,
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString()
|
||||
};
|
||||
|
||||
return [...existing, newOptOut];
|
||||
}
|
||||
},
|
||||
broadcast: true
|
||||
});
|
||||
|
||||
client.cache.evict({
|
||||
id: "ROOT_QUERY",
|
||||
fieldName: "phone_number_opt_out",
|
||||
args: { bodyshopid, search: phone_number }
|
||||
});
|
||||
client.cache.gc();
|
||||
|
||||
logLocal("handlePhoneNumberOptedOut - Cache updated successfully", data);
|
||||
} catch (error) {
|
||||
console.error("Error updating cache for phone number opt-out:", error);
|
||||
logLocal("handlePhoneNumberOptedOut - Error", { error: error.message });
|
||||
}
|
||||
};
|
||||
|
||||
// New handler for phone number opt-in
|
||||
const handlePhoneNumberOptedIn = async (data) => {
|
||||
const { bodyshopid, phone_number } = data;
|
||||
logLocal("handlePhoneNumberOptedIn - Start", data);
|
||||
|
||||
try {
|
||||
// Update the Apollo cache for GET_PHONE_NUMBER_OPT_OUTS by removing the phone number
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
phone_number_opt_out(existing = [], { readField }) {
|
||||
// Filter out the phone number from the opt-out list
|
||||
return existing.filter(
|
||||
(ref) => !(readField("phone_number", ref) === phone_number && readField("bodyshopid", ref) === bodyshopid)
|
||||
);
|
||||
}
|
||||
},
|
||||
broadcast: true // Trigger UI updates
|
||||
});
|
||||
|
||||
// Evict the cache entry to force a refetch on next query
|
||||
client.cache.evict({
|
||||
id: "ROOT_QUERY",
|
||||
fieldName: "phone_number_opt_out",
|
||||
args: { bodyshopid, search: phone_number }
|
||||
});
|
||||
client.cache.gc();
|
||||
|
||||
logLocal("handlePhoneNumberOptedIn - Cache updated successfully", data);
|
||||
} catch (error) {
|
||||
console.error("Error updating cache for phone number opt-in:", error);
|
||||
logLocal("handlePhoneNumberOptedIn - Error", { error: error.message });
|
||||
}
|
||||
};
|
||||
|
||||
socket.on("new-message-summary", handleNewMessageSummary);
|
||||
socket.on("new-message-detailed", handleNewMessageDetailed);
|
||||
socket.on("message-changed", handleMessageChanged);
|
||||
socket.on("conversation-changed", handleConversationChanged);
|
||||
socket.on("phone-number-opted-out", handlePhoneNumberOptedOut);
|
||||
socket.on("phone-number-opted-in", handlePhoneNumberOptedIn);
|
||||
};
|
||||
|
||||
export const unregisterMessagingHandlers = ({ socket }) => {
|
||||
@@ -431,4 +512,6 @@ export const unregisterMessagingHandlers = ({ socket }) => {
|
||||
socket.off("new-message-detailed");
|
||||
socket.off("message-changed");
|
||||
socket.off("conversation-changed");
|
||||
socket.off("phone-number-opted-out");
|
||||
socket.off("phone-number-opted-in");
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Badge, Card, List, Space, Tag } from "antd";
|
||||
import { Badge, Card, List, Space, Tag, Tooltip } from "antd";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { Virtuoso } from "react-virtuoso";
|
||||
@@ -9,6 +9,7 @@ import { TimeAgoFormatter } from "../../utils/DateFormatter";
|
||||
import PhoneFormatter from "../../utils/PhoneFormatter";
|
||||
import { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
|
||||
import _ from "lodash";
|
||||
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
||||
import "./chat-conversation-list.styles.scss";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { GET_PHONE_NUMBER_OPT_OUTS } from "../../graphql/phone-number-opt-out.queries.js";
|
||||
@@ -88,7 +89,13 @@ function ChatConversationListComponent({ conversationList, selectedConversation,
|
||||
const cardExtra = (
|
||||
<>
|
||||
<Badge count={item.messages_aggregate.aggregate.count} />
|
||||
{hasOptOutEntry && <Tag color="red">{t("messaging.labels.no_consent")}</Tag>}
|
||||
{hasOptOutEntry && (
|
||||
<Tooltip title={t("consent.text_body")}>
|
||||
<Tag color="red" icon={<ExclamationCircleOutlined />}>
|
||||
{t("messaging.labels.no_consent")}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ function ChatConversationContainer({ bodyshop, selectedConversation }) {
|
||||
userid
|
||||
created_at
|
||||
read
|
||||
is_system
|
||||
}
|
||||
`,
|
||||
data: message
|
||||
|
||||
@@ -13,13 +13,14 @@ import JobDocumentsGalleryExternal from "../jobs-documents-gallery/jobs-document
|
||||
import JobsDocumentImgproxyGalleryExternal from "../jobs-documents-imgproxy-gallery/jobs-documents-imgproxy-gallery.external.component";
|
||||
import JobDocumentsLocalGalleryExternal from "../jobs-documents-local-gallery/jobs-documents-local-gallery.external.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import "./chat-media-selector.styles.scss";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ChatMediaSelector);
|
||||
|
||||
export function ChatMediaSelector({ bodyshop, selectedMedia, setSelectedMedia, conversation }) {
|
||||
@@ -37,9 +38,8 @@ export function ChatMediaSelector({ bodyshop, selectedMedia, setSelectedMedia, c
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
variables: {
|
||||
jobId: conversation.job_conversations[0] && conversation.job_conversations[0]?.jobid
|
||||
jobId: conversation.job_conversations[0]?.jobid
|
||||
},
|
||||
|
||||
skip: !open || !conversation.job_conversations || conversation.job_conversations.length === 0
|
||||
});
|
||||
|
||||
@@ -56,11 +56,11 @@ export function ChatMediaSelector({ bodyshop, selectedMedia, setSelectedMedia, c
|
||||
//If Imageproxy is on, rely only on the LMS selector
|
||||
//If not on, use the old methods.
|
||||
const content = (
|
||||
<div>
|
||||
<div className="media-selector-content">
|
||||
{loading && <LoadingSpinner />}
|
||||
{error && <AlertComponent message={error.message} type="error" />}
|
||||
{selectedMedia.filter((s) => s.isSelected).length >= 10 ? (
|
||||
<div style={{ color: "red" }}>{t("messaging.labels.maxtenimages")}</div>
|
||||
<div className="error-message">{t("messaging.labels.maxtenimages")}</div>
|
||||
) : null}
|
||||
|
||||
{Imgproxy.treatment === "on" ? (
|
||||
@@ -74,7 +74,7 @@ export function ChatMediaSelector({ bodyshop, selectedMedia, setSelectedMedia, c
|
||||
{bodyshop.uselocalmediaserver && open && (
|
||||
<JobDocumentsLocalGalleryExternal
|
||||
externalMediaState={[selectedMedia, setSelectedMedia]}
|
||||
jobId={conversation.job_conversations[0] && conversation.job_conversations[0]?.jobid}
|
||||
jobId={conversation.job_conversations[0]?.jobid}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
@@ -89,7 +89,7 @@ export function ChatMediaSelector({ bodyshop, selectedMedia, setSelectedMedia, c
|
||||
{bodyshop.uselocalmediaserver && open && (
|
||||
<JobDocumentsLocalGalleryExternal
|
||||
externalMediaState={[selectedMedia, setSelectedMedia]}
|
||||
jobId={conversation.job_conversations[0] && conversation.job_conversations[0]?.jobid}
|
||||
jobId={conversation.job_conversations[0]?.jobid}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
@@ -100,12 +100,17 @@ export function ChatMediaSelector({ bodyshop, selectedMedia, setSelectedMedia, c
|
||||
return (
|
||||
<Popover
|
||||
content={
|
||||
conversation.job_conversations.length === 0 ? <div>{t("messaging.errors.noattachedjobs")}</div> : content
|
||||
conversation.job_conversations.length === 0 ? (
|
||||
<div className="no-jobs-message">{t("messaging.errors.noattachedjobs")}</div>
|
||||
) : (
|
||||
content
|
||||
)
|
||||
}
|
||||
title={t("messaging.labels.selectmedia")}
|
||||
trigger="click"
|
||||
open={open}
|
||||
onOpenChange={handleVisibleChange}
|
||||
overlayClassName="media-selector-popover"
|
||||
>
|
||||
<Badge count={selectedMedia.filter((s) => s.isSelected).length}>
|
||||
<PictureFilled style={{ margin: "0 .5rem" }} />
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
.media-selector-popover {
|
||||
.ant-popover-inner-content {
|
||||
max-width: 640px;
|
||||
max-height: 480px;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.media-selector-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: red;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.no-jobs-message {
|
||||
font-size: 14px;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* Style images within gallery components */
|
||||
.media-selector-content img {
|
||||
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
margin: 4px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
}
|
||||
|
||||
/* Grid layout for gallery components */
|
||||
.media-selector-content .ant-image, /* Assuming gallery components use Ant Design's Image */
|
||||
.media-selector-content .gallery-container { /* Fallback for custom gallery classes */
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
|
||||
gap: 4px;
|
||||
}
|
||||
@@ -4,13 +4,16 @@
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.archive-button {
|
||||
height: 20px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.chat-title {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.messages {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -37,11 +40,13 @@
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
.chat-send-message-button{
|
||||
|
||||
.chat-send-message-button {
|
||||
margin: 0.3rem;
|
||||
padding-left: 0.5rem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.message-icon {
|
||||
position: absolute;
|
||||
bottom: 0.1rem;
|
||||
@@ -125,6 +130,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
.system {
|
||||
align-items: center;
|
||||
margin: 0.5rem 10%;
|
||||
|
||||
.message {
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 10px;
|
||||
padding: 0.5rem 1rem;
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
color: #555;
|
||||
width: fit-content;
|
||||
max-width: 80%;
|
||||
}
|
||||
|
||||
.system-label {
|
||||
font-size: 0.75rem;
|
||||
color: #888;
|
||||
margin-bottom: 0.2rem;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.system-date {
|
||||
font-size: 0.75rem;
|
||||
color: #888;
|
||||
margin-top: 0.2rem;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.virtuoso-container {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
|
||||
@@ -2,17 +2,29 @@ import Icon from "@ant-design/icons";
|
||||
import { Tooltip } from "antd";
|
||||
import i18n from "i18next";
|
||||
import dayjs from "../../utils/day";
|
||||
import { MdDone, MdDoneAll } from "react-icons/md";
|
||||
import { MdClose, MdDone, MdDoneAll } from "react-icons/md";
|
||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||
|
||||
export const renderMessage = (messages, index) => {
|
||||
const message = messages[index];
|
||||
const isSystem = message.is_system;
|
||||
|
||||
// Determine message class
|
||||
const messageClass = isSystem ? "system messages" : message.isoutbound ? "mine messages" : "yours messages";
|
||||
|
||||
// Tooltip content based on message type
|
||||
const tooltipTitle = isSystem ? (
|
||||
i18n.t("consent.text_body")
|
||||
) : (
|
||||
<DateTimeFormatter>{message.created_at}</DateTimeFormatter>
|
||||
);
|
||||
|
||||
return (
|
||||
<div key={index} className={`${message.isoutbound ? "mine messages" : "yours messages"}`}>
|
||||
<div key={index} className={messageClass}>
|
||||
<div className="message msgmargin">
|
||||
<Tooltip title={DateTimeFormatter({ children: message.created_at })}>
|
||||
<Tooltip title={tooltipTitle}>
|
||||
<div>
|
||||
{isSystem && <span className="system-label">System</span>}
|
||||
{/* Render images if available */}
|
||||
{message.image && message.image_path?.length > 0 && (
|
||||
<div className="message-images">
|
||||
@@ -26,20 +38,31 @@ export const renderMessage = (messages, index) => {
|
||||
</div>
|
||||
)}
|
||||
{/* Render text if available */}
|
||||
{message.text && <div>{message.text}</div>}
|
||||
{message.text && <div className="message-text">{message.text}</div>}
|
||||
{/* Render date for system messages */}
|
||||
{isSystem && (
|
||||
<div className="system-date">
|
||||
<DateTimeFormatter>{message.created_at}</DateTimeFormatter>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
||||
{/* Message status icons */}
|
||||
{message.status && (message.status === "sent" || message.status === "delivered") && (
|
||||
<div className="message-status">
|
||||
<Icon component={message.status === "sent" ? MdDone : MdDoneAll} className="message-icon" />
|
||||
</div>
|
||||
)}
|
||||
{/* Message status icons for non-system messages */}
|
||||
{!isSystem &&
|
||||
message.status &&
|
||||
(message.status === "sent" || message.status === "delivered" || message.status === "failed") && (
|
||||
<div className="message-status">
|
||||
<Icon
|
||||
component={message.status === "sent" ? MdDone : message.status === "delivered" ? MdDoneAll : MdClose}
|
||||
className="message-icon"
|
||||
style={message.status === "failed" ? { color: "#ff0000" } : undefined}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Outbound message metadata */}
|
||||
{message.isoutbound && (
|
||||
{/* Outbound message metadata for non-system messages */}
|
||||
{!isSystem && message.isoutbound && (
|
||||
<div style={{ fontSize: 10 }}>
|
||||
{i18n.t("messaging.labels.sentby", {
|
||||
by: message.userid,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LoadingOutlined, SendOutlined } from "@ant-design/icons";
|
||||
import { Alert, Input, Spin } from "antd";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { ExclamationCircleOutlined, LoadingOutlined, SendOutlined } from "@ant-design/icons";
|
||||
import { Alert, Input, Space, Spin, Tooltip } from "antd";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -68,48 +68,67 @@ function ChatSendMessageComponent({ conversation, bodyshop, sendMessage, isSendi
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="imex-flex-row" style={{ width: "100%" }}>
|
||||
{isOptedOut && <Alert message={t("messaging.errors.no_consent")} type="warning" style={{ marginBottom: 8 }} />}
|
||||
<ChatPresetsComponent className="imex-flex-row__margin" />
|
||||
<ChatMediaSelector
|
||||
conversation={conversation}
|
||||
selectedMedia={selectedMedia}
|
||||
setSelectedMedia={setSelectedMedia}
|
||||
/>
|
||||
<span style={{ flex: 1 }}>
|
||||
<Input.TextArea
|
||||
className="imex-flex-row__margin imex-flex-row__grow"
|
||||
allowClear
|
||||
autoFocus
|
||||
ref={inputArea}
|
||||
autoSize={{ minRows: 1, maxRows: 4 }}
|
||||
value={message}
|
||||
disabled={isSending || isOptedOut}
|
||||
placeholder={t("messaging.labels.typeamessage")}
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
onPressEnter={(event) => {
|
||||
event.preventDefault();
|
||||
if (!event.shiftKey && !isOptedOut) handleEnter();
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
<SendOutlined
|
||||
className="chat-send-message-button"
|
||||
disabled={isOptedOut || message === "" || !message}
|
||||
onClick={handleEnter}
|
||||
/>
|
||||
<Spin
|
||||
style={{ display: `${isSending ? "" : "none"}` }}
|
||||
indicator={
|
||||
<LoadingOutlined
|
||||
style={{
|
||||
fontSize: 24
|
||||
}}
|
||||
spin
|
||||
<Space direction="vertical" style={{ width: "100%" }} size="middle">
|
||||
{isOptedOut && (
|
||||
<Tooltip title={t("consent.text_body")}>
|
||||
<Alert
|
||||
showIcon={true}
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
message={t("messaging.errors.no_consent")}
|
||||
type="error"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
<div className="imex-flex-row" style={{ width: "100%" }}>
|
||||
{!isOptedOut && (
|
||||
<>
|
||||
<ChatPresetsComponent disabled={isSending} className="imex-flex-row__margin" />
|
||||
<ChatMediaSelector
|
||||
disabled={isSending}
|
||||
conversation={conversation}
|
||||
selectedMedia={selectedMedia}
|
||||
setSelectedMedia={setSelectedMedia}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<span style={{ flex: 1 }}>
|
||||
<Input.TextArea
|
||||
className="imex-flex-row__margin imex-flex-row__grow"
|
||||
allowClear
|
||||
autoFocus
|
||||
ref={inputArea}
|
||||
autoSize={{ minRows: 1, maxRows: 4 }}
|
||||
value={message}
|
||||
disabled={isSending || isOptedOut}
|
||||
placeholder={t("messaging.labels.typeamessage")}
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
onPressEnter={(event) => {
|
||||
event.preventDefault();
|
||||
if (!event.shiftKey && !isOptedOut) handleEnter();
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
{!isOptedOut && (
|
||||
<SendOutlined
|
||||
className="chat-send-message-button"
|
||||
disabled={isSending || message === "" || !message}
|
||||
onClick={handleEnter}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Spin
|
||||
style={{ display: `${isSending ? "" : "none"}` }}
|
||||
indicator={
|
||||
<LoadingOutlined
|
||||
style={{
|
||||
fontSize: 24
|
||||
}}
|
||||
spin
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
HomeFilled,
|
||||
ImportOutlined,
|
||||
LineChartOutlined,
|
||||
OneToOneOutlined,
|
||||
PaperClipOutlined,
|
||||
PhoneOutlined,
|
||||
PlusCircleOutlined,
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
TeamOutlined,
|
||||
ToolFilled,
|
||||
UnorderedListOutlined,
|
||||
UsergroupAddOutlined,
|
||||
UserOutlined
|
||||
} from "@ant-design/icons";
|
||||
import { useQuery } from "@apollo/client";
|
||||
@@ -40,6 +42,7 @@ import { RiSurveyLine } from "react-icons/ri";
|
||||
import { connect } from "react-redux";
|
||||
import { Link } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
import { GET_UNREAD_COUNT } from "../../graphql/notifications.queries.js";
|
||||
import { selectRecentItems, selectSelectedHeader } from "../../redux/application/application.selectors";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
@@ -47,11 +50,10 @@ import { signOutStart } from "../../redux/user/user.actions";
|
||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
||||
import day from "../../utils/day.js";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
import { useIsEmployee } from "../../utils/useIsEmployee.js";
|
||||
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
||||
import LockWrapper from "../lock-wrapper/lock-wrapper.component";
|
||||
import NotificationCenterContainer from "../notification-center/notification-center.container.jsx";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
import { useIsEmployee } from "../../utils/useIsEmployee.js";
|
||||
|
||||
// Redux mappings
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
@@ -642,17 +644,32 @@ function Header({
|
||||
label: t("menus.header.help"),
|
||||
onClick: () => window.open("https://help.imex.online/", "_blank")
|
||||
},
|
||||
...(InstanceRenderManager({ imex: true, rome: false })
|
||||
? [
|
||||
{
|
||||
key: "rescue",
|
||||
id: "header-rescue",
|
||||
icon: <CarFilled />,
|
||||
label: t("menus.header.rescueme"),
|
||||
onClick: () => window.open("https://imexrescue.com/", "_blank")
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
key: "remoteassist",
|
||||
id: "header-remote-assist",
|
||||
icon: <OneToOneOutlined />,
|
||||
label: t("menus.header.remoteassist"),
|
||||
children: [
|
||||
...(InstanceRenderManager({ imex: true, rome: false })
|
||||
? [
|
||||
{
|
||||
key: "rescue",
|
||||
id: "header-rescue",
|
||||
icon: <PlusCircleOutlined />,
|
||||
label: t("menus.header.rescueme"),
|
||||
onClick: () => window.open("https://imexrescue.com/", "_blank")
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
key: "rescue-zoho",
|
||||
id: "header-rescue-zoho",
|
||||
icon: <UsergroupAddOutlined />,
|
||||
label: t("menus.header.rescuemezoho"),
|
||||
onClick: () => window.open("https://join.zoho.com/", "_blank")
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "shiftclock",
|
||||
id: "header-shiftclock",
|
||||
|
||||
@@ -395,32 +395,33 @@ export function ScheduleEventComponent({
|
||||
) : (
|
||||
<ScheduleManualEvent event={event} />
|
||||
)}
|
||||
{event.isintake && HasFeatureAccess({ featureName: "checklist", bodyshop }) ? (
|
||||
<Link
|
||||
to={{
|
||||
pathname: `/manage/jobs/${event.job && event.job.id}/intake`,
|
||||
search: `?appointmentId=${event.id}`
|
||||
}}
|
||||
>
|
||||
<Button disabled={event.arrived}>{t("appointments.actions.intake")}</Button>
|
||||
</Link>
|
||||
) : (
|
||||
<Popover //open={open}
|
||||
content={popMenu}
|
||||
open={popOverVisible}
|
||||
onOpenChange={setPopOverVisible}
|
||||
onClick={(e) => {
|
||||
if (event.job?.id) {
|
||||
e.stopPropagation();
|
||||
getJobDetails();
|
||||
}
|
||||
}}
|
||||
getPopupContainer={(trigger) => trigger.parentNode}
|
||||
trigger="click"
|
||||
>
|
||||
<Button disabled={event.arrived}>{t("jobs.actions.intake_quick")}</Button>
|
||||
</Popover>
|
||||
)}
|
||||
{event.job &&
|
||||
(HasFeatureAccess({ featureName: "checklist", bodyshop }) ? (
|
||||
<Link
|
||||
to={{
|
||||
pathname: `/manage/jobs/${event.job && event.job.id}/intake`,
|
||||
search: `?appointmentId=${event.id}`
|
||||
}}
|
||||
>
|
||||
<Button disabled={event.arrived}>{t("appointments.actions.intake")}</Button>
|
||||
</Link>
|
||||
) : (
|
||||
<Popover //open={open}
|
||||
content={popMenu}
|
||||
open={popOverVisible}
|
||||
onOpenChange={setPopOverVisible}
|
||||
onClick={(e) => {
|
||||
if (event.job?.id) {
|
||||
e.stopPropagation();
|
||||
getJobDetails();
|
||||
}
|
||||
}}
|
||||
getPopupContainer={(trigger) => trigger.parentNode}
|
||||
trigger="click"
|
||||
>
|
||||
<Button disabled={event.arrived}>{t("jobs.actions.intake_quick")}</Button>
|
||||
</Popover>
|
||||
))}
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button, Card, Form, Input, Switch } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
||||
@@ -9,7 +9,6 @@ import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../../../firebase/firebase.utils";
|
||||
import { MARK_APPOINTMENT_ARRIVED, MARK_LATEST_APPOINTMENT_ARRIVED } from "../../../../graphql/appointments.queries";
|
||||
import { UPDATE_JOB } from "../../../../graphql/jobs.queries";
|
||||
import { UPDATE_OWNER } from "../../../../graphql/owners.queries";
|
||||
import { insertAuditTrail } from "../../../../redux/application/application.actions";
|
||||
import { selectBodyshop, selectCurrentUser } from "../../../../redux/user/user.selectors";
|
||||
import AuditTrailMapping from "../../../../utils/AuditTrailMappings";
|
||||
@@ -32,7 +31,6 @@ export function JobChecklistForm({ insertAuditTrail, formItems, bodyshop, curren
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [markAptArrived] = useMutation(MARK_APPOINTMENT_ARRIVED);
|
||||
const [markLatestAptArrived] = useMutation(MARK_LATEST_APPOINTMENT_ARRIVED);
|
||||
const [updateOwner] = useMutation(UPDATE_OWNER);
|
||||
const notification = useNotification();
|
||||
|
||||
const { jobId } = useParams();
|
||||
@@ -129,24 +127,6 @@ export function JobChecklistForm({ insertAuditTrail, formItems, bodyshop, curren
|
||||
}
|
||||
}
|
||||
|
||||
if (type === "intake" && job.owner && job.owner.id) {
|
||||
//Updae Owner Allow to Text
|
||||
const updateOwnerResult = await updateOwner({
|
||||
variables: {
|
||||
ownerId: job.owner.id,
|
||||
owner: { allow_text_message: values.allow_text_message }
|
||||
}
|
||||
});
|
||||
|
||||
if (!!updateOwnerResult.errors) {
|
||||
notification["error"]({
|
||||
message: t("checklist.errors.complete", {
|
||||
error: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
|
||||
if (!!!result.errors) {
|
||||
@@ -189,7 +169,6 @@ export function JobChecklistForm({ insertAuditTrail, formItems, bodyshop, curren
|
||||
initialValues={{
|
||||
...(type === "intake" && {
|
||||
addToProduction: true,
|
||||
allow_text_message: job.owner && job.owner.allow_text_message,
|
||||
scheduled_completion:
|
||||
(job && job.scheduled_completion && dayjs(job.scheduled_completion)) ||
|
||||
(job &&
|
||||
@@ -228,14 +207,6 @@ export function JobChecklistForm({ insertAuditTrail, formItems, bodyshop, curren
|
||||
>
|
||||
<Switch disabled={readOnly} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="allow_text_message"
|
||||
valuePropName="checked"
|
||||
label={t("checklist.labels.allow_text_message")}
|
||||
disabled={readOnly}
|
||||
>
|
||||
<Switch disabled={readOnly} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="scheduled_completion"
|
||||
label={t("jobs.fields.scheduled_completion")}
|
||||
|
||||
@@ -80,7 +80,7 @@ export function JobEmployeeAssignments({
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover destroyTooltipOnHide content={popContent} open={visibility}>
|
||||
<Popover destroyOnHidden content={popContent} open={visibility}>
|
||||
<Spin spinning={loading}>
|
||||
<DataLabel label={t("jobs.fields.employee_body")}>
|
||||
{body ? (
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { DownloadOutlined, SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Card, Input, Space, Table } from "antd";
|
||||
import axios from "axios";
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { selectPartnerVersion } from "../../redux/application/application.selectors";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
partnerVersion: selectPartnerVersion
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
const mapDispatchToProps = () => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(JobsAvailableScan);
|
||||
@@ -126,6 +126,7 @@ export function JobsAvailableScan({ partnerVersion, refetch }) {
|
||||
onClick={() => {
|
||||
scanEstimates();
|
||||
}}
|
||||
id="scan-estimates-button"
|
||||
>
|
||||
<SyncOutlined />
|
||||
</Button>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import { Form, Input } from "antd";
|
||||
import React, { useContext } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import JobCreateContext from "../../pages/jobs-create/jobs-create.context";
|
||||
@@ -129,13 +129,6 @@ export default function JobsCreateOwnerInfoNewComponent() {
|
||||
<Form.Item label={t("owners.fields.preferred_contact")} name={["owner", "data", "preferred_contact"]}>
|
||||
<Input disabled={!state.owner.new} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("owners.fields.allow_text_message")}
|
||||
valuePropName="checked"
|
||||
name={["owner", "data", "allow_text_message"]}
|
||||
>
|
||||
<Switch disabled={!state.owner.new} />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Card, Input, Table } from "antd";
|
||||
import React, { useContext, useState } from "react";
|
||||
import { useContext, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import JobCreateContext from "../../pages/jobs-create/jobs-create.context";
|
||||
import PhoneFormatter from "../../utils/PhoneFormatter";
|
||||
@@ -91,6 +91,7 @@ export default function JobsCreateOwnerInfoSearchComponent({ loading, owners })
|
||||
});
|
||||
}}
|
||||
enterButton
|
||||
id="search-owner"
|
||||
/>
|
||||
}
|
||||
>
|
||||
@@ -112,9 +113,9 @@ export default function JobsCreateOwnerInfoSearchComponent({ loading, owners })
|
||||
type: "radio",
|
||||
selectedRowKeys: [state.owner.selectedid]
|
||||
}}
|
||||
onRow={(record, rowIndex) => {
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onClick: (event) => {
|
||||
onClick: () => {
|
||||
if (record) {
|
||||
if (record.id) {
|
||||
setState({
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function JobsCreateVehicleInfoPredefined({ disabled, form }) {
|
||||
open={open}
|
||||
placement="left"
|
||||
onOpenChange={handleOpenChange}
|
||||
destroyTooltipOnHide
|
||||
destroyOnHidden
|
||||
>
|
||||
<SearchOutlined style={{ cursor: "pointer" }} />
|
||||
</Popover>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React, { useContext, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, Input, Space, Table } from "antd";
|
||||
import { useContext, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import JobCreateContext from "../../pages/jobs-create/jobs-create.context";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import VehicleVinDisplay from "../vehicle-vin-display/vehicle-vin-display.component";
|
||||
|
||||
export default function JobsCreateVehicleInfoSearchComponent({ loading, vehicles }) {
|
||||
@@ -63,6 +63,7 @@ export default function JobsCreateVehicleInfoSearchComponent({ loading, vehicles
|
||||
});
|
||||
}}
|
||||
enterButton
|
||||
id="search-vehicle"
|
||||
/>
|
||||
</Space>
|
||||
}
|
||||
@@ -91,9 +92,9 @@ export default function JobsCreateVehicleInfoSearchComponent({ loading, vehicles
|
||||
type: "radio",
|
||||
selectedRowKeys: [state.vehicle.selectedid]
|
||||
}}
|
||||
onRow={(record, rowIndex) => {
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onClick: (event) => {
|
||||
onClick: () => {
|
||||
if (record) {
|
||||
if (record.id) {
|
||||
setState({
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
import { auth, logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { CANCEL_APPOINTMENTS_BY_JOB_ID, INSERT_MANUAL_APPT } from "../../graphql/appointments.queries";
|
||||
@@ -32,7 +33,6 @@ import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx";
|
||||
import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util";
|
||||
import DuplicateJob from "./jobs-detail-header-actions.duplicate.util";
|
||||
import JobsDetailHeaderActionsToggleProduction from "./jobs-detail-header-actions.toggle-production";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -1078,17 +1078,26 @@ export function JobsDetailHeaderActions({
|
||||
menuItems.push({
|
||||
key: "deletejob",
|
||||
id: "job-actions-deletejob",
|
||||
label: (
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.deleteconfirm")}
|
||||
okText={t("general.labels.yes")}
|
||||
cancelText={t("general.labels.no")}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onConfirm={handleDeleteJob}
|
||||
>
|
||||
{t("menus.jobsactions.deletejob")}
|
||||
</Popconfirm>
|
||||
)
|
||||
label:
|
||||
job.job_watchers.length === 0 ? (
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.deleteconfirm")}
|
||||
okText={t("general.labels.yes")}
|
||||
cancelText={t("general.labels.no")}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onConfirm={handleDeleteJob}
|
||||
>
|
||||
{t("menus.jobsactions.deletejob")}
|
||||
</Popconfirm>
|
||||
) : (
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.deletewatchers")}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
showCancel={false}
|
||||
>
|
||||
{t("menus.jobsactions.deletejob")}
|
||||
</Popconfirm>
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1109,8 +1118,8 @@ export function JobsDetailHeaderActions({
|
||||
<RbacWrapper action="jobs:void" noauth>
|
||||
<Popconfirm
|
||||
title={t("jobs.labels.voidjob")}
|
||||
okText="Yes"
|
||||
cancelText="No"
|
||||
okText={t("general.labels.yes")}
|
||||
cancelText={t("general.labels.no")}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onConfirm={handleVoidJob}
|
||||
>
|
||||
|
||||
@@ -167,7 +167,18 @@ export function JobsDetailHeaderActionsToggleProduction({
|
||||
<FormDateTimePickerComponent disabled={jobRO} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name={["actual_delivery"]} label={t("jobs.fields.actual_delivery")}>
|
||||
<Form.Item
|
||||
name={["actual_delivery"]}
|
||||
label={t("jobs.fields.actual_delivery")}
|
||||
rules={[
|
||||
{
|
||||
required: bodyshop.deliverchecklist.actual_delivery
|
||||
? bodyshop.deliverchecklist.actual_delivery
|
||||
: false
|
||||
//message: t("general.validation.required"),
|
||||
}
|
||||
]}
|
||||
>
|
||||
<FormDateTimePickerComponent disabled={jobRO} />
|
||||
</Form.Item>
|
||||
</>
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import { BranchesOutlined, ExclamationCircleFilled, PauseCircleOutlined, WarningFilled } from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Card, Checkbox, Col, Divider, Row, Space, Tag, Tooltip } from "antd";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||
import { insertAuditTrail } from "../../redux/application/application.actions.js";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||
import AuditTrailMapping from "../../utils/AuditTrailMappings.js";
|
||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||
import { DateTimeFormatter, DateTimeFormatterFunction } from "../../utils/DateFormatter";
|
||||
import dayjs from "../../utils/day";
|
||||
import PhoneNumberFormatter from "../../utils/PhoneFormatter";
|
||||
import ChatOpenButton from "../chat-open-button/chat-open-button.component";
|
||||
@@ -24,7 +27,6 @@ import ProductionListColumnComment from "../production-list-columns/production-l
|
||||
import ProductionListColumnProductionNote from "../production-list-columns/production-list-columns.productionnote.component";
|
||||
import VehicleVinDisplay from "../vehicle-vin-display/vehicle-vin-display.component";
|
||||
import "./jobs-detail-header.styles.scss";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
jobRO: selectJobReadOnly,
|
||||
@@ -38,6 +40,14 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
context: context,
|
||||
modal: "printCenter"
|
||||
})
|
||||
),
|
||||
insertAuditTrail: ({ jobid, operation, type }) =>
|
||||
dispatch(
|
||||
insertAuditTrail({
|
||||
jobid,
|
||||
operation,
|
||||
type
|
||||
})
|
||||
)
|
||||
});
|
||||
|
||||
@@ -49,7 +59,7 @@ const colSpan = {
|
||||
xl: { span: 6 }
|
||||
};
|
||||
|
||||
export function JobsDetailHeader({ job, bodyshop, disabled }) {
|
||||
export function JobsDetailHeader({ job, bodyshop, disabled, insertAuditTrail }) {
|
||||
const { t } = useTranslation();
|
||||
const { notification } = useNotification();
|
||||
const [notesClamped, setNotesClamped] = useState(true);
|
||||
@@ -66,7 +76,7 @@ export function JobsDetailHeader({ job, bodyshop, disabled }) {
|
||||
const handleCheckboxChange = async (field, checked) => {
|
||||
const value = checked ? dayjs().toISOString() : null;
|
||||
try {
|
||||
await updateJob({
|
||||
const ret = await updateJob({
|
||||
variables: {
|
||||
jobId: job.id,
|
||||
job: { [field]: value }
|
||||
@@ -74,6 +84,16 @@ export function JobsDetailHeader({ job, bodyshop, disabled }) {
|
||||
refetchQueries: ["GET_JOB_BY_PK"],
|
||||
awaitRefetchQueries: true
|
||||
});
|
||||
insertAuditTrail({
|
||||
jobid: job.id,
|
||||
operation: AuditTrailMapping.jobfieldchange(
|
||||
field,
|
||||
ret.data.update_jobs.returning[0][field]
|
||||
? DateTimeFormatterFunction(ret.data.update_jobs.returning[0][field])
|
||||
: checked
|
||||
),
|
||||
type: "jobfieldchange"
|
||||
});
|
||||
} catch (error) {
|
||||
notification.error({
|
||||
message: t("jobs.errors.saving", { error: error.message })
|
||||
|
||||
@@ -42,7 +42,7 @@ export function JobsDocumentsContainer({
|
||||
variables: { jobId: jobId },
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
skip: Imgproxy.treatment === "on" || !!billId
|
||||
skip: !!billId
|
||||
});
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Checkbox, Divider, Input, Space, Table } from "antd";
|
||||
import dayjs from "../../utils/day";
|
||||
import React, { useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import dayjs from "../../utils/day";
|
||||
import PhoneFormatter from "../../utils/PhoneFormatter";
|
||||
import FormDateTimePickerComponent from "../form-date-time-picker/form-date-time-picker.component";
|
||||
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
||||
@@ -223,9 +223,9 @@ export default function JobsFindModalComponent({
|
||||
type: "radio",
|
||||
selectedRowKeys: [selectedJob]
|
||||
}}
|
||||
onRow={(record, rowIndex) => {
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onClick: (event) => {
|
||||
onClick: () => {
|
||||
handleOnRowClick(record);
|
||||
}
|
||||
};
|
||||
@@ -241,15 +241,17 @@ export default function JobsFindModalComponent({
|
||||
overrideHeaders: e.target.checked
|
||||
})
|
||||
}
|
||||
id="override_header"
|
||||
>
|
||||
{t("jobs.labels.override_header")}
|
||||
</Checkbox>
|
||||
<Checkbox checked={partsQueueToggle} onChange={(e) => setPartsQueueToggle(e.target.checked)}>
|
||||
<Checkbox checked={partsQueueToggle} onChange={(e) => setPartsQueueToggle(e.target.checked)} id="parts_queue_toggle">
|
||||
{t("bodyshop.fields.md_functionality_toggles.parts_queue_toggle")}
|
||||
</Checkbox>
|
||||
<Checkbox
|
||||
checked={updateSchComp.checked}
|
||||
onChange={(e) => setSchComp({ ...updateSchComp, checked: e.target.checked })}
|
||||
id="update_scheduled_completion"
|
||||
>
|
||||
{t("jobs.labels.update_scheduled_completion")}
|
||||
</Checkbox>
|
||||
@@ -261,6 +263,7 @@ export default function JobsFindModalComponent({
|
||||
onChange={(e) => {
|
||||
setSchComp({ ...updateSchComp, scheduled_completion: e });
|
||||
}}
|
||||
id="scheduled_completion_date_time_picker"
|
||||
/>
|
||||
) : null}
|
||||
<Checkbox
|
||||
@@ -273,6 +276,7 @@ export default function JobsFindModalComponent({
|
||||
automatic: true
|
||||
});
|
||||
}}
|
||||
id="calculate_scheduled_completion"
|
||||
>
|
||||
{t("jobs.labels.calc_scheuled_completion")}
|
||||
</Checkbox>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { Modal } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -66,7 +65,7 @@ export default connect(
|
||||
title={t("jobs.labels.existing_jobs")}
|
||||
width={"80%"}
|
||||
destroyOnHidden
|
||||
okButtonProps={{ disabled: selectedJob ? false : true }}
|
||||
okButtonProps={{ disabled: selectedJob ? false : true, id: "jobs-find-modal-container-ok" }}
|
||||
{...modalProps}
|
||||
>
|
||||
{loading ? <LoadingSpinner /> : null}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { Form, Input, Switch } from "antd";
|
||||
import React from "react";
|
||||
import { Form, Input, Tooltip } from "antd";
|
||||
import { CloseCircleFilled } from "@ant-design/icons";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import FormFieldsChanged from "../form-fields-changed-alert/form-fields-changed-alert.component";
|
||||
import FormItemEmail from "../form-items-formatted/email-form-item.component";
|
||||
import FormItemPhone, { PhoneItemFormatterValidation } from "../form-items-formatted/phone-form-item.component";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
import { PhoneItemFormatterValidation } from "../form-items-formatted/phone-form-item.component";
|
||||
|
||||
export default function OwnerDetailFormComponent({ form, loading }) {
|
||||
export default function OwnerDetailFormComponent({ form, loading, isPhone1OptedOut, isPhone2OptedOut }) {
|
||||
const { t } = useTranslation();
|
||||
const { getFieldValue } = form;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<FormFieldsChanged form={form} />
|
||||
@@ -26,7 +27,7 @@ export default function OwnerDetailFormComponent({ form, loading }) {
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label={t("owners.fields.accountingid")} name="accountingid">
|
||||
<Input disabled/>
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow header={t("owners.forms.address")}>
|
||||
@@ -50,9 +51,6 @@ export default function OwnerDetailFormComponent({ form, loading }) {
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow header={t("owners.forms.contact")}>
|
||||
<Form.Item label={t("owners.fields.allow_text_message")} name="allow_text_message" valuePropName="checked">
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("owners.fields.ownr_ea")}
|
||||
name="ownr_ea"
|
||||
@@ -65,19 +63,55 @@ export default function OwnerDetailFormComponent({ form, loading }) {
|
||||
>
|
||||
<FormItemEmail email={getFieldValue("ownr_ea")} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("owners.fields.ownr_ph1")}
|
||||
name="ownr_ph1"
|
||||
rules={[({ getFieldValue }) => PhoneItemFormatterValidation(getFieldValue, "ownr_ph1")]}
|
||||
>
|
||||
<FormItemPhone />
|
||||
<Form.Item label={t("owners.fields.ownr_ph1")} style={{ marginBottom: 0 }}>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
|
||||
<Form.Item
|
||||
name="ownr_ph1"
|
||||
noStyle
|
||||
rules={[({ getFieldValue }) => PhoneItemFormatterValidation(getFieldValue, "ownr_ph1")]}
|
||||
>
|
||||
<Input style={{ flex: 1, minWidth: "150px" }} />
|
||||
</Form.Item>
|
||||
{isPhone1OptedOut && (
|
||||
<Tooltip title={t("consent.text_body")}>
|
||||
<CloseCircleFilled
|
||||
style={{
|
||||
color: "#ff4d4f",
|
||||
fontSize: 16,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
height: "100%"
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("owners.fields.ownr_ph2")}
|
||||
name="ownr_ph2"
|
||||
rules={[({ getFieldValue }) => PhoneItemFormatterValidation(getFieldValue, "ownr_ph2")]}
|
||||
>
|
||||
<FormItemPhone />
|
||||
<Form.Item label={t("owners.fields.ownr_ph2")} style={{ marginBottom: 0 }}>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
|
||||
<Form.Item
|
||||
name="ownr_ph2"
|
||||
noStyle
|
||||
rules={[({ getFieldValue }) => PhoneItemFormatterValidation(getFieldValue, "ownr_ph2")]}
|
||||
>
|
||||
<Input style={{ flex: 1, minWidth: "150px" }} />
|
||||
</Form.Item>
|
||||
{isPhone2OptedOut && (
|
||||
<Tooltip title={t("consent.text_body")}>
|
||||
<CloseCircleFilled
|
||||
style={{
|
||||
color: "#ff4d4f",
|
||||
fontSize: 16,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
height: "100%"
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
</Form.Item>
|
||||
<Form.Item label={t("owners.fields.preferred_contact")} name="preferred_contact">
|
||||
<Input />
|
||||
|
||||
@@ -1,69 +1,115 @@
|
||||
import { Button, Form, Popconfirm } from "antd";
|
||||
import { PageHeader } from "@ant-design/pro-layout";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { useApolloClient, useMutation } from "@apollo/client";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { DELETE_OWNER, UPDATE_OWNER } from "../../graphql/owners.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors"; // Adjust path
|
||||
import { phoneNumberOptOutService } from "../../utils/phoneOptOutService.js"; // Adjust path
|
||||
import OwnerDetailFormComponent from "./owner-detail-form.component";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { phone } from "phone"; // Import phone utility for formatting
|
||||
|
||||
function OwnerDetailFormContainer({ owner, refetch }) {
|
||||
// Connect to Redux to access bodyshop
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
|
||||
function OwnerDetailFormContainer({ owner, refetch, bodyshop }) {
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
const history = useNavigate();
|
||||
const navigate = useNavigate();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [optedOutPhones, setOptedOutPhones] = useState(new Set());
|
||||
const [updateOwner] = useMutation(UPDATE_OWNER);
|
||||
const [deleteOwner] = useMutation(DELETE_OWNER);
|
||||
const notification = useNotification();
|
||||
const apolloClient = useApolloClient();
|
||||
|
||||
// Fetch opt-out status on mount
|
||||
useEffect(() => {
|
||||
const fetchOptOutStatus = async () => {
|
||||
if (bodyshop?.id && bodyshop?.messagingservicesid && (owner?.ownr_ph1 || owner?.ownr_ph2)) {
|
||||
const phoneNumbers = [owner.ownr_ph1, owner.ownr_ph2].filter(Boolean);
|
||||
const optOutSet = await phoneNumberOptOutService(apolloClient, bodyshop.id, phoneNumbers);
|
||||
setOptedOutPhones(optOutSet);
|
||||
} else {
|
||||
setOptedOutPhones(new Set());
|
||||
}
|
||||
};
|
||||
|
||||
fetchOptOutStatus();
|
||||
}, [apolloClient, bodyshop?.id, bodyshop?.messagingservicesid, owner?.ownr_ph1, owner?.ownr_ph2]);
|
||||
|
||||
// Reset form fields when owner changes
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({
|
||||
ownr_ph1: owner?.ownr_ph1,
|
||||
ownr_ph2: owner?.ownr_ph2,
|
||||
...owner
|
||||
});
|
||||
}, [owner, form]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
setLoading(true);
|
||||
const result = await deleteOwner({
|
||||
variables: { id: owner.id }
|
||||
});
|
||||
console.log(result);
|
||||
if (result.errors) {
|
||||
notification["error"]({
|
||||
try {
|
||||
const result = await deleteOwner({
|
||||
variables: { id: owner.id }
|
||||
});
|
||||
if (result.errors) {
|
||||
notification.error({
|
||||
message: t("owners.errors.deleting", {
|
||||
error: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
} else {
|
||||
notification.success({
|
||||
message: t("owners.successes.delete")
|
||||
});
|
||||
navigate(`/manage/owners`);
|
||||
}
|
||||
} catch (error) {
|
||||
notification.error({
|
||||
message: t("owners.errors.deleting", {
|
||||
error: JSON.stringify(result.errors)
|
||||
error: error.message
|
||||
})
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("owners.successes.delete")
|
||||
});
|
||||
setLoading(false);
|
||||
history(`/manage/owners`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
setLoading(true);
|
||||
const result = await updateOwner({
|
||||
variables: { ownerId: owner.id, owner: values }
|
||||
});
|
||||
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
try {
|
||||
const result = await updateOwner({
|
||||
variables: { ownerId: owner.id, owner: values }
|
||||
});
|
||||
if (result.errors) {
|
||||
notification.error({
|
||||
message: t("owners.errors.saving", {
|
||||
error: JSON.stringify(result.errors)
|
||||
})
|
||||
});
|
||||
} else {
|
||||
notification.success({
|
||||
message: t("owners.successes.save")
|
||||
});
|
||||
if (refetch) await refetch();
|
||||
form.resetFields();
|
||||
}
|
||||
} catch (error) {
|
||||
notification.error({
|
||||
message: t("owners.errors.saving", {
|
||||
error: JSON.stringify(result.errors)
|
||||
error: error.message
|
||||
})
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
notification["success"]({
|
||||
message: t("owners.successes.save")
|
||||
});
|
||||
|
||||
if (refetch) await refetch();
|
||||
form.resetFields();
|
||||
form.resetFields();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -72,6 +118,7 @@ function OwnerDetailFormContainer({ owner, refetch }) {
|
||||
title={t("menus.header.owners")}
|
||||
extra={[
|
||||
<Popconfirm
|
||||
key="delete"
|
||||
trigger="click"
|
||||
onConfirm={handleDelete}
|
||||
disabled={owner.jobs.length !== 0}
|
||||
@@ -81,16 +128,29 @@ function OwnerDetailFormContainer({ owner, refetch }) {
|
||||
{t("general.actions.delete")}
|
||||
</Button>
|
||||
</Popconfirm>,
|
||||
<Button type="primary" loading={loading} onClick={() => form.submit()}>
|
||||
<Button key="save" type="primary" loading={loading} onClick={() => form.submit()}>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
]}
|
||||
/>
|
||||
<Form form={form} onFinish={handleFinish} autoComplete="off" layout="vertical" initialValues={owner}>
|
||||
<OwnerDetailFormComponent loading={loading} form={form} />
|
||||
<OwnerDetailFormComponent
|
||||
loading={loading}
|
||||
form={form}
|
||||
isPhone1OptedOut={
|
||||
bodyshop?.messagingservicesid &&
|
||||
owner?.ownr_ph1 &&
|
||||
optedOutPhones.has(phone(owner.ownr_ph1, "CA").phoneNumber?.replace(/^\+1/, ""))
|
||||
}
|
||||
isPhone2OptedOut={
|
||||
bodyshop?.messagingservicesid &&
|
||||
owner?.ownr_ph2 &&
|
||||
optedOutPhones.has(phone(owner.ownr_ph2, "CA").phoneNumber?.replace(/^\+1/, ""))
|
||||
}
|
||||
/>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default OwnerDetailFormContainer;
|
||||
export default connect(mapStateToProps)(OwnerDetailFormContainer);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useLazyQuery } from "@apollo/client";
|
||||
import { Input, Modal } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { QUERY_SEARCH_OWNER_BY_IDX } from "../../graphql/owners.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import OwnerFindModalComponent from "./owner-find-modal.component";
|
||||
import { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
|
||||
import OwnerFindModalComponent from "./owner-find-modal.component";
|
||||
|
||||
export default function OwnerFindModalContainer({
|
||||
loading,
|
||||
@@ -41,6 +41,7 @@ export default function OwnerFindModalContainer({
|
||||
<Modal
|
||||
title={<span id="owner-find-modal-title">{t("owners.labels.existing_owners")}</span>}
|
||||
width={"80%"}
|
||||
okButtonProps={{ id: "owner-find-modal-ok-button" }}
|
||||
{...modalProps}
|
||||
>
|
||||
{loading ? <LoadingSpinner /> : null}
|
||||
|
||||
@@ -75,7 +75,7 @@ export function PartsOrderBackorderEta({
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover destroyTooltipOnHide content={popContent} open={visibility} disabled={disabled}>
|
||||
<Popover destroyOnHidden content={popContent} open={visibility} disabled={disabled}>
|
||||
<DateFormatter>{backordered_eta}</DateFormatter>
|
||||
{isAlreadyBackordered && <CalendarFilled style={{ cursor: "pointer" }} onClick={handlePopover} />}
|
||||
{loading && <Spin />}
|
||||
|
||||
@@ -84,7 +84,7 @@ export function PartsOrderLineBackorderButton({ partsOrderStatus, partsLineId, j
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover destroyTooltipOnHide content={popContent} open={visibility} disabled={disabled}>
|
||||
<Popover destroyOnHidden content={popContent} open={visibility} disabled={disabled}>
|
||||
<Button loading={loading} onClick={handlePopover}>
|
||||
{isAlreadyBackordered ? t("parts_orders.actions.receive") : t("parts_orders.actions.backordered")}
|
||||
</Button>
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { Input, Table } from "antd";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Input, Table, Typography } from "antd";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
||||
import { GET_PHONE_NUMBER_OPT_OUTS } from "../../graphql/phone-number-opt-out.queries";
|
||||
|
||||
import PhoneNumberFormatter from "../../utils/PhoneFormatter";
|
||||
import { TimeAgoFormatter } from "../../utils/DateFormatter";
|
||||
import ChatOpenButton from "../chat-open-button/chat-open-button.component";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useState } from "react";
|
||||
|
||||
const { Paragraph } = Typography;
|
||||
|
||||
// Commented out Associated Owners section for now
|
||||
//import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
||||
//import { Link } from "react-router-dom";
|
||||
//import { useMemo, useState } from "react";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -20,18 +26,95 @@ const mapDispatchToProps = () => ({});
|
||||
function PhoneNumberConsentList({ bodyshop, currentUser }) {
|
||||
const { t } = useTranslation();
|
||||
const [search, setSearch] = useState("");
|
||||
const { loading, data } = useQuery(GET_PHONE_NUMBER_OPT_OUTS, {
|
||||
|
||||
// Fetch opt-out phone numbers
|
||||
const { loading: optOutLoading, data: optOutData } = useQuery(GET_PHONE_NUMBER_OPT_OUTS, {
|
||||
variables: { bodyshopid: bodyshop.id, search: search ? `%${search}%` : undefined },
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
// Commented out Associated Owners section for now
|
||||
/*// Prepare phone numbers for owner query
|
||||
const phoneNumbers = useMemo(() => {
|
||||
return optOutData?.phone_number_opt_out?.map((item) => item.phone_number) || [];
|
||||
}, [optOutData?.phone_number_opt_out]);
|
||||
const allPhoneNumbers = useMemo(() => {
|
||||
const normalized = phoneNumbers;
|
||||
const withPlusOne = phoneNumbers.map((num) => `+1${num}`);
|
||||
return [...normalized, ...withPlusOne].filter(Boolean);
|
||||
}, [phoneNumbers]);
|
||||
|
||||
// Fetch owners for all phone numbers
|
||||
const { loading: ownersLoading, data: ownersData } = useQuery(SEARCH_OWNERS_BY_PHONE_NUMBERS, {
|
||||
variables: { bodyshopid: bodyshop.id, phone_numbers: allPhoneNumbers },
|
||||
skip: allPhoneNumbers.length === 0 || !bodyshop.id,
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
// Map phone numbers to their associated owners and identify phone field
|
||||
const getAssociatedOwners = (phoneNumber) => {
|
||||
if (!ownersData?.owners) return [];
|
||||
const normalizedPhone = phoneNumber.replace(/^\+1/, "");
|
||||
return ownersData.owners
|
||||
.filter(
|
||||
(owner) =>
|
||||
owner.ownr_ph1 === phoneNumber ||
|
||||
owner.ownr_ph2 === phoneNumber ||
|
||||
owner.ownr_ph1 === normalizedPhone ||
|
||||
owner.ownr_ph2 === normalizedPhone ||
|
||||
owner.ownr_ph1 === `+1${phoneNumber}` ||
|
||||
owner.ownr_ph2 === `+1${phoneNumber}`
|
||||
)
|
||||
.map((owner) => ({
|
||||
...owner,
|
||||
phoneField:
|
||||
[owner.ownr_ph1, owner.ownr_ph2].includes(phoneNumber) ||
|
||||
[owner.ownr_ph1, owner.ownr_ph2].includes(normalizedPhone) ||
|
||||
[owner.ownr_ph1, owner.ownr_ph2].includes(`+1${phoneNumber}`)
|
||||
? owner.ownr_ph1 === phoneNumber ||
|
||||
owner.ownr_ph1 === normalizedPhone ||
|
||||
owner.ownr_ph1 === `+1${phoneNumber}`
|
||||
? t("consent.phone_1")
|
||||
: t("consent.phone_2")
|
||||
: null
|
||||
}));
|
||||
};*/
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t("consent.phone_number"),
|
||||
dataIndex: "phone_number",
|
||||
render: (text) => <PhoneNumberFormatter>{text}</PhoneNumberFormatter>,
|
||||
render: (text) => <ChatOpenButton phone={text} />,
|
||||
sorter: (a, b) => a.phone_number.localeCompare(b.phone_number)
|
||||
},
|
||||
// Commented out Associated Owners section for now
|
||||
/*{
|
||||
title: t("consent.associated_owners"),
|
||||
dataIndex: "phone_number",
|
||||
render: (phoneNumber) => {
|
||||
const owners = getAssociatedOwners(phoneNumber);
|
||||
if (!owners || owners.length === 0) {
|
||||
return t("consent.no_owners");
|
||||
}
|
||||
return owners.map((owner) => (
|
||||
<div key={owner.id}>
|
||||
<Space direction="horizontal">
|
||||
<Link to={"/manage/owners/" + owner.id}>
|
||||
<OwnerNameDisplay ownerObject={owner} />
|
||||
</Link>
|
||||
({owner.phoneField})
|
||||
</Space>
|
||||
</div>
|
||||
));
|
||||
},
|
||||
sorter: (a, b) => {
|
||||
const aOwners = getAssociatedOwners(a.phone_number);
|
||||
const bOwners = getAssociatedOwners(b.phone_number);
|
||||
const aName = aOwners[0] ? `${aOwners[0].ownr_fn} ${aOwners[0].ownr_ln}` : "";
|
||||
const bName = bOwners[0] ? `${bOwners[0].ownr_fn} ${bOwners[0].ownr_ln}` : "";
|
||||
return aName.localeCompare(bName);
|
||||
}
|
||||
},*/
|
||||
{
|
||||
title: t("consent.created_at"),
|
||||
dataIndex: "created_at",
|
||||
@@ -42,6 +125,7 @@ function PhoneNumberConsentList({ bodyshop, currentUser }) {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Paragraph>{t("consent.text_body")}</Paragraph>
|
||||
<Input.Search
|
||||
placeholder={t("general.labels.search")}
|
||||
onSearch={(value) => setSearch(value)}
|
||||
@@ -50,8 +134,8 @@ function PhoneNumberConsentList({ bodyshop, currentUser }) {
|
||||
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={data?.phone_number_opt_out}
|
||||
loading={loading}
|
||||
dataSource={optOutData?.phone_number_opt_out}
|
||||
loading={optOutLoading /* || ownersLoading*/}
|
||||
rowKey="id"
|
||||
style={{ marginTop: 16 }}
|
||||
/>
|
||||
|
||||
@@ -20,7 +20,7 @@ const Board = ({ id, className, orientation, cardSettings, ...additionalProps })
|
||||
default:
|
||||
return cardSizesVertical.small;
|
||||
}
|
||||
}, [cardSettings]);
|
||||
}, [cardSettings?.cardSize]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -101,11 +101,33 @@ const BoardContainer = ({
|
||||
async ({ draggableId, type, source, reason, mode, destination, combine }) => {
|
||||
setIsDragging(false);
|
||||
|
||||
// Only update drag time if it's a valid drop with a different destination
|
||||
if (type === "lane" && source && destination && !isEqual(source, destination)) {
|
||||
setDragTime(source.droppableId);
|
||||
setIsProcessing(true);
|
||||
// Validate drag type and source
|
||||
if (type !== "lane" || !source) {
|
||||
// Invalid drag type or missing source, attempt to revert if possible
|
||||
if (source) {
|
||||
dispatch(
|
||||
actions.moveCardAcrossLanes({
|
||||
fromLaneId: source.droppableId,
|
||||
toLaneId: source.droppableId,
|
||||
cardId: draggableId,
|
||||
index: source.index
|
||||
})
|
||||
);
|
||||
}
|
||||
setIsProcessing(false);
|
||||
try {
|
||||
await onDragEnd({ draggableId, type, source, reason, mode, destination, combine });
|
||||
} catch (err) {
|
||||
console.error("Error in onLaneDrag for invalid drag type or source", err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setDragTime(source.droppableId);
|
||||
setIsProcessing(true);
|
||||
|
||||
// Handle valid drop to a different lane or position
|
||||
if (destination && !isEqual(source, destination)) {
|
||||
dispatch(
|
||||
actions.moveCardAcrossLanes({
|
||||
fromLaneId: source.droppableId,
|
||||
@@ -114,14 +136,33 @@ const BoardContainer = ({
|
||||
index: destination.index
|
||||
})
|
||||
);
|
||||
} else {
|
||||
// Same-lane drop or no destination, revert to original position
|
||||
dispatch(
|
||||
actions.moveCardAcrossLanes({
|
||||
fromLaneId: source.droppableId,
|
||||
toLaneId: source.droppableId,
|
||||
cardId: draggableId,
|
||||
index: source.index
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
await onDragEnd({ draggableId, type, source, reason, mode, destination, combine });
|
||||
} catch (err) {
|
||||
console.error("Error in onLaneDrag", err);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
try {
|
||||
await onDragEnd({ draggableId, type, source, reason, mode, destination, combine });
|
||||
} catch (err) {
|
||||
console.error("Error in onLaneDrag", err);
|
||||
// Ensure revert on error
|
||||
dispatch(
|
||||
actions.moveCardAcrossLanes({
|
||||
fromLaneId: source.droppableId,
|
||||
toLaneId: source.droppableId,
|
||||
cardId: draggableId,
|
||||
index: source.index
|
||||
})
|
||||
);
|
||||
} finally {
|
||||
setIsProcessing(false);
|
||||
}
|
||||
},
|
||||
[dispatch, onDragEnd, setDragTime]
|
||||
|
||||
@@ -133,7 +133,9 @@ const Lane = ({
|
||||
Item: ItemComponent
|
||||
},
|
||||
itemContent: (index, item) => <ItemWrapper>{renderDraggable(index, item)}</ItemWrapper>,
|
||||
overscan: { main: 10, reverse: 10 }
|
||||
overscan: { main: 10, reverse: 10 },
|
||||
// Ensure a minimum height for empty lanes to allow dropping
|
||||
style: renderedCards.length === 0 ? { minHeight: "5px" } : {}
|
||||
};
|
||||
|
||||
const horizontalProps = {
|
||||
@@ -149,8 +151,6 @@ const Lane = ({
|
||||
|
||||
const componentProps = orientation === "vertical" ? verticalProps : horizontalProps;
|
||||
|
||||
// If the lane is collapsed, we want to render a div instead of the virtualized list, and we want to set the height to the max height of the lane so that
|
||||
// the lane doesn't shrink when collapsed (in horizontal mode)
|
||||
const finalComponentProps = collapsed
|
||||
? orientation === "horizontal"
|
||||
? {
|
||||
@@ -161,9 +161,8 @@ const Lane = ({
|
||||
: {}
|
||||
: componentProps;
|
||||
|
||||
// If the lane is horizontal and collapsed, we want to render a placeholder so that the lane doesn't shrink to 0 height and grows when
|
||||
// a card is dragged over it
|
||||
const shouldRenderPlaceholder = orientation !== "horizontal" && (collapsed || renderedCards.length === 0);
|
||||
// Always render placeholder for empty lanes in vertical mode to ensure droppable area
|
||||
const shouldRenderPlaceholder = orientation === "vertical" ? collapsed || renderedCards.length === 0 : collapsed;
|
||||
|
||||
return (
|
||||
<HeightMemoryWrapper
|
||||
@@ -178,8 +177,8 @@ const Lane = ({
|
||||
override={orientation !== "horizontal" && (collapsed || !renderedCards.length)}
|
||||
>
|
||||
<div
|
||||
ref={laneRef} // Ensure laneRef is set here
|
||||
style={{ height: "100%", width: "100%" }} // Make it scrollable
|
||||
ref={laneRef}
|
||||
style={{ height: "100%", width: "100%" }}
|
||||
className={`react-trello-lane ${collapsed ? "lane-collapsed" : ""}`}
|
||||
>
|
||||
<div {...provided.droppableProps} ref={provided.innerRef} style={{ ...provided.droppableProps.style }}>
|
||||
|
||||
@@ -140,7 +140,7 @@ export function ProductionListEmpAssignment({ insertAuditTrail, bodyshop, record
|
||||
if (record[type]) theEmployee = bodyshop.employees.find((e) => e.id === record[type]);
|
||||
|
||||
return (
|
||||
<Popover destroyTooltipOnHide content={popContent} open={visibility}>
|
||||
<Popover destroyOnHidden content={popContent} open={visibility}>
|
||||
<Spin spinning={loading}>
|
||||
{record[type] ? (
|
||||
<div>
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Button, Card, Tabs } from "antd";
|
||||
import React from "react";
|
||||
import queryString from "query-string";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
||||
import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component";
|
||||
import ShopInfoGeneral from "./shop-info.general.component";
|
||||
import ShopInfoIntakeChecklistComponent from "./shop-info.intake.component";
|
||||
import ShopInfoLaborRates from "./shop-info.laborrates.component";
|
||||
import ShopInfoNotificationsAutoadd from "./shop-info.notifications-autoadd.component.jsx";
|
||||
import ShopInfoOrderStatusComponent from "./shop-info.orderstatus.component";
|
||||
import ShopInfoPartsScan from "./shop-info.parts-scan";
|
||||
import ShopInfoRbacComponent from "./shop-info.rbac.component";
|
||||
import ShopInfoResponsibilityCenterComponent from "./shop-info.responsibilitycenters.component";
|
||||
import ShopInfoRoGuard from "./shop-info.roguard.component";
|
||||
import ShopInfoROStatusComponent from "./shop-info.rostatus.component";
|
||||
import ShopInfoSchedulingComponent from "./shop-info.scheduling.component";
|
||||
import ShopInfoSpeedPrint from "./shop-info.speedprint.component";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import ShopInfoTaskPresets from "./shop-info.task-presets.component";
|
||||
import queryString from "query-string";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||
import ShopInfoRoGuard from "./shop-info.roguard.component";
|
||||
import ShopInfoIntellipay from "./shop-intellipay-config.component";
|
||||
import { HasFeatureAccess } from "../feature-wrapper/feature-wrapper.component";
|
||||
import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
import ShopInfoNotificationsAutoadd from "./shop-info.notifications-autoadd.component.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
const mapDispatchToProps = () => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoComponent);
|
||||
@@ -158,7 +157,7 @@ export function ShopInfoComponent({ bodyshop, form, saveLoading }) {
|
||||
return (
|
||||
<Card
|
||||
extra={
|
||||
<Button type="primary" loading={saveLoading} onClick={() => form.submit()}>
|
||||
<Button type="primary" loading={saveLoading} onClick={() => form.submit()} id="shop-info-save-button">
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { DeleteFilled } from "@ant-design/icons";
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Button, DatePicker, Form, Input, InputNumber, Radio, Select, Space, Switch } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -19,7 +18,7 @@ const timeZonesList = Intl.supportedValuesOf("timeZone");
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
const mapDispatchToProps = () => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoGeneral);
|
||||
@@ -823,7 +822,7 @@ export function ShopInfoGeneral({ form, bodyshop }) {
|
||||
}}
|
||||
</Form.List>
|
||||
</LayoutFormRow>
|
||||
<LayoutFormRow grow header={t("bodyshop.labels.insurancecos")} id="insurancecos">
|
||||
<LayoutFormRow grow header=<span id="insurancecos-header">{t("bodyshop.labels.insurancecos")}</span> id="insurancecos">
|
||||
<Form.List name={["md_ins_cos"]}>
|
||||
{(fields, { add, remove, move }) => {
|
||||
return (
|
||||
|
||||
@@ -16,5 +16,6 @@ export default connect(mapStateToProps, mapDispatchToProps)(ShopSubStatus);
|
||||
export function ShopSubStatus({ bodyshop }) {
|
||||
const { t } = useTranslation();
|
||||
const { sub_status } = bodyshop;
|
||||
return <Result status="403" title={t(`general.labels.sub_status.${sub_status}`)} />;
|
||||
// ‘expired’ ‘trail-expired' are the valid sub_status values
|
||||
return <Result status="403" title={t(`general.errors.sub_status.${sub_status}`)} />;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export default function TimeTicketCalculatorComponent({
|
||||
open={visible}
|
||||
onOpenChange={handleOpenChange}
|
||||
placement="right"
|
||||
destroyTooltipOnHide
|
||||
destroyOnHidden
|
||||
>
|
||||
<Button onClick={(e) => e.preventDefault()}>
|
||||
<Space>
|
||||
|
||||
@@ -312,7 +312,6 @@ export const QUERY_INTAKE_CHECKLIST = gql`
|
||||
intakechecklist
|
||||
status
|
||||
owner {
|
||||
allow_text_message
|
||||
id
|
||||
}
|
||||
labhrs: joblines_aggregate(where: { _and: [{ mod_lbr_ty: { _neq: "LAR" } }, { removed: { _eq: false } }] }) {
|
||||
|
||||
@@ -43,6 +43,7 @@ export const CONVERSATION_SUBSCRIPTION_BY_PK = gql`
|
||||
id
|
||||
status
|
||||
text
|
||||
is_system
|
||||
isoutbound
|
||||
image
|
||||
image_path
|
||||
@@ -77,6 +78,7 @@ export const GET_CONVERSATION_DETAILS = gql`
|
||||
id
|
||||
status
|
||||
text
|
||||
is_system
|
||||
isoutbound
|
||||
image
|
||||
image_path
|
||||
|
||||
@@ -874,7 +874,6 @@ export const QUERY_JOB_CARD_DETAILS = gql`
|
||||
}
|
||||
owner {
|
||||
id
|
||||
allow_text_message
|
||||
preferred_contact
|
||||
tax_number
|
||||
}
|
||||
@@ -2071,7 +2070,6 @@ export const QUERY_JOB_CHECKLISTS = gql`
|
||||
production_vars
|
||||
owner {
|
||||
id
|
||||
allow_text_message
|
||||
}
|
||||
bodyshop {
|
||||
id
|
||||
@@ -2428,7 +2426,6 @@ export const QUERY_PARTS_QUEUE_CARD_DETAILS = gql`
|
||||
ownr_ph2
|
||||
owner {
|
||||
id
|
||||
allow_text_message
|
||||
preferred_contact
|
||||
tax_number
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ export const QUERY_OWNER_BY_ID = gql`
|
||||
owners_by_pk(id: $id) {
|
||||
id
|
||||
accountingid
|
||||
allow_text_message
|
||||
ownr_addr1
|
||||
ownr_addr2
|
||||
ownr_co_nm
|
||||
@@ -104,7 +103,6 @@ export const QUERY_ALL_OWNERS = gql`
|
||||
query QUERY_ALL_OWNERS {
|
||||
owners {
|
||||
id
|
||||
allow_text_message
|
||||
created_at
|
||||
ownr_addr1
|
||||
ownr_addr2
|
||||
@@ -129,7 +127,6 @@ export const QUERY_ALL_OWNERS_PAGINATED = gql`
|
||||
query QUERY_ALL_OWNERS_PAGINATED($search: String, $offset: Int, $limit: Int, $order: [owners_order_by!]!) {
|
||||
search_owners(args: { search: $search }, offset: $offset, limit: $limit, order_by: $order) {
|
||||
id
|
||||
allow_text_message
|
||||
created_at
|
||||
ownr_addr1
|
||||
ownr_addr2
|
||||
|
||||
@@ -26,3 +26,39 @@ export const GET_PHONE_NUMBER_OPT_OUTS = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const GET_PHONE_NUMBER_OPT_OUTS_BY_NUMBERS = gql`
|
||||
query GET_PHONE_NUMBER_OPT_OUTS_BY_NUMBERS($bodyshopid: uuid!, $phone_numbers: [String!]) {
|
||||
phone_number_opt_out(
|
||||
where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _in: $phone_numbers } }
|
||||
) {
|
||||
id
|
||||
bodyshopid
|
||||
phone_number
|
||||
created_at
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const SEARCH_OWNERS_BY_PHONE_NUMBERS = gql`
|
||||
query SEARCH_OWNERS_BY_PHONE_NUMBERS($bodyshopid: uuid!, $phone_numbers: [String!]) {
|
||||
owners(
|
||||
where: {
|
||||
shopid: { _eq: $bodyshopid },
|
||||
_or: [
|
||||
{ ownr_ph1: { _in: $phone_numbers } },
|
||||
{ ownr_ph2: { _in: $phone_numbers } }
|
||||
]
|
||||
}
|
||||
) {
|
||||
id
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
ownr_co_nm
|
||||
ownr_ph1
|
||||
ownr_ph2
|
||||
__typename
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -114,7 +114,6 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader }) {
|
||||
if (!!!job.ownerid) {
|
||||
ownerData = job.owner.data;
|
||||
ownerData.shopid = bodyshop.id;
|
||||
delete ownerData.allow_text_message;
|
||||
delete ownerData.preferred_contact;
|
||||
delete job.ownerid;
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,7 @@ import { Badge, Button, Divider, Form, Space, Tabs } from "antd";
|
||||
import Axios from "axios";
|
||||
import _ from "lodash";
|
||||
import queryString from "query-string";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FaHardHat, FaRegStickyNote, FaShieldAlt, FaTasks } from "react-icons/fa";
|
||||
import { connect } from "react-redux";
|
||||
@@ -28,6 +28,7 @@ import JobLineUpsertModalContainer from "../../components/job-lines-upsert-modal
|
||||
import JobProfileDataWarning from "../../components/job-profile-data-warning/job-profile-data-warning.component";
|
||||
import JobReconciliationModal from "../../components/job-reconciliation-modal/job-reconciliation.modal.container";
|
||||
import JobSyncButton from "../../components/job-sync-button/job-sync-button.component";
|
||||
import JobWatcherToggleContainer from "../../components/job-watcher-toggle/job-watcher-toggle.container.jsx";
|
||||
import JobsChangeStatus from "../../components/jobs-change-status/jobs-change-status.component";
|
||||
import JobsConvertButton from "../../components/jobs-convert-button/jobs-convert-button.component";
|
||||
import JobsDetailDatesComponent from "../../components/jobs-detail-dates/jobs-detail-dates.component";
|
||||
@@ -45,6 +46,8 @@ import LockWrapperComponent from "../../components/lock-wrapper/lock-wrapper.com
|
||||
import NoteUpsertModalComponent from "../../components/note-upsert-modal/note-upsert-modal.container";
|
||||
import ScheduleJobModalContainer from "../../components/schedule-job-modal/schedule-job-modal.container";
|
||||
import TaskListContainer from "../../components/task-list/task-list.container.jsx";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
import { QUERY_PARTS_BILLS_BY_JOBID } from "../../graphql/bills.queries.js";
|
||||
import { QUERY_JOB_TASKS_PAGINATED } from "../../graphql/tasks.queries.js";
|
||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||
@@ -55,9 +58,6 @@ import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||
import { DateTimeFormat } from "../../utils/DateFormatter";
|
||||
import dayjs from "../../utils/day";
|
||||
import UndefinedToNull from "../../utils/undefinedtonull";
|
||||
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket.js";
|
||||
import JobWatcherToggleContainer from "../../components/job-watcher-toggle/job-watcher-toggle.container.jsx";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -322,11 +322,11 @@ export function JobsDetailPage({
|
||||
>
|
||||
<PageHeader
|
||||
// onBack={() => window.history.back()}
|
||||
|
||||
id="job-detail-header"
|
||||
title={
|
||||
<Space>
|
||||
{scenarioNotificationsOn && <JobWatcherToggleContainer job={job} />}
|
||||
{job.ro_number || t("general.labels.na")}
|
||||
<span id="job-ro_number">{job.ro_number || t("general.labels.na")}</span>
|
||||
</Space>
|
||||
}
|
||||
extra={menuExtra}
|
||||
|
||||
@@ -92,13 +92,15 @@ export function ShopPage({ bodyshop, setSelectedHeader, setBreadcrumbs }) {
|
||||
});
|
||||
}
|
||||
|
||||
// Add Consent Settings tab
|
||||
items.push({
|
||||
key: "consent",
|
||||
label: t("bodyshop.labels.consent_settings"),
|
||||
children: <ShopInfoConsentComponent bodyshop={bodyshop} />
|
||||
});
|
||||
|
||||
if (bodyshop.messagingservicesid) {
|
||||
// Add Consent Settings tab
|
||||
items.push({
|
||||
key: "consent",
|
||||
label: t("bodyshop.labels.consent_settings"),
|
||||
children: <ShopInfoConsentComponent bodyshop={bodyshop} />
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<RbacWrapper action="shop:config">
|
||||
<Tabs activeKey={search.tab} onChange={(key) => history({ search: `?tab=${key}` })} items={items} />
|
||||
|
||||
@@ -335,20 +335,12 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
||||
}
|
||||
|
||||
try {
|
||||
InstanceRenderManager({
|
||||
executeFunction: true,
|
||||
args: [],
|
||||
imex: () => {
|
||||
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
||||
window.$crisp.push(["set", "session:segments", [[`region:${payload.region_config}`]]]);
|
||||
if (authRecord[0] && authRecord[0].user.validemail) {
|
||||
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
||||
}
|
||||
},
|
||||
rome: () => {
|
||||
window.$zoho.salesiq.visitor.info({ "Shop Name": payload.shopname });
|
||||
}
|
||||
});
|
||||
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
||||
window.$crisp.push(["set", "session:segments", [[`region:${payload.region_config}`]]]);
|
||||
if (authRecord[0] && authRecord[0].user.validemail) {
|
||||
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
||||
}
|
||||
|
||||
payload.features?.allAccess === true
|
||||
? window.$crisp.push(["set", "session:segments", [["allAccess"]]])
|
||||
: (() => {
|
||||
@@ -359,6 +351,14 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
||||
);
|
||||
window.$crisp.push(["set", "session:segments", [["basic", ...featureKeys]]]);
|
||||
})();
|
||||
|
||||
InstanceRenderManager({
|
||||
executeFunction: true,
|
||||
args: [],
|
||||
rome: () => {
|
||||
window.$zoho.salesiq.visitor.info({ "Shop Name": payload.shopname });
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn("Couldnt find $crisp.", error.message);
|
||||
}
|
||||
|
||||
@@ -775,7 +775,6 @@
|
||||
},
|
||||
"labels": {
|
||||
"addtoproduction": "Add Job to Production?",
|
||||
"allow_text_message": "Permission to Text?",
|
||||
"checklist": "Checklist",
|
||||
"printpack": "Job Intake Print Pack",
|
||||
"removefromproduction": "Remove Job from Production?"
|
||||
@@ -1231,7 +1230,11 @@
|
||||
"fcm": "You must allow notification permissions to have real time messaging. Click to try again.",
|
||||
"notfound": "No record was found.",
|
||||
"sizelimit": "The selected items exceed the size limit.",
|
||||
"submit-for-testing": "Error submitting Job for testing."
|
||||
"submit-for-testing": "Error submitting Job for testing.",
|
||||
"sub_status": {
|
||||
"expired": "The subscription for this shop has expired. Please contact Sales to reactivate.",
|
||||
"trial-expired": "The trial for this shop has expired. Please contact Sales to reactivate."
|
||||
}
|
||||
},
|
||||
"itemtypes": {
|
||||
"contract": "CC Contract",
|
||||
@@ -2032,9 +2035,10 @@
|
||||
"stands": "Stands",
|
||||
"waived": "Waived"
|
||||
},
|
||||
"deleteconfirm": "Are you sure you want to delete this Job? This cannot be undone. ",
|
||||
"deleteconfirm": "Are you sure you want to delete this Job? This cannot be undone.",
|
||||
"deletedelivery": "Delete Delivery Checklist",
|
||||
"deleteintake": "Delete Intake Checklist",
|
||||
"deletewatchers": "Remove Watchers before deleting this Job.",
|
||||
"deliverchecklist": "Deliver Checklist",
|
||||
"difference": "Difference",
|
||||
"diskscan": "Scan Disk for Estimates",
|
||||
@@ -2302,8 +2306,10 @@
|
||||
"productionlist": "Production Board - List",
|
||||
"readyjobs": "Ready Jobs",
|
||||
"recent": "Recent Items",
|
||||
"remoteassist": "Remote Assist",
|
||||
"reportcenter": "Report Center",
|
||||
"rescueme": "Rescue me!",
|
||||
"rescueme": "Rescue Me!",
|
||||
"rescuemezoho": "Remote Me In!",
|
||||
"schedule": "Schedule",
|
||||
"scoreboard": "Scoreboard",
|
||||
"search": {
|
||||
@@ -2379,7 +2385,7 @@
|
||||
"invalidphone": "The phone number is invalid. Unable to open conversation. ",
|
||||
"noattachedjobs": "No Jobs have been associated to this conversation. ",
|
||||
"updatinglabel": "Error updating label. {{error}}",
|
||||
"no_consent": "This phone number has not consented to receive messages."
|
||||
"no_consent": "This phone number has opted-out of Messaging."
|
||||
},
|
||||
"labels": {
|
||||
"addlabel": "Add a label to this conversation.",
|
||||
@@ -2396,7 +2402,7 @@
|
||||
"sentby": "Sent by {{by}} at {{time}}",
|
||||
"typeamessage": "Send a message...",
|
||||
"unarchive": "Unarchive",
|
||||
"no_consent": "No Consent"
|
||||
"no_consent": "Opted-out"
|
||||
},
|
||||
"render": {
|
||||
"conversation_list": "Conversation List"
|
||||
@@ -2521,7 +2527,6 @@
|
||||
"fields": {
|
||||
"accountingid": "Accounting ID",
|
||||
"address": "Address",
|
||||
"allow_text_message": "Permission to Text?",
|
||||
"name": "Name",
|
||||
"note": "Owner Note",
|
||||
"ownr_addr1": "Address",
|
||||
@@ -3869,8 +3874,12 @@
|
||||
},
|
||||
"consent": {
|
||||
"phone_number": "Phone Number",
|
||||
"status": "Consent Status",
|
||||
"created_at": "Created At"
|
||||
"associated_owners": "Associated Owners",
|
||||
"created_at": "Opt-Out Date",
|
||||
"no_owners": "No Associated Owners",
|
||||
"phone_1": "Phone 1",
|
||||
"phone_2": "Phone 2",
|
||||
"text_body": "Users can opt out of receiving SMS messages by replying with keywords such as STOP, UNSUBSCRIBE, CANCEL, END, QUIT, STOPALL, REVOKE and OPTOUT. To opt back in, users can reply with START, YES, or UNSTOP. Even after opting out, users can still send messages to us, which will be received and processed as needed. Ensure customers are informed to reply with these keywords to manage their messaging preferences. After opting out, users receive a confirmation message and will not receive further messages until they opt back in."
|
||||
},
|
||||
"settings": {
|
||||
"title": "Phone Number Opt-Out List"
|
||||
|
||||
@@ -656,6 +656,7 @@
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"consent_settings": "",
|
||||
"2tiername": "",
|
||||
"2tiersetup": "",
|
||||
"2tiersource": "",
|
||||
@@ -774,7 +775,6 @@
|
||||
},
|
||||
"labels": {
|
||||
"addtoproduction": "",
|
||||
"allow_text_message": "",
|
||||
"checklist": "",
|
||||
"printpack": "",
|
||||
"removefromproduction": ""
|
||||
@@ -1230,7 +1230,11 @@
|
||||
"fcm": "",
|
||||
"notfound": "",
|
||||
"sizelimit": "",
|
||||
"submit-for-testing": ""
|
||||
"submit-for-testing": "",
|
||||
"sub_status": {
|
||||
"expired": "",
|
||||
"trial-expired": ""
|
||||
}
|
||||
},
|
||||
"itemtypes": {
|
||||
"contract": "",
|
||||
@@ -2034,6 +2038,7 @@
|
||||
"deleteconfirm": "",
|
||||
"deletedelivery": "",
|
||||
"deleteintake": "",
|
||||
"deletewatchers": "",
|
||||
"deliverchecklist": "",
|
||||
"difference": "",
|
||||
"diskscan": "",
|
||||
@@ -2301,8 +2306,10 @@
|
||||
"productionlist": "",
|
||||
"readyjobs": "",
|
||||
"recent": "",
|
||||
"remoteassist": "",
|
||||
"reportcenter": "",
|
||||
"rescueme": "",
|
||||
"rescuemezoho": "",
|
||||
"schedule": "Programar",
|
||||
"scoreboard": "",
|
||||
"search": {
|
||||
@@ -2377,7 +2384,8 @@
|
||||
"errors": {
|
||||
"invalidphone": "",
|
||||
"noattachedjobs": "",
|
||||
"updatinglabel": ""
|
||||
"updatinglabel": "",
|
||||
"no_consent": ""
|
||||
},
|
||||
"labels": {
|
||||
"addlabel": "",
|
||||
@@ -2393,7 +2401,8 @@
|
||||
"selectmedia": "",
|
||||
"sentby": "",
|
||||
"typeamessage": "Enviar un mensaje...",
|
||||
"unarchive": ""
|
||||
"unarchive": "",
|
||||
"no_consent": ""
|
||||
},
|
||||
"render": {
|
||||
"conversation_list": ""
|
||||
@@ -2498,7 +2507,8 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"job-watchers": "",
|
||||
"not-employee": ""
|
||||
"not-employee": "",
|
||||
"not-employee-notifications": ""
|
||||
}
|
||||
},
|
||||
"owner": {
|
||||
@@ -2519,7 +2529,6 @@
|
||||
"fields": {
|
||||
"accountingid": "",
|
||||
"address": "Dirección",
|
||||
"allow_text_message": "Permiso de texto?",
|
||||
"name": "Nombre",
|
||||
"note": "",
|
||||
"ownr_addr1": "Dirección",
|
||||
@@ -3864,6 +3873,18 @@
|
||||
"validation": {
|
||||
"unique_vendor_name": ""
|
||||
}
|
||||
},
|
||||
"consent": {
|
||||
"phone_number": "",
|
||||
"associated_owners": "",
|
||||
"created_at": "",
|
||||
"no_owners": "",
|
||||
"phone_1": "",
|
||||
"phone_2": "",
|
||||
"text_body": ""
|
||||
},
|
||||
"settings": {
|
||||
"title": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -656,6 +656,7 @@
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"consent_settings": "",
|
||||
"2tiername": "",
|
||||
"2tiersetup": "",
|
||||
"2tiersource": "",
|
||||
@@ -774,7 +775,6 @@
|
||||
},
|
||||
"labels": {
|
||||
"addtoproduction": "",
|
||||
"allow_text_message": "",
|
||||
"checklist": "",
|
||||
"printpack": "",
|
||||
"removefromproduction": ""
|
||||
@@ -1230,7 +1230,11 @@
|
||||
"fcm": "",
|
||||
"notfound": "",
|
||||
"sizelimit": "",
|
||||
"submit-for-testing": ""
|
||||
"submit-for-testing": "",
|
||||
"sub_status": {
|
||||
"expired": "",
|
||||
"trial-expired": ""
|
||||
}
|
||||
},
|
||||
"itemtypes": {
|
||||
"contract": "",
|
||||
@@ -2034,6 +2038,7 @@
|
||||
"deleteconfirm": "",
|
||||
"deletedelivery": "",
|
||||
"deleteintake": "",
|
||||
"deletewatchers": "",
|
||||
"deliverchecklist": "",
|
||||
"difference": "",
|
||||
"diskscan": "",
|
||||
@@ -2301,8 +2306,10 @@
|
||||
"productionlist": "",
|
||||
"readyjobs": "",
|
||||
"recent": "",
|
||||
"remoteassist": "",
|
||||
"reportcenter": "",
|
||||
"rescueme": "",
|
||||
"rescuemezoho": "",
|
||||
"schedule": "Programme",
|
||||
"scoreboard": "",
|
||||
"search": {
|
||||
@@ -2377,7 +2384,8 @@
|
||||
"errors": {
|
||||
"invalidphone": "",
|
||||
"noattachedjobs": "",
|
||||
"updatinglabel": ""
|
||||
"updatinglabel": "",
|
||||
"no_consent": ""
|
||||
},
|
||||
"labels": {
|
||||
"addlabel": "",
|
||||
@@ -2393,7 +2401,8 @@
|
||||
"selectmedia": "",
|
||||
"sentby": "",
|
||||
"typeamessage": "Envoyer un message...",
|
||||
"unarchive": ""
|
||||
"unarchive": "",
|
||||
"no_consent": ""
|
||||
},
|
||||
"render": {
|
||||
"conversation_list": ""
|
||||
@@ -2498,7 +2507,8 @@
|
||||
},
|
||||
"tooltips": {
|
||||
"job-watchers": "",
|
||||
"not-employee": ""
|
||||
"not-employee": "",
|
||||
"not-employee-notifications": ""
|
||||
}
|
||||
},
|
||||
"owner": {
|
||||
@@ -2519,7 +2529,6 @@
|
||||
"fields": {
|
||||
"accountingid": "",
|
||||
"address": "Adresse",
|
||||
"allow_text_message": "Autorisation de texte?",
|
||||
"name": "Prénom",
|
||||
"note": "",
|
||||
"ownr_addr1": "Adresse",
|
||||
@@ -3864,6 +3873,18 @@
|
||||
"validation": {
|
||||
"unique_vendor_name": ""
|
||||
}
|
||||
},
|
||||
"consent": {
|
||||
"phone_number": "Phone Number",
|
||||
"associated_owners": "Associated Owners",
|
||||
"created_at": "Opt-Out Date",
|
||||
"no_owners": "No Associated Owners",
|
||||
"phone_1": "Phone 1",
|
||||
"phone_2": "Phone 2",
|
||||
"text_body": ""
|
||||
},
|
||||
"settings": {
|
||||
"title": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Tooltip } from "antd";
|
||||
import dayjs from "../utils/day";
|
||||
import React from "react";
|
||||
|
||||
export function DateFormatter(props) {
|
||||
return props.children ? dayjs(props.children).format(props.includeDay ? "ddd MM/DD/YYYY" : "MM/DD/YYYY") : null;
|
||||
|
||||
48
client/src/utils/phoneOptOutService.js
Normal file
48
client/src/utils/phoneOptOutService.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { phone } from "phone";
|
||||
import { GET_PHONE_NUMBER_OPT_OUTS_BY_NUMBERS } from "../graphql/phone-number-opt-out.queries";
|
||||
|
||||
/**
|
||||
* Check if phone numbers are opted out for a given bodyshop
|
||||
* @param {Object} apolloClient - Apollo Client instance
|
||||
* @param {string} bodyshopId - The ID of the bodyshop
|
||||
* @param {string[]} phoneNumbers - Array of phone numbers to check
|
||||
* @returns {Promise<Set<string>>} - Set of normalized opted-out phone numbers
|
||||
*/
|
||||
export const phoneNumberOptOutService = async (apolloClient, bodyshopId, phoneNumbers) => {
|
||||
if (!apolloClient || !bodyshopId || !phoneNumbers?.length) {
|
||||
return new Set();
|
||||
}
|
||||
|
||||
// Normalize phone numbers (remove +1 for CA numbers)
|
||||
const normalizedPhones = phoneNumbers
|
||||
.filter(Boolean)
|
||||
.map((num) => phone(num, "CA").phoneNumber?.replace(/^\+1/, ""))
|
||||
.filter(Boolean);
|
||||
|
||||
if (!normalizedPhones.length) {
|
||||
return new Set();
|
||||
}
|
||||
|
||||
const optedOutPhones = new Set();
|
||||
|
||||
try {
|
||||
const { data } = await apolloClient.query({
|
||||
query: GET_PHONE_NUMBER_OPT_OUTS_BY_NUMBERS,
|
||||
variables: {
|
||||
bodyshopid: bodyshopId,
|
||||
phone_numbers: normalizedPhones // Array of phone numbers
|
||||
},
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
if (data?.phone_number_opt_out?.length) {
|
||||
data.phone_number_opt_out.forEach((optOut) => {
|
||||
optedOutPhones.add(optOut.phone_number);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error checking opt-out statuses:", error);
|
||||
}
|
||||
|
||||
return optedOutPhones;
|
||||
};
|
||||
@@ -1035,6 +1035,7 @@
|
||||
- use_fippa
|
||||
- use_paint_scale_data
|
||||
- uselocalmediaserver
|
||||
- external_shop_id
|
||||
- website
|
||||
- workingdays
|
||||
- zip_post
|
||||
@@ -1130,6 +1131,7 @@
|
||||
- use_fippa
|
||||
- use_paint_scale_data
|
||||
- uselocalmediaserver
|
||||
- external_shop_id
|
||||
- website
|
||||
- workingdays
|
||||
- zip_post
|
||||
@@ -4742,6 +4744,7 @@
|
||||
- id
|
||||
- image
|
||||
- image_path
|
||||
- is_system
|
||||
- isoutbound
|
||||
- msid
|
||||
- read
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."messages" add column "is_system" boolean
|
||||
-- null default 'false';
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."messages" add column "is_system" boolean
|
||||
null default 'false';
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Could not auto-generate a down migration.
|
||||
-- Please write an appropriate down migration for the SQL below:
|
||||
-- alter table "public"."bodyshops" add column "we_profile_id" text
|
||||
-- null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."bodyshops" add column "we_profile_id" text
|
||||
null;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."bodyshops" rename column "parts_management_key" to "we_profile_id";
|
||||
alter table "public"."bodyshops" drop constraint "bodyshops_we_profile_id_key";
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table "public"."bodyshops" add constraint "bodyshops_we_profile_id_key" unique ("we_profile_id");
|
||||
alter table "public"."bodyshops" rename column "we_profile_id" to "parts_management_key";
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."bodyshops" rename column "external_shop_id" to "parts_management_key";
|
||||
@@ -0,0 +1 @@
|
||||
alter table "public"."bodyshops" rename column "parts_management_key" to "external_shop_id";
|
||||
@@ -10028,25 +10028,6 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>allow_text_message</name>
|
||||
<description/>
|
||||
<comment/>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-ES</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>checklist</name>
|
||||
<description/>
|
||||
@@ -33000,25 +32981,6 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>allow_text_message</name>
|
||||
<description/>
|
||||
<comment/>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-ES</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>name</name>
|
||||
<description/>
|
||||
|
||||
2105
package-lock.json
generated
2105
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@@ -16,14 +16,14 @@
|
||||
"job-totals-fixtures:local": "docker exec node-app /usr/bin/node /app/download-job-totals-fixtures.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-cloudwatch-logs": "^3.812.0",
|
||||
"@aws-sdk/client-elasticache": "^3.812.0",
|
||||
"@aws-sdk/client-s3": "^3.812.0",
|
||||
"@aws-sdk/client-secrets-manager": "^3.812.0",
|
||||
"@aws-sdk/client-ses": "^3.812.0",
|
||||
"@aws-sdk/credential-provider-node": "^3.812.0",
|
||||
"@aws-sdk/lib-storage": "^3.812.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.812.0",
|
||||
"@aws-sdk/client-cloudwatch-logs": "^3.826.0",
|
||||
"@aws-sdk/client-elasticache": "^3.826.0",
|
||||
"@aws-sdk/client-s3": "^3.826.0",
|
||||
"@aws-sdk/client-secrets-manager": "^3.826.0",
|
||||
"@aws-sdk/client-ses": "^3.826.0",
|
||||
"@aws-sdk/credential-provider-node": "^3.826.0",
|
||||
"@aws-sdk/lib-storage": "^3.826.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.826.0",
|
||||
"@opensearch-project/opensearch": "^2.13.0",
|
||||
"@socket.io/admin-ui": "^0.5.1",
|
||||
"@socket.io/redis-adapter": "^8.3.0",
|
||||
@@ -31,14 +31,14 @@
|
||||
"aws4": "^1.13.2",
|
||||
"axios": "^1.8.4",
|
||||
"better-queue": "^3.8.12",
|
||||
"bullmq": "^5.53.0",
|
||||
"bullmq": "^5.53.2",
|
||||
"chart.js": "^4.4.8",
|
||||
"cloudinary": "^2.6.1",
|
||||
"compression": "^1.8.0",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"cors": "^2.8.5",
|
||||
"crisp-status-reporter": "^1.2.2",
|
||||
"dd-trace": "^5.52.0",
|
||||
"dd-trace": "^5.55.0",
|
||||
"dinero.js": "^1.9.1",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.21.1",
|
||||
@@ -52,7 +52,7 @@
|
||||
"juice": "^11.0.1",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.30.1",
|
||||
"moment-timezone": "^0.5.48",
|
||||
"moment-timezone": "^0.6.0",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"node-persist": "^4.0.4",
|
||||
"nodemailer": "^6.10.0",
|
||||
@@ -61,11 +61,11 @@
|
||||
"recursive-diff": "^1.0.9",
|
||||
"rimraf": "^6.0.1",
|
||||
"skia-canvas": "^2.0.2",
|
||||
"soap": "^1.1.10",
|
||||
"soap": "^1.1.12",
|
||||
"socket.io": "^4.8.1",
|
||||
"socket.io-adapter": "^2.5.5",
|
||||
"ssh2-sftp-client": "^11.0.0",
|
||||
"twilio": "^5.6.1",
|
||||
"twilio": "^5.7.0",
|
||||
"uuid": "^11.1.0",
|
||||
"winston": "^3.17.0",
|
||||
"winston-cloudwatch": "^6.3.0",
|
||||
@@ -73,14 +73,14 @@
|
||||
"xmlbuilder2": "^3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.27.0",
|
||||
"eslint": "^9.27.0",
|
||||
"@eslint/js": "^9.28.0",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"globals": "^15.15.0",
|
||||
"mock-require": "^3.0.3",
|
||||
"p-limit": "^3.1.0",
|
||||
"prettier": "^3.5.3",
|
||||
"supertest": "^7.1.1",
|
||||
"vitest": "^3.1.4"
|
||||
"vitest": "^3.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,6 +282,7 @@ const applySocketIO = async ({ server, app }) => {
|
||||
logger.log("Redis connections closed.", "INFO", "redis", "api");
|
||||
});
|
||||
|
||||
// IO Redis
|
||||
const ioRedis = new Server(server, {
|
||||
path: "/wss",
|
||||
adapter: createAdapter(pubClient, subClient),
|
||||
|
||||
@@ -35,7 +35,7 @@ exports.default = async (req, res) => {
|
||||
//Query the usage data.
|
||||
const queryResults = await client.request(queries.STATUS_UPDATE, {
|
||||
today: moment().startOf("day").subtract(7, "days"),
|
||||
period: moment().subtract(90, "days").startOf("day")
|
||||
period: moment().subtract(365, "days").startOf("day")
|
||||
});
|
||||
|
||||
//Massage the data.
|
||||
@@ -66,7 +66,7 @@ exports.default = async (req, res) => {
|
||||
Usage Report for ${moment().format("MM/DD/YYYY")} for Rome Online Customers.
|
||||
|
||||
Notes:
|
||||
- Days Since Creation: The number of days since the shop was created. Only shops created in the last 90 days are included.
|
||||
- Days Since Creation: The number of days since the shop was created. Only shops created in the last 365 days are included.
|
||||
- Updated values should be higher than created values.
|
||||
- Counts are inclusive of the last 7 days of data.
|
||||
`,
|
||||
|
||||
@@ -2980,4 +2980,59 @@ exports.INSERT_INTEGRATION_LOG = `
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
`;
|
||||
|
||||
exports.INSERT_PHONE_NUMBER_OPT_OUT = `
|
||||
mutation INSERT_PHONE_NUMBER_OPT_OUT($optOutInput: [phone_number_opt_out_insert_input!]!) {
|
||||
insert_phone_number_opt_out(objects: $optOutInput, on_conflict: { constraint: phone_number_consent_bodyshopid_phone_number_key, update_columns: [updated_at] }) {
|
||||
affected_rows
|
||||
returning {
|
||||
id
|
||||
bodyshopid
|
||||
phone_number
|
||||
created_at
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
// Query to check if a phone number is opted out
|
||||
exports.CHECK_PHONE_NUMBER_OPT_OUT = `
|
||||
query CHECK_PHONE_NUMBER_OPT_OUT($bodyshopid: uuid!, $phone_number: String!) {
|
||||
phone_number_opt_out(where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _eq: $phone_number } }) {
|
||||
id
|
||||
bodyshopid
|
||||
phone_number
|
||||
created_at
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
// Query to check if a phone number is opted out
|
||||
exports.CHECK_PHONE_NUMBER_OPT_OUT = `
|
||||
query CHECK_PHONE_NUMBER_OPT_OUT($bodyshopid: uuid!, $phone_number: String!) {
|
||||
phone_number_opt_out(where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _eq: $phone_number } }) {
|
||||
id
|
||||
bodyshopid
|
||||
phone_number
|
||||
created_at
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
// Mutation to delete a phone number opt-out record
|
||||
exports.DELETE_PHONE_NUMBER_OPT_OUT = `
|
||||
mutation DELETE_PHONE_NUMBER_OPT_OUT($bodyshopid: uuid!, $phone_number: String!) {
|
||||
delete_phone_number_opt_out(where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _eq: $phone_number } }) {
|
||||
affected_rows
|
||||
returning {
|
||||
id
|
||||
bodyshopid
|
||||
phone_number
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
1236
server/integrations/partsManagement/defaultNewShop.json
Normal file
1236
server/integrations/partsManagement/defaultNewShop.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,257 @@
|
||||
const crypto = require("crypto");
|
||||
const admin = require("firebase-admin");
|
||||
const client = require("../../graphql-client/graphql-client").client;
|
||||
const DefaultNewShop = require("./defaultNewShop.json");
|
||||
|
||||
/**
|
||||
* Ensures that the required fields are present in the payload.
|
||||
* @param payload
|
||||
* @param fields
|
||||
*/
|
||||
const requireFields = (payload, fields) => {
|
||||
for (const field of fields) {
|
||||
if (!payload[field]) {
|
||||
throw { status: 400, message: `${field} is required.` };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Ensures that the email is not already registered in Firebase.
|
||||
* @param email
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const ensureEmailNotRegistered = async (email) => {
|
||||
try {
|
||||
await admin.auth().getUserByEmail(email);
|
||||
throw { status: 400, message: "userEmail is already registered in Firebase." };
|
||||
} catch (err) {
|
||||
if (err.code !== "auth/user-not-found") {
|
||||
throw { status: 500, message: "Error validating userEmail uniqueness", detail: err };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new Firebase user with the provided email.
|
||||
* @param email
|
||||
* @returns {Promise<UserRecord>}
|
||||
*/
|
||||
const createFirebaseUser = async (email) => {
|
||||
return admin.auth().createUser({ email });
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes a Firebase user by their UID.
|
||||
* @param uid
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const deleteFirebaseUser = async (uid) => {
|
||||
return admin.auth().deleteUser(uid);
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a password reset link for the given email.
|
||||
* @param email
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
const generateResetLink = async (email) => {
|
||||
return admin.auth().generatePasswordResetLink(email);
|
||||
};
|
||||
|
||||
/**
|
||||
* Ensures that the external shop ID is unique in the database.
|
||||
* @param externalId
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const ensureExternalIdUnique = async (externalId) => {
|
||||
const query = `
|
||||
query CHECK_KEY($key: String!) {
|
||||
bodyshops(where: { external_shop_id: { _eq: $key } }) {
|
||||
external_shop_id
|
||||
}
|
||||
}`;
|
||||
const resp = await client.request(query, { key: externalId });
|
||||
if (resp.bodyshops.length) {
|
||||
throw { status: 400, message: `external_shop_id '${externalId}' is already in use.` };
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Inserts a new bodyshop into the database.
|
||||
* @param input
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
const insertBodyshop = async (input) => {
|
||||
const mutation = `
|
||||
mutation CREATE_SHOP($bs: bodyshops_insert_input!) {
|
||||
insert_bodyshops_one(object: $bs) { id }
|
||||
}`;
|
||||
const resp = await client.request(mutation, { bs: input });
|
||||
return resp.insert_bodyshops_one.id;
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes all vendors associated with a specific shop ID.
|
||||
* @param shopId
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const deleteVendorsByShop = async (shopId) => {
|
||||
const mutation = `
|
||||
mutation DELETE_VENDORS($shopId: uuid!) {
|
||||
delete_vendors(where: { shopid: { _eq: $shopId } }) {
|
||||
affected_rows
|
||||
}
|
||||
}`;
|
||||
await client.request(mutation, { shopId });
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes a bodyshop by its ID.
|
||||
* @param shopId
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const deleteBodyshop = async (shopId) => {
|
||||
const mutation = `
|
||||
mutation DELETE_SHOP($id: uuid!) {
|
||||
delete_bodyshops_by_pk(id: $id) { id }
|
||||
}`;
|
||||
await client.request(mutation, { id: shopId });
|
||||
};
|
||||
|
||||
/**
|
||||
* Inserts a new user association into the database.
|
||||
* @param uid
|
||||
* @param email
|
||||
* @param shopId
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
const insertUserAssociation = async (uid, email, shopId) => {
|
||||
const mutation = `
|
||||
mutation CREATE_USER($u: users_insert_input!) {
|
||||
insert_users_one(object: $u) {
|
||||
id: authid
|
||||
email
|
||||
}
|
||||
}`;
|
||||
const vars = {
|
||||
u: {
|
||||
email,
|
||||
authid: uid,
|
||||
validemail: true,
|
||||
associations: {
|
||||
data: [{ shopid: shopId, authlevel: 80, active: true }]
|
||||
}
|
||||
}
|
||||
};
|
||||
const resp = await client.request(mutation, vars);
|
||||
return resp.insert_users_one;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles the provisioning of a new parts management shop and user.
|
||||
* @param req
|
||||
* @param res
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
const partsManagementProvisioning = async (req, res) => {
|
||||
const { logger } = req;
|
||||
const p = { ...req.body, userEmail: req.body.userEmail?.toLowerCase() };
|
||||
|
||||
try {
|
||||
// Validate inputs
|
||||
await ensureEmailNotRegistered(p.userEmail);
|
||||
requireFields(p, [
|
||||
"external_shop_id",
|
||||
"shopname",
|
||||
"address1",
|
||||
"city",
|
||||
"state",
|
||||
"zip_post",
|
||||
"country",
|
||||
"email",
|
||||
"phone",
|
||||
"userEmail"
|
||||
]);
|
||||
await ensureExternalIdUnique(p.external_shop_id);
|
||||
|
||||
logger.log("admin-create-shop-user", "debug", p.userEmail, null, {
|
||||
request: req.body,
|
||||
ioadmin: true
|
||||
});
|
||||
|
||||
// Create shop
|
||||
const shopInput = {
|
||||
shopname: p.shopname,
|
||||
address1: p.address1,
|
||||
address2: p.address2 || null,
|
||||
city: p.city,
|
||||
state: p.state,
|
||||
zip_post: p.zip_post,
|
||||
country: p.country,
|
||||
email: p.email,
|
||||
external_shop_id: p.external_shop_id,
|
||||
timezone: p.timezone,
|
||||
phone: p.phone,
|
||||
logo_img_path: {
|
||||
src: p.logoUrl,
|
||||
width: "",
|
||||
height: "",
|
||||
headerMargin: DefaultNewShop.logo_img_path.headerMargin
|
||||
},
|
||||
md_ro_statuses: DefaultNewShop.md_ro_statuses,
|
||||
vendors: {
|
||||
data: p.vendors.map((v) => ({
|
||||
name: v.name,
|
||||
street1: v.street1 || null,
|
||||
street2: v.street2 || null,
|
||||
city: v.city || null,
|
||||
state: v.state || null,
|
||||
zip: v.zip || null,
|
||||
country: v.country || null,
|
||||
email: v.email || null,
|
||||
discount: v.discount ?? 0,
|
||||
due_date: v.due_date ?? null,
|
||||
cost_center: v.cost_center || null,
|
||||
favorite: v.favorite ?? [],
|
||||
phone: v.phone || null,
|
||||
active: v.active ?? true,
|
||||
dmsid: v.dmsid || null
|
||||
}))
|
||||
}
|
||||
};
|
||||
const newShopId = await insertBodyshop(shopInput);
|
||||
|
||||
// Create user + association
|
||||
const userRecord = await createFirebaseUser(p.userEmail);
|
||||
const resetLink = await generateResetLink(p.userEmail);
|
||||
const createdUser = await insertUserAssociation(userRecord.uid, p.userEmail, newShopId);
|
||||
|
||||
return res.status(200).json({
|
||||
shop: { id: newShopId, shopname: p.shopname },
|
||||
user: {
|
||||
id: createdUser.id,
|
||||
email: createdUser.email,
|
||||
resetLink
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
logger.log("admin-create-shop-user-error", "error", p.userEmail, null, {
|
||||
message: err.message,
|
||||
detail: err.detail || err
|
||||
});
|
||||
|
||||
// Cleanup on failure
|
||||
if (err.userRecord) {
|
||||
await deleteFirebaseUser(err.userRecord.uid).catch(() => {});
|
||||
}
|
||||
if (err.newShopId) {
|
||||
await deleteVendorsByShop(err.newShopId).catch(() => {});
|
||||
await deleteBodyshop(err.newShopId).catch(() => {});
|
||||
}
|
||||
|
||||
return res.status(err.status || 500).json({ error: err.message || "Internal server error" });
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = partsManagementProvisioning;
|
||||
160
server/integrations/partsManagement/swagger.yaml
Normal file
160
server/integrations/partsManagement/swagger.yaml
Normal file
@@ -0,0 +1,160 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Parts Management Provisioning API
|
||||
description: API endpoint to provision a new shop and user in the Parts Management system.
|
||||
version: 1.0.0
|
||||
|
||||
paths:
|
||||
/parts-management/provision:
|
||||
post:
|
||||
summary: Provision a new parts management shop and user
|
||||
operationId: partsManagementProvisioning
|
||||
tags:
|
||||
- Parts Management
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- external_shop_id
|
||||
- shopname
|
||||
- address1
|
||||
- city
|
||||
- state
|
||||
- zip_post
|
||||
- country
|
||||
- email
|
||||
- phone
|
||||
- userEmail
|
||||
properties:
|
||||
external_shop_id:
|
||||
type: string
|
||||
description: External shop ID (must be unique)
|
||||
shopname:
|
||||
type: string
|
||||
address1:
|
||||
type: string
|
||||
address2:
|
||||
type: string
|
||||
nullable: true
|
||||
city:
|
||||
type: string
|
||||
state:
|
||||
type: string
|
||||
zip_post:
|
||||
type: string
|
||||
country:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
userEmail:
|
||||
type: string
|
||||
format: email
|
||||
logoUrl:
|
||||
type: string
|
||||
format: uri
|
||||
nullable: true
|
||||
timezone:
|
||||
type: string
|
||||
nullable: true
|
||||
vendors:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
street1:
|
||||
type: string
|
||||
nullable: true
|
||||
street2:
|
||||
type: string
|
||||
nullable: true
|
||||
city:
|
||||
type: string
|
||||
nullable: true
|
||||
state:
|
||||
type: string
|
||||
nullable: true
|
||||
zip:
|
||||
type: string
|
||||
nullable: true
|
||||
country:
|
||||
type: string
|
||||
nullable: true
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
nullable: true
|
||||
discount:
|
||||
type: number
|
||||
nullable: true
|
||||
due_date:
|
||||
type: string
|
||||
format: date
|
||||
nullable: true
|
||||
cost_center:
|
||||
type: string
|
||||
nullable: true
|
||||
favorite:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
phone:
|
||||
type: string
|
||||
nullable: true
|
||||
active:
|
||||
type: boolean
|
||||
nullable: true
|
||||
dmsid:
|
||||
type: string
|
||||
nullable: true
|
||||
responses:
|
||||
'200':
|
||||
description: Shop and user successfully created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
shop:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
shopname:
|
||||
type: string
|
||||
user:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
resetLink:
|
||||
type: string
|
||||
format: uri
|
||||
'400':
|
||||
description: Bad request (missing or invalid fields)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
'500':
|
||||
description: Internal server error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
23
server/middleware/partsManagementIntegrationMiddleware.js
Normal file
23
server/middleware/partsManagementIntegrationMiddleware.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Middleware to check if the request is authorized for Parts Management Integration.
|
||||
* @param req
|
||||
* @param res
|
||||
* @param next
|
||||
* @returns {*}
|
||||
*/
|
||||
const partsManagementIntegrationMiddleware = (req, res, next) => {
|
||||
const secret = process.env.PARTS_MANAGEMENT_INTEGRATION_SECRET;
|
||||
if (typeof secret !== "string" || secret.length === 0) {
|
||||
return res.status(500).send("Server misconfiguration");
|
||||
}
|
||||
|
||||
const headerValue = req.headers["parts-management-integration-secret"];
|
||||
if (typeof headerValue !== "string" || headerValue.trim() !== secret) {
|
||||
return res.status(401).send("Unauthorized");
|
||||
}
|
||||
|
||||
req.isPartsManagementIntegrationAuthorized = true;
|
||||
next();
|
||||
};
|
||||
|
||||
module.exports = partsManagementIntegrationMiddleware;
|
||||
@@ -1,16 +1,19 @@
|
||||
/**
|
||||
* VSSTA Integration Middleware
|
||||
* @param req
|
||||
* @param res
|
||||
* @param next
|
||||
* @returns {*}
|
||||
* Fails closed if the env var is missing or empty, and strictly compares header.
|
||||
*/
|
||||
const vsstaIntegrationMiddleware = (req, res, next) => {
|
||||
if (req?.headers?.["vssta-integration-secret"] !== process.env?.VSSTA_INTEGRATION_SECRET) {
|
||||
const secret = process.env.VSSTA_INTEGRATION_SECRET;
|
||||
if (typeof secret !== "string" || secret.length === 0) {
|
||||
return res.status(500).send("Server misconfiguration");
|
||||
}
|
||||
|
||||
const headerValue = req.headers["vssta-integration-secret"];
|
||||
if (typeof headerValue !== "string" || headerValue.trim() !== secret) {
|
||||
return res.status(401).send("Unauthorized");
|
||||
}
|
||||
|
||||
req.isIntegrationAuthorized = true;
|
||||
req.isVsstaIntegrationAuthorized = true;
|
||||
next();
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ async function OpenSearchUpdateHandler(req, res) {
|
||||
document = pick(req.body.event.data.new, ["id", "ownr_fn", "ownr_ln", "ownr_co_nm", "ownr_ph1", "ownr_ph2"]);
|
||||
document.bodyshopid = req.body.event.data.new.shopid;
|
||||
break;
|
||||
case "bills":
|
||||
case "bills": {
|
||||
const bill = await client.request(
|
||||
`query ADMIN_GET_BILL_BY_ID($billId: uuid!) {
|
||||
bills_by_pk(id: $billId) {
|
||||
@@ -97,7 +97,8 @@ async function OpenSearchUpdateHandler(req, res) {
|
||||
bodyshopid: bill.bills_by_pk.job.shopid
|
||||
};
|
||||
break;
|
||||
case "payments":
|
||||
}
|
||||
case "payments": {
|
||||
//Query to get the job and RO number
|
||||
|
||||
const payment = await client.request(
|
||||
@@ -141,6 +142,7 @@ async function OpenSearchUpdateHandler(req, res) {
|
||||
bodyshopid: payment.payments_by_pk.job.shopid
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
const payload = {
|
||||
id: req.body.event.data.new.id,
|
||||
@@ -255,6 +257,7 @@ async function OpenSearchSearchHandler(req, res) {
|
||||
"*ownr_co_nm^8",
|
||||
"*ownr_ph1^8",
|
||||
"*ownr_ph2^8",
|
||||
"*vendor.name^8",
|
||||
"*comment^6"
|
||||
// "*"
|
||||
]
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
const express = require("express");
|
||||
const vsstaIntegration = require("../integrations/VSSTA/vsstaIntegrationRoute");
|
||||
const vsstaMiddleware = require("../middleware/vsstaIntegrationMiddleware");
|
||||
const router = express.Router();
|
||||
|
||||
router.post("/vssta", vsstaMiddleware, vsstaIntegration);
|
||||
// Pull secrets from env
|
||||
const { VSSTA_INTEGRATION_SECRET, PARTS_MANAGEMENT_INTEGRATION_SECRET } = process.env;
|
||||
|
||||
// Only load VSSTA routes if the secret is set
|
||||
if (typeof VSSTA_INTEGRATION_SECRET === "string" && VSSTA_INTEGRATION_SECRET.length > 0) {
|
||||
const vsstaIntegration = require("../integrations/VSSTA/vsstaIntegrationRoute");
|
||||
const vsstaMiddleware = require("../middleware/vsstaIntegrationMiddleware");
|
||||
|
||||
router.post("/vssta", vsstaMiddleware, vsstaIntegration);
|
||||
} else {
|
||||
console.warn("VSSTA_INTEGRATION_SECRET is not set — skipping /vssta integration route");
|
||||
}
|
||||
|
||||
// Only load Parts Management routes if that secret is set
|
||||
if (typeof PARTS_MANAGEMENT_INTEGRATION_SECRET === "string" && PARTS_MANAGEMENT_INTEGRATION_SECRET.length > 0) {
|
||||
const partsManagementProvisioning = require("../integrations/partsManagement/partsManagementProvisioning");
|
||||
const partsManagementIntegrationMiddleware = require("../middleware/partsManagementIntegrationMiddleware");
|
||||
|
||||
router.post("/parts-management/provision", partsManagementIntegrationMiddleware, partsManagementProvisioning);
|
||||
} else {
|
||||
console.warn("PARTS_MANAGEMENT_INTEGRATION_SECRET is not set — skipping /parts-management/provision route");
|
||||
}
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -3,12 +3,25 @@ const {
|
||||
FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID,
|
||||
UNARCHIVE_CONVERSATION,
|
||||
CREATE_CONVERSATION,
|
||||
INSERT_MESSAGE
|
||||
INSERT_MESSAGE,
|
||||
CHECK_PHONE_NUMBER_OPT_OUT,
|
||||
DELETE_PHONE_NUMBER_OPT_OUT,
|
||||
INSERT_PHONE_NUMBER_OPT_OUT
|
||||
} = require("../graphql-client/queries");
|
||||
const { phone } = require("phone");
|
||||
const { admin } = require("../firebase/firebase-handler");
|
||||
const InstanceManager = require("../utils/instanceMgr").default;
|
||||
|
||||
// Note: When we handle different languages, we might need to adjust these keywords accordingly.
|
||||
const optInKeywords = ["START", "YES", "UNSTOP"];
|
||||
const optOutKeywords = ["STOP", "STOPALL", "UNSUBSCRIBE", "CANCEL", "END", "QUIT", "REVOKE", "OPTOUT"];
|
||||
|
||||
// System Message text, will also need to be localized if we support multiple languages
|
||||
const systemMessageOptions = {
|
||||
optIn: "Customer has opted-in",
|
||||
optOut: "Customer has opted-out"
|
||||
};
|
||||
|
||||
/**
|
||||
* Receive SMS messages from Twilio and process them
|
||||
* @param req
|
||||
@@ -51,22 +64,16 @@ const receive = async (req, res) => {
|
||||
}
|
||||
|
||||
const bodyshop = response.bodyshops[0];
|
||||
const normalizedPhone = phone(req.body.From).phoneNumber.replace(/^\+1/, ""); // Normalize phone number (remove +1 for CA numbers)
|
||||
const messageText = (req.body.Body || "").trim().toUpperCase();
|
||||
|
||||
// Step 4: Process conversation
|
||||
// Step 2: Process conversation
|
||||
const sortedConversations = bodyshop.conversations.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
|
||||
const existingConversation = sortedConversations.length
|
||||
? sortedConversations[sortedConversations.length - 1]
|
||||
: null;
|
||||
|
||||
let conversationid;
|
||||
let newMessage = {
|
||||
msid: req.body.SmsMessageSid,
|
||||
text: req.body.Body,
|
||||
image: !!req.body.MediaUrl0,
|
||||
image_path: generateMediaArray(req.body, logger),
|
||||
isoutbound: false,
|
||||
userid: null
|
||||
};
|
||||
|
||||
if (existingConversation) {
|
||||
conversationid = existingConversation.id;
|
||||
@@ -88,9 +95,134 @@ const receive = async (req, res) => {
|
||||
conversationid = createdConversation.id;
|
||||
}
|
||||
|
||||
newMessage.conversationid = conversationid;
|
||||
// Step 3: Handle opt-in or opt-out keywords
|
||||
let systemMessageText = "";
|
||||
let socketEventType = "";
|
||||
|
||||
if (optInKeywords.includes(messageText) || optOutKeywords.includes(messageText)) {
|
||||
// Check if the phone number is in phone_number_opt_out
|
||||
const optOutCheck = await client.request(CHECK_PHONE_NUMBER_OPT_OUT, {
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: normalizedPhone
|
||||
});
|
||||
|
||||
// Opt In
|
||||
if (optInKeywords.includes(messageText)) {
|
||||
// Handle opt-in
|
||||
if (optOutCheck.phone_number_opt_out.length > 0) {
|
||||
// Phone number is opted out; delete the record
|
||||
const deleteResponse = await client.request(DELETE_PHONE_NUMBER_OPT_OUT, {
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: normalizedPhone
|
||||
});
|
||||
|
||||
logger.log("sms-opt-in-success", "INFO", "api", null, {
|
||||
msid: req.body.SmsMessageSid,
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: normalizedPhone,
|
||||
affected_rows: deleteResponse.delete_phone_number_opt_out.affected_rows
|
||||
});
|
||||
|
||||
systemMessageText = systemMessageOptions.optIn;
|
||||
socketEventType = "phone-number-opted-in";
|
||||
}
|
||||
}
|
||||
// Opt Out
|
||||
else if (optOutKeywords.includes(messageText)) {
|
||||
// Handle opt-out
|
||||
if (optOutCheck.phone_number_opt_out.length === 0) {
|
||||
// Phone number is not opted out; insert a new record
|
||||
const now = new Date().toISOString();
|
||||
const optOutInput = {
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: normalizedPhone,
|
||||
created_at: now,
|
||||
updated_at: now
|
||||
};
|
||||
|
||||
const insertResponse = await client.request(INSERT_PHONE_NUMBER_OPT_OUT, {
|
||||
optOutInput: [optOutInput]
|
||||
});
|
||||
|
||||
logger.log("sms-opt-out-success", "INFO", "api", null, {
|
||||
msid: req.body.SmsMessageSid,
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: normalizedPhone,
|
||||
affected_rows: insertResponse.insert_phone_number_opt_out.affected_rows
|
||||
});
|
||||
|
||||
systemMessageText = systemMessageOptions.optOut;
|
||||
socketEventType = "phone-number-opted-out";
|
||||
}
|
||||
}
|
||||
|
||||
// Insert system message if an opt-in or opt-out action was taken
|
||||
if (systemMessageText) {
|
||||
const systemMessage = {
|
||||
msid: `SYS_${req.body.SmsMessageSid}_${Date.now()}`, // Unique ID for system message
|
||||
text: systemMessageText,
|
||||
conversationid,
|
||||
isoutbound: false,
|
||||
userid: null,
|
||||
image: false,
|
||||
image_path: null,
|
||||
is_system: true
|
||||
};
|
||||
|
||||
const systemMessageResponse = await client.request(INSERT_MESSAGE, {
|
||||
msg: systemMessage,
|
||||
conversationid
|
||||
});
|
||||
|
||||
const insertedSystemMessage = systemMessageResponse.insert_messages.returning[0];
|
||||
|
||||
// Emit WebSocket events for system message
|
||||
const broadcastRoom = getBodyshopRoom(bodyshop.id);
|
||||
const conversationRoom = getBodyshopConversationRoom({
|
||||
bodyshopId: bodyshop.id,
|
||||
conversationId: conversationid
|
||||
});
|
||||
|
||||
const systemPayload = {
|
||||
isoutbound: false,
|
||||
conversationId: conversationid,
|
||||
updated_at: insertedSystemMessage.updated_at,
|
||||
msid: insertedSystemMessage.msid,
|
||||
existingConversation: !!existingConversation,
|
||||
newConversation: !existingConversation ? insertedSystemMessage.conversation : null
|
||||
};
|
||||
|
||||
ioRedis.to(broadcastRoom).emit("new-message-summary", {
|
||||
...systemPayload,
|
||||
summary: true
|
||||
});
|
||||
|
||||
ioRedis.to(conversationRoom).emit("new-message-detailed", {
|
||||
newMessage: insertedSystemMessage,
|
||||
...systemPayload,
|
||||
summary: false
|
||||
});
|
||||
|
||||
// Emit opt-in or opt-out event
|
||||
ioRedis.to(broadcastRoom).emit(socketEventType, {
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: normalizedPhone
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Insert the original message
|
||||
const newMessage = {
|
||||
msid: req.body.SmsMessageSid,
|
||||
text: req.body.Body,
|
||||
image: !!req.body.MediaUrl0,
|
||||
image_path: generateMediaArray(req.body, logger),
|
||||
isoutbound: false,
|
||||
userid: null,
|
||||
conversationid,
|
||||
is_system: false
|
||||
};
|
||||
|
||||
// Step 5: Insert the message
|
||||
const insertresp = await client.request(INSERT_MESSAGE, {
|
||||
msg: newMessage,
|
||||
conversationid
|
||||
@@ -103,7 +235,7 @@ const receive = async (req, res) => {
|
||||
throw new Error("Conversation data is missing from the response.");
|
||||
}
|
||||
|
||||
// Step 6: Notify clients
|
||||
// Step 5: Notify clients for original message
|
||||
const conversationRoom = getBodyshopConversationRoom({
|
||||
bodyshopId: conversation.bodyshop.id,
|
||||
conversationId: conversation.id
|
||||
@@ -113,7 +245,7 @@ const receive = async (req, res) => {
|
||||
isoutbound: false,
|
||||
conversationId: conversation.id,
|
||||
updated_at: message.updated_at,
|
||||
msid: message.sid
|
||||
msid: message.msid
|
||||
};
|
||||
|
||||
const broadcastRoom = getBodyshopRoom(conversation.bodyshop.id);
|
||||
@@ -133,7 +265,7 @@ const receive = async (req, res) => {
|
||||
summary: false
|
||||
});
|
||||
|
||||
// Step 7: Send FCM notification
|
||||
// Step 6: Send FCM notification
|
||||
const fcmresp = await admin.messaging().send({
|
||||
topic: `${message.conversation.bodyshop.imexshopid}-messaging`,
|
||||
notification: {
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
const { UPDATE_MESSAGE_STATUS, MARK_MESSAGES_AS_READ } = require("../graphql-client/queries");
|
||||
const {
|
||||
UPDATE_MESSAGE_STATUS,
|
||||
MARK_MESSAGES_AS_READ,
|
||||
INSERT_PHONE_NUMBER_OPT_OUT,
|
||||
FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID
|
||||
} = require("../graphql-client/queries");
|
||||
const logger = require("../utils/logger");
|
||||
const { phone } = require("phone");
|
||||
|
||||
/**
|
||||
* Handle the status of an SMS message
|
||||
@@ -9,7 +15,7 @@ const logger = require("../utils/logger");
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
const status = async (req, res) => {
|
||||
const { SmsSid, SmsStatus } = req.body;
|
||||
const { SmsSid, SmsStatus, ErrorCode, To, MessagingServiceSid } = req.body;
|
||||
const {
|
||||
ioRedis,
|
||||
ioHelpers: { getBodyshopRoom, getBodyshopConversationRoom }
|
||||
@@ -21,18 +27,76 @@ const status = async (req, res) => {
|
||||
return res.status(200).json({ message: "Status 'queued' disregarded." });
|
||||
}
|
||||
|
||||
// Handle ErrorCode 21610 (Attempt to send to unsubscribed recipient) first
|
||||
if (ErrorCode === "21610" && To && MessagingServiceSid) {
|
||||
try {
|
||||
// Step 1: Find the bodyshop by MessagingServiceSid
|
||||
const bodyshopResponse = await client.request(FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID, {
|
||||
mssid: MessagingServiceSid,
|
||||
phone: phone(To).phoneNumber // Pass the normalized phone number as required
|
||||
});
|
||||
|
||||
const bodyshop = bodyshopResponse.bodyshops[0];
|
||||
if (!bodyshop) {
|
||||
logger.log("sms-opt-out-error", "ERROR", "api", null, {
|
||||
msid: SmsSid,
|
||||
messagingServiceSid: MessagingServiceSid,
|
||||
to: To,
|
||||
error: "No matching bodyshop found"
|
||||
});
|
||||
} else {
|
||||
// Step 2: Insert into phone_number_opt_out table
|
||||
const now = new Date().toISOString();
|
||||
const optOutInput = {
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: phone(To).phoneNumber.replace(/^\+1/, ""), // Normalize phone number (remove +1 for CA numbers)
|
||||
created_at: now,
|
||||
updated_at: now
|
||||
};
|
||||
|
||||
const optOutResponse = await client.request(INSERT_PHONE_NUMBER_OPT_OUT, {
|
||||
optOutInput: [optOutInput]
|
||||
});
|
||||
|
||||
logger.log("sms-opt-out-success", "INFO", null, null, {
|
||||
msid: SmsSid,
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: optOutInput.phone_number,
|
||||
affected_rows: optOutResponse.insert_phone_number_opt_out.affected_rows
|
||||
});
|
||||
|
||||
// Store bodyshopid for potential use in WebSocket notification
|
||||
const broadcastRoom = getBodyshopRoom(bodyshop.id);
|
||||
ioRedis.to(broadcastRoom).emit("phone-number-opted-out", {
|
||||
bodyshopid: bodyshop.id,
|
||||
phone_number: optOutInput.phone_number
|
||||
// Note: conversationId is not included yet; will be set after message lookup
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
logger.log("sms-opt-out-error", "ERROR", "api", null, {
|
||||
msid: SmsSid,
|
||||
messagingServiceSid: MessagingServiceSid,
|
||||
to: To,
|
||||
error: error.message,
|
||||
stack: error.stack
|
||||
});
|
||||
// Continue processing to update message status
|
||||
}
|
||||
}
|
||||
|
||||
// Update message status in the database
|
||||
const response = await client.request(UPDATE_MESSAGE_STATUS, {
|
||||
msid: SmsSid,
|
||||
fields: { status: SmsStatus }
|
||||
});
|
||||
|
||||
const message = response.update_messages.returning[0];
|
||||
const message = response.update_messages?.returning?.[0];
|
||||
|
||||
if (message) {
|
||||
logger.log("sms-status-update", "DEBUG", "api", null, {
|
||||
msid: SmsSid,
|
||||
fields: { status: SmsStatus }
|
||||
status: SmsStatus
|
||||
});
|
||||
|
||||
// Emit WebSocket event to notify the change in message status
|
||||
@@ -47,20 +111,20 @@ const status = async (req, res) => {
|
||||
type: "status-changed"
|
||||
});
|
||||
} else {
|
||||
logger.log("sms-status-update-warning", "WARN", "api", null, {
|
||||
logger.log("sms-status-update-warning", "WARN", null, null, {
|
||||
msid: SmsSid,
|
||||
fields: { status: SmsStatus },
|
||||
warning: "No message returned from the database update."
|
||||
status: SmsStatus,
|
||||
warning: "No message found in database for update"
|
||||
});
|
||||
}
|
||||
|
||||
res.sendStatus(200);
|
||||
} catch (error) {
|
||||
} catch (err) {
|
||||
logger.log("sms-status-update-error", "ERROR", "api", null, {
|
||||
msid: SmsSid,
|
||||
fields: { status: SmsStatus },
|
||||
stack: error.stack,
|
||||
message: error.message
|
||||
status: SmsStatus,
|
||||
error: err.message,
|
||||
stack: err.stack
|
||||
});
|
||||
res.status(500).json({ error: "Failed to update message status." });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user