Refactored dashboard sort logic.

This commit is contained in:
Mike Cao 2022-08-04 21:37:18 -07:00
parent 42e87a4691
commit 62b032ab19
8 changed files with 32 additions and 40 deletions

View file

@ -5,15 +5,14 @@ import { getItem, setItem } from 'lib/web';
export const initialState = {
showCharts: true,
limit: DEFAULT_WEBSITE_LIMIT,
websiteOrder: {},
websiteOrder: [],
editing: false,
};
const store = create(() => ({ ...initialState, ...getItem(DASHBOARD_CONFIG) }));
export function saveDashboard(settings) {
const state = typeof settings === 'function' ? settings(store.getState()) : settings;
store.setState(state);
store.setState(settings);
setItem(DASHBOARD_CONFIG, store.getState());
}