umami/store/dashboard.js

21 lines
505 B
JavaScript
Raw Normal View History

2023-05-20 16:02:08 +00:00
import { create } from 'zustand';
2022-08-04 10:56:30 +00:00
import { DASHBOARD_CONFIG, DEFAULT_WEBSITE_LIMIT } from 'lib/constants';
2022-08-29 03:20:54 +00:00
import { getItem, setItem } from 'next-basics';
2022-08-04 10:56:30 +00:00
export const initialState = {
showCharts: true,
limit: DEFAULT_WEBSITE_LIMIT,
2022-08-05 04:37:18 +00:00
websiteOrder: [],
2022-08-04 10:56:30 +00:00
editing: false,
};
const store = create(() => ({ ...initialState, ...getItem(DASHBOARD_CONFIG) }));
export function saveDashboard(settings) {
2022-08-05 04:37:18 +00:00
store.setState(settings);
2022-08-04 10:56:30 +00:00
setItem(DASHBOARD_CONFIG, store.getState());
}
export default store;