homebox/frontend/composables/use-preferences.ts
Hayden 461be2afca
feat: currency selection support (#72)
* initial UI for currency selection

* add task to purge invitation tokens

* group API contracts

* fix type import

* use auth middleware

* add currency setting support (UI)

* use group settings for format currency

* fix casing
2022-10-15 12:15:55 -08:00

30 lines
879 B
TypeScript

import { Ref } from "vue";
import { DaisyTheme } from "~~/lib/data/themes";
export type LocationViewPreferences = {
showDetails: boolean;
showEmpty: boolean;
editorSimpleView: boolean;
theme: DaisyTheme;
};
/**
* useViewPreferences loads the view preferences from local storage and hydrates
* them. These are reactive and will update the local storage when changed.
*/
export function useViewPreferences(): Ref<LocationViewPreferences> {
const results = useLocalStorage(
"homebox/preferences/location",
{
showDetails: true,
showEmpty: true,
editorSimpleView: true,
theme: "garden",
},
{ mergeDefaults: true }
);
// casting is required because the type returned is removable, however since we
// use `mergeDefaults` the result _should_ always be present.
return results as unknown as Ref<LocationViewPreferences>;
}