Replaced redux with zustand. Fixed login issue, closes #980.

This commit is contained in:
Mike Cao 2022-02-22 22:47:59 -08:00
parent 7071f5fba5
commit 9937caa569
33 changed files with 234 additions and 286 deletions

30
store/app.js Normal file
View file

@ -0,0 +1,30 @@
import create from 'zustand';
import { DEFAULT_LOCALE, DEFAULT_THEME, LOCALE_CONFIG, THEME_CONFIG } from 'lib/constants';
import { getItem } from 'lib/web';
const initialState = {
locale: getItem(LOCALE_CONFIG) || DEFAULT_LOCALE,
theme: getItem(THEME_CONFIG) || DEFAULT_THEME,
shareToken: null,
user: null,
};
const store = create(() => ({ ...initialState }));
export function setTheme(theme) {
store.setState({ theme });
}
export function setLocale(locale) {
store.setState({ locale });
}
export function setShareToken(shareToken) {
store.setState({ shareToken });
}
export function setUser(user) {
store.setState({ user });
}
export default store;