Merged in release/2021-09-24 (pull request #222)

release/2021-09-24

Approved-by: Patrick Fic
This commit is contained in:
Patrick Fic
2021-09-22 23:11:31 +00:00
13 changed files with 89 additions and 29 deletions

View File

@@ -13,6 +13,7 @@ const BillLineSearchSelect = ({ options, disabled, ...restProps }, ref) => {
ref={ref} ref={ref}
showSearch showSearch
optionFilterProp="line_desc" optionFilterProp="line_desc"
notFoundContent={"Removed."}
{...restProps} {...restProps}
> >
<Select.Option key={null} value={"noline"} cost={0} line_desc={""}> <Select.Option key={null} value={"noline"} cost={0} line_desc={""}>
@@ -21,14 +22,18 @@ const BillLineSearchSelect = ({ options, disabled, ...restProps }, ref) => {
{options {options
? options.map((item) => ( ? options.map((item) => (
<Option <Option
disabled={item.removed}
key={item.id} key={item.id}
value={item.id} value={item.id}
cost={item.act_price ? item.act_price : 0} cost={item.act_price ? item.act_price : 0}
part_type={item.part_type} part_type={item.part_type}
line_desc={item.line_desc} line_desc={item.line_desc}
part_qty={item.part_qty} part_qty={item.part_qty}
style={{
...(item.removed ? { textDecoration: "line-through" } : {}),
}}
> >
{`${item.line_desc}${ {`${item.removed ? `(REMOVED) ` : ""}${item.line_desc}${
item.oem_partno ? ` - ${item.oem_partno}` : "" item.oem_partno ? ` - ${item.oem_partno}` : ""
}`} }`}
</Option> </Option>

View File

@@ -8,6 +8,7 @@ import { selectSelectedConversation } from "../../redux/messaging/messaging.sele
import PhoneFormatter from "../../utils/PhoneFormatter"; import PhoneFormatter from "../../utils/PhoneFormatter";
import "./chat-conversation-list.styles.scss"; import "./chat-conversation-list.styles.scss";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { TimeAgoFormatter } from "../../utils/DateFormatter";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
selectedConversation: selectSelectedConversation, selectedConversation: selectSelectedConversation,
@@ -60,13 +61,18 @@ export function ChatConversationListComponent({
) : ( ) : (
<PhoneFormatter>{item.phone_num}</PhoneFormatter> <PhoneFormatter>{item.phone_num}</PhoneFormatter>
)} )}
{item.job_conversations.length > 0 <div sryle={{ display: "inline-block" }}>
? item.job_conversations.map((j, idx) => ( <div>
<Tag key={idx} className="ro-number-tag"> {item.job_conversations.length > 0
{j.job.ro_number} ? item.job_conversations.map((j, idx) => (
</Tag> <Tag key={idx} className="ro-number-tag">
)) {j.job.ro_number}
: null} </Tag>
))
: null}
</div>
<TimeAgoFormatter>{item.updated_at}</TimeAgoFormatter>
</div>
<Badge count={item.messages_aggregate.aggregate.count || 0} /> <Badge count={item.messages_aggregate.aggregate.count || 0} />
</List.Item> </List.Item>
)} )}

View File

@@ -1,4 +1,5 @@
import Icon from "@ant-design/icons"; import Icon from "@ant-design/icons";
import { Tooltip } from "antd";
import i18n from "i18next"; import i18n from "i18next";
import moment from "moment"; import moment from "moment";
import React, { useEffect, useRef } from "react"; import React, { useEffect, useRef } from "react";
@@ -9,6 +10,7 @@ import {
CellMeasurerCache, CellMeasurerCache,
List, List,
} from "react-virtualized"; } from "react-virtualized";
import { DateTimeFormatter } from "../../utils/DateFormatter";
import "./chat-message-list.styles.scss"; import "./chat-message-list.styles.scss";
export default function ChatMessageListComponent({ messages }) { export default function ChatMessageListComponent({ messages }) {
@@ -85,17 +87,22 @@ export default function ChatMessageListComponent({ messages }) {
const MessageRender = (message) => { const MessageRender = (message) => {
return ( return (
<div> <Tooltip title={DateTimeFormatter({ children: message.created_at })}>
{message.image_path && <div>
message.image_path.map((i, idx) => ( {message.image_path &&
<div key={idx} style={{ display: "flex", justifyContent: "center" }}> message.image_path.map((i, idx) => (
<a href={i} target="__blank"> <div
<img alt="Received" className="message-img" src={i} /> key={idx}
</a> style={{ display: "flex", justifyContent: "center" }}
</div> >
))} <a href={i} target="__blank">
<div>{message.text}</div> <img alt="Received" className="message-img" src={i} />
</div> </a>
</div>
))}
<div>{message.text}</div>
</div>
</Tooltip>
); );
}; };

View File

@@ -400,7 +400,7 @@ export function JobLinesComponent({
setState({ setState({
...state, ...state,
filteredInfo: { filteredInfo: {
part_type: ["PAN,PAC,PAR,PAL,PAA,PAM,PAP,PAO,PAS,PASL,PAG"], part_type: ["PAN,PAC,PAR,PAL,PAA,PAM,PAP,PAS,PASL,PAG"],
}, },
}); });
}} }}

View File

@@ -9,6 +9,7 @@ export const CONVERSATION_LIST_SUBSCRIPTION = gql`
) { ) {
phone_num phone_num
id id
updated_at
job_conversations { job_conversations {
job { job {
id id

View File

@@ -160,7 +160,8 @@ export const UPDATE_JOB_LINE = gql`
export const GET_JOB_LINES_TO_ENTER_BILL = gql` export const GET_JOB_LINES_TO_ENTER_BILL = gql`
query GET_JOB_LINES_TO_ENTER_BILL($id: uuid!) { query GET_JOB_LINES_TO_ENTER_BILL($id: uuid!) {
joblines(where: { jobid: { _eq: $id }, removed: { _eq: false } }) { joblines(where: { jobid: { _eq: $id } }) {
removed
id id
line_desc line_desc
part_type part_type

View File

@@ -90,8 +90,6 @@ export function* onSendMessage() {
} }
export function* sendMessage({ payload }) { export function* sendMessage({ payload }) {
try { try {
yield logImEXEvent("messaging_send_message");
const response = yield call(axios.post, "/sms/send", payload); const response = yield call(axios.post, "/sms/send", payload);
if (response.status === 200) { if (response.status === 200) {
yield put(sendMessageSuccess(payload)); yield put(sendMessageSuccess(payload));

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,15 @@
- type: run_sql
args:
cascade: false
read_only: false
sql: |-
CREATE OR REPLACE FUNCTION public.update_conversation_on_message()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
UPDATE conversations SET updated_at = now() WHERE id = NEW.conversationid;
RETURN NEW;
END;
$function$
;

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,15 @@
- type: run_sql
args:
cascade: false
read_only: false
sql: |-
CREATE OR REPLACE FUNCTION public.update_conversation_on_message()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
UPDATE conversations SET updated_at = now() WHERE conversations.id = NEW.conversationid;
RETURN NEW;
END;
$function$
;

View File

@@ -12,14 +12,24 @@ query FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID(
} }
`; `;
exports.INSERT_MESSAGE = ` exports.UNARCHIVE_CONVERSATION = `
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!, $conversationid: uuid) { mutation UNARCHIVE_CONVERSATION($id: uuid!) {
update_conversations(where: {id: {_eq: $conversationid}}, _set: {archived: false}) { update_conversations_by_pk(pk_columns: {id: $id}, _set: {archived: false}) {
affected_rows id
} }
insert_messages(objects: $msg) { }
`;
exports.INSERT_MESSAGE = `
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!, $conversationid: uuid!) {
update_conversations_by_pk(pk_columns: {id: $conversationid}, _set: {archived: false}) {
id
}
insert_messages(objects: $msg) {
returning { returning {
conversation { conversation {
id
archived
bodyshop { bodyshop {
associations(where: {active: {_eq: true}}) { associations(where: {active: {_eq: true}}) {
user { user {

View File

@@ -55,7 +55,7 @@ exports.send = (req, res) => {
: [], : [],
}; };
gqlClient gqlClient
.request(queries.INSERT_MESSAGE, { msg: newMessage }) .request(queries.INSERT_MESSAGE, { msg: newMessage, conversationid })
.then((r2) => { .then((r2) => {
//console.log("Responding GQL Message ID", JSON.stringify(r2)); //console.log("Responding GQL Message ID", JSON.stringify(r2));
logger.log("sms-outbound-success", "DEBUG", req.user.email, null, { logger.log("sms-outbound-success", "DEBUG", req.user.email, null, {