Open source personal finance application
refactor: move filter components to stat folder
Ilya Komichev6f3f8354cc10
diff --git a/app/components/categories/StatPage.vue b/app/components/categories/StatPage.vueindex ee90e63e..88d238ea 100644--- a/app/components/categories/StatPage.vue+++ b/app/components/categories/StatPage.vue@@ -6,7 +6,7 @@ import type { StatTabSlug } from '~/components/stat/types'import { useCategoriesStore } from '~/components/categories/useCategoriesStore'import { useStatDate } from '~/components/date/useStatDate'-import { useFilter } from '~/components/filter/useFilter'+import { useFilter } from '~/components/stat/filter/useFilter'import { useStatConfig } from '~/components/stat/useStatConfig'import { getTypesMapping } from '~/components/stat/utils'import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'diff --git a/app/components/categories/page/id/Index.vue b/app/components/categories/page/id/Index.vueindex 4144f76f..1109597c 100644--- a/app/components/categories/page/id/Index.vue+++ b/app/components/categories/page/id/Index.vue@@ -9,7 +9,7 @@ import { errorEmo, random, successEmo } from '~/assets/js/emo'import { useCategoriesStore } from '~/components/categories/useCategoriesStore'import { useStatDate } from '~/components/date/useStatDate'import { calculateBestIntervalsBy } from '~/components/date/utils'-import { useFilter } from '~/components/filter/useFilter'+import { useFilter } from '~/components/stat/filter/useFilter'import { useStatConfig } from '~/components/stat/useStatConfig'import { getTypesMapping } from '~/components/stat/utils'import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'diff --git a/app/components/date/useDateFormats.ts b/app/components/date/useDateFormats.tsindex d207dd20..9b3bb2b3 100644--- a/app/components/date/useDateFormats.ts+++ b/app/components/date/useDateFormats.ts@@ -1,6 +1,6 @@import { differenceInDays } from 'date-fns'-import type { PeriodNameWithAll } from '~/components/filter/types'+import type { PeriodNameWithAll } from '~/components/stat/filter/types'import { formatByLocale, getEndOf, getStartOf } from '~/components/date/utils'import { useGetDateRange } from '~/components/stat/date/useGetDateRange'diff --git a/app/components/stat/Average.vue b/app/components/stat/Average.vueindex 6c26402d..2a703143 100644--- a/app/components/stat/Average.vue+++ b/app/components/stat/Average.vue@@ -4,7 +4,7 @@ import { sub } from 'date-fns'import type { CategoryId } from '~/components/categories/types'import type { Range, StatDateProvider } from '~/components/date/types'-import type { FilterProvider } from '~/components/filter/types'+import type { FilterProvider } from '~/components/stat/filter/types'import type { SeriesSlugSelected } from '~/components/stat/types'import type { TrnId } from '~/components/trns/types'import type { WalletId } from '~/components/wallets/types'diff --git a/app/components/stat/Dashboard.vue b/app/components/stat/Dashboard.vueindex f64d602b..7a669f33 100644--- a/app/components/stat/Dashboard.vue+++ b/app/components/stat/Dashboard.vue@@ -6,7 +6,7 @@ import type { StatTabSlug } from '~/components/stat/types'import type { WalletId } from '~/components/wallets/types'import { useStatDate } from '~/components/date/useStatDate'-import { useFilter } from '~/components/filter/useFilter'+import { useFilter } from '~/components/stat/filter/useFilter'import { useStatConfig } from '~/components/stat/useStatConfig'import { useTrnsStore } from '~/components/trns/useTrnsStore'diff --git a/app/components/stat/Header.vue b/app/components/stat/Header.vueindex d22cab96..21e2a44f 100644--- a/app/components/stat/Header.vue+++ b/app/components/stat/Header.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import type { FilterProvider } from '~/components/filter/types'+import type { FilterProvider } from '~/components/stat/filter/types'import type { StatConfigModal, StatTabSlug } from '~/components/stat/types'import type { StatConfigProvider } from '~/components/stat/useStatConfig'import type { WalletId } from '~/components/wallets/types'@@ -58,7 +58,7 @@ const statConfigModal: Ref<StatConfigModal> = ref({v-if="props.filter || props.config"class="ml-auto flex items-center gap-1">- <FilterSelector+ <StatFilterSelectorv-if="props.filter":isShowCategories="!!props.filter.isShowCategories":isShowWallets="!!props.filter.isShowWallets"diff --git a/app/components/stat/Item.vue b/app/components/stat/Item.vueindex c5b6e3cf..de98a123 100644--- a/app/components/stat/Item.vue+++ b/app/components/stat/Item.vue@@ -4,7 +4,7 @@ import { differenceInDays, differenceInMonths, differenceInWeeks } from 'date-fnimport type { CategoryId } from '~/components/categories/types'import type { Range, StatDateProvider } from '~/components/date/types'-import type { FilterProvider } from '~/components/filter/types'+import type { FilterProvider } from '~/components/stat/filter/types'import type { ChartSeries, IntervalData, SeriesSlugSelected, StatTabSlug } from '~/components/stat/types'import type { StatConfigProvider } from '~/components/stat/useStatConfig'import type { TrnId } from '~/components/trns/types'@@ -244,32 +244,38 @@ function getIntervalsData(trnsIds: TrnId[], intervalsInRange: Range[]) {<div class="@container/stat"><StatChartWrapv-if="!props.isOneCategory || (props.isOneCategory && !categoriesStore.transferCategoriesIds.includes(categoryId))"- class="pb-3":chartView="statConfig.config.value.chartView":series="chart.series.value":xAxisLabels="chart.xAxisLabels.value"+ class="pb-3"><StatDateQuick v-if="statConfig.config.value.date.isShowQuick" /></StatChartWrap><div class="grid content-start gap-3">- <StatDateNavigation />+ <StatDateNavigation>+ <StatFilterSelected+ v-if="filter.isShow?.value && filter.categoriesIds.value.length > 0 || filter.walletsIds.value.length > 0"+ isShowCategories+ isShowWallets+ />+ </StatDateNavigation><StatSumWrapv-if="!props.isOneCategory || (props.isOneCategory && !categoriesStore.transferCategoriesIds.includes(categoryId))"+ :averageConfig="statConfig.config.value.statAverage.count":averageTotal- :isShowExpense="statTypeShow.expense"- :isShowIncome="statTypeShow.income"- :filteredType="filteredType"- :total="rangeTotal"- :type="selectedType3":categoryId:filter+ :filteredType="filteredType"+ :isShowAverage="statConfig.config.value.statAverage.isShow"+ :isShowExpense="statTypeShow.expense"+ :isShowIncome="statTypeShow.income":statDate+ :total="rangeTotal":trnsIds+ :type="selectedType3":walletId- :averageConfig="statConfig.config.value.statAverage.count"- :isShowAverage="statConfig.config.value.statAverage.isShow"@click="onClickSumItem"@clickAverage="statConfig.updateConfig('statAverage', { isShow: !statConfig.config.value.statAverage.isShow })"/>@@ -277,10 +283,10 @@ function getIntervalsData(trnsIds: TrnId[], intervalsInRange: Range[]) {<div class="_min-h-dvh grid content-start items-start gap-4"><StatCategoriesSectionv-if="statConfig.config.value.catsRound.isShow && (props.hasChildren || (props.preCategoriesIds ?? []).length > 0)"+ :filteredCategoriesIds:isOneCategory="props.isOneCategory":preCategoriesIds="props.preCategoriesIds || categoriesStore.favoriteCategoriesIds":selectedTrnsIds- :filteredCategoriesIds@clickCategory="onClickCategory"@onSetCategoryFilter="onSetCategoryFilter"/>diff --git a/app/components/stat/chart/View.vue b/app/components/stat/chart/View.vueindex 997f3fd9..9d9fca39 100644--- a/app/components/stat/chart/View.vue+++ b/app/components/stat/chart/View.vue@@ -7,7 +7,7 @@ import { SVGRenderer } from 'echarts/renderers'import VChart from 'vue-echarts'import type { Period } from '~/components/date/types'-import type { PeriodNameWithAll } from '~/components/filter/types'+import type { PeriodNameWithAll } from '~/components/stat/filter/types'import type { ChartType } from '~/components/stat/chart/types'import { formatByLocale } from '~/components/date/utils'diff --git a/app/components/stat/date/Navigation.vue b/app/components/stat/date/Navigation.vueindex 9780fdaa..5571052b 100644--- a/app/components/stat/date/Navigation.vue+++ b/app/components/stat/date/Navigation.vue@@ -2,7 +2,7 @@import { sub } from 'date-fns'import type { StatDateProvider } from '~/components/date/types'-import type { FilterProvider } from '~/components/filter/types'+import type { FilterProvider } from '~/components/stat/filter/types'import { getEndOf, getStartOf } from '~/components/date/utils'@@ -96,10 +96,6 @@ function changeDate(way: 'next' | 'prev' | 'today') {</template></BottomSheetOrDropdown>- <FilterSelected- v-if="filter.isShow?.value && filter.categoriesIds.value.length > 0 || filter.walletsIds.value.length > 0"- isShowCategories- isShowWallets- />+ <slot /></div></template>diff --git a/app/components/filter/Selected.vue b/app/components/stat/filter/Selected.vuesimilarity index 95%rename from app/components/filter/Selected.vuerename to app/components/stat/filter/Selected.vueindex 1c54d291..f5154659 100644--- a/app/components/filter/Selected.vue+++ b/app/components/stat/filter/Selected.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import type { FilterProvider } from '~/components/filter/types'+import type { FilterProvider } from '~/components/stat/filter/types'import { useCategoriesStore } from '~/components/categories/useCategoriesStore'import { getStyles } from '~/components/ui/getStyles'diff --git a/app/components/filter/Selector.vue b/app/components/stat/filter/Selector.vuesimilarity index 97%rename from app/components/filter/Selector.vuerename to app/components/stat/filter/Selector.vueindex 9d2877f3..e2d829b3 100644--- a/app/components/filter/Selector.vue+++ b/app/components/stat/filter/Selector.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import type { FilterProvider } from '~/components/filter/types'+import type { FilterProvider } from '~/components/stat/filter/types'const props = defineProps<{isShowCategories?: booleandiff --git a/app/components/filter/types.ts b/app/components/stat/filter/types.tssimilarity index 82%rename from app/components/filter/types.tsrename to app/components/stat/filter/types.tsindex 39a5946f..a6bbbb11 100644--- a/app/components/filter/types.ts+++ b/app/components/stat/filter/types.ts@@ -1,4 +1,4 @@-import type { useFilter } from '~/components/filter/useFilter'+import type { useFilter } from '~/components/stat/filter/useFilter'export type PeriodSchema = {date: numberdiff --git a/app/components/filter/useFilter.ts b/app/components/stat/filter/useFilter.tssimilarity index 100%rename from app/components/filter/useFilter.tsrename to app/components/stat/filter/useFilter.tsdiff --git a/app/components/stat/sum/Wrap.vue b/app/components/stat/sum/Wrap.vueindex 1486e35a..b8d0b489 100644--- a/app/components/stat/sum/Wrap.vue+++ b/app/components/stat/sum/Wrap.vue@@ -4,7 +4,7 @@ import { cn } from '~~/lib/cn'import type { TotalReturns } from '~/components/amount/getTotal'import type { CategoryId } from '~/components/categories/types'import type { StatDateProvider } from '~/components/date/types'-import type { FilterProvider } from '~/components/filter/types'+import type { FilterProvider } from '~/components/stat/filter/types'import type { SeriesSlugSelected, StatTabSlug } from '~/components/stat/types'import type { StatConfigProvider } from '~/components/stat/useStatConfig'import type { TrnId } from '~/components/trns/types'diff --git a/app/components/trns/pages/History.vue b/app/components/trns/pages/History.vueindex ee6c2585..995388b8 100644--- a/app/components/trns/pages/History.vue+++ b/app/components/trns/pages/History.vue@@ -4,7 +4,7 @@ import { useStorage } from '@vueuse/core'import type { CategoryId } from '~/components/categories/types'import type { WalletId } from '~/components/wallets/types'-import { useFilter } from '~/components/filter/useFilter'+import { useFilter } from '~/components/stat/filter/useFilter'import { useTrnsStore } from '~/components/trns/useTrnsStore'const { t } = useI18n()@@ -49,7 +49,7 @@ watch([filter.categoriesIds, filter.walletsIds], () => {<UiHeader><UiHeaderTitle>{{ t("trns.history") }}</UiHeaderTitle><template #actions>- <FilterSelector+ <StatFilterSelectorclass="flex gap-1"isShowCategoriesisShowWallets@@ -57,7 +57,7 @@ watch([filter.categoriesIds, filter.walletsIds], () => {</template><template v-if="filter.isShow.value" #selected>- <FilterSelected+ <StatFilterSelectedclass="pb-2"isShowCategoriesisShowWallets@@ -65,7 +65,7 @@ watch([filter.categoriesIds, filter.walletsIds], () => {</template></UiHeader>- <div class="pageWrapper mb-4 rounded-xl bg-default pb-4 pt-1">+ <div class="pageWrapper bg-default mb-4 rounded-xl pt-1 pb-4"><div class="grid gap-3 @3xl/main:max-w-md"><TrnsList:trnsIdsdiff --git a/app/components/wallets/page/id/Index.vue b/app/components/wallets/page/id/Index.vueindex 5a2dd54a..f80f211f 100644--- a/app/components/wallets/page/id/Index.vue+++ b/app/components/wallets/page/id/Index.vue@@ -7,7 +7,7 @@ import type { WalletId } from '~/components/wallets/types'import { random, successEmo } from '~/assets/js/emo'import { useStatDate } from '~/components/date/useStatDate'-import { useFilter } from '~/components/filter/useFilter'+import { useFilter } from '~/components/stat/filter/useFilter'import { useStatConfig } from '~/components/stat/useStatConfig'import { getTypesMapping } from '~/components/stat/utils'import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'