CreatorCenter_OOIN/src/store/slices/notificationBarSlice.js

30 lines
691 B
JavaScript
Raw Normal View History

2025-05-24 08:16:21 +08:00
import { createSlice } from "@reduxjs/toolkit";
2025-05-23 22:27:14 +08:00
const initialState = {
message: '',
show: false,
type: 'success', // success, warning, error, info
};
const notificationBarSlice = createSlice({
name: 'notificationBar',
initialState,
reducers: {
setNotificationBarMessage: (state, action) => {
2025-05-24 08:16:21 +08:00
const { message, type } = action.payload;
state.message = message;
state.type = type;
state.show = true;
2025-05-23 22:27:14 +08:00
},
resetNotificationBar: (state) => {
state.message = '';
state.show = false;
state.type = 'success';
},
},
});
2025-05-24 08:16:21 +08:00
export const { setNotificationBarMessage, resetNotificationBar } = notificationBarSlice.actions;
2025-05-23 22:27:14 +08:00
export default notificationBarSlice.reducer;