@@ -2370,6 +2370,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>onlycmforinvoiced</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>retailtotal</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -11317,6 +11338,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>documents</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>generatingemail</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -25356,6 +25398,27 @@
|
||||
<folder_node>
|
||||
<name>labels</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>archive</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>maxtenimages</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -25545,6 +25608,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>unarchive</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>
|
||||
</children>
|
||||
</folder_node>
|
||||
</children>
|
||||
|
||||
20456
client/package-lock.json
generated
20456
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -26,14 +26,6 @@ export default function AppContainer() {
|
||||
s.async = 1;
|
||||
d.getElementsByTagName("head")[0].appendChild(s);
|
||||
|
||||
//Release Notes
|
||||
|
||||
// var rs = d.createElement("script");
|
||||
// rs.src = "https://sdk.noticeable.io/s.js";
|
||||
// //rs.async = 1;
|
||||
// d.getElementsByTagName("head")[0].appendChild(rs);
|
||||
// // window.noticeable.render("widget", "IABVNO4scRKY11XBQkNr");
|
||||
|
||||
return () => {
|
||||
d.getElementsByTagName("head")[0].removeChild(s);
|
||||
};
|
||||
|
||||
@@ -41,6 +41,7 @@ export function BillFormComponent({
|
||||
loadLines,
|
||||
billEdit,
|
||||
disableInvNumber,
|
||||
job,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const client = useApolloClient();
|
||||
@@ -50,6 +51,10 @@ export function BillFormComponent({
|
||||
setDiscount(opt.discount);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (job) form.validateFields(["is_credit_memo"]);
|
||||
}, [job, form]);
|
||||
|
||||
useEffect(() => {
|
||||
if (form.getFieldValue("vendorid") && vendorAutoCompleteOptions) {
|
||||
const vendorId = form.getFieldValue("vendorid");
|
||||
@@ -89,7 +94,7 @@ export function BillFormComponent({
|
||||
<JobSearchSelect
|
||||
disabled={billEdit || disabled}
|
||||
convertedOnly
|
||||
// notExported={false}
|
||||
notExported={false}
|
||||
onBlur={() => {
|
||||
if (form.getFieldValue("jobid") !== null) {
|
||||
loadLines({ variables: { id: form.getFieldValue("jobid") } });
|
||||
@@ -187,6 +192,22 @@ export function BillFormComponent({
|
||||
label={t("bills.fields.is_credit_memo")}
|
||||
name="is_credit_memo"
|
||||
valuePropName="checked"
|
||||
rules={[
|
||||
({ getFieldValue }) => ({
|
||||
validator(rule, value) {
|
||||
if (
|
||||
(job.status === bodyshop.md_ro_statuses.default_invoiced ||
|
||||
job.status === bodyshop.md_ro_statuses.default_exported ||
|
||||
job.status === bodyshop.md_ro_statuses.default_void) &&
|
||||
(value === false || !value)
|
||||
) {
|
||||
return Promise.reject(t("bills.labels.onlycmforinvoiced"));
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
}),
|
||||
]}
|
||||
>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
|
||||
@@ -34,6 +34,7 @@ export function BillFormContainer({
|
||||
}
|
||||
loadLines={loadLines}
|
||||
lineData={lineData ? lineData.joblines : []}
|
||||
job={lineData ? lineData.jobs_by_pk : null}
|
||||
responsibilityCenters={bodyshop.md_responsibility_centers || null}
|
||||
disableInvNumber={disableInvNumber}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EyeFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { EditFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Card, Checkbox, Input, Space, Table } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -47,7 +47,7 @@ export function BillsListTableComponent({
|
||||
<Space wrap>
|
||||
{showView && (
|
||||
<Button onClick={() => handleOnRowClick(record)}>
|
||||
<EyeFilled />
|
||||
<EditFilled />
|
||||
</Button>
|
||||
)}
|
||||
<BillDeleteButton bill={record} />
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TOGGLE_CONVERSATION_ARCHIVE } from "../../graphql/conversations.queries";
|
||||
|
||||
export default function ChatArchiveButton({ conversation }) {
|
||||
console.log(
|
||||
"🚀 ~ file: chat-archive-button.component.jsx ~ line 6 ~ conversation",
|
||||
conversation
|
||||
);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const [updateConversation] = useMutation(TOGGLE_CONVERSATION_ARCHIVE);
|
||||
const handleToggleArchive = async () => {
|
||||
setLoading(true);
|
||||
|
||||
await updateConversation({
|
||||
variables: { id: conversation.id, archived: !conversation.archived },
|
||||
});
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleToggleArchive} loading={loading} type="primary">
|
||||
{conversation.archived
|
||||
? t("messaging.labels.unarchive")
|
||||
: t("messaging.labels.archive")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
import { Space } from "antd";
|
||||
import React from "react";
|
||||
import PhoneNumberFormatter from "../../utils/PhoneFormatter";
|
||||
import ChatArchiveButton from "../chat-archive-button/chat-archive-button.component";
|
||||
import ChatConversationTitleTags from "../chat-conversation-title-tags/chat-conversation-title-tags.component";
|
||||
import ChatTagRoContainer from "../chat-tag-ro/chat-tag-ro.container";
|
||||
|
||||
export default function ChatConversationTitle({ conversation }) {
|
||||
return (
|
||||
<Space flex>
|
||||
<Space wrap>
|
||||
<PhoneNumberFormatter>
|
||||
{conversation && conversation.phone_num}
|
||||
</PhoneNumberFormatter>
|
||||
@@ -16,6 +17,7 @@ export default function ChatConversationTitle({ conversation }) {
|
||||
}
|
||||
/>
|
||||
<ChatTagRoContainer conversation={conversation || []} />
|
||||
<ChatArchiveButton conversation={conversation} />
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { useQuery } from "@apollo/client";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { GET_DOCUMENTS_BY_JOB } from "../../graphql/documents.queries";
|
||||
import { selectEmailConfig } from "../../redux/email/email.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import JobDocumentsGalleryExternal from "../jobs-documents-gallery/jobs-documents-gallery.external.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
emailConfig: selectEmailConfig,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(EmailDocumentsComponent);
|
||||
|
||||
export function EmailDocumentsComponent({
|
||||
emailConfig,
|
||||
|
||||
selectedMediaState,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [selectedMedia, setSelectedMedia] = selectedMediaState;
|
||||
const { loading, error, data } = useQuery(GET_DOCUMENTS_BY_JOB, {
|
||||
variables: {
|
||||
jobId: emailConfig.jobid,
|
||||
},
|
||||
skip: !emailConfig.jobid,
|
||||
});
|
||||
console.log(
|
||||
"🚀 ~ file: email-documents.component.jsx ~ line 38 ~ emailConfig",
|
||||
emailConfig
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{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>
|
||||
) : null}
|
||||
{data && (
|
||||
<JobDocumentsGalleryExternal
|
||||
data={data ? data.documents : []}
|
||||
externalMediaState={[selectedMedia, setSelectedMedia]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import { UploadOutlined } from "@ant-design/icons";
|
||||
import { Card, Divider, Form, Input, Select, Upload } from "antd";
|
||||
import { Divider, Form, Input, Select, Tabs, Upload } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import EmailDocumentsComponent from "../email-documents/email-documents.component";
|
||||
|
||||
export default function EmailOverlayComponent({ form }) {
|
||||
export default function EmailOverlayComponent({ form, selectedMediaState }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div>
|
||||
@@ -52,34 +53,38 @@ export default function EmailOverlayComponent({ form }) {
|
||||
}}
|
||||
</Form.Item>
|
||||
|
||||
<Card title={t("emails.labels.attachments")}>
|
||||
<Form.Item
|
||||
name="fileList"
|
||||
valuePropName="fileList"
|
||||
getValueFromEvent={(e) => {
|
||||
console.log("Upload event:", e);
|
||||
if (Array.isArray(e)) {
|
||||
return e;
|
||||
}
|
||||
return e && e.fileList;
|
||||
}}
|
||||
>
|
||||
<Upload.Dragger
|
||||
beforeUpload={Upload.LIST_IGNORE}
|
||||
multiple
|
||||
listType="picture-card"
|
||||
<Tabs>
|
||||
<Tabs.TabPane tab={t("emails.labels.documents")} key="documents">
|
||||
<EmailDocumentsComponent selectedMediaState={selectedMediaState} />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab={t("emails.labels.attachments")} key="attachments">
|
||||
<Form.Item
|
||||
name="fileList"
|
||||
valuePropName="fileList"
|
||||
getValueFromEvent={(e) => {
|
||||
if (Array.isArray(e)) {
|
||||
return e;
|
||||
}
|
||||
return e && e.fileList;
|
||||
}}
|
||||
>
|
||||
<>
|
||||
<p className="ant-upload-drag-icon">
|
||||
<UploadOutlined />
|
||||
</p>
|
||||
<p className="ant-upload-text">
|
||||
Click or drag files to this area to upload.
|
||||
</p>
|
||||
</>
|
||||
</Upload.Dragger>
|
||||
</Form.Item>
|
||||
</Card>
|
||||
<Upload.Dragger
|
||||
beforeUpload={Upload.LIST_IGNORE}
|
||||
multiple
|
||||
listType="picture-card"
|
||||
>
|
||||
<>
|
||||
<p className="ant-upload-drag-icon">
|
||||
<UploadOutlined />
|
||||
</p>
|
||||
<p className="ant-upload-text">
|
||||
Click or drag files to this area to upload.
|
||||
</p>
|
||||
</>
|
||||
</Upload.Dragger>
|
||||
</Form.Item>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ export function EmailOverlayContainer({
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [sending, setSending] = useState(false);
|
||||
const [rawHtml, setRawHtml] = useState("");
|
||||
const [selectedMedia, setSelectedMedia] = useState([]);
|
||||
|
||||
const defaultEmailFrom = {
|
||||
from: {
|
||||
name: `${currentUser.displayName} @ ${bodyshop.shopname}`,
|
||||
@@ -56,17 +58,18 @@ export function EmailOverlayContainer({
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
logImEXEvent("email_send_from_modal");
|
||||
console.log(`values`, values);
|
||||
|
||||
const attachments = [];
|
||||
|
||||
await asyncForEach(values.fileList, async (f) => {
|
||||
const t = {
|
||||
ContentType: f.type,
|
||||
Filename: f.name,
|
||||
Base64Content: (await toBase64(f.originFileObj)).split(",")[1],
|
||||
};
|
||||
attachments.push(t);
|
||||
});
|
||||
if (values.fileList)
|
||||
await asyncForEach(values.fileList, async (f) => {
|
||||
const t = {
|
||||
ContentType: f.type,
|
||||
Filename: f.name,
|
||||
Base64Content: (await toBase64(f.originFileObj)).split(",")[1],
|
||||
};
|
||||
attachments.push(t);
|
||||
});
|
||||
|
||||
setSending(true);
|
||||
try {
|
||||
@@ -74,9 +77,12 @@ export function EmailOverlayContainer({
|
||||
...defaultEmailFrom,
|
||||
...values,
|
||||
html: rawHtml,
|
||||
attachments: await Promise.all(
|
||||
values.fileList.map(async (f) => await toBase64(f.originFileObj))
|
||||
),
|
||||
attachments:
|
||||
values.fileList &&
|
||||
(await Promise.all(
|
||||
values.fileList.map(async (f) => await toBase64(f.originFileObj))
|
||||
)),
|
||||
media: selectedMedia.filter((m) => m.isSelected).map((m) => m.src),
|
||||
//attachments,
|
||||
});
|
||||
notification["success"]({ message: t("emails.successes.sent") });
|
||||
@@ -137,7 +143,12 @@ export function EmailOverlayContainer({
|
||||
<LoadingSpinner message={t("emails.labels.generatingemail")} />
|
||||
</div>
|
||||
)}
|
||||
{!loading && <EmailOverlayComponent form={form} />}
|
||||
{!loading && (
|
||||
<EmailOverlayComponent
|
||||
form={form}
|
||||
selectedMediaState={[selectedMedia, setSelectedMedia]}
|
||||
/>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
@@ -87,9 +87,7 @@ export function Jobd3RdPartyModal({ bodyshop, jobId }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button type="primary" onClick={showModal}>
|
||||
{t("printcenter.jobs.3rdpartypayer")}
|
||||
</Button>
|
||||
<Button onClick={showModal}>{t("printcenter.jobs.3rdpartypayer")}</Button>
|
||||
<Modal visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
|
||||
<Form
|
||||
onFinish={handleFinish}
|
||||
|
||||
@@ -97,7 +97,8 @@ export function ScheduleEventComponent({
|
||||
variables: { id: event.job.id },
|
||||
},
|
||||
{ to: event.job && event.job.ownr_ea, subject: Template.subject },
|
||||
"e"
|
||||
"e",
|
||||
event.job && event.job.id
|
||||
);
|
||||
}}
|
||||
disabled={event.arrived}
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
FilterFilled,
|
||||
SyncOutlined,
|
||||
WarningFilled,
|
||||
EditFilled,
|
||||
} from "@ant-design/icons";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import {
|
||||
@@ -286,7 +287,7 @@ export function JobLinesComponent({
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("general.actions.edit")}
|
||||
<EditFilled />
|
||||
</Button>
|
||||
<Button
|
||||
disabled={jobRO}
|
||||
|
||||
@@ -123,6 +123,7 @@ export function JobPayments({
|
||||
messageObject={{
|
||||
to: job.ownr_ea,
|
||||
}}
|
||||
id={job.id}
|
||||
/>
|
||||
),
|
||||
},
|
||||
@@ -154,7 +155,7 @@ export function JobPayments({
|
||||
extra={
|
||||
<Space wrap>
|
||||
<Button
|
||||
disabled={jobRO}
|
||||
disabled={!job.converted}
|
||||
onClick={() =>
|
||||
setPaymentContext({
|
||||
actions: { refetch: refetch },
|
||||
|
||||
@@ -155,7 +155,7 @@ export function JobsDetailHeaderActions({
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
key="enterpayments"
|
||||
disabled={jobRO || !job.converted}
|
||||
disabled={!job.converted}
|
||||
onClick={() => {
|
||||
logImEXEvent("job_header_enter_payment");
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ export function JobsDetailHeaderCsi({
|
||||
}
|
||||
if (e.key === "email")
|
||||
setEmailOptions({
|
||||
jobid: job.id,
|
||||
messageOptions: {
|
||||
to: [job.ownr_ea],
|
||||
replyTo: bodyshop.email,
|
||||
@@ -139,6 +140,7 @@ export function JobsDetailHeaderCsi({
|
||||
} else {
|
||||
if (e.key === "email")
|
||||
setEmailOptions({
|
||||
jobid: job.id,
|
||||
messageOptions: {
|
||||
to: [job.ownr_ea],
|
||||
replyTo: bodyshop.email,
|
||||
|
||||
@@ -9,9 +9,18 @@ export const GenerateSrcUrl = (value) => {
|
||||
)}/upload/${value.key}${extension ? `.${extension}` : ""}`;
|
||||
};
|
||||
|
||||
export const GenerateThumbUrl = (value) =>
|
||||
`${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${DetermineFileType(
|
||||
export const GenerateThumbUrl = (value) => {
|
||||
let extension = value.extension;
|
||||
if (extension && extension.toLowerCase().includes("heic")) extension = "jpg";
|
||||
else if (
|
||||
DetermineFileType(value.type) !== "image" ||
|
||||
(value.type && value.type.includes("application"))
|
||||
)
|
||||
extension = "jpg";
|
||||
|
||||
return `${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${DetermineFileType(
|
||||
value.type
|
||||
)}/upload/${process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS}/${
|
||||
value.key
|
||||
}`;
|
||||
}${extension ? `.${extension}` : ""}`;
|
||||
};
|
||||
|
||||
@@ -5,9 +5,7 @@ import axios from "axios";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { DELETE_DOCUMENT } from "../../graphql/documents.queries";
|
||||
import cleanAxios from "../../utils/CleanAxios";
|
||||
import { DetermineFileType } from "../documents-upload/documents-upload.utility";
|
||||
import { DELETE_DOCUMENTS } from "../../graphql/documents.queries";
|
||||
//Context: currentUserEmail, bodyshop, jobid, invoiceid
|
||||
|
||||
export default function JobsDocumentsDeleteButton({
|
||||
@@ -15,73 +13,57 @@ export default function JobsDocumentsDeleteButton({
|
||||
deletionCallback,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [deleteDocument] = useMutation(DELETE_DOCUMENT);
|
||||
const [deleteDocument] = useMutation(DELETE_DOCUMENTS);
|
||||
const imagesToDelete = [
|
||||
...galleryImages.images.filter((image) => image.isSelected),
|
||||
...galleryImages.other.filter((image) => image.isSelected),
|
||||
];
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleDelete = () => {
|
||||
const handleDelete = async () => {
|
||||
logImEXEvent("job_documents_delete", { count: imagesToDelete.length });
|
||||
setLoading(true);
|
||||
imagesToDelete.forEach((image) => {
|
||||
let timestamp = Math.floor(Date.now() / 1000);
|
||||
let public_id = image.key;
|
||||
|
||||
axios
|
||||
.post("/media/sign", {
|
||||
public_id: public_id,
|
||||
timestamp: timestamp,
|
||||
})
|
||||
.then((response) => {
|
||||
var signature = response.data;
|
||||
var options = {
|
||||
headers: { "X-Requested-With": "XMLHttpRequest" },
|
||||
};
|
||||
const formData = new FormData();
|
||||
formData.append("api_key", process.env.REACT_APP_CLOUDINARY_API_KEY);
|
||||
formData.append("public_id", public_id);
|
||||
formData.append("timestamp", timestamp);
|
||||
formData.append("signature", signature);
|
||||
|
||||
cleanAxios
|
||||
.post(
|
||||
`${
|
||||
process.env.REACT_APP_CLOUDINARY_ENDPOINT_API
|
||||
}/${DetermineFileType(image.type)}/destroy`,
|
||||
formData,
|
||||
options
|
||||
)
|
||||
.then((response) => {
|
||||
deleteDocument({ variables: { id: image.id } })
|
||||
.then((r) => {
|
||||
notification.open({
|
||||
key: "docdeletedsuccesfully",
|
||||
type: "success",
|
||||
message: t("documents.successes.delete"),
|
||||
});
|
||||
|
||||
if (deletionCallback) deletionCallback();
|
||||
})
|
||||
.catch((error) => {
|
||||
notification["error"]({
|
||||
message: t("documents.errors.deleting", {
|
||||
message: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
});
|
||||
//Delete it from our database.
|
||||
})
|
||||
.catch((error) => {
|
||||
notification["error"]({
|
||||
message: t("documents.errors.deleting_cloudinary", {
|
||||
message: JSON.stringify(error),
|
||||
}),
|
||||
});
|
||||
});
|
||||
});
|
||||
const res = await axios.post("/media/delete", {
|
||||
ids: imagesToDelete,
|
||||
});
|
||||
|
||||
const successfulDeletes = [];
|
||||
res.data.forEach((resType) => {
|
||||
Object.keys(resType.deleted).forEach((key) => {
|
||||
if (resType.deleted[key] !== "deleted") {
|
||||
notification["error"]({
|
||||
message: t("documents.errors.deleting_cloudinary", {
|
||||
message: JSON.stringify(resType.deleted[key]),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
successfulDeletes.push(key);
|
||||
}
|
||||
});
|
||||
});
|
||||
const delres = await deleteDocument({
|
||||
variables: {
|
||||
ids: imagesToDelete
|
||||
.filter((i) => successfulDeletes.includes(i.key))
|
||||
.map((i) => i.id),
|
||||
},
|
||||
});
|
||||
if (delres.errors) {
|
||||
notification["error"]({
|
||||
message: t("documents.errors.deleting", {
|
||||
message: JSON.stringify(delres.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
notification.open({
|
||||
key: "docdeletedsuccesfully",
|
||||
type: "success",
|
||||
message: t("documents.successes.delete"),
|
||||
});
|
||||
|
||||
if (deletionCallback) deletionCallback();
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect } from "react";
|
||||
import Gallery from "react-grid-gallery";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DetermineFileType } from "../documents-upload/documents-upload.utility";
|
||||
import { GenerateSrcUrl, GenerateThumbUrl } from "./job-documents.utility";
|
||||
|
||||
function JobsDocumentGalleryExternal({
|
||||
data,
|
||||
@@ -15,14 +15,8 @@ function JobsDocumentGalleryExternal({
|
||||
let documents = data.reduce((acc, value) => {
|
||||
if (value.type.startsWith("image")) {
|
||||
acc.push({
|
||||
src: `${
|
||||
process.env.REACT_APP_CLOUDINARY_ENDPOINT
|
||||
}/${DetermineFileType(value.type)}/upload/${value.key}`,
|
||||
thumbnail: `${
|
||||
process.env.REACT_APP_CLOUDINARY_ENDPOINT
|
||||
}/${DetermineFileType(value.type)}/upload/${
|
||||
process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS
|
||||
}/${value.key}`,
|
||||
src: GenerateSrcUrl(value),
|
||||
thumbnail: GenerateThumbUrl(value),
|
||||
thumbnailHeight: 225,
|
||||
thumbnailWidth: 225,
|
||||
isSelected: false,
|
||||
|
||||
@@ -183,6 +183,7 @@ export function PartsOrderListTableComponent({
|
||||
? Templates.parts_return_slip.subject
|
||||
: Templates.parts_order.subject,
|
||||
}}
|
||||
id={job.id}
|
||||
/>
|
||||
</Space>
|
||||
);
|
||||
|
||||
@@ -180,7 +180,8 @@ export function PartsOrderModalContainer({
|
||||
? Templates.parts_return_slip.subject
|
||||
: Templates.parts_order.subject,
|
||||
},
|
||||
"e"
|
||||
"e",
|
||||
jobId
|
||||
);
|
||||
} else if (sendType === "p") {
|
||||
GenerateDocument(
|
||||
|
||||
@@ -133,7 +133,8 @@ function PaymentModalContainer({
|
||||
replyTo: bodyshop.email,
|
||||
subject: Templates.payment_receipt.subject,
|
||||
},
|
||||
sendby === "email" ? "e" : "p"
|
||||
sendby === "email" ? "e" : "p",
|
||||
paymentObj.jobid
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SyncOutlined } from "@ant-design/icons";
|
||||
import { EditFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React, { useState } from "react";
|
||||
@@ -160,7 +160,7 @@ export function PaymentsListPaginated({
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("general.actions.edit")}
|
||||
<EditFilled />
|
||||
</Button>
|
||||
<PrintWrapperComponent
|
||||
templateObject={{
|
||||
@@ -168,6 +168,7 @@ export function PaymentsListPaginated({
|
||||
variables: { id: record.id },
|
||||
}}
|
||||
messageObject={{ subject: Templates.payment_receipt.subject }}
|
||||
id={record.job && record.job.id}
|
||||
/>
|
||||
</Space>
|
||||
),
|
||||
|
||||
@@ -52,7 +52,8 @@ export function PrintCenterItemComponent({
|
||||
variables: { id: id },
|
||||
},
|
||||
{ to: context.job && context.job.ownr_ea, subject: item.subject },
|
||||
"e"
|
||||
"e",
|
||||
id
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Card, Col, Input, Row, Typography } from "antd";
|
||||
import { Card, Col, Input, Row, Space, Typography } from "antd";
|
||||
import _ from "lodash";
|
||||
import React, { useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
@@ -42,10 +42,13 @@ export function PrintCenterJobsComponent({ printCenterModal }) {
|
||||
<Col lg={16} md={12} sm={24} className="print-center-list">
|
||||
<Card
|
||||
extra={
|
||||
<Input.Search
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
value={search}
|
||||
/>
|
||||
<Space wrap>
|
||||
<Jobd3RdPartyModal jobId={jobId} />
|
||||
<Input.Search
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
value={search}
|
||||
/>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<Row gutter={[16, 16]}>
|
||||
@@ -71,7 +74,6 @@ export function PrintCenterJobsComponent({ printCenterModal }) {
|
||||
))}
|
||||
</Row>
|
||||
</Card>
|
||||
<Jobd3RdPartyModal jobId={jobId} />
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
@@ -7,11 +7,12 @@ export default function PrintWrapperComponent({
|
||||
templateObject,
|
||||
messageObject = {},
|
||||
children,
|
||||
id,
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const handlePrint = async (type) => {
|
||||
setLoading(true);
|
||||
await GenerateDocument(templateObject, messageObject, type);
|
||||
await GenerateDocument(templateObject, messageObject, type, id);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
@@ -32,27 +32,23 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
const Templates = TemplateList("report_center");
|
||||
const { visible } = reportCenterModal;
|
||||
|
||||
const [
|
||||
callVendorQuery,
|
||||
{ data: vendorData, called: vendorCalled },
|
||||
] = useLazyQuery(QUERY_ALL_VENDORS, {
|
||||
skip: !(
|
||||
visible &&
|
||||
Templates[form.getFieldValue("key")] &&
|
||||
Templates[form.getFieldValue("key")].idtype
|
||||
),
|
||||
});
|
||||
const [callVendorQuery, { data: vendorData, called: vendorCalled }] =
|
||||
useLazyQuery(QUERY_ALL_VENDORS, {
|
||||
skip: !(
|
||||
visible &&
|
||||
Templates[form.getFieldValue("key")] &&
|
||||
Templates[form.getFieldValue("key")].idtype
|
||||
),
|
||||
});
|
||||
|
||||
const [
|
||||
callEmployeeQuery,
|
||||
{ data: employeeData, called: employeeCalled },
|
||||
] = useLazyQuery(QUERY_ACTIVE_EMPLOYEES, {
|
||||
skip: !(
|
||||
visible &&
|
||||
Templates[form.getFieldValue("key")] &&
|
||||
Templates[form.getFieldValue("key")].idtype
|
||||
),
|
||||
});
|
||||
const [callEmployeeQuery, { data: employeeData, called: employeeCalled }] =
|
||||
useLazyQuery(QUERY_ACTIVE_EMPLOYEES, {
|
||||
skip: !(
|
||||
visible &&
|
||||
Templates[form.getFieldValue("key")] &&
|
||||
Templates[form.getFieldValue("key")].idtype
|
||||
),
|
||||
});
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
setLoading(true);
|
||||
@@ -73,7 +69,8 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
|
||||
to: values.to,
|
||||
subject: Templates[values.key]?.subject,
|
||||
},
|
||||
values.sendby === "email" ? "e" : "p"
|
||||
values.sendby === "email" ? "e" : "p",
|
||||
id
|
||||
);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
@@ -148,6 +148,7 @@ export function ScheduleJobModalContainer({
|
||||
toggleModalVisible();
|
||||
if (values.notifyCustomer) {
|
||||
setEmailOptions({
|
||||
jobid: jobId,
|
||||
messageOptions: {
|
||||
to: [values.email],
|
||||
replyTo: bodyshop.email,
|
||||
|
||||
@@ -261,7 +261,6 @@ export default function ShopInfoGeneral({ form }) {
|
||||
label={t("bodyshop.fields.md_categories")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
//message: t("general.validation.required"),
|
||||
type: "array",
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Card, Space, Table } from "antd";
|
||||
import { EditFilled } from "@ant-design/icons";
|
||||
import moment from "moment";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -190,7 +191,7 @@ export function TimeTicketList({
|
||||
context={{ id: record.id, timeticket: record }}
|
||||
disabled={!record.job || disabled}
|
||||
>
|
||||
{t("general.actions.edit")}
|
||||
<EditFilled />
|
||||
</TimeTicketEnterButton>
|
||||
)}
|
||||
{!techConsole && (
|
||||
@@ -216,7 +217,7 @@ export function TimeTicketList({
|
||||
: !record.jobid
|
||||
}
|
||||
>
|
||||
{t("general.actions.edit")}
|
||||
<EditFilled />
|
||||
</TimeTicketEnterButton>
|
||||
</RbacWrapper>
|
||||
)}
|
||||
|
||||
@@ -30,7 +30,9 @@ export default function VehiclesListComponent({
|
||||
dataIndex: "v_vin",
|
||||
key: "v_vin",
|
||||
render: (text, record) => (
|
||||
<Link to={"/manage/vehicles/" + record.id}>{record.v_vin}</Link>
|
||||
<Link to={"/manage/vehicles/" + record.id}>
|
||||
{record.v_vin || "N/A"}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -39,7 +41,9 @@ export default function VehiclesListComponent({
|
||||
key: "description",
|
||||
render: (text, record) => {
|
||||
return (
|
||||
<span>{`${record.v_model_yr} ${record.v_make_desc} ${record.v_model_desc} ${record.v_color}`}</span>
|
||||
<span>{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
|
||||
record.v_model_desc || ""
|
||||
} ${record.v_color || ""}`}</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -48,7 +52,9 @@ export default function VehiclesListComponent({
|
||||
dataIndex: "plate",
|
||||
key: "plate",
|
||||
render: (text, record) => {
|
||||
return <span>{`${record.plate_st} | ${record.plate_no}`}</span>;
|
||||
return (
|
||||
<span>{`${record.plate_st || ""} | ${record.plate_no || ""}`}</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -2,7 +2,11 @@ import { gql } from "@apollo/client";
|
||||
|
||||
export const CONVERSATION_LIST_SUBSCRIPTION = gql`
|
||||
subscription CONVERSATION_LIST_SUBSCRIPTION {
|
||||
conversations(order_by: { updated_at: desc }, limit: 100) {
|
||||
conversations(
|
||||
order_by: { updated_at: desc }
|
||||
limit: 100
|
||||
where: { archived: { _eq: false } }
|
||||
) {
|
||||
phone_num
|
||||
id
|
||||
job_conversations {
|
||||
@@ -51,6 +55,7 @@ export const CONVERSATION_SUBSCRIPTION_BY_PK = gql`
|
||||
}
|
||||
id
|
||||
phone_num
|
||||
archived
|
||||
job_conversations {
|
||||
jobid
|
||||
conversationid
|
||||
@@ -87,3 +92,14 @@ export const CREATE_CONVERSATION = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const TOGGLE_CONVERSATION_ARCHIVE = gql`
|
||||
mutation TOGGLE_CONVERSATION_ARCHIVE($id: uuid!, $archived: Boolean) {
|
||||
update_conversations_by_pk(
|
||||
pk_columns: { id: $id }
|
||||
_set: { archived: $archived }
|
||||
) {
|
||||
archived
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -84,7 +84,15 @@ export const DELETE_DOCUMENT = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const DELETE_DOCUMENTS = gql`
|
||||
mutation DELETE_DOCUMENTS($ids: [uuid!]!) {
|
||||
delete_documents(where: { id: { _in: $ids } }) {
|
||||
returning {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const QUERY_TEMPORARY_DOCS = gql`
|
||||
query QUERY_TEMPORARY_DOCS {
|
||||
documents(
|
||||
|
||||
@@ -186,6 +186,10 @@ export const GET_JOB_LINES_TO_ENTER_BILL = gql`
|
||||
lbr_amt
|
||||
op_code_desc
|
||||
}
|
||||
jobs_by_pk(id: $id) {
|
||||
id
|
||||
status
|
||||
}
|
||||
}
|
||||
`;
|
||||
// oem_partno: {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { createSelector } from "reselect";
|
||||
|
||||
const selectEmail = (state) => state.email;
|
||||
const selectEmailConfigMessageOptions = (state) =>
|
||||
state.email.emailConfig.messageOptions;
|
||||
const selectEmailConfigTemplate = (state) => state.email.emailConfig.template;
|
||||
|
||||
export const selectEmailVisible = createSelector(
|
||||
[selectEmail],
|
||||
@@ -11,9 +8,6 @@ export const selectEmailVisible = createSelector(
|
||||
);
|
||||
|
||||
export const selectEmailConfig = createSelector(
|
||||
[selectEmailConfigMessageOptions, selectEmailConfigTemplate],
|
||||
(messageOptions, template) => ({
|
||||
messageOptions,
|
||||
template,
|
||||
})
|
||||
[selectEmail],
|
||||
(email) => email.emailConfig
|
||||
);
|
||||
|
||||
@@ -230,16 +230,10 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
||||
try {
|
||||
const userEmail = yield select((state) => state.user.currentUser.email);
|
||||
|
||||
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
||||
|
||||
const authRecord = payload.associations.filter(
|
||||
(a) => a.useremail === userEmail
|
||||
);
|
||||
|
||||
if (authRecord[0] && authRecord[0].user.validemail) {
|
||||
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
||||
}
|
||||
|
||||
yield put(setAuthlevel(authRecord[0] ? authRecord[0].authlevel : 0));
|
||||
yield put(
|
||||
updateUserDetailsSuccess(
|
||||
@@ -248,6 +242,15 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
|
||||
: { validemail: false }
|
||||
)
|
||||
);
|
||||
try {
|
||||
window.$crisp.push(["set", "user:company", [payload.shopname]]);
|
||||
if (authRecord[0] && authRecord[0].user.validemail) {
|
||||
console.log("$crisp user email", authRecord[0].user.email);
|
||||
window.$crisp.push(["set", "user:email", [authRecord[0].user.email]]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Couldnt find $crisp.");
|
||||
}
|
||||
} catch (error) {
|
||||
yield put(signInFailure(error.message));
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
"markforreexport": "Mark for Re-export",
|
||||
"new": "New Bill",
|
||||
"noneselected": "No bill selected.",
|
||||
"onlycmforinvoiced": "Only credit memos can be entered for any job that has been invoiced.",
|
||||
"retailtotal": "Bills Retail Total",
|
||||
"state_tax": "Provincial/State Tax",
|
||||
"subtotal": "Subtotal",
|
||||
@@ -723,6 +724,7 @@
|
||||
},
|
||||
"labels": {
|
||||
"attachments": "Attachments",
|
||||
"documents": "Documents",
|
||||
"generatingemail": "Generating email...",
|
||||
"preview": "Email Preview"
|
||||
},
|
||||
@@ -1499,6 +1501,7 @@
|
||||
"invalidphone": "The phone number is invalid. Unable to open conversation. "
|
||||
},
|
||||
"labels": {
|
||||
"archive": "Archive",
|
||||
"maxtenimages": "You can only select up to a maximum of 10 images at a time.",
|
||||
"messaging": "Messaging",
|
||||
"noallowtxt": "This customer has not indicated their permission to be messaged.",
|
||||
@@ -1507,7 +1510,8 @@
|
||||
"presets": "Presets",
|
||||
"selectmedia": "Select Media",
|
||||
"sentby": "Sent by {{by}} at {{time}}",
|
||||
"typeamessage": "Send a message..."
|
||||
"typeamessage": "Send a message...",
|
||||
"unarchive": "Unarchive"
|
||||
}
|
||||
},
|
||||
"notes": {
|
||||
@@ -1728,7 +1732,7 @@
|
||||
"state": "Province/State",
|
||||
"zip": "Postal Code/Zip"
|
||||
},
|
||||
"3rdpartypayer": "Third Party Payer",
|
||||
"3rdpartypayer": "Invoice to Third Party Payer",
|
||||
"appointment_confirmation": "Appointment Confirmation",
|
||||
"appointment_reminder": "Appointment Reminder",
|
||||
"casl_authorization": "CASL Authorization",
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
"markforreexport": "",
|
||||
"new": "",
|
||||
"noneselected": "",
|
||||
"onlycmforinvoiced": "",
|
||||
"retailtotal": "",
|
||||
"state_tax": "",
|
||||
"subtotal": "",
|
||||
@@ -723,6 +724,7 @@
|
||||
},
|
||||
"labels": {
|
||||
"attachments": "",
|
||||
"documents": "",
|
||||
"generatingemail": "",
|
||||
"preview": ""
|
||||
},
|
||||
@@ -1499,6 +1501,7 @@
|
||||
"invalidphone": ""
|
||||
},
|
||||
"labels": {
|
||||
"archive": "",
|
||||
"maxtenimages": "",
|
||||
"messaging": "Mensajería",
|
||||
"noallowtxt": "",
|
||||
@@ -1507,7 +1510,8 @@
|
||||
"presets": "",
|
||||
"selectmedia": "",
|
||||
"sentby": "",
|
||||
"typeamessage": "Enviar un mensaje..."
|
||||
"typeamessage": "Enviar un mensaje...",
|
||||
"unarchive": ""
|
||||
}
|
||||
},
|
||||
"notes": {
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
"markforreexport": "",
|
||||
"new": "",
|
||||
"noneselected": "",
|
||||
"onlycmforinvoiced": "",
|
||||
"retailtotal": "",
|
||||
"state_tax": "",
|
||||
"subtotal": "",
|
||||
@@ -723,6 +724,7 @@
|
||||
},
|
||||
"labels": {
|
||||
"attachments": "",
|
||||
"documents": "",
|
||||
"generatingemail": "",
|
||||
"preview": ""
|
||||
},
|
||||
@@ -1499,6 +1501,7 @@
|
||||
"invalidphone": ""
|
||||
},
|
||||
"labels": {
|
||||
"archive": "",
|
||||
"maxtenimages": "",
|
||||
"messaging": "Messagerie",
|
||||
"noallowtxt": "",
|
||||
@@ -1507,7 +1510,8 @@
|
||||
"presets": "",
|
||||
"selectmedia": "",
|
||||
"sentby": "",
|
||||
"typeamessage": "Envoyer un message..."
|
||||
"typeamessage": "Envoyer un message...",
|
||||
"unarchive": ""
|
||||
}
|
||||
},
|
||||
"notes": {
|
||||
|
||||
@@ -147,11 +147,17 @@ export async function RenderTemplates(
|
||||
}
|
||||
}
|
||||
|
||||
export const GenerateDocument = async (template, messageOptions, sendType) => {
|
||||
export const GenerateDocument = async (
|
||||
template,
|
||||
messageOptions,
|
||||
sendType,
|
||||
jobid
|
||||
) => {
|
||||
const bodyshop = store.getState().user.bodyshop;
|
||||
if (sendType === "e") {
|
||||
store.dispatch(
|
||||
setEmailOptions({
|
||||
jobid,
|
||||
messageOptions: {
|
||||
...messageOptions,
|
||||
to: Array.isArray(messageOptions.to)
|
||||
|
||||
@@ -765,7 +765,7 @@ export const TemplateList = (type, context) => {
|
||||
disabled: false,
|
||||
rangeFilter: {
|
||||
object: i18n.t("reportcenter.labels.objects.jobs"),
|
||||
field: i18n.t("jobs.fields.date_invoiced"),
|
||||
field: i18n.t("jobs.fields.date_open"),
|
||||
},
|
||||
},
|
||||
job_costing_ro_date_summary: {
|
||||
|
||||
20688
client/yarn.lock
20688
client/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,7 @@ app.post(
|
||||
);
|
||||
app.post("/media/download", fb.validateFirebaseIdToken, media.downloadFiles);
|
||||
app.post("/media/rename", fb.validateFirebaseIdToken, media.renameKeys);
|
||||
app.post("/media/delete", fb.validateFirebaseIdToken, media.deleteFiles);
|
||||
|
||||
//SMS/Twilio Paths
|
||||
var smsReceive = require("./server/sms/receive");
|
||||
|
||||
@@ -5,12 +5,7 @@ require("dotenv").config({
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
const mailjet = require("node-mailjet").connect(
|
||||
process.env.email_api,
|
||||
process.env.email_secret
|
||||
);
|
||||
|
||||
const axios = require("axios");
|
||||
let nodemailer = require("nodemailer");
|
||||
let aws = require("aws-sdk");
|
||||
|
||||
@@ -28,21 +23,41 @@ exports.sendEmail = async (req, res) => {
|
||||
console.log("[EMAIL] Incoming Message", req.body.from.name);
|
||||
}
|
||||
|
||||
let downloadedMedia = [];
|
||||
if (req.body.media && req.body.media.length > 0) {
|
||||
downloadedMedia = await Promise.all(
|
||||
req.body.media.map((m) => {
|
||||
try {
|
||||
return getImage(m);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
transporter.sendMail(
|
||||
{
|
||||
from: `${req.body.from.name} <${req.body.from.address}>`,
|
||||
replyTo: req.body.ReplyTo.Email,
|
||||
to: req.body.to,
|
||||
cc: req.body.cc,
|
||||
subject: "Message",
|
||||
subject: req.body.subject,
|
||||
attachments:
|
||||
(req.body.attachments &&
|
||||
req.body.attachments.map((a) => {
|
||||
[
|
||||
...((req.body.attachments &&
|
||||
req.body.attachments.map((a) => {
|
||||
return {
|
||||
path: a,
|
||||
};
|
||||
})) ||
|
||||
[]),
|
||||
...downloadedMedia.map((a) => {
|
||||
return {
|
||||
path: a,
|
||||
};
|
||||
})) ||
|
||||
null,
|
||||
}),
|
||||
] || null,
|
||||
html: req.body.html,
|
||||
ses: {
|
||||
// optional extra arguments for SendRawEmail
|
||||
@@ -65,71 +80,10 @@ exports.sendEmail = async (req, res) => {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// const inlinedCssHtml = await inlineCssTool(req.body.html, {
|
||||
// url: "https://imex.online",
|
||||
// });
|
||||
|
||||
// console.log("inlinedCssHtml", inlinedCssHtml);
|
||||
|
||||
// Create the promise and SES service object
|
||||
|
||||
// const request = mailjet.post("send", { version: "v3.1" }).request({
|
||||
// Messages: [
|
||||
// {
|
||||
// From: {
|
||||
// Email: req.body.from.address,
|
||||
// Name: req.body.from.name,
|
||||
// },
|
||||
// To:
|
||||
// req.body.to &&
|
||||
// req.body.to.map((i) => {
|
||||
// return { Email: i };
|
||||
// }),
|
||||
// CC:
|
||||
// req.body.cc &&
|
||||
// req.body.cc.map((i) => {
|
||||
// return { Email: i };
|
||||
// }),
|
||||
// ReplyTo: {
|
||||
// Email: req.body.ReplyTo.Email,
|
||||
// Name: req.body.ReplyTo.Name,
|
||||
// },
|
||||
// Subject: req.body.subject,
|
||||
// // TextPart:
|
||||
// // "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
|
||||
// HTMLPart: req.body.html,
|
||||
// Attachments: req.body.attachments || null,
|
||||
// },
|
||||
// ],
|
||||
// });
|
||||
|
||||
// request
|
||||
// .then((result) => {
|
||||
// console.log("[EMAIL] Email sent: " + result);
|
||||
// res.json({ success: true, response: result });
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// console.log("[EMAIL] Email send failed. ", err);
|
||||
// res.json({ success: false, error: err.message });
|
||||
// });
|
||||
|
||||
// transporter.sendMail(
|
||||
// {
|
||||
// ...req.body,
|
||||
// from: {
|
||||
// name: req.body.from.name ,
|
||||
// address: "noreply@bodyshop.app",
|
||||
// },
|
||||
// },
|
||||
// function (error, info) {
|
||||
// if (error) {
|
||||
// console.log("[EMAIL] Email send failed. ", error);
|
||||
// res.json({ success: false, error: error });
|
||||
// } else {
|
||||
// console.log("[EMAIL] Email sent: " + info.response);
|
||||
// res.json({ success: true, response: info.response });
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
};
|
||||
|
||||
async function getImage(imageUrl) {
|
||||
let image = await axios.get(imageUrl, { responseType: "arraybuffer" });
|
||||
let raw = Buffer.from(image.data).toString("base64");
|
||||
return "data:" + image.headers["content-type"] + ";base64," + raw;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ query FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID(
|
||||
`;
|
||||
|
||||
exports.INSERT_MESSAGE = `
|
||||
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!) {
|
||||
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!, $conversationid: uuid) {
|
||||
update_conversations(where: {id: {_eq: $conversationid}}, _set: {archived: false}) {
|
||||
affected_rows
|
||||
}
|
||||
insert_messages(objects: $msg) {
|
||||
returning {
|
||||
conversation {
|
||||
@@ -28,6 +31,7 @@ mutation INSERT_MESSAGE($msg: [messages_insert_input!]!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
exports.UPDATE_MESSAGE_STATUS = `
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const path = require("path");
|
||||
const _ = require("lodash");
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
@@ -22,6 +23,7 @@ exports.createSignedUploadURL = (req, res) => {
|
||||
|
||||
exports.downloadFiles = (req, res) => {
|
||||
const { ids } = req.body;
|
||||
|
||||
const url = cloudinary.utils.download_zip_url({
|
||||
public_ids: ids,
|
||||
flatten_folders: true,
|
||||
@@ -29,6 +31,45 @@ exports.downloadFiles = (req, res) => {
|
||||
res.send(url);
|
||||
};
|
||||
|
||||
exports.deleteFiles = async (req, res) => {
|
||||
const { ids } = req.body;
|
||||
const types = _.groupBy(ids, (x) => DetermineFileType(x.type));
|
||||
console.log("🚀 ~ file: media.js ~ line 28 ~ types", types);
|
||||
|
||||
const returns = [];
|
||||
if (types.image) {
|
||||
//delete images
|
||||
|
||||
returns.push(
|
||||
await cloudinary.api.delete_resources(
|
||||
types.image.map((x) => x.key),
|
||||
{ resource_type: "image" }
|
||||
)
|
||||
);
|
||||
}
|
||||
if (types.video) {
|
||||
//delete images returns.push(
|
||||
returns.push(
|
||||
await cloudinary.api.delete_resources(
|
||||
types.video.map((x) => x.key),
|
||||
{ resource_type: "video" }
|
||||
)
|
||||
);
|
||||
}
|
||||
if (types.raw) {
|
||||
//delete images returns.push(
|
||||
returns.push(
|
||||
await cloudinary.api.delete_resources(
|
||||
types.raw.map((x) => x.key),
|
||||
{ resource_type: "raw" }
|
||||
)
|
||||
);
|
||||
}
|
||||
console.log("🚀 ~ file: media.js ~ line 40 ~ returns", returns);
|
||||
|
||||
res.send(returns);
|
||||
};
|
||||
|
||||
exports.renameKeys = async (req, res) => {
|
||||
const { documents } = req.body;
|
||||
//{id: "", from: "", to:""}
|
||||
|
||||
@@ -62,13 +62,17 @@ exports.receive = (req, res) => {
|
||||
}
|
||||
|
||||
client
|
||||
.request(queries.INSERT_MESSAGE, { msg: newMessage })
|
||||
.request(queries.INSERT_MESSAGE, {
|
||||
msg: newMessage,
|
||||
conversationid: response.bodyshops[0].conversations[0].id,
|
||||
})
|
||||
.then((r2) => {
|
||||
res.status(200).send("");
|
||||
|
||||
const arrayOfAllUserFcmTokens = r2.insert_messages.returning[0].conversation.bodyshop.associations.map(
|
||||
(a) => a.user.fcmtokens
|
||||
);
|
||||
const arrayOfAllUserFcmTokens =
|
||||
r2.insert_messages.returning[0].conversation.bodyshop.associations.map(
|
||||
(a) => a.user.fcmtokens
|
||||
);
|
||||
const allTokens = [];
|
||||
arrayOfAllUserFcmTokens.map((i) =>
|
||||
Object.keys(i).map((k) => allTokens.push(k))
|
||||
|
||||
Reference in New Issue
Block a user