Open source personal finance application
refactor(Stat): update components
ilkome26541a7cb670
diff --git a/components/stat/Filter.vue b/components/stat/Filter.vueindex 48ef5cac..3788dc16 100644--- a/components/stat/Filter.vue+++ b/components/stat/Filter.vue@@ -1,37 +1,25 @@<script setup lang="ts">-import useFilter from '~/modules/filter/useFilter'-+import type { CategoryID } from '~/components/categories/types'const { $store } = useNuxtApp()-const { setFilterCatsId } = useFilter()--const filterWalletsItems = computed(() => {- let wallets = {}-- for (const walletId of $store.state.filter.walletsIds) {- const wallet = $store.state.wallets.items[walletId]- if (!wallet)- break- wallets = { ...wallets, [walletId]: wallet }- }-- return wallets-})--const filterCatsItems = computed(() => {- let cats = {}- for (const catId of $store.state.filter.catsIds) {- const cat = $store.state.categories.items[catId]- if (!cat)- break- cats = { ...cats, [catId]: cat }- }+const filterWalletsItems = computed(() =>+ $store.state.filter.walletsIds+ .reduce((acc, id) => {+ acc[id] = $store.state.wallets.items[id]+ return acc+ }, {}),+)- return cats-})+const filterCatsItems = computed(() =>+ $store.state.filter.catsIds+ .reduce((acc, id) => {+ acc[id] = $store.state.categories.items[id]+ return acc+ }, {}),+)-const onClickCategory = (catId) => {- $store.commit('filter/removeFilterCatId', catId)+const onClickCategory = (id: CategoryID) => {+ $store.commit('filter/removeFilterCatId', id)}const onClearFilter = () => {diff --git a/components/stat/History.vue b/components/stat/History.vueindex 32a8b7e0..01144843 100644--- a/components/stat/History.vue+++ b/components/stat/History.vue@@ -1,10 +1,8 @@<script setup lang="ts">import { getCatsIds } from '~/components/categories/getCategories'import { getTrnsIds } from '~/components/trns/getTrns'-import useStatPage from '~/components/stat/useStatPage'const { $store } = useNuxtApp()-const { statPage } = useStatPage()const catsItems = computed(() => $store.state.categories.items)const trnsItems = computed(() => $store.state.trns.items)const storeFilter = computed(() => $store.state.filter)diff --git a/components/stat/MobileNav.vue b/components/stat/MobileNav.vuedeleted file mode 100644index 874feaa9..00000000--- a/components/stat/MobileNav.vue+++ /dev/null@@ -1,8 +0,0 @@-<script setup lang="ts">--</script>--<template lang="pug">-.my-6- StatPeriodArrows-</template>diff --git a/components/stat/Page.vue b/components/stat/Page.vuenew file mode 100644index 00000000..136e49cf--- /dev/null+++ b/components/stat/Page.vue@@ -0,0 +1,25 @@+<script lang="ts">+import { useWindowSize } from '@vueuse/core'+export default {+ setup() {+ const { width } = useWindowSize()++ return { width }+ },++ head() {+ return {+ title: this.$t('stat.title'),+ }+ },+}+</script>++<template lang="pug">+.overflow-hidden.h-full+ template(v-if="$store.getters['trns/hasTrns']")+ LazyStatLaptopView(v-if="width >= 1024")+ LazyStatMobileView(v-else)++ LazyStatWelcomeActions(v-if="!$store.getters['trns/hasTrns']")+</template>diff --git a/components/stat/NoStatActions.vue b/components/stat/WelcomeActions.vuesimilarity index 100%rename from components/stat/NoStatActions.vuerename to components/stat/WelcomeActions.vuediff --git a/components/stat/ChartConfig.vue b/components/stat/chart/Options.vuesimilarity index 100%rename from components/stat/ChartConfig.vuerename to components/stat/chart/Options.vuediff --git a/components/stat/Periods.vue b/components/stat/chart/Periods.vuesimilarity index 100%rename from components/stat/Periods.vuerename to components/stat/chart/Periods.vuediff --git a/components/stat/ChartLines.vue b/components/stat/chart/View.vuesimilarity index 99%rename from components/stat/ChartLines.vuerename to components/stat/chart/View.vueindex a0f08b41..574e5ea8 100644--- a/components/stat/ChartLines.vue+++ b/components/stat/chart/View.vue@@ -1,6 +1,6 @@<script lang="ts">import { Chart } from 'highcharts-vue'-import chartOptions from '~/components/stat/chartOptions'+import chartOptions from '~/components/stat/chart/chartOptions'import useChart from '~/components/chart/useChart'import useFilter from '~/modules/filter/useFilter'import { getCatsIds, getTransferCategoriesIds } from '~/components/categories/getCategories'diff --git a/components/stat/Chart.vue b/components/stat/chart/Wrap.vuesimilarity index 97%rename from components/stat/Chart.vuerename to components/stat/chart/Wrap.vueindex 40d9567b..a91b73cc 100644--- a/components/stat/Chart.vue+++ b/components/stat/chart/Wrap.vue@@ -18,7 +18,7 @@ const chartType = computed(() => {<template lang="pug">.h-48(v-if="chartState.show.expense || chartState.show.income")- LazyStatChartLines(+ LazyStatChartView(:categoryId="filter.categoryId":chartType="chartType":isShowExpense="chartState.show.expense"diff --git a/components/stat/chartOptions.js b/components/stat/chart/chartOptions.jssimilarity index 100%rename from components/stat/chartOptions.jsrename to components/stat/chart/chartOptions.jsdiff --git a/components/stat/GroupItem.vue b/components/stat/group/Item.vuesimilarity index 100%rename from components/stat/GroupItem.vuerename to components/stat/group/Item.vuediff --git a/components/stat/group/Pie.vue b/components/stat/group/Pie.vueindex a8fc954e..e8b25ff6 100644--- a/components/stat/group/Pie.vue+++ b/components/stat/group/Pie.vue@@ -23,7 +23,7 @@ export default defineComponent({<template lang="pug">.my-6(v-if="isShow")- LazyStatChartPie(+ LazyStatPieChart(v-if="isShow":amountType="typeText")diff --git a/components/stat/StatChartPie.vue b/components/stat/group/PieChart.vuesimilarity index 88%rename from components/stat/StatChartPie.vuerename to components/stat/group/PieChart.vueindex 47431cb0..b297ccb1 100644--- a/components/stat/StatChartPie.vue+++ b/components/stat/group/PieChart.vue@@ -1,24 +1,13 @@<script>import { Chart } from 'highcharts-vue'-import chartOptions from '~/components/stat/chartOptions'+import chartOptions from '~/components/stat/chart/chartOptions'export default {- name: 'StatChartPie',-- components: {- Chart,- },+ components: { Chart },props: {- chartType: {- type: String,- default: 'pie',- },-- amountType: {- type: String,- default: null,- },+ chartType: { type: String, default: 'pie' },+ amountType: { type: String, default: null },},computed: {diff --git a/components/stat/MenuLaptop.vue b/components/stat/laptop/Menu.vuesimilarity index 100%rename from components/stat/MenuLaptop.vuerename to components/stat/laptop/Menu.vuediff --git a/components/stat/Laptop.vue b/components/stat/laptop/View.vuesimilarity index 97%rename from components/stat/Laptop.vuerename to components/stat/laptop/View.vueindex 029181e4..2fba3d20 100644--- a/components/stat/Laptop.vue+++ b/components/stat/laptop/View.vue@@ -68,13 +68,13 @@ onDeactivated(async () => {WalletsCurrenciesChanger.mx-2.mb-4.rounded-lg.bg-skin-item-main-bg.border.dark_border-neutral-800- LazyStatChart(+ LazyStatChartWrap(:key="chartKeyDirtyFix"v-if="ui.showMainChart && statPage.isHasTrns").sm_flex.justify-between.px-2.pb-2- StatPeriods- StatChartConfig+ StatChartPeriods+ StatChartOptions.my-4.mx-2.p-3.rounded-lg.bg-skin-item-main-active(v-if="statPage.filter.isShow")LazyStatFilter(v-if="statPage.filter.isShow")@@ -84,7 +84,7 @@ onDeactivated(async () => {StatViewConfig.pb-4.px-2- StatMenuLaptop+ StatLaptopMenutemplate(v-if="statPage.activeTab !== 'trns' && statPage.activeTab !== 'history'")//- Loop throw income / expensediff --git a/components/stat/MenuMobile.vue b/components/stat/mobile/MobileMenu.vuesimilarity index 100%rename from components/stat/MenuMobile.vuerename to components/stat/mobile/MobileMenu.vuediff --git a/components/stat/MobileSlide.vue b/components/stat/mobile/Slide.vuesimilarity index 90%rename from components/stat/MobileSlide.vuerename to components/stat/mobile/Slide.vueindex c05bc8f2..2cd186dd 100644--- a/components/stat/MobileSlide.vue+++ b/components/stat/mobile/Slide.vue@@ -13,5 +13,5 @@ const { statPage } = useStatPage()slot.my-6- StatMobileNav(:slider="sliderObject")+ StatPeriodArrows</template>diff --git a/components/stat/Mobile.vue b/components/stat/mobile/View.vuesimilarity index 96%rename from components/stat/Mobile.vuerename to components/stat/mobile/View.vueindex fc152465..cd8de16d 100644--- a/components/stat/Mobile.vue+++ b/components/stat/mobile/View.vue@@ -64,25 +64,25 @@ onDeactivated(async () => {)| {{ $store.state.currencies.base }}- StatMenuMobile(:slider="sliderObject")+ StatMobileMenu(:slider="sliderObject").swiper-container.overflow-hidden.h-full(ref="sliderRef").swiper-wrapper//- SummaryStatMobileSlide.my-4.px-2- StatSumTotalStatSumGroup(typeText="income")StatSumGroup(typeText="expense")+ StatSumTotal.my-6.mx-2.rounded-lg.bg-skin-item-main-bg.border.dark_border-neutral-800- LazyStatChart(+ LazyStatChartWrap(:key="chartKeyDirtyFix"v-if="ui.showMainChart && statPage.isHasTrns").sm_flex.justify-between.px-2.pb-2- StatPeriods- StatChartConfig+ StatChartPeriods+ StatChartOptions//- ExpenseStatMobileSlidediff --git a/components/stat/SummaryRowItemView.vue b/components/stat/sum/Average.vuesimilarity index 100%rename from components/stat/SummaryRowItemView.vuerename to components/stat/sum/Average.vuediff --git a/components/stat/sum/Group.vue b/components/stat/sum/Group.vueindex 6e0108bb..736599cb 100644--- a/components/stat/sum/Group.vue+++ b/components/stat/sum/Group.vue@@ -27,7 +27,7 @@ const typeNumber = computed(() => moneyTypes.find(t => t.id === `${props.typeTex)//- Average- LazyStatSummaryRowItemView(+ LazyStatSumAverage(v-if="statPage.average[typeText] !== 0":amount="statPage.average[typeText]":title="$t(`money.average.${typeText}`)"diff --git a/components/stat/sum/Total.vue b/components/stat/sum/Total.vueindex cfed2772..19745500 100644--- a/components/stat/sum/Total.vue+++ b/components/stat/sum/Total.vue@@ -10,7 +10,7 @@ const statAverage = computed(() => $store.getters['stat/statAverage']).overflow-hidden.overflow-x-auto.scrollbar.flex.items-center//- Total- .pr-6.text-4xl+ .pr-6.text-3xlAmount(:amount="statCurrentPeriod.income.total - statCurrentPeriod.expense.total":colorize="(statCurrentPeriod.income.total - statCurrentPeriod.expense.total) > 0 ? 'income' : 'expense'"@@ -20,7 +20,7 @@ const statAverage = computed(() => $store.getters['stat/statAverage']):type="(statCurrentPeriod.income.total - statCurrentPeriod.expense.total) > 0 ? 1 : 0")- LazyStatSummaryRowItemView(+ LazyStatSumAverage(v-if="statAverage.sum !== 0":type="statAverage.sum > 0 ? 1 : 0":amount="statAverage.sum"diff --git a/pages/dashboard.vue b/pages/dashboard.vueindex 1f267550..fc0d2b95 100644--- a/pages/dashboard.vue+++ b/pages/dashboard.vue@@ -1,25 +1,3 @@-<script lang="ts">-import { useWindowSize } from '@vueuse/core'-export default {- setup() {- const { width } = useWindowSize()-- return { width }- },-- head() {- return {- title: this.$t('stat.title'),- }- },-}-</script>-<template lang="pug">-.overflow-hidden.h-full- template(v-if="$store.getters['trns/hasTrns']")- LazyStatLaptop(v-if="width >= 1024")- LazyStatMobile(v-else)-- LazyStatNoStatActions(v-if="!$store.getters['trns/hasTrns']")+StatPage</template>