This commit is contained in:
chamikaJ
2025-04-17 18:28:54 +05:30
parent f583291d8a
commit 8825b0410a
2837 changed files with 241385 additions and 127578 deletions

View File

@@ -0,0 +1,43 @@
import { AlertConfig, AlertState, AlertType } from '@/types/alert.types';
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { notification } from 'antd';
import DOMPurify from 'dompurify';
const initialState: AlertState = {
activeAlerts: new Set(),
config: {
position: 'topRight',
duration: 4.5,
maxCount: 5,
},
};
const alertSlice = createSlice({
name: 'alert',
initialState,
reducers: {
showAlert: (
state,
action: PayloadAction<{
type: AlertType;
title: string;
message: string;
duration?: number;
}>
) => {
if (!state.activeAlerts.has(action.payload.message)) {
state.activeAlerts.add(action.payload.message);
}
},
hideAlert: (state, action: PayloadAction<string>) => {
state.activeAlerts.delete(action.payload);
},
updateAlertConfig: (state, action: PayloadAction<Partial<AlertConfig>>) => {
state.config = { ...state.config, ...action.payload };
},
},
});
export const { showAlert, hideAlert, updateAlertConfig } = alertSlice.actions;
export default alertSlice.reducer;