Create reducer "notificationsSlice"

This commit is contained in:
danidfra 2025-02-03 20:49:40 -03:00
parent 15d96e8fdf
commit 63335e9274
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
interface NotificationState {
home: boolean;
public: boolean;
instance: boolean;
}
const initialState: NotificationState = {
home: false,
public: false,
instance: false,
};
const notificationsTab = createSlice({
name: 'notificationsSlice',
initialState,
reducers: {
setNotification: (
state,
action: PayloadAction<{ timelineId: string; value: boolean }>,
) => {
if (action.payload.timelineId in state) {
state[action.payload.timelineId as keyof NotificationState] = action.payload.value;
}
},
resetNotifications: (state) => {
state.home = false;
state.public = false;
state.instance = false;
},
},
});
export const { setNotification, resetNotifications } = notificationsTab.actions;
export default notificationsTab.reducer;