mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Moved code into src folder. Added build for component library.
This commit is contained in:
parent
7a7233ead4
commit
ede658771e
490 changed files with 749 additions and 442 deletions
47
src/store/app.js
Normal file
47
src/store/app.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { create } from 'zustand';
|
||||
import {
|
||||
DATE_RANGE_CONFIG,
|
||||
DEFAULT_DATE_RANGE,
|
||||
DEFAULT_LOCALE,
|
||||
DEFAULT_THEME,
|
||||
LOCALE_CONFIG,
|
||||
THEME_CONFIG,
|
||||
} from 'lib/constants';
|
||||
import { getItem } from 'next-basics';
|
||||
|
||||
const initialState = {
|
||||
locale: getItem(LOCALE_CONFIG) || DEFAULT_LOCALE,
|
||||
theme: getItem(THEME_CONFIG) || DEFAULT_THEME,
|
||||
dateRange: getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE,
|
||||
shareToken: null,
|
||||
user: null,
|
||||
config: 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 function setConfig(config) {
|
||||
store.setState({ config });
|
||||
}
|
||||
|
||||
export function setDateRange(dateRange) {
|
||||
store.setState({ dateRange });
|
||||
}
|
||||
|
||||
export default store;
|
||||
Loading…
Add table
Add a link
Reference in a new issue