diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index 46aa75c86..5fcb5546a 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -25398,6 +25398,27 @@
labels
+
+ archive
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
maxtenimages
false
@@ -25587,6 +25608,27 @@
+
+ unarchive
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
diff --git a/client/src/components/chat-archive-button/chat-archive-button.component.jsx b/client/src/components/chat-archive-button/chat-archive-button.component.jsx
new file mode 100644
index 000000000..dcda38860
--- /dev/null
+++ b/client/src/components/chat-archive-button/chat-archive-button.component.jsx
@@ -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 (
+
+ );
+}
diff --git a/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx b/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx
index 7fa5bf585..16ff571fd 100644
--- a/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx
+++ b/client/src/components/chat-conversation-title/chat-conversation-title.component.jsx
@@ -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 (
-
+
{conversation && conversation.phone_num}
@@ -16,6 +17,7 @@ export default function ChatConversationTitle({ conversation }) {
}
/>
+
);
}
diff --git a/client/src/graphql/conversations.queries.js b/client/src/graphql/conversations.queries.js
index f18b43eca..d6b0f4e71 100644
--- a/client/src/graphql/conversations.queries.js
+++ b/client/src/graphql/conversations.queries.js
@@ -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
+ }
+ }
+`;
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index 62c264f66..e0a98ab1b 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -1501,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.",
@@ -1509,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": {
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index f3ca17de3..8d5cd2fc2 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -1501,6 +1501,7 @@
"invalidphone": ""
},
"labels": {
+ "archive": "",
"maxtenimages": "",
"messaging": "Mensajería",
"noallowtxt": "",
@@ -1509,7 +1510,8 @@
"presets": "",
"selectmedia": "",
"sentby": "",
- "typeamessage": "Enviar un mensaje..."
+ "typeamessage": "Enviar un mensaje...",
+ "unarchive": ""
}
},
"notes": {
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index 1e96195c4..2ef28a3eb 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -1501,6 +1501,7 @@
"invalidphone": ""
},
"labels": {
+ "archive": "",
"maxtenimages": "",
"messaging": "Messagerie",
"noallowtxt": "",
@@ -1509,7 +1510,8 @@
"presets": "",
"selectmedia": "",
"sentby": "",
- "typeamessage": "Envoyer un message..."
+ "typeamessage": "Envoyer un message...",
+ "unarchive": ""
}
},
"notes": {
diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js
index ee3de5cf9..6ee17551a 100644
--- a/server/graphql-client/queries.js
+++ b/server/graphql-client/queries.js
@@ -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 = `
diff --git a/server/sms/receive.js b/server/sms/receive.js
index 44fee6251..081cd383b 100644
--- a/server/sms/receive.js
+++ b/server/sms/receive.js
@@ -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))