Merged in feature/2021-06-18 (pull request #106)

Feature/2021 06 18
This commit is contained in:
Patrick Fic
2021-06-11 17:04:23 +00:00
48 changed files with 20486 additions and 21467 deletions

View File

@@ -2370,6 +2370,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </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> <concept_node>
<name>retailtotal</name> <name>retailtotal</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -11317,6 +11338,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </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> <concept_node>
<name>generatingemail</name> <name>generatingemail</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -25356,6 +25398,27 @@
<folder_node> <folder_node>
<name>labels</name> <name>labels</name>
<children> <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> <concept_node>
<name>maxtenimages</name> <name>maxtenimages</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -25545,6 +25608,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </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> </children>
</folder_node> </folder_node>
</children> </children>

20456
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -26,14 +26,6 @@ export default function AppContainer() {
s.async = 1; s.async = 1;
d.getElementsByTagName("head")[0].appendChild(s); 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 () => { return () => {
d.getElementsByTagName("head")[0].removeChild(s); d.getElementsByTagName("head")[0].removeChild(s);
}; };

View File

@@ -41,6 +41,7 @@ export function BillFormComponent({
loadLines, loadLines,
billEdit, billEdit,
disableInvNumber, disableInvNumber,
job,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const client = useApolloClient(); const client = useApolloClient();
@@ -50,6 +51,10 @@ export function BillFormComponent({
setDiscount(opt.discount); setDiscount(opt.discount);
}; };
useEffect(() => {
if (job) form.validateFields(["is_credit_memo"]);
}, [job, form]);
useEffect(() => { useEffect(() => {
if (form.getFieldValue("vendorid") && vendorAutoCompleteOptions) { if (form.getFieldValue("vendorid") && vendorAutoCompleteOptions) {
const vendorId = form.getFieldValue("vendorid"); const vendorId = form.getFieldValue("vendorid");
@@ -89,7 +94,7 @@ export function BillFormComponent({
<JobSearchSelect <JobSearchSelect
disabled={billEdit || disabled} disabled={billEdit || disabled}
convertedOnly convertedOnly
// notExported={false} notExported={false}
onBlur={() => { onBlur={() => {
if (form.getFieldValue("jobid") !== null) { if (form.getFieldValue("jobid") !== null) {
loadLines({ variables: { id: form.getFieldValue("jobid") } }); loadLines({ variables: { id: form.getFieldValue("jobid") } });
@@ -187,6 +192,22 @@ export function BillFormComponent({
label={t("bills.fields.is_credit_memo")} label={t("bills.fields.is_credit_memo")}
name="is_credit_memo" name="is_credit_memo"
valuePropName="checked" 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 /> <Switch />
</Form.Item> </Form.Item>

View File

@@ -34,6 +34,7 @@ export function BillFormContainer({
} }
loadLines={loadLines} loadLines={loadLines}
lineData={lineData ? lineData.joblines : []} lineData={lineData ? lineData.joblines : []}
job={lineData ? lineData.jobs_by_pk : null}
responsibilityCenters={bodyshop.md_responsibility_centers || null} responsibilityCenters={bodyshop.md_responsibility_centers || null}
disableInvNumber={disableInvNumber} disableInvNumber={disableInvNumber}
/> />

View File

@@ -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 { Button, Card, Checkbox, Input, Space, Table } from "antd";
import React, { useState } from "react"; import React, { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -47,7 +47,7 @@ export function BillsListTableComponent({
<Space wrap> <Space wrap>
{showView && ( {showView && (
<Button onClick={() => handleOnRowClick(record)}> <Button onClick={() => handleOnRowClick(record)}>
<EyeFilled /> <EditFilled />
</Button> </Button>
)} )}
<BillDeleteButton bill={record} /> <BillDeleteButton bill={record} />

View File

@@ -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>
);
}

View File

@@ -1,12 +1,13 @@
import { Space } from "antd"; import { Space } from "antd";
import React from "react"; import React from "react";
import PhoneNumberFormatter from "../../utils/PhoneFormatter"; 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 ChatConversationTitleTags from "../chat-conversation-title-tags/chat-conversation-title-tags.component";
import ChatTagRoContainer from "../chat-tag-ro/chat-tag-ro.container"; import ChatTagRoContainer from "../chat-tag-ro/chat-tag-ro.container";
export default function ChatConversationTitle({ conversation }) { export default function ChatConversationTitle({ conversation }) {
return ( return (
<Space flex> <Space wrap>
<PhoneNumberFormatter> <PhoneNumberFormatter>
{conversation && conversation.phone_num} {conversation && conversation.phone_num}
</PhoneNumberFormatter> </PhoneNumberFormatter>
@@ -16,6 +17,7 @@ export default function ChatConversationTitle({ conversation }) {
} }
/> />
<ChatTagRoContainer conversation={conversation || []} /> <ChatTagRoContainer conversation={conversation || []} />
<ChatArchiveButton conversation={conversation} />
</Space> </Space>
); );
} }

View File

@@ -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>
);
}

View File

@@ -1,9 +1,10 @@
import { UploadOutlined } from "@ant-design/icons"; 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 React from "react";
import { useTranslation } from "react-i18next"; 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(); const { t } = useTranslation();
return ( return (
<div> <div>
@@ -52,34 +53,38 @@ export default function EmailOverlayComponent({ form }) {
}} }}
</Form.Item> </Form.Item>
<Card title={t("emails.labels.attachments")}> <Tabs>
<Form.Item <Tabs.TabPane tab={t("emails.labels.documents")} key="documents">
name="fileList" <EmailDocumentsComponent selectedMediaState={selectedMediaState} />
valuePropName="fileList" </Tabs.TabPane>
getValueFromEvent={(e) => { <Tabs.TabPane tab={t("emails.labels.attachments")} key="attachments">
console.log("Upload event:", e); <Form.Item
if (Array.isArray(e)) { name="fileList"
return e; valuePropName="fileList"
} getValueFromEvent={(e) => {
return e && e.fileList; if (Array.isArray(e)) {
}} return e;
> }
<Upload.Dragger return e && e.fileList;
beforeUpload={Upload.LIST_IGNORE} }}
multiple
listType="picture-card"
> >
<> <Upload.Dragger
<p className="ant-upload-drag-icon"> beforeUpload={Upload.LIST_IGNORE}
<UploadOutlined /> multiple
</p> listType="picture-card"
<p className="ant-upload-text"> >
Click or drag files to this area to upload. <>
</p> <p className="ant-upload-drag-icon">
</> <UploadOutlined />
</Upload.Dragger> </p>
</Form.Item> <p className="ant-upload-text">
</Card> Click or drag files to this area to upload.
</p>
</>
</Upload.Dragger>
</Form.Item>
</Tabs.TabPane>
</Tabs>
</div> </div>
); );
} }

View File

@@ -43,6 +43,8 @@ export function EmailOverlayContainer({
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [sending, setSending] = useState(false); const [sending, setSending] = useState(false);
const [rawHtml, setRawHtml] = useState(""); const [rawHtml, setRawHtml] = useState("");
const [selectedMedia, setSelectedMedia] = useState([]);
const defaultEmailFrom = { const defaultEmailFrom = {
from: { from: {
name: `${currentUser.displayName} @ ${bodyshop.shopname}`, name: `${currentUser.displayName} @ ${bodyshop.shopname}`,
@@ -56,17 +58,18 @@ export function EmailOverlayContainer({
const handleFinish = async (values) => { const handleFinish = async (values) => {
logImEXEvent("email_send_from_modal"); logImEXEvent("email_send_from_modal");
console.log(`values`, values);
const attachments = []; const attachments = [];
await asyncForEach(values.fileList, async (f) => { if (values.fileList)
const t = { await asyncForEach(values.fileList, async (f) => {
ContentType: f.type, const t = {
Filename: f.name, ContentType: f.type,
Base64Content: (await toBase64(f.originFileObj)).split(",")[1], Filename: f.name,
}; Base64Content: (await toBase64(f.originFileObj)).split(",")[1],
attachments.push(t); };
}); attachments.push(t);
});
setSending(true); setSending(true);
try { try {
@@ -74,9 +77,12 @@ export function EmailOverlayContainer({
...defaultEmailFrom, ...defaultEmailFrom,
...values, ...values,
html: rawHtml, html: rawHtml,
attachments: await Promise.all( attachments:
values.fileList.map(async (f) => await toBase64(f.originFileObj)) 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, //attachments,
}); });
notification["success"]({ message: t("emails.successes.sent") }); notification["success"]({ message: t("emails.successes.sent") });
@@ -137,7 +143,12 @@ export function EmailOverlayContainer({
<LoadingSpinner message={t("emails.labels.generatingemail")} /> <LoadingSpinner message={t("emails.labels.generatingemail")} />
</div> </div>
)} )}
{!loading && <EmailOverlayComponent form={form} />} {!loading && (
<EmailOverlayComponent
form={form}
selectedMediaState={[selectedMedia, setSelectedMedia]}
/>
)}
</Form> </Form>
</Modal> </Modal>
); );

View File

@@ -87,9 +87,7 @@ export function Jobd3RdPartyModal({ bodyshop, jobId }) {
return ( return (
<> <>
<Button type="primary" onClick={showModal}> <Button onClick={showModal}>{t("printcenter.jobs.3rdpartypayer")}</Button>
{t("printcenter.jobs.3rdpartypayer")}
</Button>
<Modal visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}> <Modal visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
<Form <Form
onFinish={handleFinish} onFinish={handleFinish}

View File

@@ -97,7 +97,8 @@ export function ScheduleEventComponent({
variables: { id: event.job.id }, variables: { id: event.job.id },
}, },
{ to: event.job && event.job.ownr_ea, subject: Template.subject }, { to: event.job && event.job.ownr_ea, subject: Template.subject },
"e" "e",
event.job && event.job.id
); );
}} }}
disabled={event.arrived} disabled={event.arrived}

View File

@@ -3,6 +3,7 @@ import {
FilterFilled, FilterFilled,
SyncOutlined, SyncOutlined,
WarningFilled, WarningFilled,
EditFilled,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { useMutation } from "@apollo/client"; import { useMutation } from "@apollo/client";
import { import {
@@ -286,7 +287,7 @@ export function JobLinesComponent({
}); });
}} }}
> >
{t("general.actions.edit")} <EditFilled />
</Button> </Button>
<Button <Button
disabled={jobRO} disabled={jobRO}

View File

@@ -123,6 +123,7 @@ export function JobPayments({
messageObject={{ messageObject={{
to: job.ownr_ea, to: job.ownr_ea,
}} }}
id={job.id}
/> />
), ),
}, },
@@ -154,7 +155,7 @@ export function JobPayments({
extra={ extra={
<Space wrap> <Space wrap>
<Button <Button
disabled={jobRO} disabled={!job.converted}
onClick={() => onClick={() =>
setPaymentContext({ setPaymentContext({
actions: { refetch: refetch }, actions: { refetch: refetch },

View File

@@ -155,7 +155,7 @@ export function JobsDetailHeaderActions({
</Menu.Item> </Menu.Item>
<Menu.Item <Menu.Item
key="enterpayments" key="enterpayments"
disabled={jobRO || !job.converted} disabled={!job.converted}
onClick={() => { onClick={() => {
logImEXEvent("job_header_enter_payment"); logImEXEvent("job_header_enter_payment");

View File

@@ -97,6 +97,7 @@ export function JobsDetailHeaderCsi({
} }
if (e.key === "email") if (e.key === "email")
setEmailOptions({ setEmailOptions({
jobid: job.id,
messageOptions: { messageOptions: {
to: [job.ownr_ea], to: [job.ownr_ea],
replyTo: bodyshop.email, replyTo: bodyshop.email,
@@ -139,6 +140,7 @@ export function JobsDetailHeaderCsi({
} else { } else {
if (e.key === "email") if (e.key === "email")
setEmailOptions({ setEmailOptions({
jobid: job.id,
messageOptions: { messageOptions: {
to: [job.ownr_ea], to: [job.ownr_ea],
replyTo: bodyshop.email, replyTo: bodyshop.email,

View File

@@ -9,9 +9,18 @@ export const GenerateSrcUrl = (value) => {
)}/upload/${value.key}${extension ? `.${extension}` : ""}`; )}/upload/${value.key}${extension ? `.${extension}` : ""}`;
}; };
export const GenerateThumbUrl = (value) => export const GenerateThumbUrl = (value) => {
`${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${DetermineFileType( 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 value.type
)}/upload/${process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS}/${ )}/upload/${process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS}/${
value.key value.key
}`; }${extension ? `.${extension}` : ""}`;
};

View File

@@ -5,9 +5,7 @@ import axios from "axios";
import React, { useState } from "react"; import React, { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { logImEXEvent } from "../../firebase/firebase.utils"; import { logImEXEvent } from "../../firebase/firebase.utils";
import { DELETE_DOCUMENT } from "../../graphql/documents.queries"; import { DELETE_DOCUMENTS } from "../../graphql/documents.queries";
import cleanAxios from "../../utils/CleanAxios";
import { DetermineFileType } from "../documents-upload/documents-upload.utility";
//Context: currentUserEmail, bodyshop, jobid, invoiceid //Context: currentUserEmail, bodyshop, jobid, invoiceid
export default function JobsDocumentsDeleteButton({ export default function JobsDocumentsDeleteButton({
@@ -15,73 +13,57 @@ export default function JobsDocumentsDeleteButton({
deletionCallback, deletionCallback,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [deleteDocument] = useMutation(DELETE_DOCUMENT); const [deleteDocument] = useMutation(DELETE_DOCUMENTS);
const imagesToDelete = [ const imagesToDelete = [
...galleryImages.images.filter((image) => image.isSelected), ...galleryImages.images.filter((image) => image.isSelected),
...galleryImages.other.filter((image) => image.isSelected), ...galleryImages.other.filter((image) => image.isSelected),
]; ];
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const handleDelete = () => { const handleDelete = async () => {
logImEXEvent("job_documents_delete", { count: imagesToDelete.length }); logImEXEvent("job_documents_delete", { count: imagesToDelete.length });
setLoading(true); setLoading(true);
imagesToDelete.forEach((image) => { const res = await axios.post("/media/delete", {
let timestamp = Math.floor(Date.now() / 1000); ids: imagesToDelete,
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 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); setLoading(false);
}; };

View File

@@ -1,7 +1,7 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import Gallery from "react-grid-gallery"; import Gallery from "react-grid-gallery";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { DetermineFileType } from "../documents-upload/documents-upload.utility"; import { GenerateSrcUrl, GenerateThumbUrl } from "./job-documents.utility";
function JobsDocumentGalleryExternal({ function JobsDocumentGalleryExternal({
data, data,
@@ -15,14 +15,8 @@ function JobsDocumentGalleryExternal({
let documents = data.reduce((acc, value) => { let documents = data.reduce((acc, value) => {
if (value.type.startsWith("image")) { if (value.type.startsWith("image")) {
acc.push({ acc.push({
src: `${ src: GenerateSrcUrl(value),
process.env.REACT_APP_CLOUDINARY_ENDPOINT thumbnail: GenerateThumbUrl(value),
}/${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}`,
thumbnailHeight: 225, thumbnailHeight: 225,
thumbnailWidth: 225, thumbnailWidth: 225,
isSelected: false, isSelected: false,

View File

@@ -183,6 +183,7 @@ export function PartsOrderListTableComponent({
? Templates.parts_return_slip.subject ? Templates.parts_return_slip.subject
: Templates.parts_order.subject, : Templates.parts_order.subject,
}} }}
id={job.id}
/> />
</Space> </Space>
); );

View File

@@ -180,7 +180,8 @@ export function PartsOrderModalContainer({
? Templates.parts_return_slip.subject ? Templates.parts_return_slip.subject
: Templates.parts_order.subject, : Templates.parts_order.subject,
}, },
"e" "e",
jobId
); );
} else if (sendType === "p") { } else if (sendType === "p") {
GenerateDocument( GenerateDocument(

View File

@@ -133,7 +133,8 @@ function PaymentModalContainer({
replyTo: bodyshop.email, replyTo: bodyshop.email,
subject: Templates.payment_receipt.subject, subject: Templates.payment_receipt.subject,
}, },
sendby === "email" ? "e" : "p" sendby === "email" ? "e" : "p",
paymentObj.jobid
); );
} }
} else { } else {

View File

@@ -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 { Button, Card, Input, Space, Table, Typography } from "antd";
import queryString from "query-string"; import queryString from "query-string";
import React, { useState } from "react"; import React, { useState } from "react";
@@ -160,7 +160,7 @@ export function PaymentsListPaginated({
}); });
}} }}
> >
{t("general.actions.edit")} <EditFilled />
</Button> </Button>
<PrintWrapperComponent <PrintWrapperComponent
templateObject={{ templateObject={{
@@ -168,6 +168,7 @@ export function PaymentsListPaginated({
variables: { id: record.id }, variables: { id: record.id },
}} }}
messageObject={{ subject: Templates.payment_receipt.subject }} messageObject={{ subject: Templates.payment_receipt.subject }}
id={record.job && record.job.id}
/> />
</Space> </Space>
), ),

View File

@@ -52,7 +52,8 @@ export function PrintCenterItemComponent({
variables: { id: id }, variables: { id: id },
}, },
{ to: context.job && context.job.ownr_ea, subject: item.subject }, { to: context.job && context.job.ownr_ea, subject: item.subject },
"e" "e",
id
); );
}} }}
/> />

View File

@@ -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 _ from "lodash";
import React, { useState } from "react"; import React, { useState } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
@@ -42,10 +42,13 @@ export function PrintCenterJobsComponent({ printCenterModal }) {
<Col lg={16} md={12} sm={24} className="print-center-list"> <Col lg={16} md={12} sm={24} className="print-center-list">
<Card <Card
extra={ extra={
<Input.Search <Space wrap>
onChange={(e) => setSearch(e.target.value)} <Jobd3RdPartyModal jobId={jobId} />
value={search} <Input.Search
/> onChange={(e) => setSearch(e.target.value)}
value={search}
/>
</Space>
} }
> >
<Row gutter={[16, 16]}> <Row gutter={[16, 16]}>
@@ -71,7 +74,6 @@ export function PrintCenterJobsComponent({ printCenterModal }) {
))} ))}
</Row> </Row>
</Card> </Card>
<Jobd3RdPartyModal jobId={jobId} />
</Col> </Col>
</Row> </Row>
</div> </div>

View File

@@ -7,11 +7,12 @@ export default function PrintWrapperComponent({
templateObject, templateObject,
messageObject = {}, messageObject = {},
children, children,
id,
}) { }) {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const handlePrint = async (type) => { const handlePrint = async (type) => {
setLoading(true); setLoading(true);
await GenerateDocument(templateObject, messageObject, type); await GenerateDocument(templateObject, messageObject, type, id);
setLoading(false); setLoading(false);
}; };

View File

@@ -32,27 +32,23 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
const Templates = TemplateList("report_center"); const Templates = TemplateList("report_center");
const { visible } = reportCenterModal; const { visible } = reportCenterModal;
const [ const [callVendorQuery, { data: vendorData, called: vendorCalled }] =
callVendorQuery, useLazyQuery(QUERY_ALL_VENDORS, {
{ data: vendorData, called: vendorCalled }, skip: !(
] = useLazyQuery(QUERY_ALL_VENDORS, { visible &&
skip: !( Templates[form.getFieldValue("key")] &&
visible && Templates[form.getFieldValue("key")].idtype
Templates[form.getFieldValue("key")] && ),
Templates[form.getFieldValue("key")].idtype });
),
});
const [ const [callEmployeeQuery, { data: employeeData, called: employeeCalled }] =
callEmployeeQuery, useLazyQuery(QUERY_ACTIVE_EMPLOYEES, {
{ data: employeeData, called: employeeCalled }, skip: !(
] = useLazyQuery(QUERY_ACTIVE_EMPLOYEES, { visible &&
skip: !( Templates[form.getFieldValue("key")] &&
visible && Templates[form.getFieldValue("key")].idtype
Templates[form.getFieldValue("key")] && ),
Templates[form.getFieldValue("key")].idtype });
),
});
const handleFinish = async (values) => { const handleFinish = async (values) => {
setLoading(true); setLoading(true);
@@ -73,7 +69,8 @@ export function ReportCenterModalComponent({ reportCenterModal }) {
to: values.to, to: values.to,
subject: Templates[values.key]?.subject, subject: Templates[values.key]?.subject,
}, },
values.sendby === "email" ? "e" : "p" values.sendby === "email" ? "e" : "p",
id
); );
setLoading(false); setLoading(false);
}; };

View File

@@ -148,6 +148,7 @@ export function ScheduleJobModalContainer({
toggleModalVisible(); toggleModalVisible();
if (values.notifyCustomer) { if (values.notifyCustomer) {
setEmailOptions({ setEmailOptions({
jobid: jobId,
messageOptions: { messageOptions: {
to: [values.email], to: [values.email],
replyTo: bodyshop.email, replyTo: bodyshop.email,

View File

@@ -261,7 +261,6 @@ export default function ShopInfoGeneral({ form }) {
label={t("bodyshop.fields.md_categories")} label={t("bodyshop.fields.md_categories")}
rules={[ rules={[
{ {
required: true,
//message: t("general.validation.required"), //message: t("general.validation.required"),
type: "array", type: "array",
}, },

View File

@@ -1,4 +1,5 @@
import { Card, Space, Table } from "antd"; import { Card, Space, Table } from "antd";
import { EditFilled } from "@ant-design/icons";
import moment from "moment"; import moment from "moment";
import React, { useMemo, useState } from "react"; import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -190,7 +191,7 @@ export function TimeTicketList({
context={{ id: record.id, timeticket: record }} context={{ id: record.id, timeticket: record }}
disabled={!record.job || disabled} disabled={!record.job || disabled}
> >
{t("general.actions.edit")} <EditFilled />
</TimeTicketEnterButton> </TimeTicketEnterButton>
)} )}
{!techConsole && ( {!techConsole && (
@@ -216,7 +217,7 @@ export function TimeTicketList({
: !record.jobid : !record.jobid
} }
> >
{t("general.actions.edit")} <EditFilled />
</TimeTicketEnterButton> </TimeTicketEnterButton>
</RbacWrapper> </RbacWrapper>
)} )}

View File

@@ -30,7 +30,9 @@ export default function VehiclesListComponent({
dataIndex: "v_vin", dataIndex: "v_vin",
key: "v_vin", key: "v_vin",
render: (text, record) => ( 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", key: "description",
render: (text, record) => { render: (text, record) => {
return ( 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", dataIndex: "plate",
key: "plate", key: "plate",
render: (text, record) => { render: (text, record) => {
return <span>{`${record.plate_st} | ${record.plate_no}`}</span>; return (
<span>{`${record.plate_st || ""} | ${record.plate_no || ""}`}</span>
);
}, },
}, },
]; ];

View File

@@ -2,7 +2,11 @@ import { gql } from "@apollo/client";
export const CONVERSATION_LIST_SUBSCRIPTION = gql` export const CONVERSATION_LIST_SUBSCRIPTION = gql`
subscription CONVERSATION_LIST_SUBSCRIPTION { 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 phone_num
id id
job_conversations { job_conversations {
@@ -51,6 +55,7 @@ export const CONVERSATION_SUBSCRIPTION_BY_PK = gql`
} }
id id
phone_num phone_num
archived
job_conversations { job_conversations {
jobid jobid
conversationid 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
}
}
`;

View File

@@ -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` export const QUERY_TEMPORARY_DOCS = gql`
query QUERY_TEMPORARY_DOCS { query QUERY_TEMPORARY_DOCS {
documents( documents(

View File

@@ -186,6 +186,10 @@ export const GET_JOB_LINES_TO_ENTER_BILL = gql`
lbr_amt lbr_amt
op_code_desc op_code_desc
} }
jobs_by_pk(id: $id) {
id
status
}
} }
`; `;
// oem_partno: { // oem_partno: {

View File

@@ -1,9 +1,6 @@
import { createSelector } from "reselect"; import { createSelector } from "reselect";
const selectEmail = (state) => state.email; const selectEmail = (state) => state.email;
const selectEmailConfigMessageOptions = (state) =>
state.email.emailConfig.messageOptions;
const selectEmailConfigTemplate = (state) => state.email.emailConfig.template;
export const selectEmailVisible = createSelector( export const selectEmailVisible = createSelector(
[selectEmail], [selectEmail],
@@ -11,9 +8,6 @@ export const selectEmailVisible = createSelector(
); );
export const selectEmailConfig = createSelector( export const selectEmailConfig = createSelector(
[selectEmailConfigMessageOptions, selectEmailConfigTemplate], [selectEmail],
(messageOptions, template) => ({ (email) => email.emailConfig
messageOptions,
template,
})
); );

View File

@@ -230,16 +230,10 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
try { try {
const userEmail = yield select((state) => state.user.currentUser.email); const userEmail = yield select((state) => state.user.currentUser.email);
window.$crisp.push(["set", "user:company", [payload.shopname]]);
const authRecord = payload.associations.filter( const authRecord = payload.associations.filter(
(a) => a.useremail === userEmail (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(setAuthlevel(authRecord[0] ? authRecord[0].authlevel : 0));
yield put( yield put(
updateUserDetailsSuccess( updateUserDetailsSuccess(
@@ -248,6 +242,15 @@ export function* SetAuthLevelFromShopDetails({ payload }) {
: { validemail: false } : { 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) { } catch (error) {
yield put(signInFailure(error.message)); yield put(signInFailure(error.message));
} }

View File

@@ -156,6 +156,7 @@
"markforreexport": "Mark for Re-export", "markforreexport": "Mark for Re-export",
"new": "New Bill", "new": "New Bill",
"noneselected": "No bill selected.", "noneselected": "No bill selected.",
"onlycmforinvoiced": "Only credit memos can be entered for any job that has been invoiced.",
"retailtotal": "Bills Retail Total", "retailtotal": "Bills Retail Total",
"state_tax": "Provincial/State Tax", "state_tax": "Provincial/State Tax",
"subtotal": "Subtotal", "subtotal": "Subtotal",
@@ -723,6 +724,7 @@
}, },
"labels": { "labels": {
"attachments": "Attachments", "attachments": "Attachments",
"documents": "Documents",
"generatingemail": "Generating email...", "generatingemail": "Generating email...",
"preview": "Email Preview" "preview": "Email Preview"
}, },
@@ -1499,6 +1501,7 @@
"invalidphone": "The phone number is invalid. Unable to open conversation. " "invalidphone": "The phone number is invalid. Unable to open conversation. "
}, },
"labels": { "labels": {
"archive": "Archive",
"maxtenimages": "You can only select up to a maximum of 10 images at a time.", "maxtenimages": "You can only select up to a maximum of 10 images at a time.",
"messaging": "Messaging", "messaging": "Messaging",
"noallowtxt": "This customer has not indicated their permission to be messaged.", "noallowtxt": "This customer has not indicated their permission to be messaged.",
@@ -1507,7 +1510,8 @@
"presets": "Presets", "presets": "Presets",
"selectmedia": "Select Media", "selectmedia": "Select Media",
"sentby": "Sent by {{by}} at {{time}}", "sentby": "Sent by {{by}} at {{time}}",
"typeamessage": "Send a message..." "typeamessage": "Send a message...",
"unarchive": "Unarchive"
} }
}, },
"notes": { "notes": {
@@ -1728,7 +1732,7 @@
"state": "Province/State", "state": "Province/State",
"zip": "Postal Code/Zip" "zip": "Postal Code/Zip"
}, },
"3rdpartypayer": "Third Party Payer", "3rdpartypayer": "Invoice to Third Party Payer",
"appointment_confirmation": "Appointment Confirmation", "appointment_confirmation": "Appointment Confirmation",
"appointment_reminder": "Appointment Reminder", "appointment_reminder": "Appointment Reminder",
"casl_authorization": "CASL Authorization", "casl_authorization": "CASL Authorization",

View File

@@ -156,6 +156,7 @@
"markforreexport": "", "markforreexport": "",
"new": "", "new": "",
"noneselected": "", "noneselected": "",
"onlycmforinvoiced": "",
"retailtotal": "", "retailtotal": "",
"state_tax": "", "state_tax": "",
"subtotal": "", "subtotal": "",
@@ -723,6 +724,7 @@
}, },
"labels": { "labels": {
"attachments": "", "attachments": "",
"documents": "",
"generatingemail": "", "generatingemail": "",
"preview": "" "preview": ""
}, },
@@ -1499,6 +1501,7 @@
"invalidphone": "" "invalidphone": ""
}, },
"labels": { "labels": {
"archive": "",
"maxtenimages": "", "maxtenimages": "",
"messaging": "Mensajería", "messaging": "Mensajería",
"noallowtxt": "", "noallowtxt": "",
@@ -1507,7 +1510,8 @@
"presets": "", "presets": "",
"selectmedia": "", "selectmedia": "",
"sentby": "", "sentby": "",
"typeamessage": "Enviar un mensaje..." "typeamessage": "Enviar un mensaje...",
"unarchive": ""
} }
}, },
"notes": { "notes": {

View File

@@ -156,6 +156,7 @@
"markforreexport": "", "markforreexport": "",
"new": "", "new": "",
"noneselected": "", "noneselected": "",
"onlycmforinvoiced": "",
"retailtotal": "", "retailtotal": "",
"state_tax": "", "state_tax": "",
"subtotal": "", "subtotal": "",
@@ -723,6 +724,7 @@
}, },
"labels": { "labels": {
"attachments": "", "attachments": "",
"documents": "",
"generatingemail": "", "generatingemail": "",
"preview": "" "preview": ""
}, },
@@ -1499,6 +1501,7 @@
"invalidphone": "" "invalidphone": ""
}, },
"labels": { "labels": {
"archive": "",
"maxtenimages": "", "maxtenimages": "",
"messaging": "Messagerie", "messaging": "Messagerie",
"noallowtxt": "", "noallowtxt": "",
@@ -1507,7 +1510,8 @@
"presets": "", "presets": "",
"selectmedia": "", "selectmedia": "",
"sentby": "", "sentby": "",
"typeamessage": "Envoyer un message..." "typeamessage": "Envoyer un message...",
"unarchive": ""
} }
}, },
"notes": { "notes": {

View File

@@ -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; const bodyshop = store.getState().user.bodyshop;
if (sendType === "e") { if (sendType === "e") {
store.dispatch( store.dispatch(
setEmailOptions({ setEmailOptions({
jobid,
messageOptions: { messageOptions: {
...messageOptions, ...messageOptions,
to: Array.isArray(messageOptions.to) to: Array.isArray(messageOptions.to)

View File

@@ -765,7 +765,7 @@ export const TemplateList = (type, context) => {
disabled: false, disabled: false,
rangeFilter: { rangeFilter: {
object: i18n.t("reportcenter.labels.objects.jobs"), 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: { job_costing_ro_date_summary: {

File diff suppressed because it is too large Load Diff

View File

@@ -78,6 +78,7 @@ app.post(
); );
app.post("/media/download", fb.validateFirebaseIdToken, media.downloadFiles); app.post("/media/download", fb.validateFirebaseIdToken, media.downloadFiles);
app.post("/media/rename", fb.validateFirebaseIdToken, media.renameKeys); app.post("/media/rename", fb.validateFirebaseIdToken, media.renameKeys);
app.post("/media/delete", fb.validateFirebaseIdToken, media.deleteFiles);
//SMS/Twilio Paths //SMS/Twilio Paths
var smsReceive = require("./server/sms/receive"); var smsReceive = require("./server/sms/receive");

View File

@@ -5,12 +5,7 @@ require("dotenv").config({
`.env.${process.env.NODE_ENV || "development"}` `.env.${process.env.NODE_ENV || "development"}`
), ),
}); });
const axios = require("axios");
const mailjet = require("node-mailjet").connect(
process.env.email_api,
process.env.email_secret
);
let nodemailer = require("nodemailer"); let nodemailer = require("nodemailer");
let aws = require("aws-sdk"); let aws = require("aws-sdk");
@@ -28,21 +23,41 @@ exports.sendEmail = async (req, res) => {
console.log("[EMAIL] Incoming Message", req.body.from.name); 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( transporter.sendMail(
{ {
from: `${req.body.from.name} <${req.body.from.address}>`, from: `${req.body.from.name} <${req.body.from.address}>`,
replyTo: req.body.ReplyTo.Email, replyTo: req.body.ReplyTo.Email,
to: req.body.to, to: req.body.to,
cc: req.body.cc, cc: req.body.cc,
subject: "Message", subject: req.body.subject,
attachments: attachments:
(req.body.attachments && [
req.body.attachments.map((a) => { ...((req.body.attachments &&
req.body.attachments.map((a) => {
return {
path: a,
};
})) ||
[]),
...downloadedMedia.map((a) => {
return { return {
path: a, path: a,
}; };
})) || }),
null, ] || null,
html: req.body.html, html: req.body.html,
ses: { ses: {
// optional extra arguments for SendRawEmail // 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;
}

View File

@@ -13,7 +13,10 @@ query FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID(
`; `;
exports.INSERT_MESSAGE = ` 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) { insert_messages(objects: $msg) {
returning { returning {
conversation { conversation {
@@ -28,6 +31,7 @@ mutation INSERT_MESSAGE($msg: [messages_insert_input!]!) {
} }
} }
} }
`; `;
exports.UPDATE_MESSAGE_STATUS = ` exports.UPDATE_MESSAGE_STATUS = `

View File

@@ -1,4 +1,5 @@
const path = require("path"); const path = require("path");
const _ = require("lodash");
require("dotenv").config({ require("dotenv").config({
path: path.resolve( path: path.resolve(
process.cwd(), process.cwd(),
@@ -22,6 +23,7 @@ exports.createSignedUploadURL = (req, res) => {
exports.downloadFiles = (req, res) => { exports.downloadFiles = (req, res) => {
const { ids } = req.body; const { ids } = req.body;
const url = cloudinary.utils.download_zip_url({ const url = cloudinary.utils.download_zip_url({
public_ids: ids, public_ids: ids,
flatten_folders: true, flatten_folders: true,
@@ -29,6 +31,45 @@ exports.downloadFiles = (req, res) => {
res.send(url); 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) => { exports.renameKeys = async (req, res) => {
const { documents } = req.body; const { documents } = req.body;
//{id: "", from: "", to:""} //{id: "", from: "", to:""}

View File

@@ -62,13 +62,17 @@ exports.receive = (req, res) => {
} }
client client
.request(queries.INSERT_MESSAGE, { msg: newMessage }) .request(queries.INSERT_MESSAGE, {
msg: newMessage,
conversationid: response.bodyshops[0].conversations[0].id,
})
.then((r2) => { .then((r2) => {
res.status(200).send(""); res.status(200).send("");
const arrayOfAllUserFcmTokens = r2.insert_messages.returning[0].conversation.bodyshop.associations.map( const arrayOfAllUserFcmTokens =
(a) => a.user.fcmtokens r2.insert_messages.returning[0].conversation.bodyshop.associations.map(
); (a) => a.user.fcmtokens
);
const allTokens = []; const allTokens = [];
arrayOfAllUserFcmTokens.map((i) => arrayOfAllUserFcmTokens.map((i) =>
Object.keys(i).map((k) => allTokens.push(k)) Object.keys(i).map((k) => allTokens.push(k))