mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
adds conversation slice
This commit is contained in:
29
frontend/src/conversation/conversationSlice.ts
Normal file
29
frontend/src/conversation/conversationSlice.ts
Normal 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;
|
||||
Reference in New Issue
Block a user