mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 04:15:35 +00:00
adds conversation slice
This commit is contained in:
1 parent
a86744d9d6
commit
d20b5f3e09
2 files changed
+31
-2
No files matched your search
@@ -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;
|
||||
@@ -1,11 +1,11 @@
|
||||
// import { configureStore, createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import { conversationSlice } from './conversation/conversationSlice';
|
||||
import { prefSlice } from './preferences/preferenceSlice';
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
preference: prefSlice.reducer,
|
||||
conversation: conversationSlice.reducer,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user