General formatting for messaging + reshaping of messaging components and their structure.

This commit is contained in:
Patrick Fic
2020-02-21 13:20:41 -08:00
parent 9b39f28ced
commit 0639131936
17 changed files with 273 additions and 107 deletions

View File

@@ -1,7 +1,11 @@
import MessagingActionTypes from "./messaging.types";
const INITIAL_STATE = {
visible: false
visible: false,
conversations: [
{ id: 1, phone: "6049992002", open: false },
{ id: 2, phone: "6049992991", open: false }
]
};
const messagingReducer = (state = INITIAL_STATE, action) => {
@@ -16,6 +20,23 @@ const messagingReducer = (state = INITIAL_STATE, action) => {
...state,
visible: true
};
case MessagingActionTypes.OPEN_CONVERSATION:
return {
...state,
conversations: [...state.conversations, action.payload]
};
case MessagingActionTypes.CLOSE_CONVERSATION:
return {
...state,
conversations: state.conversations.filter(c => c !== action.paylod)
};
case MessagingActionTypes.TOGGLE_CONVERSATION_VISIBLE:
return {
...state,
conversations: state.conversations.map(c =>
c.id === action.payload ? { ...c, open: !c.open } : c
)
};
default:
return state;
}