General formatting for messaging + reshaping of messaging components and their structure.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user