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>
</translations>
</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>
<name>logo_img_path</name>
<definition_loaded>false</definition_loaded>
@@ -1274,6 +1295,69 @@
</translation>
</translations>
</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>
<name>responsibilitycenter</name>
<definition_loaded>false</definition_loaded>
@@ -5494,6 +5578,27 @@
<folder_node>
<name>actions</name>
<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>
<name>cancel</name>
<definition_loaded>false</definition_loaded>
@@ -14796,6 +14901,27 @@
</translation>
</translations>
</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>
<name>typeamessage</name>
<definition_loaded>false</definition_loaded>

View File

@@ -2,6 +2,7 @@ import { Space } from "antd";
import React from "react";
import ChatConversationTitleTags from "../chat-conversation-title-tags/chat-conversation-title-tags.component";
import ChatTagRoContainer from "../chat-tag-ro/chat-tag-ro.container";
import ChatPresetsComponent from "../chat-presets/chat-presets.component";
export default function ChatConversationTitle({ conversation }) {
return (
@@ -17,13 +18,14 @@ export default function ChatConversationTitle({ conversation }) {
)}
</span>
</Space>
<div className='imex-flex-row imex-flex-row__margin'>
<div className="imex-flex-row imex-flex-row__margin">
<ChatConversationTitleTags
jobConversations={
(conversation && conversation.job_conversations) || []
}
/>
<ChatTagRoContainer conversation={conversation || []} />
<ChatPresetsComponent />
</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 { Input, Spin } from "antd";
import React, { useEffect, useRef, useState } from "react";
import React, { useEffect, useRef } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { sendMessage } from "../../redux/messaging/messaging.actions";
import { selectIsSending } from "../../redux/messaging/messaging.selectors";
import {
sendMessage,
setMessage,
} from "../../redux/messaging/messaging.actions";
import {
selectIsSending,
selectMessage,
} from "../../redux/messaging/messaging.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
isSending: selectIsSending,
message: selectMessage,
});
const mapDispatchToProps = (dispatch) => ({
sendMessage: (message) => dispatch(sendMessage(message)),
setMessage: (message) => dispatch(setMessage(message)),
});
function ChatSendMessageComponent({
@@ -23,13 +31,11 @@ function ChatSendMessageComponent({
bodyshop,
sendMessage,
isSending,
message,
setMessage,
}) {
const [message, setMessage] = useState("");
const inputArea = useRef(null);
useEffect(() => {
if (isSending === false) {
setMessage("");
}
inputArea.current.focus();
}, [isSending, setMessage]);

View File

@@ -8,6 +8,7 @@ import {
Radio,
Select,
} from "antd";
import { DeleteFilled } from "@ant-design/icons";
import { useTranslation } from "react-i18next";
import ShopInfoROStatusComponent from "./shop-info.rostatus.component";
import ShopInfoOrderStatusComponent from "./shop-info.orderstatus.component";
@@ -188,6 +189,68 @@ export default function ShopInfoComponent({ form }) {
}}
</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
name={["md_referral_sources"]}
label={t("bodyshop.fields.md_referral_sources")}

View File

@@ -13,25 +13,24 @@ export default function ShopInfoContainer() {
const { t } = useTranslation();
const [updateBodyshop] = useMutation(UPDATE_SHOP);
const { loading, error, data, refetch } = useQuery(QUERY_BODYSHOP, {
fetchPolicy: "network-only"
fetchPolicy: "network-only",
});
const handleFinish = values => {
const handleFinish = (values) => {
console.log("values", values);
logImEXEvent("shop_update");
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") });
refetch().then(_ => form.resetFields());
refetch().then((_) => form.resetFields());
})
.catch(error => {
notification["error"](
{ message: t("bodyshop.errors.saving") },
{ message: error }
);
.catch((error) => {
notification["error"]({
message: t("bodyshop.errors.saving", { message: error }),
});
});
};

View File

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

View File

@@ -27,4 +27,9 @@ export const setSelectedConversation = (conversationId) => ({
export const openChatByPhone = (phoneNumber) => ({
type: MessagingActionTypes.OPEN_CHAT_BY_PHONE,
payload: phoneNumber,
});
export const setMessage = (message) => ({
type: MessagingActionTypes.SET_MESSAGE,
payload: message,
});

View File

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

View File

@@ -21,3 +21,8 @@ export const selectSelectedConversation = createSelector(
[selectMessaging],
(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",
SET_SELECTED_CONVERSATION: "SET_SELECTED_CONVERSATION",
OPEN_CHAT_BY_PHONE: "OPEN_CHAT_BY_PHONE",
SET_MESSAGE: "SET_MESSAGE",
};
export default MessagingActionTypes;

View File

@@ -94,7 +94,11 @@
"invoice_federal_tax_rate": "Invoices - Federal Tax Rate %",
"invoice_local_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",
"md_referral_sources": "Referral Sources",
"messaginglabel": "Messaging Preset Label",
"messagingtext": "Messaging Preset Text",
"responsibilitycenter": "Responsibility Center",
"responsibilitycenter_accountdesc": "Account Description",
"responsibilitycenter_accountitem": "Item",
@@ -377,6 +381,7 @@
},
"general": {
"actions": {
"add": "Add",
"cancel": "Cancel",
"close": "Close",
"create": "Create",
@@ -901,6 +906,7 @@
"labels": {
"messaging": "Messaging",
"nojobs": "Not associated to any job.",
"presets": "Presets",
"typeamessage": "Send a message..."
}
},

View File

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

View File

@@ -94,7 +94,11 @@
"invoice_federal_tax_rate": "",
"invoice_local_tax_rate": "",
"invoice_state_tax_rate": "",
"lastnumberworkingdays": "",
"logo_img_path": "",
"md_referral_sources": "",
"messaginglabel": "",
"messagingtext": "",
"responsibilitycenter": "",
"responsibilitycenter_accountdesc": "",
"responsibilitycenter_accountitem": "",
@@ -377,6 +381,7 @@
},
"general": {
"actions": {
"add": "",
"cancel": "",
"close": "",
"create": "",
@@ -901,6 +906,7 @@
"labels": {
"messaging": "Messagerie",
"nojobs": "",
"presets": "",
"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
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_order_statuses
- md_referral_sources
- md_responsibility_centers
@@ -517,6 +518,7 @@ tables:
- intakechecklist
- invoice_tax_rates
- logo_img_path
- md_messaging_presets
- md_order_statuses
- md_referral_sources
- md_responsibility_centers