Resolve phone number parsing issue on messaging.
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import phone from "phone";
|
import parsePhoneNumber from "libphonenumber-js";
|
||||||
import { all, call, put, select, takeLatest } from "redux-saga/effects";
|
import { all, call, put, select, takeLatest } from "redux-saga/effects";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import {
|
import {
|
||||||
CONVERSATION_ID_BY_PHONE,
|
CONVERSATION_ID_BY_PHONE,
|
||||||
CREATE_CONVERSATION,
|
CREATE_CONVERSATION
|
||||||
} from "../../graphql/conversations.queries";
|
} from "../../graphql/conversations.queries";
|
||||||
import { INSERT_CONVERSATION_TAG } from "../../graphql/job-conversations.queries";
|
import { INSERT_CONVERSATION_TAG } from "../../graphql/job-conversations.queries";
|
||||||
import client from "../../utils/GraphQLClient";
|
import client from "../../utils/GraphQLClient";
|
||||||
@@ -12,7 +12,7 @@ import { selectBodyshop } from "../user/user.selectors";
|
|||||||
import {
|
import {
|
||||||
sendMessageFailure,
|
sendMessageFailure,
|
||||||
sendMessageSuccess,
|
sendMessageSuccess,
|
||||||
setSelectedConversation,
|
setSelectedConversation
|
||||||
} from "./messaging.actions";
|
} from "./messaging.actions";
|
||||||
import MessagingActionTypes from "./messaging.types";
|
import MessagingActionTypes from "./messaging.types";
|
||||||
|
|
||||||
@@ -33,13 +33,14 @@ export function* openChatByPhone({ payload }) {
|
|||||||
logImEXEvent("messaging_open_by_phone");
|
logImEXEvent("messaging_open_by_phone");
|
||||||
const { phone_num, jobid } = payload;
|
const { phone_num, jobid } = payload;
|
||||||
|
|
||||||
|
const p = parsePhoneNumber(phone_num, "CA");
|
||||||
const bodyshop = yield select(selectBodyshop);
|
const bodyshop = yield select(selectBodyshop);
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { conversations },
|
data: { conversations },
|
||||||
} = yield client.query({
|
} = yield client.query({
|
||||||
query: CONVERSATION_ID_BY_PHONE,
|
query: CONVERSATION_ID_BY_PHONE,
|
||||||
variables: { phone: phone(phone_num).phoneNumber },
|
variables: { phone: p.number },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (conversations.length === 0) {
|
if (conversations.length === 0) {
|
||||||
@@ -52,7 +53,7 @@ export function* openChatByPhone({ payload }) {
|
|||||||
variables: {
|
variables: {
|
||||||
conversation: [
|
conversation: [
|
||||||
{
|
{
|
||||||
phone_num: phone(phone_num).phoneNumber,
|
phone_num: p.number,
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
job_conversations: jobid ? { data: { jobid: jobid } } : null,
|
job_conversations: jobid ? { data: { jobid: jobid } } : null,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user