feat(history): add energy price history feature
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { create } from 'axios';
|
||||
import { ref } from 'vue';
|
||||
import HistoryData = App.Features.History.Data.HistoryData;
|
||||
|
||||
export default function useHistoryViewModel() {
|
||||
const isLoading = ref<boolean>(false);
|
||||
const historyData = ref<HistoryData>();
|
||||
|
||||
function getHistoryData(date: string) {
|
||||
isLoading.value = true;
|
||||
|
||||
const client = create();
|
||||
client
|
||||
.get<HistoryData>('/api/history', {
|
||||
params: {
|
||||
date,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
historyData.value = res.data;
|
||||
})
|
||||
.finally(() => (isLoading.value = false));
|
||||
}
|
||||
|
||||
return { isLoading, historyData, getHistoryData };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user