adds conversation slice

This commit is contained in:
ajaythapliyal
2023-02-19 09:53:39 +05:30
parent a86744d9d6
commit d20b5f3e09
2 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
import { createSlice } from '@reduxjs/toolkit';
type MESSAGE_TYPE = 'QUESTION' | 'ANSWER';
interface SingleConversation {
message: string;
messageType: MESSAGE_TYPE;
}
interface ConversationState {
conversation: SingleConversation[];
}
const initialState: ConversationState = {
conversation: [],
};
export const conversationSlice = createSlice({
name: 'conversation',
initialState,
reducers: {
addMessage(state, action) {
state.conversation.push(action.payload);
},
},
});
export const { addMessage } = conversationSlice.actions;
export default conversationSlice.reducer;