1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
| import { createSlice } from '@reduxjs/toolkit';
|
| const initialState = {
| overview: {
| totalVolunteers: 0,
| totalPoints: 0,
| totalActivities: 0,
| totalRegistrations: 0,
| pointsTimeList: [],
| volTimeList: [],
| typeList: [],
| distributionList: [],
| },
| trends: {
| pointsTrend: [],
| activityTrend: [],
| registrationTrend: [],
| },
| reports: [],
| loading: false,
| error: null,
| };
|
| const statisticsSlice = createSlice({
| name: 'statistics',
| initialState,
| reducers: {
| setLoading: (state, action) => {
| state.loading = action.payload;
| },
| setError: (state, action) => {
| state.error = action.payload;
| state.loading = false;
| },
| setOverview: (state, action) => {
| state.overview = action.payload;
| state.loading = false;
| },
| setTrends: (state, action) => {
| state.trends = action.payload;
| state.loading = false;
| },
| setReports: (state, action) => {
| state.reports = action.payload;
| state.loading = false;
| },
| updateOverview: (state, action) => {
| state.overview = { ...state.overview, ...action.payload };
| },
| },
| });
|
| export const {
| setLoading,
| setError,
| setOverview,
| setTrends,
| setReports,
| updateOverview,
| } = statisticsSlice.actions;
|
| export default statisticsSlice.reducer;
|
|