diff --git a/src/app/components/Header/ChartToggle.vue b/src/app/components/Header/ChartToggle.vue
index ad69d8d0..9ebb8be1 100644
--- a/src/app/components/Header/ChartToggle.vue
+++ b/src/app/components/Header/ChartToggle.vue
@@ -1,6 +1,6 @@
{
const sortClient = ref(true); // Sort clients by name, true = asc, false = desc
- const uiShowCharts = ref(getItem('uiShowCharts') === '1');
+ const uiShowCharts = useCookie('uiShowCharts', {
+ default: () => false,
+ maxAge: 365 * 24 * 60 * 60,
+ });
function toggleCharts() {
- setItem('uiShowCharts', uiShowCharts.value ? '1' : '0');
+ uiShowCharts.value = !uiShowCharts.value;
}
- const uiChartType = ref(getItem('uiChartType') ?? 'area');
+ const uiChartType = useCookie<'area' | 'bar' | 'line'>('uiChartType', {
+ default: () => 'area',
+ maxAge: 365 * 24 * 60 * 60,
+ });
return {
sortClient,
diff --git a/src/app/utils/localStorage.ts b/src/app/utils/localStorage.ts
deleted file mode 100644
index abe5f4cc..00000000
--- a/src/app/utils/localStorage.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-export type LocalStorage = {
- uiShowCharts: '1' | '0';
- uiChartType: 'area' | 'bar' | 'line';
-};
-
-export function getItem(
- item: K
-): LocalStorage[K] | null {
- if (import.meta.client) {
- return localStorage.getItem(item) as LocalStorage[K] | null;
- } else {
- return null;
- }
-}
-
-export function setItem(
- item: K,
- value: LocalStorage[K]
-) {
- if (import.meta.client) {
- localStorage.setItem(item, value);
-
- return true;
- } else {
- return false;
- }
-}