BOD-14 Backend server work + sending of messages WIP for front end
This commit is contained in:
@@ -19,3 +19,13 @@ export const closeConversation = phone => ({
|
||||
type: MessagingActionTypes.CLOSE_CONVERSATION,
|
||||
payload: phone
|
||||
});
|
||||
|
||||
export const sendMessage = message => ({
|
||||
type: MessagingActionTypes.SEND_MESSAGE,
|
||||
payload: message
|
||||
});
|
||||
|
||||
export const sendMessageFailure = error => ({
|
||||
type: MessagingActionTypes.SEND_MESSAGE_FAILURE,
|
||||
payload: error
|
||||
});
|
||||
|
||||
@@ -3,8 +3,16 @@ import MessagingActionTypes from "./messaging.types";
|
||||
const INITIAL_STATE = {
|
||||
visible: false,
|
||||
conversations: [
|
||||
{ phone: "6049992002", open: false },
|
||||
{ phone: "6049992991", open: false }
|
||||
{
|
||||
phone: "6049992002",
|
||||
id: "519ba10d-6467-4fa5-9c22-59ae891edeb6",
|
||||
open: false
|
||||
},
|
||||
{
|
||||
phone: "6049992991",
|
||||
id: "ab57deba-eeb9-40db-b5ae-23f3ce8d7c7b",
|
||||
open: false
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
import { all } from "redux-saga/effects";
|
||||
import { all, call, put, takeLatest } from "redux-saga/effects";
|
||||
import { sendMessageFailure } from "./messaging.actions";
|
||||
import MessagingActionTypes from "./messaging.types";
|
||||
import axios from "axios";
|
||||
|
||||
export function* onSendMessage() {
|
||||
yield takeLatest(MessagingActionTypes.SEND_MESSAGE, sendMessage);
|
||||
}
|
||||
export function* sendMessage(payload) {
|
||||
try {
|
||||
console.log("Message Contents", payload);
|
||||
axios.post("/sms/send", payload).then(response => {
|
||||
console.log(JSON.stringify(response));
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Error in sendMessage saga.");
|
||||
yield put(sendMessageFailure(error));
|
||||
}
|
||||
}
|
||||
|
||||
export function* messagingSagas() {
|
||||
yield all([]);
|
||||
yield all([call(onSendMessage)]);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ const MessagingActionTypes = {
|
||||
OPEN_CONVERSATION: "OPEN_CONVERSATION",
|
||||
CLOSE_CONVERSATION: "CLOSE_CONVERSATION",
|
||||
TOGGLE_CONVERSATION_VISIBLE: "TOGGLE_CONVERSATION_VISIBLE",
|
||||
SEND_MESSAGE: "SEND_MESSAGE"
|
||||
SEND_MESSAGE: "SEND_MESSAGE",
|
||||
SEND_MESSAGE_FAILURE: "SEND_MESSAGE_FAILURE"
|
||||
};
|
||||
export default MessagingActionTypes;
|
||||
|
||||
Reference in New Issue
Block a user