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;