feat(dashboard): add price history, caching, and i18n
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import useDashboardViewModel from '../viewmodels/DashboardViewModel';
|
||||
|
||||
<template></template>
|
||||
const model = useDashboardViewModel();
|
||||
|
||||
onMounted(() => {
|
||||
model.getDashboardData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>{{ model.isLoading }}</div>
|
||||
<div>{{ model.dashboardData }}</div>
|
||||
</template>
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
export default function DashboardViewModel() {
|
||||
return {};
|
||||
import { create } from 'axios';
|
||||
import { ref } from 'vue';
|
||||
import DashboardData = App.Features.Dashboard.Data.DashboardData;
|
||||
|
||||
export default function useDashboardViewModel() {
|
||||
const isLoading = ref<boolean>(false);
|
||||
const dashboardData = ref<DashboardData>();
|
||||
|
||||
function getDashboardData() {
|
||||
isLoading.value = true;
|
||||
|
||||
const client = create();
|
||||
client
|
||||
.get<DashboardData>('/api/energy-prices')
|
||||
.then((res) => {
|
||||
dashboardData.value = res.data;
|
||||
})
|
||||
.finally(() => (isLoading.value = false));
|
||||
}
|
||||
|
||||
return { isLoading, dashboardData, getDashboardData };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user