Compare commits
27 Commits
rrScratch2
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca1a456312 | ||
|
|
c010665ea9 | ||
|
|
d6fba12cd9 | ||
|
|
6ea1c291e6 | ||
|
|
05d5c96491 | ||
|
|
35a566cbe5 | ||
|
|
f12e40e4c6 | ||
|
|
bb4e671c83 | ||
|
|
d1637d2432 | ||
|
|
1c79628613 | ||
|
|
521a7084b7 | ||
|
|
77268d5f5b | ||
|
|
1b3abf17ec | ||
|
|
3cfd445894 | ||
|
|
b510eec9aa | ||
|
|
e5eac0933f | ||
|
|
a3c71fdfc0 | ||
|
|
78750d3d96 | ||
|
|
90edf94fee | ||
|
|
065fb72677 | ||
|
|
ddc6141480 | ||
|
|
7bc137fa79 | ||
|
|
dafe9de753 | ||
|
|
78a8474a24 | ||
|
|
123066f1cd | ||
|
|
a153cca3c0 | ||
|
|
35c7c32c8e |
@@ -138,7 +138,7 @@ export function App({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentEula && !currentUser.eulaIsAccepted) {
|
if (!isPartsEntry && currentEula && !currentUser.eulaIsAccepted) {
|
||||||
return <Eula />;
|
return <Eula />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,17 +142,37 @@ export default function JobLifecycleDashboardComponent({ data, bodyshop, ...card
|
|||||||
title={t("job_lifecycle.content.legend_title")}
|
title={t("job_lifecycle.content.legend_title")}
|
||||||
style={{ marginTop: "10px" }}
|
style={{ marginTop: "10px" }}
|
||||||
>
|
>
|
||||||
<div>
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
gap: 8
|
||||||
|
}}
|
||||||
|
>
|
||||||
{lifecycleData.summations.map((key) => (
|
{lifecycleData.summations.map((key) => (
|
||||||
<Tag key={key.status} color={key.color} style={{ width: "13vh", padding: "4px", margin: "4px" }}>
|
<Tag
|
||||||
|
key={key.status}
|
||||||
|
color={key.color}
|
||||||
|
style={{
|
||||||
|
// IMPORTANT: let the tag grow with its content
|
||||||
|
width: "auto",
|
||||||
|
padding: 0,
|
||||||
|
margin: 0,
|
||||||
|
display: "inline-flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
boxSizing: "border-box"
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
aria-label={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
aria-label={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
||||||
title={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
title={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "var(--tag-wrapper-bg)",
|
backgroundColor: "var(--tag-wrapper-bg)",
|
||||||
color: "var(--tag-wrapper-text)",
|
color: "var(--tag-wrapper-text)",
|
||||||
padding: "4px",
|
padding: "4px 8px",
|
||||||
textAlign: "center"
|
textAlign: "center",
|
||||||
|
whiteSpace: "nowrap" // keep it on one line while letting the pill expand
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{key.status} [{lifecycleData.statusCounts[key.status]}] ({key.roundedPercentage})
|
{key.status} [{lifecycleData.statusCounts[key.status]}] ({key.roundedPercentage})
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ const Eula = ({ currentEula, currentUser, acceptEula }) => {
|
|||||||
const useremail = currentUser.email;
|
const useremail = currentUser.email;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { ...otherFormValues } = formValues;
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const { accepted_terms, ...otherFormValues } = formValues;
|
||||||
|
|
||||||
// Trim the values of the fields before submitting
|
// Trim the values of the fields before submitting
|
||||||
const trimmedFormValues = Object.entries(otherFormValues).reduce((acc, [key, value]) => {
|
const trimmedFormValues = Object.entries(otherFormValues).reduce((acc, [key, value]) => {
|
||||||
|
|||||||
@@ -222,17 +222,37 @@ export function JobLifecycleComponent({ bodyshop, job, statuses }) {
|
|||||||
</div>
|
</div>
|
||||||
</BlurWrapperComponent>
|
</BlurWrapperComponent>
|
||||||
<Card type="inner" title={t("job_lifecycle.content.legend_title")} style={{ marginTop: "10px" }}>
|
<Card type="inner" title={t("job_lifecycle.content.legend_title")} style={{ marginTop: "10px" }}>
|
||||||
<div>
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
gap: 8
|
||||||
|
}}
|
||||||
|
>
|
||||||
{lifecycleData.durations.summations.map((key) => (
|
{lifecycleData.durations.summations.map((key) => (
|
||||||
<Tag key={key.status} color={key.color} style={{ width: "13vh", padding: "4px", margin: "4px" }}>
|
<Tag
|
||||||
|
key={key.status}
|
||||||
|
color={key.color}
|
||||||
|
style={{
|
||||||
|
// let the tag grow with its content
|
||||||
|
width: "auto",
|
||||||
|
padding: 0,
|
||||||
|
margin: 0,
|
||||||
|
display: "inline-flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
boxSizing: "border-box"
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
aria-label={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
aria-label={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
||||||
title={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
title={`${key.status} | ${key.roundedPercentage} | ${key.humanReadable}`}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "var(--tag-wrapper-bg)",
|
backgroundColor: "var(--tag-wrapper-bg)",
|
||||||
color: "var(--tag-wrapper-text)",
|
color: "var(--tag-wrapper-text)",
|
||||||
padding: "4px",
|
padding: "4px 8px",
|
||||||
textAlign: "center"
|
textAlign: "center",
|
||||||
|
whiteSpace: "nowrap" // single line; tag gets wider instead of text escaping
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{key.status} (
|
{key.status} (
|
||||||
|
|||||||
@@ -35,16 +35,14 @@ export function JobsDocumentsImgproxyDownloadButton({ galleryImages, identifier,
|
|||||||
...galleryImages.other.filter((image) => image.isSelected)
|
...galleryImages.other.filter((image) => image.isSelected)
|
||||||
];
|
];
|
||||||
|
|
||||||
function downloadProgress(progressEvent) {
|
const downloadProgress = ({ loaded }) => {
|
||||||
setDownload((currentDownloadState) => {
|
setDownload((currentDownloadState) => ({
|
||||||
return {
|
downloaded: loaded ?? 0,
|
||||||
downloaded: progressEvent.loaded || 0,
|
speed: (loaded ?? 0) - (currentDownloadState?.downloaded ?? 0)
|
||||||
speed: (progressEvent.loaded || 0) - ((currentDownloadState && currentDownloadState.downloaded) || 0)
|
}));
|
||||||
};
|
};
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function standardMediaDownload(bufferData) {
|
const standardMediaDownload = (bufferData) => {
|
||||||
try {
|
try {
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
const url = window.URL.createObjectURL(new Blob([bufferData]));
|
const url = window.URL.createObjectURL(new Blob([bufferData]));
|
||||||
@@ -55,29 +53,26 @@ export function JobsDocumentsImgproxyDownloadButton({ galleryImages, identifier,
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
setDownload(null);
|
setDownload(null);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleDownload = async () => {
|
const handleDownload = async () => {
|
||||||
logImEXEvent("jobs_documents_download");
|
logImEXEvent("jobs_documents_download");
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await axios({
|
const { data } = await axios({
|
||||||
url: "/media/imgproxy/download",
|
url: "/media/imgproxy/download",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
data: { jobId, documentids: imagesToDownload.map((_) => _.id) },
|
data: { jobId, documentids: imagesToDownload.map((_) => _.id) },
|
||||||
onDownloadProgress: downloadProgress
|
onDownloadProgress: downloadProgress
|
||||||
});
|
});
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
setDownload(null);
|
|
||||||
|
|
||||||
// Use the response data (Blob) to trigger download
|
// Use the response data (Blob) to trigger download
|
||||||
standardMediaDownload(response.data);
|
standardMediaDownload(data);
|
||||||
} catch {
|
} catch {
|
||||||
|
// handle error (optional)
|
||||||
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setDownload(null);
|
setDownload(null);
|
||||||
// handle error (optional)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -76,14 +76,14 @@ function JobsDocumentsImgproxyComponent({
|
|||||||
<SyncOutlined />
|
<SyncOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
<JobsDocumentsGallerySelectAllComponent galleryImages={galleryImages} setGalleryImages={setGalleryImages} />
|
<JobsDocumentsGallerySelectAllComponent galleryImages={galleryImages} setGalleryImages={setGalleryImages} />
|
||||||
|
{!billId && (
|
||||||
|
<JobsDocumentsGalleryReassign galleryImages={galleryImages} callback={fetchThumbnails || refetch} />
|
||||||
|
)}
|
||||||
<JobsDocumentsDownloadButton galleryImages={galleryImages} identifier={downloadIdentifier} jobId={jobId} />
|
<JobsDocumentsDownloadButton galleryImages={galleryImages} identifier={downloadIdentifier} jobId={jobId} />
|
||||||
<JobsDocumentsDeleteButton
|
<JobsDocumentsDeleteButton
|
||||||
galleryImages={galleryImages}
|
galleryImages={galleryImages}
|
||||||
deletionCallback={billsCallback || fetchThumbnails || refetch}
|
deletionCallback={billsCallback || fetchThumbnails || refetch}
|
||||||
/>
|
/>
|
||||||
{!billId && (
|
|
||||||
<JobsDocumentsGalleryReassign galleryImages={galleryImages} callback={fetchThumbnails || refetch} />
|
|
||||||
)}
|
|
||||||
</Space>
|
</Space>
|
||||||
</Col>
|
</Col>
|
||||||
{!hasMediaAccess && (
|
{!hasMediaAccess && (
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export default function JobsDocumentsImgproxyDeleteButton({ galleryImages, delet
|
|||||||
okButtonProps={{ danger: true }}
|
okButtonProps={{ danger: true }}
|
||||||
cancelText={t("general.actions.cancel")}
|
cancelText={t("general.actions.cancel")}
|
||||||
>
|
>
|
||||||
<Button disabled={imagesToDelete.length < 1} loading={loading}>
|
<Button danger disabled={imagesToDelete.length < 1} loading={loading}>
|
||||||
{t("documents.actions.delete")}
|
{t("documents.actions.delete")}
|
||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ export function JobsDocumentsLocalGallery({
|
|||||||
<a href={CreateExplorerLinkForJob({ jobid: job.id })}>
|
<a href={CreateExplorerLinkForJob({ jobid: job.id })}>
|
||||||
<Button>{t("documents.labels.openinexplorer")}</Button>
|
<Button>{t("documents.labels.openinexplorer")}</Button>
|
||||||
</a>
|
</a>
|
||||||
<JobsDocumentsLocalGalleryReassign jobid={job.id} />
|
|
||||||
<JobsDocumentsLocalGallerySelectAllComponent jobid={job.id} />
|
<JobsDocumentsLocalGallerySelectAllComponent jobid={job.id} />
|
||||||
|
<JobsDocumentsLocalGalleryReassign jobid={job.id} />
|
||||||
<JobsLocalGalleryDownloadButton job={job} />
|
<JobsLocalGalleryDownloadButton job={job} />
|
||||||
<JobsDocumentsLocalDeleteButton jobid={job.id} />
|
<JobsDocumentsLocalDeleteButton jobid={job.id} />
|
||||||
</Space>
|
</Space>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ export function JobsDocumentsLocalDeleteButton({ bodyshop, getJobMedia, allMedia
|
|||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const imagesToDelete = (allMedia?.[jobid] || []).filter((i) => i.isSelected);
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
logImEXEvent("job_documents_delete");
|
logImEXEvent("job_documents_delete");
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -36,7 +38,7 @@ export function JobsDocumentsLocalDeleteButton({ bodyshop, getJobMedia, allMedia
|
|||||||
`${bodyshop.localmediaserverhttp}/jobs/delete`,
|
`${bodyshop.localmediaserverhttp}/jobs/delete`,
|
||||||
{
|
{
|
||||||
jobid: jobid,
|
jobid: jobid,
|
||||||
files: (allMedia?.[jobid] || []).filter((i) => i.isSelected).map((i) => i.filename)
|
files: imagesToDelete.map((i) => i.filename)
|
||||||
},
|
},
|
||||||
{ headers: { ims_token: bodyshop.localmediatoken } }
|
{ headers: { ims_token: bodyshop.localmediatoken } }
|
||||||
);
|
);
|
||||||
@@ -60,14 +62,17 @@ export function JobsDocumentsLocalDeleteButton({ bodyshop, getJobMedia, allMedia
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
|
disabled={imagesToDelete.length < 1}
|
||||||
icon={<QuestionCircleOutlined style={{ color: "red" }} />}
|
icon={<QuestionCircleOutlined style={{ color: "red" }} />}
|
||||||
onConfirm={handleDelete}
|
onConfirm={handleDelete}
|
||||||
title={t("documents.labels.confirmdelete")}
|
title={t("documents.labels.confirmdelete")}
|
||||||
okText={t("general.actions.delete")}
|
okText={t("general.actions.delete")}
|
||||||
okButtonProps={{ type: "danger" }}
|
okButtonProps={{ danger: true }}
|
||||||
cancelText={t("general.actions.cancel")}
|
cancelText={t("general.actions.cancel")}
|
||||||
>
|
>
|
||||||
<Button loading={loading}>{t("documents.actions.delete")}</Button>
|
<Button danger disabled={imagesToDelete.length < 1} loading={loading}>
|
||||||
|
{t("documents.actions.delete")}
|
||||||
|
</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Button } from "antd";
|
import { Button, Space } from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import cleanAxios from "../../utils/CleanAxios";
|
import cleanAxios from "../../utils/CleanAxios";
|
||||||
|
import formatBytes from "../../utils/formatbytes";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectAllMedia } from "../../redux/media/media.selectors";
|
import { selectAllMedia } from "../../redux/media/media.selectors";
|
||||||
@@ -19,45 +19,63 @@ export default connect(mapStateToProps, mapDispatchToProps)(JobsLocalGalleryDown
|
|||||||
|
|
||||||
export function JobsLocalGalleryDownloadButton({ bodyshop, allMedia, job }) {
|
export function JobsLocalGalleryDownloadButton({ bodyshop, allMedia, job }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [download, setDownload] = useState(null);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [download, setDownload] = useState(false);
|
||||||
|
|
||||||
function downloadProgress(progressEvent) {
|
const imagesToDownload = (allMedia?.[job.id] || []).filter((i) => i.isSelected);
|
||||||
setDownload((currentDownloadState) => {
|
|
||||||
return {
|
const downloadProgress = ({ loaded }) => {
|
||||||
downloaded: progressEvent.loaded || 0,
|
setDownload((currentDownloadState) => ({
|
||||||
speed: (progressEvent.loaded || 0) - (currentDownloadState?.downloaded || 0)
|
downloaded: loaded || 0,
|
||||||
};
|
speed: (loaded || 0) - (currentDownloadState?.downloaded || 0)
|
||||||
});
|
}));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const standardMediaDownload = (bufferData, filename) => {
|
||||||
|
try {
|
||||||
|
const a = document.createElement("a");
|
||||||
|
const url = window.URL.createObjectURL(new Blob([bufferData]));
|
||||||
|
a.href = url;
|
||||||
|
a.download = `${filename}.zip`;
|
||||||
|
a.click();
|
||||||
|
} catch {
|
||||||
|
setLoading(false);
|
||||||
|
setDownload(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleDownload = async () => {
|
const handleDownload = async () => {
|
||||||
const theDownloadedZip = await cleanAxios.post(
|
const { localmediaserverhttp, localmediatoken } = bodyshop;
|
||||||
`${bodyshop.localmediaserverhttp}/jobs/download`,
|
const { id, ro_number } = job;
|
||||||
{
|
setLoading(true);
|
||||||
jobid: job.id,
|
try {
|
||||||
files: (allMedia?.[job.id] || []).filter((i) => i.isSelected).map((i) => i.filename)
|
const response = await cleanAxios.post(
|
||||||
},
|
`${localmediaserverhttp}/jobs/download`,
|
||||||
{
|
{
|
||||||
headers: { ims_token: bodyshop.localmediatoken },
|
jobid: id,
|
||||||
responseType: "arraybuffer",
|
files: imagesToDownload.map((i) => i.filename)
|
||||||
onDownloadProgress: downloadProgress
|
},
|
||||||
}
|
{
|
||||||
);
|
headers: { ims_token: localmediatoken },
|
||||||
setDownload(null);
|
responseType: "arraybuffer",
|
||||||
standardMediaDownload(theDownloadedZip.data, job.ro_number);
|
onDownloadProgress: downloadProgress
|
||||||
|
}
|
||||||
|
);
|
||||||
|
standardMediaDownload(response.data, ro_number);
|
||||||
|
} catch {
|
||||||
|
// handle error (optional)
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
setDownload(null);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button loading={!!download} onClick={handleDownload}>
|
<Button disabled={imagesToDownload < 1} loading={download || loading} onClick={handleDownload}>
|
||||||
{t("documents.actions.download")}
|
<Space>
|
||||||
|
<span>{t("documents.actions.download")}</span>
|
||||||
|
{download && <span>{`(${formatBytes(download.downloaded)} @ ${formatBytes(download.speed)} / second)`}</span>}
|
||||||
|
</Space>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function standardMediaDownload(bufferData, filename) {
|
|
||||||
const a = document.createElement("a");
|
|
||||||
const url = window.URL.createObjectURL(new Blob([bufferData]));
|
|
||||||
a.href = url;
|
|
||||||
a.download = `${filename}.zip`;
|
|
||||||
a.click();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default function ShopInfoNotificationsAutoadd({ bodyshop }) {
|
|||||||
<Text type="secondary">{t("bodyshop.labels.notifications.followers")}</Text>
|
<Text type="secondary">{t("bodyshop.labels.notifications.followers")}</Text>
|
||||||
{employeeOptions.length > 0 ? (
|
{employeeOptions.length > 0 ? (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
normalize={(value) => (value || []).filter((id) => typeof id === "string" && id.trim() !== "")}
|
||||||
name="notification_followers"
|
name="notification_followers"
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
@@ -42,11 +43,6 @@ export default function ShopInfoNotificationsAutoadd({ bodyshop }) {
|
|||||||
options={employeeOptions}
|
options={employeeOptions}
|
||||||
placeholder={t("bodyshop.fields.notifications.placeholder")}
|
placeholder={t("bodyshop.fields.notifications.placeholder")}
|
||||||
showEmail={true}
|
showEmail={true}
|
||||||
onChange={(value) => {
|
|
||||||
// Filter out null or invalid values before passing to Form
|
|
||||||
const cleanedValue = value?.filter((id) => id != null && typeof id === "string" && id.trim() !== "");
|
|
||||||
return cleanedValue;
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const mapDispatchToProps = () => ({
|
|||||||
export function TechHeader({ technician }) {
|
export function TechHeader({ technician }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<Header style={{ textAlign: "center" }}>
|
<Header style={{ textAlign: "center", height: "auto", overflow: "visible" }}>
|
||||||
<Typography.Title style={{ color: "#fff" }}>
|
<Typography.Title style={{ color: "#fff" }}>
|
||||||
{technician
|
{technician
|
||||||
? t("tech.labels.loggedin", {
|
? t("tech.labels.loggedin", {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useMutation, useQuery } from "@apollo/client";
|
import { useMutation, useQuery } from "@apollo/client";
|
||||||
import { Button, Card, Col, Form, InputNumber, Popover, Row, Select } from "antd";
|
import { Button, Card, Form, InputNumber, Popover, Select, Space } from "antd";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -124,103 +124,12 @@ export function TechClockOffButton({
|
|||||||
cost_center: isShiftTicket ? "timetickets.labels.shift" : technician ? technician.cost_center : null
|
cost_center: isShiftTicket ? "timetickets.labels.shift" : technician ? technician.cost_center : null
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Row gutter={[16, 16]}>
|
<Space direction="vertical">
|
||||||
<Col span={!isShiftTicket ? 8 : 24}>
|
{!isShiftTicket ? (
|
||||||
{!isShiftTicket ? (
|
<div>
|
||||||
<div>
|
|
||||||
<Form.Item
|
|
||||||
label={t("timetickets.fields.actualhrs")}
|
|
||||||
name="actualhrs"
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber min={0} precision={1} />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
label={t("timetickets.fields.productivehrs")}
|
|
||||||
name="productivehrs"
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
},
|
|
||||||
({ getFieldValue }) => ({
|
|
||||||
validator(rule, value) {
|
|
||||||
if (!bodyshop.tt_enforce_hours_for_tech_console) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
if (!value || getFieldValue("cost_center") === null || !lineTicketData)
|
|
||||||
return Promise.resolve();
|
|
||||||
|
|
||||||
//Check the cost center,
|
|
||||||
const totals = CalculateAllocationsTotals(
|
|
||||||
bodyshop,
|
|
||||||
lineTicketData.joblines,
|
|
||||||
lineTicketData.timetickets,
|
|
||||||
lineTicketData.jobs_by_pk.lbr_adjustments
|
|
||||||
);
|
|
||||||
|
|
||||||
const fieldTypeToCheck =
|
|
||||||
bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber ? "mod_lbr_ty" : "cost_center";
|
|
||||||
|
|
||||||
const costCenterDiff =
|
|
||||||
Math.round(
|
|
||||||
totals.find((total) => total[fieldTypeToCheck] === getFieldValue("cost_center"))
|
|
||||||
?.difference * 10
|
|
||||||
) / 10;
|
|
||||||
|
|
||||||
if (value > costCenterDiff)
|
|
||||||
return Promise.reject(t("timetickets.validation.hoursenteredmorethanavailable"));
|
|
||||||
else {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber min={0} precision={1} />
|
|
||||||
</Form.Item>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
<Form.Item
|
|
||||||
name="cost_center"
|
|
||||||
label={t("timetickets.fields.cost_center")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true
|
|
||||||
//message: t("general.validation.required"),
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Select disabled={isShiftTicket}>
|
|
||||||
{isShiftTicket ? (
|
|
||||||
<Select.Option value="timetickets.labels.shift">{t("timetickets.labels.shift")}</Select.Option>
|
|
||||||
) : (
|
|
||||||
emps &&
|
|
||||||
emps.rates.map((item) => (
|
|
||||||
<Select.Option key={item.cost_center}>
|
|
||||||
{item.cost_center === "timetickets.labels.shift"
|
|
||||||
? t(item.cost_center)
|
|
||||||
: bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
|
||||||
? t(`joblines.fields.lbr_types.${item.cost_center.toUpperCase()}`)
|
|
||||||
: item.cost_center}
|
|
||||||
</Select.Option>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
{isShiftTicket ? (
|
|
||||||
<div></div>
|
|
||||||
) : (
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="status"
|
label={t("timetickets.fields.actualhrs")}
|
||||||
label={t("jobs.fields.status")}
|
name="actualhrs"
|
||||||
initialValue={lineTicketData && lineTicketData.jobs_by_pk.status}
|
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true
|
required: true
|
||||||
@@ -228,35 +137,117 @@ export function TechClockOffButton({
|
|||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select>
|
<InputNumber min={0} precision={1} />
|
||||||
{bodyshop.md_ro_statuses.production_statuses.map((item) => (
|
|
||||||
<Select.Option key={item}></Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
<Form.Item
|
||||||
<Button type="primary" htmlType="submit" loading={loading}>
|
label={t("timetickets.fields.productivehrs")}
|
||||||
{t("general.actions.save")}
|
name="productivehrs"
|
||||||
</Button>
|
rules={[
|
||||||
<TechJobClockoutDelete completedCallback={completedCallback} timeTicketId={timeTicketId} />
|
{
|
||||||
</Col>
|
required: true
|
||||||
{!isShiftTicket && (
|
//message: t("general.validation.required"),
|
||||||
<Col span={16}>
|
},
|
||||||
<LaborAllocationContainer
|
({ getFieldValue }) => ({
|
||||||
jobid={jobId || null}
|
validator(rule, value) {
|
||||||
loading={queryLoading}
|
if (!bodyshop.tt_enforce_hours_for_tech_console) {
|
||||||
lineTicketData={lineTicketData}
|
return Promise.resolve();
|
||||||
/>
|
}
|
||||||
</Col>
|
if (!value || getFieldValue("cost_center") === null || !lineTicketData)
|
||||||
|
return Promise.resolve();
|
||||||
|
//Check the cost center,
|
||||||
|
const totals = CalculateAllocationsTotals(
|
||||||
|
bodyshop,
|
||||||
|
lineTicketData.joblines,
|
||||||
|
lineTicketData.timetickets,
|
||||||
|
lineTicketData.jobs_by_pk.lbr_adjustments
|
||||||
|
);
|
||||||
|
const fieldTypeToCheck =
|
||||||
|
bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber ? "mod_lbr_ty" : "cost_center";
|
||||||
|
const costCenterDiff =
|
||||||
|
Math.round(
|
||||||
|
totals.find((total) => total[fieldTypeToCheck] === getFieldValue("cost_center"))
|
||||||
|
?.difference * 10
|
||||||
|
) / 10;
|
||||||
|
if (value > costCenterDiff)
|
||||||
|
return Promise.reject(t("timetickets.validation.hoursenteredmorethanavailable"));
|
||||||
|
else {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<InputNumber min={0} precision={1} />
|
||||||
|
</Form.Item>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<Form.Item
|
||||||
|
name="cost_center"
|
||||||
|
label={t("timetickets.fields.cost_center")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select disabled={isShiftTicket}>
|
||||||
|
{isShiftTicket ? (
|
||||||
|
<Select.Option value="timetickets.labels.shift">{t("timetickets.labels.shift")}</Select.Option>
|
||||||
|
) : (
|
||||||
|
emps &&
|
||||||
|
emps.rates.map((item) => (
|
||||||
|
<Select.Option key={item.cost_center}>
|
||||||
|
{item.cost_center === "timetickets.labels.shift"
|
||||||
|
? t(item.cost_center)
|
||||||
|
: bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
||||||
|
? t(`joblines.fields.lbr_types.${item.cost_center.toUpperCase()}`)
|
||||||
|
: item.cost_center}
|
||||||
|
</Select.Option>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
{isShiftTicket ? (
|
||||||
|
<div></div>
|
||||||
|
) : (
|
||||||
|
<Form.Item
|
||||||
|
name="status"
|
||||||
|
label={t("jobs.fields.status")}
|
||||||
|
initialValue={lineTicketData && lineTicketData.jobs_by_pk.status}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select>
|
||||||
|
{bodyshop.md_ro_statuses.production_statuses.map((item) => (
|
||||||
|
<Select.Option key={item}></Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
</Row>
|
<Button type="primary" htmlType="submit" loading={loading}>
|
||||||
|
{t("general.actions.save")}
|
||||||
|
</Button>
|
||||||
|
<TechJobClockoutDelete completedCallback={completedCallback} timeTicketId={timeTicketId} />
|
||||||
|
{!isShiftTicket && (
|
||||||
|
<LaborAllocationContainer jobid={jobId || null} loading={queryLoading} lineTicketData={lineTicketData} />
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover content={overlay} trigger="click">
|
<Popover
|
||||||
|
content={<div style={{ maxHeight: "75vh", overflowY: "auto" }}>{overlay}</div>}
|
||||||
|
trigger="click"
|
||||||
|
getPopupContainer={() => document.querySelector('#time-ticket-modal')}
|
||||||
|
>
|
||||||
<Button loading={loading} {...otherBtnProps}>
|
<Button loading={loading} {...otherBtnProps}>
|
||||||
{t("timetickets.actions.clockout")}
|
{t("timetickets.actions.clockout")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import {
|
|||||||
} from "./user.actions";
|
} from "./user.actions";
|
||||||
import UserActionTypes from "./user.types";
|
import UserActionTypes from "./user.types";
|
||||||
//import * as amplitude from '@amplitude/analytics-browser';
|
//import * as amplitude from '@amplitude/analytics-browser';
|
||||||
import posthog from 'posthog-js';
|
import posthog from "posthog-js";
|
||||||
|
|
||||||
const fpPromise = FingerprintJS.load();
|
const fpPromise = FingerprintJS.load();
|
||||||
|
|
||||||
@@ -269,11 +269,11 @@ export function* signInSuccessSaga({ payload }) {
|
|||||||
instanceSeg,
|
instanceSeg,
|
||||||
...(isParts
|
...(isParts
|
||||||
? [
|
? [
|
||||||
InstanceRenderManager({
|
InstanceRenderManager({
|
||||||
imex: "ImexPartsManagement",
|
imex: "ImexPartsManagement",
|
||||||
rome: "RomePartsManagement"
|
rome: "RomePartsManagement"
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
: [])
|
: [])
|
||||||
];
|
];
|
||||||
window.$crisp.push(["set", "session:segments", [segs]]);
|
window.$crisp.push(["set", "session:segments", [segs]]);
|
||||||
@@ -375,17 +375,31 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
|||||||
const isParts = yield select((state) => state.application.isPartsEntry === true);
|
const isParts = yield select((state) => state.application.isPartsEntry === true);
|
||||||
const instanceSeg = InstanceRenderManager({ imex: "imex", rome: "rome" });
|
const instanceSeg = InstanceRenderManager({ imex: "imex", rome: "rome" });
|
||||||
|
|
||||||
let featureSegments;
|
const featureSegments =
|
||||||
if (payload.features?.allAccess === true) {
|
payload.features?.allAccess === true
|
||||||
featureSegments = ["allAccess"];
|
? ["allAccess"]
|
||||||
} else {
|
: [
|
||||||
const featureKeys = Object.keys(payload.features).filter(
|
"basic",
|
||||||
(key) =>
|
...Object.keys(payload.features).filter(
|
||||||
payload.features[key] === true ||
|
(key) =>
|
||||||
(typeof payload.features[key] === "string" && !isNaN(Date.parse(payload.features[key])))
|
payload.features[key] === true ||
|
||||||
);
|
(typeof payload.features[key] === "string" && !isNaN(Date.parse(payload.features[key])))
|
||||||
featureSegments = ["basic", ...featureKeys];
|
)
|
||||||
}
|
];
|
||||||
|
|
||||||
|
const additionalSegments = [
|
||||||
|
payload.cdk_dealerid && "CDK",
|
||||||
|
payload.pbs_serialnumber && "PBS",
|
||||||
|
// payload.rr_dealerid && "Reynolds",
|
||||||
|
payload.accountingconfig.qbo === true && "QBO",
|
||||||
|
payload.accountingconfig.qbo === false &&
|
||||||
|
!payload.cdk_dealerid &&
|
||||||
|
!payload.pbs_serialnumber &&
|
||||||
|
// !payload.rr_dealerid &&
|
||||||
|
"QBD"
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
featureSegments.push(...additionalSegments);
|
||||||
|
|
||||||
const regionSeg = payload.region_config ? `region:${payload.region_config}` : null;
|
const regionSeg = payload.region_config ? `region:${payload.region_config}` : null;
|
||||||
const segments = [instanceSeg, ...(regionSeg ? [regionSeg] : []), ...featureSegments];
|
const segments = [instanceSeg, ...(regionSeg ? [regionSeg] : []), ...featureSegments];
|
||||||
|
|||||||
@@ -1221,7 +1221,7 @@ export const TemplateList = (type, context) => {
|
|||||||
payments_by_date_excel: {
|
payments_by_date_excel: {
|
||||||
title: i18n.t("reportcenter.templates.payments_by_date_excel"),
|
title: i18n.t("reportcenter.templates.payments_by_date_excel"),
|
||||||
subject: i18n.t("reportcenter.templates.payments_by_date_excel"),
|
subject: i18n.t("reportcenter.templates.payments_by_date_excel"),
|
||||||
key: "payments_by_date",
|
key: "payments_by_date_excel",
|
||||||
reporttype: "excel",
|
reporttype: "excel",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
rangeFilter: {
|
rangeFilter: {
|
||||||
|
|||||||
@@ -1156,7 +1156,11 @@
|
|||||||
enable_manual: false
|
enable_manual: false
|
||||||
update:
|
update:
|
||||||
columns:
|
columns:
|
||||||
|
- imexshopid
|
||||||
|
- timezone
|
||||||
- shopname
|
- shopname
|
||||||
|
- notification_followers
|
||||||
|
- state
|
||||||
- md_order_statuses
|
- md_order_statuses
|
||||||
retry_conf:
|
retry_conf:
|
||||||
interval_sec: 10
|
interval_sec: 10
|
||||||
@@ -3698,6 +3702,7 @@
|
|||||||
- deliverchecklist
|
- deliverchecklist
|
||||||
- depreciation_taxes
|
- depreciation_taxes
|
||||||
- dms_allocation
|
- dms_allocation
|
||||||
|
- dms_id
|
||||||
- driveable
|
- driveable
|
||||||
- employee_body
|
- employee_body
|
||||||
- employee_csr
|
- employee_csr
|
||||||
@@ -3975,6 +3980,7 @@
|
|||||||
- deliverchecklist
|
- deliverchecklist
|
||||||
- depreciation_taxes
|
- depreciation_taxes
|
||||||
- dms_allocation
|
- dms_allocation
|
||||||
|
- dms_id
|
||||||
- driveable
|
- driveable
|
||||||
- employee_body
|
- employee_body
|
||||||
- employee_csr
|
- employee_csr
|
||||||
@@ -4264,6 +4270,7 @@
|
|||||||
- deliverchecklist
|
- deliverchecklist
|
||||||
- depreciation_taxes
|
- depreciation_taxes
|
||||||
- dms_allocation
|
- dms_allocation
|
||||||
|
- dms_id
|
||||||
- driveable
|
- driveable
|
||||||
- employee_body
|
- employee_body
|
||||||
- employee_csr
|
- employee_csr
|
||||||
|
|||||||
@@ -117,44 +117,46 @@ async function processShopData(shopsToProcess, start, end, skipUpload, ignoreDat
|
|||||||
imexshopid: shopid,
|
imexshopid: shopid,
|
||||||
json: JSON.stringify(carfaxObject, null, 2),
|
json: JSON.stringify(carfaxObject, null, 2),
|
||||||
filename: `${shopid}_${moment().format("DDMMYYYY_HHMMss")}.json`,
|
filename: `${shopid}_${moment().format("DDMMYYYY_HHMMss")}.json`,
|
||||||
count: carfaxObject.job.length
|
count: carfaxObject?.job?.length || 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (skipUpload) {
|
if (skipUpload) {
|
||||||
fs.writeFileSync(`./logs/${jsonObj.filename}`, jsonObj.json);
|
fs.writeFileSync(`./logs/${jsonObj.filename}`, jsonObj.json);
|
||||||
uploadToS3(jsonObj, S3_BUCKET_NAME);
|
uploadToS3(jsonObj, S3_BUCKET_NAME);
|
||||||
} else {
|
} else {
|
||||||
await uploadViaSFTP(jsonObj);
|
if (jsonObj.count > 0) {
|
||||||
|
await uploadViaSFTP(jsonObj);
|
||||||
|
|
||||||
await sendMexicoBillingEmail({
|
await sendMexicoBillingEmail({
|
||||||
subject: `${shopid.replace(/_/g, "").toUpperCase()}_MexicoRPS_${moment().format("MMDDYYYY")} ROs ${jsonObj.count} Error ${errorCode(jsonObj)}`,
|
subject: `${shopid.replace(/_/g, "").toUpperCase()}_MexicoRPS_${moment().format("MMDDYYYY")} ROs ${jsonObj.count} Error ${errorCode(jsonObj)}`,
|
||||||
text: `Errors:\n${JSON.stringify(
|
text: `Errors:\n${JSON.stringify(
|
||||||
erroredJobs.map((ej) => ({
|
erroredJobs.map((ej) => ({
|
||||||
jobid: ej.job?.id,
|
jobid: ej.job?.id,
|
||||||
error: ej.error
|
error: ej.error
|
||||||
})),
|
})),
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
)}\n\nUploaded:\n${JSON.stringify(
|
)}\n\nUploaded:\n${JSON.stringify(
|
||||||
{
|
{
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
imexshopid: shopid,
|
imexshopid: shopid,
|
||||||
count: jsonObj.count,
|
count: jsonObj.count,
|
||||||
filename: jsonObj.filename,
|
filename: jsonObj.filename,
|
||||||
result: jsonObj.result
|
result: jsonObj.result
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
)}`
|
)}`
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allJSONResults.push({
|
jsonObj.count > 0 && allJSONResults.push({
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
imexshopid: shopid,
|
imexshopid: shopid,
|
||||||
count: jsonObj.count,
|
count: jsonObj.count,
|
||||||
filename: jsonObj.filename,
|
filename: jsonObj.filename,
|
||||||
result: jsonObj.result
|
result: jsonObj.result || "No Upload Result Available"
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.log("CARFAX-RPS-end-shop-extract", "DEBUG", "api", bodyshop.id, {
|
logger.log("CARFAX-RPS-end-shop-extract", "DEBUG", "api", bodyshop.id, {
|
||||||
@@ -234,11 +236,10 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
|||||||
const ret = {
|
const ret = {
|
||||||
ro_number: crypto.createHash("md5").update(job.id, "utf8").digest("hex"),
|
ro_number: crypto.createHash("md5").update(job.id, "utf8").digest("hex"),
|
||||||
v_vin: job.v_vin || "",
|
v_vin: job.v_vin || "",
|
||||||
v_year: job.v_model_yr
|
v_year: (() => {
|
||||||
? parseInt(job.v_model_yr.match(/\d/g))
|
const y = parseInt(job.v_model_yr);
|
||||||
? parseInt(job.v_model_yr.match(/\d/g).join(""), 10)
|
return isNaN(y) ? null : y < 100 ? y + (y >= (new Date().getFullYear() + 1) % 100 ? 1900 : 2000) : y;
|
||||||
: ""
|
})(),
|
||||||
: "",
|
|
||||||
v_make: job.v_makedesc || "",
|
v_make: job.v_makedesc || "",
|
||||||
v_model: job.v_model || "",
|
v_model: job.v_model || "",
|
||||||
|
|
||||||
|
|||||||
@@ -160,40 +160,42 @@ async function processShopData(shopsToProcess, start, end, skipUpload, ignoreDat
|
|||||||
imexshopid: shopid,
|
imexshopid: shopid,
|
||||||
json: JSON.stringify(carfaxObject, null, 2),
|
json: JSON.stringify(carfaxObject, null, 2),
|
||||||
filename: `${shopid}_${moment().format("DDMMYYYY_HHMMss")}.json`,
|
filename: `${shopid}_${moment().format("DDMMYYYY_HHMMss")}.json`,
|
||||||
count: carfaxObject.job.length
|
count: carfaxObject?.job?.length || 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (skipUpload) {
|
if (skipUpload) {
|
||||||
fs.writeFileSync(`./logs/${jsonObj.filename}`, jsonObj.json);
|
fs.writeFileSync(`./logs/${jsonObj.filename}`, jsonObj.json);
|
||||||
uploadToS3(jsonObj);
|
uploadToS3(jsonObj);
|
||||||
} else {
|
} else {
|
||||||
await uploadViaSFTP(jsonObj);
|
if (jsonObj.count > 0) {
|
||||||
|
await uploadViaSFTP(jsonObj);
|
||||||
|
|
||||||
await sendMexicoBillingEmail({
|
await sendMexicoBillingEmail({
|
||||||
subject: `${shopid.replace(/_/g, "").toUpperCase()}_Mexico${InstanceManager({
|
subject: `${shopid.replace(/_/g, "").toUpperCase()}_Mexico${InstanceManager({
|
||||||
imex: "IO",
|
imex: "IO",
|
||||||
rome: "RO"
|
rome: "RO"
|
||||||
})}_${moment().format("MMDDYYYY")} ROs ${jsonObj.count} Error ${errorCode(jsonObj)}`,
|
})}_${moment().format("MMDDYYYY")} ROs ${jsonObj.count} Error ${errorCode(jsonObj)}`,
|
||||||
text: `Errors:\n${JSON.stringify(
|
text: `Errors:\n${JSON.stringify(
|
||||||
erroredJobs.map((ej) => ({
|
erroredJobs.map((ej) => ({
|
||||||
ro_number: ej.job?.ro_number,
|
ro_number: ej.job?.ro_number,
|
||||||
jobid: ej.job?.id,
|
jobid: ej.job?.id,
|
||||||
error: ej.error
|
error: ej.error
|
||||||
})),
|
})),
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
)}\n\nUploaded:\n${JSON.stringify(
|
)}\n\nUploaded:\n${JSON.stringify(
|
||||||
{
|
{
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
imexshopid: shopid,
|
imexshopid: shopid,
|
||||||
count: jsonObj.count,
|
count: jsonObj.count,
|
||||||
filename: jsonObj.filename,
|
filename: jsonObj.filename,
|
||||||
result: jsonObj.result
|
result: jsonObj.result
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2
|
2
|
||||||
)}`
|
)}`
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allJSONResults.push({
|
allJSONResults.push({
|
||||||
@@ -201,7 +203,7 @@ async function processShopData(shopsToProcess, start, end, skipUpload, ignoreDat
|
|||||||
imexshopid: shopid,
|
imexshopid: shopid,
|
||||||
count: jsonObj.count,
|
count: jsonObj.count,
|
||||||
filename: jsonObj.filename,
|
filename: jsonObj.filename,
|
||||||
result: jsonObj.result
|
result: jsonObj.result || "No Upload Result Available"
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.log("CARFAX-end-shop-extract", "DEBUG", "api", bodyshop.id, {
|
logger.log("CARFAX-end-shop-extract", "DEBUG", "api", bodyshop.id, {
|
||||||
@@ -286,11 +288,10 @@ const CreateRepairOrderTag = (job, errorCallback) => {
|
|||||||
const ret = {
|
const ret = {
|
||||||
ro_number: crypto.createHash("md5").update(job.ro_number, "utf8").digest("hex"),
|
ro_number: crypto.createHash("md5").update(job.ro_number, "utf8").digest("hex"),
|
||||||
v_vin: job.v_vin || "",
|
v_vin: job.v_vin || "",
|
||||||
v_year: job.v_model_yr
|
v_year: (() => {
|
||||||
? parseInt(job.v_model_yr.match(/\d/g))
|
const y = parseInt(job.v_model_yr);
|
||||||
? parseInt(job.v_model_yr.match(/\d/g).join(""), 10)
|
return isNaN(y) ? null : y < 100 ? y + (y >= (new Date().getFullYear() + 1) % 100 ? 1900 : 2000) : y;
|
||||||
: ""
|
})(),
|
||||||
: "",
|
|
||||||
v_make: job.v_make_desc || "",
|
v_make: job.v_make_desc || "",
|
||||||
v_model: job.v_model_desc || "",
|
v_model: job.v_model_desc || "",
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ exports.default = async (req, res) => {
|
|||||||
"patrick.fic@convenient-brands.com",
|
"patrick.fic@convenient-brands.com",
|
||||||
"bradley.rhoades@convenient-brands.com",
|
"bradley.rhoades@convenient-brands.com",
|
||||||
"jrome@rometech.com",
|
"jrome@rometech.com",
|
||||||
"ivana@imexsystems.ca"
|
"ivana@imexsystems.ca",
|
||||||
|
"support@imexsystems.ca",
|
||||||
|
"sarah@rometech.com"
|
||||||
],
|
],
|
||||||
subject: `RO Usage Report - ${moment().format("MM/DD/YYYY")}`,
|
subject: `RO Usage Report - ${moment().format("MM/DD/YYYY")}`,
|
||||||
text: `
|
text: `
|
||||||
|
|||||||
@@ -2926,6 +2926,15 @@ exports.GET_BODYSHOP_BY_ID = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports.GET_BODYSHOP_WATCHERS_BY_ID = `
|
||||||
|
query GET_BODYSHOP_BY_ID($id: uuid!) {
|
||||||
|
bodyshops_by_pk(id: $id) {
|
||||||
|
id
|
||||||
|
notification_followers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports.GET_DOCUMENTS_BY_JOB = `
|
exports.GET_DOCUMENTS_BY_JOB = `
|
||||||
query GET_DOCUMENTS_BY_JOB($jobId: uuid!) {
|
query GET_DOCUMENTS_BY_JOB($jobId: uuid!) {
|
||||||
jobs_by_pk(id: $jobId) {
|
jobs_by_pk(id: $jobId) {
|
||||||
|
|||||||
@@ -134,13 +134,16 @@ const insertUserAssociation = async (uid, email, shopId) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* PATCH handler for updating bodyshop fields.
|
* PATCH handler for updating bodyshop fields.
|
||||||
* Allows patching: shopname, address1, address2, city, state, zip_post, country, email, timezone, phone, logo_img_path
|
* Allows patching: shopname, address1, address2, city, state, zip_post, country, email, timezone, phone
|
||||||
|
* Also allows updating logo_img_path via a simple logoUrl string, which is expanded to the full object.
|
||||||
* @param req
|
* @param req
|
||||||
* @param res
|
* @param res
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
const patchPartsManagementProvisioning = async (req, res) => {
|
const patchPartsManagementProvisioning = async (req, res) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
|
||||||
|
// Fields that can be directly patched 1:1
|
||||||
const allowedFields = [
|
const allowedFields = [
|
||||||
"shopname",
|
"shopname",
|
||||||
"address1",
|
"address1",
|
||||||
@@ -151,31 +154,58 @@ const patchPartsManagementProvisioning = async (req, res) => {
|
|||||||
"country",
|
"country",
|
||||||
"email",
|
"email",
|
||||||
"timezone",
|
"timezone",
|
||||||
"phone",
|
"phone"
|
||||||
"logo_img_path"
|
// NOTE: logo_img_path is handled separately via logoUrl
|
||||||
];
|
];
|
||||||
|
|
||||||
const updateFields = {};
|
const updateFields = {};
|
||||||
|
|
||||||
|
// Copy over simple scalar fields if present
|
||||||
for (const field of allowedFields) {
|
for (const field of allowedFields) {
|
||||||
if (req.body[field] !== undefined) {
|
if (req.body[field] !== undefined) {
|
||||||
updateFields[field] = req.body[field];
|
updateFields[field] = req.body[field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle logo update via a simple href string, same behavior as provision route
|
||||||
|
if (typeof req.body.logo_img_path === "string") {
|
||||||
|
const trimmed = req.body.logo_img_path.trim();
|
||||||
|
if (trimmed) {
|
||||||
|
updateFields.logo_img_path = {
|
||||||
|
src: trimmed,
|
||||||
|
width: "",
|
||||||
|
height: "",
|
||||||
|
headerMargin: DefaultNewShop.logo_img_path.headerMargin
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Object.keys(updateFields).length === 0) {
|
if (Object.keys(updateFields).length === 0) {
|
||||||
return res.status(400).json({ error: "No valid fields provided for update." });
|
return res.status(400).json({ error: "No valid fields provided for update." });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the bodyshop has an external_shop_id before allowing patch
|
// Check that the bodyshop has an external_shop_id before allowing patch
|
||||||
try {
|
try {
|
||||||
// Fetch the bodyshop by id
|
|
||||||
const shopResp = await client.request(
|
const shopResp = await client.request(
|
||||||
`query GetBodyshop($id: uuid!) { bodyshops_by_pk(id: $id) { id external_shop_id } }`,
|
`query GetBodyshop($id: uuid!) {
|
||||||
|
bodyshops_by_pk(id: $id) {
|
||||||
|
id
|
||||||
|
external_shop_id
|
||||||
|
}
|
||||||
|
}`,
|
||||||
{ id }
|
{ id }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!shopResp.bodyshops_by_pk?.external_shop_id) {
|
if (!shopResp.bodyshops_by_pk?.external_shop_id) {
|
||||||
return res.status(400).json({ error: "Cannot patch: bodyshop does not have an external_shop_id." });
|
return res.status(400).json({ error: "Cannot patch: bodyshop does not have an external_shop_id." });
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return res.status(500).json({ error: "Failed to validate bodyshop external_shop_id.", detail: err });
|
return res.status(500).json({
|
||||||
|
error: "Failed to validate bodyshop external_shop_id.",
|
||||||
|
detail: err
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await client.request(UPDATE_BODYSHOP_BY_ID, { id, fields: updateFields });
|
const resp = await client.request(UPDATE_BODYSHOP_BY_ID, { id, fields: updateFields });
|
||||||
if (!resp.update_bodyshops_by_pk) {
|
if (!resp.update_bodyshops_by_pk) {
|
||||||
@@ -211,6 +241,8 @@ const partsManagementProvisioning = async (req, res) => {
|
|||||||
"phone",
|
"phone",
|
||||||
"userEmail"
|
"userEmail"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// TODO add in check for early access
|
||||||
await ensureExternalIdUnique(body.external_shop_id);
|
await ensureExternalIdUnique(body.external_shop_id);
|
||||||
|
|
||||||
logger.log("admin-create-shop-user", "debug", body.userEmail, null, {
|
logger.log("admin-create-shop-user", "debug", body.userEmail, null, {
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
* This module handles automatically adding watchers to new jobs based on the notifications_autoadd
|
* This module handles automatically adding watchers to new jobs based on the notifications_autoadd
|
||||||
* boolean field in the associations table and the notification_followers JSON field in the bodyshops table.
|
* boolean field in the associations table and the notification_followers JSON field in the bodyshops table.
|
||||||
* It ensures users are not added twice and logs the process.
|
* It ensures users are not added twice and logs the process.
|
||||||
|
*
|
||||||
|
* NOTE: Bodyshop notification_followers is fetched directly from the DB (Hasura) to avoid stale Redis cache.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { client: gqlClient } = require("../graphql-client/graphql-client");
|
const { client: gqlClient } = require("../graphql-client/graphql-client");
|
||||||
const { isEmpty } = require("lodash");
|
const { isEmpty } = require("lodash");
|
||||||
const {
|
const {
|
||||||
|
GET_BODYSHOP_WATCHERS_BY_ID,
|
||||||
GET_JOB_WATCHERS_MINIMAL,
|
GET_JOB_WATCHERS_MINIMAL,
|
||||||
GET_NOTIFICATION_WATCHERS,
|
GET_NOTIFICATION_WATCHERS,
|
||||||
INSERT_JOB_WATCHERS
|
INSERT_JOB_WATCHERS
|
||||||
@@ -26,10 +29,7 @@ const FILTER_SELF_FROM_WATCHERS = process.env?.FILTER_SELF_FROM_WATCHERS !== "fa
|
|||||||
*/
|
*/
|
||||||
const autoAddWatchers = async (req) => {
|
const autoAddWatchers = async (req) => {
|
||||||
const { event, trigger } = req.body;
|
const { event, trigger } = req.body;
|
||||||
const {
|
const { logger } = req;
|
||||||
logger,
|
|
||||||
sessionUtils: { getBodyshopFromRedis }
|
|
||||||
} = req;
|
|
||||||
|
|
||||||
// Validate that this is an INSERT event, bail
|
// Validate that this is an INSERT event, bail
|
||||||
if (trigger?.name !== "notifications_jobs_autoadd" || event.op !== "INSERT" || event.data.old) {
|
if (trigger?.name !== "notifications_jobs_autoadd" || event.op !== "INSERT" || event.data.old) {
|
||||||
@@ -48,20 +48,20 @@ const autoAddWatchers = async (req) => {
|
|||||||
const hasuraUserId = event?.session_variables?.["x-hasura-user-id"];
|
const hasuraUserId = event?.session_variables?.["x-hasura-user-id"];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch bodyshop data from Redis
|
// Fetch bodyshop data directly from DB (avoid Redis staleness)
|
||||||
const bodyshopData = await getBodyshopFromRedis(shopId);
|
const bodyshopResponse = await gqlClient.request(GET_BODYSHOP_WATCHERS_BY_ID, { id: shopId });
|
||||||
let notificationFollowers = bodyshopData?.notification_followers;
|
const bodyshopData = bodyshopResponse?.bodyshops_by_pk;
|
||||||
|
|
||||||
// Bail if notification_followers is missing or not an array
|
const notificationFollowersRaw = bodyshopData?.notification_followers;
|
||||||
if (!notificationFollowers || !Array.isArray(notificationFollowers)) {
|
const notificationFollowers = Array.isArray(notificationFollowersRaw)
|
||||||
return;
|
? [...new Set(notificationFollowersRaw.filter((id) => id))] // de-dupe + remove falsy
|
||||||
}
|
: [];
|
||||||
|
|
||||||
// Execute queries in parallel
|
// Execute queries in parallel
|
||||||
const [notificationData, existingWatchersData] = await Promise.all([
|
const [notificationData, existingWatchersData] = await Promise.all([
|
||||||
gqlClient.request(GET_NOTIFICATION_WATCHERS, {
|
gqlClient.request(GET_NOTIFICATION_WATCHERS, {
|
||||||
shopId,
|
shopId,
|
||||||
employeeIds: notificationFollowers.filter((id) => id)
|
employeeIds: notificationFollowers
|
||||||
}),
|
}),
|
||||||
gqlClient.request(GET_JOB_WATCHERS_MINIMAL, { jobid: jobId })
|
gqlClient.request(GET_JOB_WATCHERS_MINIMAL, { jobid: jobId })
|
||||||
]);
|
]);
|
||||||
@@ -73,7 +73,7 @@ const autoAddWatchers = async (req) => {
|
|||||||
associationId: assoc.id
|
associationId: assoc.id
|
||||||
})) || [];
|
})) || [];
|
||||||
|
|
||||||
// Get users from notification_followers
|
// Get users from notification_followers (employee IDs -> employee emails)
|
||||||
const followerEmails =
|
const followerEmails =
|
||||||
notificationData?.employees
|
notificationData?.employees
|
||||||
?.filter((e) => e.user_email)
|
?.filter((e) => e.user_email)
|
||||||
@@ -84,7 +84,7 @@ const autoAddWatchers = async (req) => {
|
|||||||
|
|
||||||
// Combine and deduplicate emails (use email as the unique key)
|
// Combine and deduplicate emails (use email as the unique key)
|
||||||
const usersToAdd = [...autoAddUsers, ...followerEmails].reduce((acc, user) => {
|
const usersToAdd = [...autoAddUsers, ...followerEmails].reduce((acc, user) => {
|
||||||
if (!acc.some((u) => u.email === user.email)) {
|
if (user?.email && !acc.some((u) => u.email === user.email)) {
|
||||||
acc.push(user);
|
acc.push(user);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
@@ -123,6 +123,7 @@ const autoAddWatchers = async (req) => {
|
|||||||
message: error?.message,
|
message: error?.message,
|
||||||
stack: error?.stack,
|
stack: error?.stack,
|
||||||
jobId,
|
jobId,
|
||||||
|
shopId,
|
||||||
roNumber
|
roNumber
|
||||||
});
|
});
|
||||||
throw error; // Re-throw to ensure the error is logged in the handler
|
throw error; // Re-throw to ensure the error is logged in the handler
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ const alternateTransportChangedBuilder = (data) => {
|
|||||||
* @returns {{app: {jobId, jobRoNumber: *, bodyShopId: *, key: string, body: string, variables: Object, recipients: *[]}, email: {jobId, jobRoNumber: *, bodyShopName: *, body: string, recipients: *[]}, fcm: {recipients: *[]}}}
|
* @returns {{app: {jobId, jobRoNumber: *, bodyShopId: *, key: string, body: string, variables: Object, recipients: *[]}, email: {jobId, jobRoNumber: *, bodyShopName: *, body: string, recipients: *[]}, fcm: {recipients: *[]}}}
|
||||||
*/
|
*/
|
||||||
const billPostedBuilder = (data) => {
|
const billPostedBuilder = (data) => {
|
||||||
const facing = data?.data?.isinhouse ? "in-house" : "vendor";
|
const facing = data?.data?.isinhouse ? "An In House" : "A Vendor";
|
||||||
const body = `An ${facing} ${data?.data?.is_credit_memo ? "credit memo" : "bill"} has been posted.`.trim();
|
const body = `${facing} ${data?.data?.is_credit_memo ? "credit memo" : "bill"} has been posted.`.trim();
|
||||||
|
|
||||||
return buildNotification(data, "notifications.job.billPosted", body, {
|
return buildNotification(data, "notifications.job.billPosted", body, {
|
||||||
isInHouse: data?.data?.isinhouse,
|
isInHouse: data?.data?.isinhouse,
|
||||||
|
|||||||
Reference in New Issue
Block a user