Revize a7ae217f
Přidáno uživatelem Václav Honzík před asi 2 roky(ů)
frontend/src/features/Notification/notificationSlice.ts | ||
---|---|---|
1 | 1 |
import { AlertColor } from '@mui/material' |
2 |
import { createSlice } from '@reduxjs/toolkit' |
|
2 |
import { Action, createSlice } from '@reduxjs/toolkit'
|
|
3 | 3 |
|
4 | 4 |
export interface NotificationState { |
5 | 5 |
message?: string |
... | ... | |
7 | 7 |
autohideSecs?: number |
8 | 8 |
} |
9 | 9 |
|
10 |
const initialState = { |
|
10 |
const initialState: NotificationState = {
|
|
11 | 11 |
message: undefined, |
12 | 12 |
severity: 'info', |
13 | 13 |
autohideSecs: undefined |
... | ... | |
17 | 17 |
name: 'notification', |
18 | 18 |
initialState, |
19 | 19 |
reducers: { |
20 |
showNotification: (state, action) => ({
|
|
20 |
showNotification: (state: NotificationState, action: { payload: NotificationState }) => ({
|
|
21 | 21 |
...state, |
22 | 22 |
message: action.payload.message, |
23 | 23 |
severity: action.payload.severity, |
24 | 24 |
autohideSecs: action.payload.autohideSecs, |
25 | 25 |
}), |
26 | 26 |
// consumes the message so it is not displayed after the page gets refreshed |
27 |
consumeNotification: (state) => ({
|
|
27 |
consumeNotification: () => ({ |
|
28 | 28 |
...initialState, |
29 | 29 |
}), |
30 | 30 |
}, |
Také k dispozici: Unified diff
import export part 1
re #9741