diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 0ef9e24dd..98c98dd1c 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -18197,6 +18197,27 @@ + + new + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -18244,6 +18265,27 @@ + + phonenumber + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + presets false diff --git a/client/src/components/chat-new-conversation/chat-new-conversation.component.jsx b/client/src/components/chat-new-conversation/chat-new-conversation.component.jsx new file mode 100644 index 000000000..1fd219662 --- /dev/null +++ b/client/src/components/chat-new-conversation/chat-new-conversation.component.jsx @@ -0,0 +1,49 @@ +import { PlusCircleFilled } from "@ant-design/icons"; +import { Button, Form, Popover } from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { openChatByPhone } from "../../redux/messaging/messaging.actions"; +import PhoneFormItem from "../form-items-formatted/phone-form-item.component"; + +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser +}); +const mapDispatchToProps = (dispatch) => ({ + openChatByPhone: (phone) => dispatch(openChatByPhone(phone)), +}); + +export function ChatNewConversation({ openChatByPhone }) { + const { t } = useTranslation(); + const [form] = Form.useForm(); + const handleFinish = (values) => { + console.log("values :>> ", values); + openChatByPhone({ phone_num: values.phoneNumber }); + form.resetFields(); + }; + + const popContent = ( +
+
+ + + + +
+
+ ); + + return ( + + + + ); +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(ChatNewConversation); diff --git a/client/src/components/chat-popup/chat-popup.component.jsx b/client/src/components/chat-popup/chat-popup.component.jsx index 51eaa4f5e..dff58ef4f 100644 --- a/client/src/components/chat-popup/chat-popup.component.jsx +++ b/client/src/components/chat-popup/chat-popup.component.jsx @@ -9,6 +9,7 @@ import ChatConversationListComponent from "../chat-conversation-list/chat-conver import ChatConversationContainer from "../chat-conversation/chat-conversation.container"; import { selectSelectedConversation } from "../../redux/messaging/messaging.selectors"; import "./chat-popup.styles.scss"; +import ChatNewConversation from "../chat-new-conversation/chat-new-conversation.component"; const mapStateToProps = createStructuredSelector({ selectedConversation: selectSelectedConversation, @@ -25,9 +26,12 @@ export function ChatPopupComponent({ const { t } = useTranslation(); return (
- - {t("messaging.labels.messaging")} - +
+ + {t("messaging.labels.messaging")} + + +
toggleChatVisible()} style={{ position: "absolute", right: ".5rem", top: ".5rem" }} diff --git a/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx b/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx index 6a84cd2a1..9abdfef20 100644 --- a/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx +++ b/client/src/components/chat-tag-ro/chat-tag-ro.container.jsx @@ -20,7 +20,7 @@ export default function ChatTagRoContainer({ conversation }) { loadRo(v); }; - const debouncedExecuteSearch = _.debounce(executeSearch, 800); + const debouncedExecuteSearch = _.debounce(executeSearch, 500); const handleSearch = (value) => { debouncedExecuteSearch({ variables: { search: value } }); diff --git a/client/src/components/job-search-select/job-search-select.component.jsx b/client/src/components/job-search-select/job-search-select.component.jsx index 1db4244b4..3f239bf01 100644 --- a/client/src/components/job-search-select/job-search-select.component.jsx +++ b/client/src/components/job-search-select/job-search-select.component.jsx @@ -23,7 +23,7 @@ const JobSearchSelect = ({ value, onChange, onBlur, disabled }, ref) => { const executeSearch = (v) => { callSearch(v); }; - const debouncedExecuteSearch = _.debounce(executeSearch, 800); + const debouncedExecuteSearch = _.debounce(executeSearch, 500); const handleSearch = (value) => { debouncedExecuteSearch({ variables: { search: value } }); diff --git a/client/src/components/jobs-change-status/jobs-change-status.component.jsx b/client/src/components/jobs-change-status/jobs-change-status.component.jsx index 61d35290e..04cba9d62 100644 --- a/client/src/components/jobs-change-status/jobs-change-status.component.jsx +++ b/client/src/components/jobs-change-status/jobs-change-status.component.jsx @@ -44,6 +44,9 @@ export function JobsChangeStatus({ job, bodyshop }) { ) setAvailableStatuses(bodyshop.md_ro_statuses.post_production_statuses); else { + console.log( + "Status didn't match any restrictions. Allowing all status changes." + ); setAvailableStatuses(bodyshop.statuses); } } diff --git a/client/src/redux/messaging/messaging.sagas.js b/client/src/redux/messaging/messaging.sagas.js index a63a9e065..8d45112a6 100644 --- a/client/src/redux/messaging/messaging.sagas.js +++ b/client/src/redux/messaging/messaging.sagas.js @@ -32,6 +32,7 @@ export function* onOpenChatByPhone() { export function* openChatByPhone({ payload }) { logImEXEvent("messaging_open_by_phone"); const { phone_num, jobid } = payload; + const bodyshop = yield select(selectBodyshop); try { const { @@ -39,7 +40,9 @@ export function* openChatByPhone({ payload }) { } = yield client.query({ query: CONVERSATION_ID_BY_PHONE, variables: { phone: phone(phone_num)[0] }, + fetchPolicy: "network-only", }); + if (conversations.length === 0) { const { data: { @@ -61,13 +64,14 @@ export function* openChatByPhone({ payload }) { } else if (conversations.length === 1) { //got the ID. Open it. yield put(setSelectedConversation(conversations[0].id)); - yield client.mutate({ - mutation: INSERT_CONVERSATION_TAG, - variables: { - conversationId: conversations[0].id, - jobId: jobid, - }, - }); + if (jobid) + yield client.mutate({ + mutation: INSERT_CONVERSATION_TAG, + variables: { + conversationId: conversations[0].id, + jobId: jobid, + }, + }); } else { console.log("ERROR: Multiple conversations found. "); //TODO Graceful handling of this situation } diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 5c090b59e..81fd5bf61 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1106,11 +1106,13 @@ }, "messaging": { "actions": { - "link": "Link to Job" + "link": "Link to Job", + "new": "New Conversation" }, "labels": { "messaging": "Messaging", "nojobs": "Not associated to any job.", + "phonenumber": "Phone #", "presets": "Presets", "typeamessage": "Send a message..." } diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 22a63d8f1..fab6b1612 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1106,11 +1106,13 @@ }, "messaging": { "actions": { - "link": "" + "link": "", + "new": "" }, "labels": { "messaging": "Mensajería", "nojobs": "", + "phonenumber": "", "presets": "", "typeamessage": "Enviar un mensaje..." } diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 9f8aa9083..5aaf6d46d 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1106,11 +1106,13 @@ }, "messaging": { "actions": { - "link": "" + "link": "", + "new": "" }, "labels": { "messaging": "Messagerie", "nojobs": "", + "phonenumber": "", "presets": "", "typeamessage": "Envoyer un message..." }