reorganize components and add root import plugin

This commit is contained in:
Danny Avila 2023-02-07 10:26:19 -05:00
parent faf8800e67
commit 9d41ed4615
27 changed files with 76 additions and 27 deletions

24
src/store/convoSlice.js Normal file
View file

@ -0,0 +1,24 @@
import { createSlice } from '@reduxjs/toolkit';
const initialState = {
active: false,
conversationId: null,
parentMessageId: null,
};
const currentSlice = createSlice({
name: 'convo',
initialState,
reducers: {
setConversation: (state, action) => {
const { conversationId, parentMessageId } = action.payload;
state.conversationId = conversationId;
state.parentMessageId = parentMessageId;
},
}
});
//
export const { setConversation } = currentSlice.actions;
export default currentSlice.reducer;

11
src/store/index.js Normal file
View file

@ -0,0 +1,11 @@
import { configureStore } from '@reduxjs/toolkit';
import convoReducer from './convoSlice.js';
import messageReducer from './messageSlice.js'
export const store = configureStore({
reducer: {
convo: convoReducer,
messages: messageReducer,
},
});

18
src/store/messageSlice.js Normal file
View file

@ -0,0 +1,18 @@
import { createSlice } from '@reduxjs/toolkit';
const initialState = [];
const currentSlice = createSlice({
name: 'messages',
initialState,
reducers: {
setMessages: (state, action) => {
const { payload } = action;
return [...payload];
},
}
});
export const { setMessages } = currentSlice.actions;
export default currentSlice.reducer;