Added messaging presets BOD-107

This commit is contained in:
Patrick Fic
2020-07-21 16:12:32 -07:00
parent 0ef4d77275
commit 7b99a2e612
21 changed files with 526 additions and 18 deletions

View File

@@ -1253,6 +1253,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>lastnumberworkingdays</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>logo_img_path</name> <name>logo_img_path</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -1274,6 +1295,69 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>md_referral_sources</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>messaginglabel</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>messagingtext</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>responsibilitycenter</name> <name>responsibilitycenter</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -5494,6 +5578,27 @@
<folder_node> <folder_node>
<name>actions</name> <name>actions</name>
<children> <children>
<concept_node>
<name>add</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>cancel</name> <name>cancel</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>
@@ -14796,6 +14901,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>presets</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>typeamessage</name> <name>typeamessage</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -2,6 +2,7 @@ import { Space } from "antd";
import React from "react"; import React from "react";
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";
import ChatPresetsComponent from "../chat-presets/chat-presets.component";
export default function ChatConversationTitle({ conversation }) { export default function ChatConversationTitle({ conversation }) {
return ( return (
@@ -17,13 +18,14 @@ export default function ChatConversationTitle({ conversation }) {
)} )}
</span> </span>
</Space> </Space>
<div className='imex-flex-row imex-flex-row__margin'> <div className="imex-flex-row imex-flex-row__margin">
<ChatConversationTitleTags <ChatConversationTitleTags
jobConversations={ jobConversations={
(conversation && conversation.job_conversations) || [] (conversation && conversation.job_conversations) || []
} }
/> />
<ChatTagRoContainer conversation={conversation || []} /> <ChatTagRoContainer conversation={conversation || []} />
<ChatPresetsComponent />
</div> </div>
</div> </div>
); );

View File

