mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 07:13:37 +01:00
30 lines
683 B
JavaScript
30 lines
683 B
JavaScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
const websites = createSlice({
|
|
name: 'websites',
|
|
initialState: {},
|
|
reducers: {
|
|
updateWebsites(state, action) {
|
|
state = action.payload;
|
|
return state;
|
|
},
|
|
updateWebsite(state, action) {
|
|
const { websiteId, ...data } = action.payload;
|
|
state[websiteId] = data;
|
|
return state;
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { updateWebsites, updateWebsite } = websites.actions;
|
|
|
|
export default websites.reducer;
|
|
|
|
export function setDateRange(websiteId, dateRange) {
|
|
return dispatch => {
|
|
return dispatch(
|
|
updateWebsite({ websiteId, dateRange: { ...dateRange, modified: Date.now() } }),
|
|
);
|
|
};
|
|
}
|