Skip to content

Commit cbd8470

Browse files
committed
feat: add unit to useAggregateValue composable for improved data handling
1 parent 9ad6a27 commit cbd8470

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/core/foundation-core-services/composables/services/useAggregateValue.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const useAggregateValue = () => {
1212
const fetching = ref(false);
1313
const error = ref<string | null>(null);
1414
const value = ref<number | null>(null);
15+
const unit = ref<string | null>(null);
1516

1617
const fetch = async (filter: AggregateValueFilter) => {
1718
fetching.value = true;
@@ -62,8 +63,10 @@ export const useAggregateValue = () => {
6263
const dataSerie = await getManyDatas(periodFilters);
6364

6465
const dataSerieValue = dataSerie?.[0]?.datas?.[0]?.values?.[0];
66+
const dataSerieUnit = dataSerie?.[0]?.meta.valueUnits?.[0];;
6567

6668
value.value = dataSerieValue == null ? null : Number(dataSerieValue);
69+
unit.value = dataSerieUnit == null ? null : dataSerieUnit;
6770

6871
} catch (exception: any) {
6972
error.value = exception.response?.data ?? exception.message;
@@ -76,6 +79,7 @@ export const useAggregateValue = () => {
7679
fetching,
7780
error,
7881
value,
82+
unit,
7983
fetch,
8084
};
8185
};

0 commit comments

Comments
 (0)