@@ -0,0 +1,50 @@
import React from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setMessage } from "../../redux/messaging/messaging.actions";
import { Dropdown, Button, Menu } from "antd";
import { useTranslation } from "react-i18next";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { DownOutlined } from "@ant-design/icons";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language))
setMessage: (message) => dispatch(setMessage(message)),
});
export function ChatPresetsComponent({ bodyshop, setMessage }) {
const { t } = useTranslation();
const menu = (
<Menu>
{bodyshop.md_messaging_presets.map((i, idx) => (
<Menu.Item onClick={() => setMessage(i.text)} key={idx}>
{i.label}
</Menu.Item>
))}
</Menu>
);
return (
<div>
<Dropdown trigger={["click"]} overlay={menu}>
<a
className="ant-dropdown-link"
href="javascript:void(0);"
onClick={(e) => e.preventDefault()}
>
{t("messaging.labels.presets")} <DownOutlined />
</a>
</Dropdown>
</div>
);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(ChatPresetsComponent);

View File

@@ -1,21 +1,29 @@
import { LoadingOutlined } from "@ant-design/icons"; import { LoadingOutlined } from "@ant-design/icons";
import { Input, Spin } from "antd"; import { Input, Spin } from "antd";
import React, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.utils"; import { logImEXEvent } from "../../firebase/firebase.utils";
import { sendMessage } from "../../redux/messaging/messaging.actions"; import {
import { selectIsSending } from "../../redux/messaging/messaging.selectors"; sendMessage,
setMessage,
} from "../../redux/messaging/messaging.actions";
import {
selectIsSending,
selectMessage,
} from "../../redux/messaging/messaging.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
isSending: selectIsSending, isSending: selectIsSending,
message: selectMessage,
}); });
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
sendMessage: (message) => dispatch(sendMessage(message)), sendMessage: (message) => dispatch(sendMessage(message)),
setMessage: (message) => dispatch(setMessage(message)),
}); });
function ChatSendMessageComponent({ function ChatSendMessageComponent({
@@ -23,13 +31,11 @@ function ChatSendMessageComponent({
bodyshop, bodyshop,
sendMessage, sendMessage,
isSending, isSending,
message,
setMessage,
}) { }) {
const [message, setMessage] = useState("");
const inputArea = useRef(null); const inputArea = useRef(null);
useEffect(() => { useEffect(() => {
if (isSending === false) {
setMessage("");
}
inputArea.current.focus(); inputArea.current.focus();
}, [isSending, setMessage]); }, [isSending, setMessage]);

View File

@@ -8,6 +8,7 @@ import {
Radio, Radio,
Select, Select,
} from "antd"; } from "antd";
import { DeleteFilled } from "@ant-design/icons";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import ShopInfoROStatusComponent from "./shop-info.rostatus.component"; import ShopInfoROStatusComponent from "./shop-info.rostatus.component";
import ShopInfoOrderStatusComponent from "./shop-info.orderstatus.component"; import ShopInfoOrderStatusComponent from "./shop-info.orderstatus.component";
@@ -188,6 +189,68 @@ export default function ShopInfoComponent({ form }) {
}} }}
</Form.Item> </Form.Item>
<Form.List name={["md_messaging_presets"]}>
{(fields, { add, remove }) => {
return (
<div>
{fields.map((field, index) => (
<Form.Item
key={field.key}
style={{ padding: 0, margin: 2 }}
>
<div style={{ display: "flex" }}>
<Form.Item
style={{ padding: 0, margin: 2 }}
label={t("bodyshop.fields.messaginglabel")}
key={`${index}label`}
name={[field.name, "label"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<Form.Item
style={{ padding: 0, margin: 2 }}
label={t("bodyshop.fields.messagingtext")}
key={`${index}text`}
name={[field.name, "text"]}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input />
</Form.Item>
<DeleteFilled
onClick={() => {
remove(field.name);
}}
/>
</div>
</Form.Item>
))}
<Form.Item>
<Button
type="dashed"
onClick={() => {
add();
}}
style={{ width: "100%" }}
>
{t("general.actions.add")}
</Button>
</Form.Item>
</div>
);
}}
</Form.List>
<Form.Item <Form.Item
name={["md_referral_sources"]} name={["md_referral_sources"]}
label={t("bodyshop.fields.md_referral_sources")} label={t("bodyshop.fields.md_referral_sources")}

View File

@@ -13,25 +13,24 @@ export default function ShopInfoContainer() {
const { t } = useTranslation(); const { t } = useTranslation();
const [updateBodyshop] = useMutation(UPDATE_SHOP); const [updateBodyshop] = useMutation(UPDATE_SHOP);
const { loading, error, data, refetch } = useQuery(QUERY_BODYSHOP, { const { loading, error, data, refetch } = useQuery(QUERY_BODYSHOP, {
fetchPolicy: "network-only" fetchPolicy: "network-only",
}); });
const handleFinish = values => { const handleFinish = (values) => {
console.log("values", values); console.log("values", values);
logImEXEvent("shop_update"); logImEXEvent("shop_update");
updateBodyshop({ updateBodyshop({
variables: { id: data.bodyshops[0].id, shop: values } variables: { id: data.bodyshops[0].id, shop: values },
}) })
.then(r => { .then((r) => {
notification["success"]({ message: t("bodyshop.successes.save") }); notification["success"]({ message: t("bodyshop.successes.save") });
refetch().then(_ => form.resetFields()); refetch().then((_) => form.resetFields());
}) })
.catch(error => { .catch((error) => {
notification["error"]( notification["error"]({
{ message: t("bodyshop.errors.saving") }, message: t("bodyshop.errors.saving", { message: error }),
{ message: error } });
);
}); });
}; };

View File

@@ -45,6 +45,7 @@ export const QUERY_BODYSHOP = gql`
ssbuckets ssbuckets
scoreboard_target scoreboard_target
md_referral_sources md_referral_sources
md_messaging_presets
employees { employees {
id id
first_name first_name
@@ -98,6 +99,7 @@ export const UPDATE_SHOP = gql`
ssbuckets ssbuckets
scoreboard_target scoreboard_target
md_referral_sources md_referral_sources
md_messaging_presets
employees { employees {
id id
first_name first_name

View File

@@ -28,3 +28,8 @@ export const openChatByPhone = (phoneNumber) => ({
type: MessagingActionTypes.OPEN_CHAT_BY_PHONE, type: MessagingActionTypes.OPEN_CHAT_BY_PHONE,
payload: phoneNumber, payload: phoneNumber,
}); });
export const setMessage = (message) => ({
type: MessagingActionTypes.SET_MESSAGE,
payload: message,
});

View File

@@ -5,10 +5,13 @@ const INITIAL_STATE = {
selectedConversationId: null, selectedConversationId: null,
isSending: false, isSending: false,
error: null, error: null,
message: null,
}; };
const messagingReducer = (state = INITIAL_STATE, action) => { const messagingReducer = (state = INITIAL_STATE, action) => {
switch (action.type) { switch (action.type) {
case MessagingActionTypes.SET_MESSAGE:
return { ...state, message: action.payload };
case MessagingActionTypes.TOGGLE_CHAT_VISIBLE: case MessagingActionTypes.TOGGLE_CHAT_VISIBLE:
return { return {
...state, ...state,
@@ -29,6 +32,7 @@ const messagingReducer = (state = INITIAL_STATE, action) => {
case MessagingActionTypes.SEND_MESSAGE_SUCCESS: case MessagingActionTypes.SEND_MESSAGE_SUCCESS:
return { return {
...state, ...state,
message: "",
isSending: false, isSending: false,
}; };
case MessagingActionTypes.SEND_MESSAGE_FAILURE: case MessagingActionTypes.SEND_MESSAGE_FAILURE:

View File

@@ -21,3 +21,8 @@ export const selectSelectedConversation = createSelector(
[selectMessaging], [selectMessaging],
(messaging) => messaging.selectedConversationId (messaging) => messaging.selectedConversationId
); );
export const selectMessage = createSelector(
[selectMessaging],
(messaging) => messaging.message
);

View File

@@ -5,5 +5,6 @@ const MessagingActionTypes = {
SEND_MESSAGE_FAILURE: "SEND_MESSAGE_FAILURE", SEND_MESSAGE_FAILURE: "SEND_MESSAGE_FAILURE",
SET_SELECTED_CONVERSATION: "SET_SELECTED_CONVERSATION", SET_SELECTED_CONVERSATION: "SET_SELECTED_CONVERSATION",
OPEN_CHAT_BY_PHONE: "OPEN_CHAT_BY_PHONE", OPEN_CHAT_BY_PHONE: "OPEN_CHAT_BY_PHONE",
SET_MESSAGE: "SET_MESSAGE",
}; };
export default MessagingActionTypes; export default MessagingActionTypes;

View File

@@ -94,7 +94,11 @@
"invoice_federal_tax_rate": "Invoices - Federal Tax Rate %", "invoice_federal_tax_rate": "Invoices - Federal Tax Rate %",
"invoice_local_tax_rate": "Invoices - State Tax Rate %", "invoice_local_tax_rate": "Invoices - State Tax Rate %",
"invoice_state_tax_rate": "Invoices - State Tax Rate %", "invoice_state_tax_rate": "Invoices - State Tax Rate %",
"lastnumberworkingdays": "Scoreboard - Last Number of Working Days",
"logo_img_path": "Shop Logo", "logo_img_path": "Shop Logo",
"md_referral_sources": "Referral Sources",
"messaginglabel": "Messaging Preset Label",
"messagingtext": "Messaging Preset Text",
"responsibilitycenter": "Responsibility Center", "responsibilitycenter": "Responsibility Center",
"responsibilitycenter_accountdesc": "Account Description", "responsibilitycenter_accountdesc": "Account Description",
"responsibilitycenter_accountitem": "Item", "responsibilitycenter_accountitem": "Item",
@@ -377,6 +381,7 @@
}, },
"general": { "general": {
"actions": { "actions": {
"add": "Add",
"cancel": "Cancel", "cancel": "Cancel",
"close": "Close", "close": "Close",
"create": "Create", "create": "Create",
@@ -901,6 +906,7 @@
"labels": { "labels": {
"messaging": "Messaging", "messaging": "Messaging",
"nojobs": "Not associated to any job.", "nojobs": "Not associated to any job.",
"presets": "Presets",
"typeamessage": "Send a message..." "typeamessage": "Send a message..."
} }
}, },

View File

@@ -94,7 +94,11 @@
"invoice_federal_tax_rate": "", "invoice_federal_tax_rate": "",
"invoice_local_tax_rate": "", "invoice_local_tax_rate": "",
"invoice_state_tax_rate": "", "invoice_state_tax_rate": "",
"lastnumberworkingdays": "",
"logo_img_path": "", "logo_img_path": "",
"md_referral_sources": "",
"messaginglabel": "",
"messagingtext": "",
"responsibilitycenter": "", "responsibilitycenter": "",
"responsibilitycenter_accountdesc": "", "responsibilitycenter_accountdesc": "",
"responsibilitycenter_accountitem": "", "responsibilitycenter_accountitem": "",
@@ -377,6 +381,7 @@
}, },
"general": { "general": {
"actions": { "actions": {
"add": "",
"cancel": "", "cancel": "",
"close": "", "close": "",
"create": "", "create": "",
@@ -901,6 +906,7 @@
"labels": { "labels": {
"messaging": "Mensajería", "messaging": "Mensajería",
"nojobs": "", "nojobs": "",
"presets": "",
"typeamessage": "Enviar un mensaje..." "typeamessage": "Enviar un mensaje..."
} }
}, },

View File

@@ -94,7 +94,11 @@
"invoice_federal_tax_rate": "", "invoice_federal_tax_rate": "",
"invoice_local_tax_rate": "", "invoice_local_tax_rate": "",
"invoice_state_tax_rate": "", "invoice_state_tax_rate": "",
"lastnumberworkingdays": "",
"logo_img_path": "", "logo_img_path": "",
"md_referral_sources": "",
"messaginglabel": "",
"messagingtext": "",
"responsibilitycenter": "", "responsibilitycenter": "",
"responsibilitycenter_accountdesc": "", "responsibilitycenter_accountdesc": "",
"responsibilitycenter_accountitem": "", "responsibilitycenter_accountitem": "",
@@ -377,6 +381,7 @@
}, },
"general": { "general": {
"actions": { "actions": {
"add": "",
"cancel": "", "cancel": "",
"close": "", "close": "",
"create": "", "create": "",
@@ -901,6 +906,7 @@
"labels": { "labels": {
"messaging": "Messagerie", "messaging": "Messagerie",
"nojobs": "", "nojobs": "",
"presets": "",
"typeamessage": "Envoyer un message..." "typeamessage": "Envoyer un message..."
} }
}, },

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."bodyshops" DROP COLUMN "md_messaging_presets";
type: run_sql

View File

@@ -0,0 +1,6 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."bodyshops" ADD COLUMN "md_messaging_presets" jsonb
NULL DEFAULT jsonb_build_array();
type: run_sql

View File

@@ -0,0 +1,56 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_order_statuses
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- messagingservicesid
- production_config
- region_config
- scoreboard_target
- shopname
- shoprates
- ssbuckets
- state
- state_tax_id
- stripe_acct_id
- template_header
- textid
- updated_at
- zip_post
computed_fields: []
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,57 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_select_permission
- args:
permission:
allow_aggregations: false
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_order_statuses
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- messagingservicesid
- production_config
- region_config
- scoreboard_target
- shopname
- shoprates
- ssbuckets
- state
- state_tax_id
- stripe_acct_id
- template_header
- textid
- updated_at
- zip_post
computed_fields: []
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
role: user
table:
name: bodyshops
schema: public
type: create_select_permission

View File

@@ -0,0 +1,50 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_order_statuses
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- production_config
- scoreboard_target
- shopname
- shoprates
- ssbuckets
- state
- state_tax_id
- updated_at
- zip_post
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

@@ -0,0 +1,51 @@
- args:
role: user
table:
name: bodyshops
schema: public
type: drop_update_permission
- args:
permission:
columns:
- accountingconfig
- address1
- address2
- appt_length
- city
- country
- created_at
- email
- federal_tax_id
- id
- inhousevendorid
- insurance_vendor_id
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_order_statuses
- md_referral_sources
- md_responsibility_centers
- md_ro_statuses
- production_config
- scoreboard_target
- shopname
- shoprates
- ssbuckets
- state
- state_tax_id
- updated_at
- zip_post
filter:
associations:
bodyshop:
associations:
user:
authid:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: bodyshops
schema: public
type: create_update_permission

View File

@@ -473,6 +473,7 @@ tables:
- intakechecklist - intakechecklist
- invoice_tax_rates - invoice_tax_rates
- logo_img_path - logo_img_path
- md_messaging_presets
- md_order_statuses - md_order_statuses
- md_referral_sources - md_referral_sources
- md_responsibility_centers - md_responsibility_centers
@@ -517,6 +518,7 @@ tables:
- intakechecklist - intakechecklist
- invoice_tax_rates - invoice_tax_rates
- logo_img_path - logo_img_path
- md_messaging_presets
- md_order_statuses - md_order_statuses
- md_referral_sources - md_referral_sources
- md_responsibility_centers - md_responsibility_centers