Skip to content

Open source personal finance application

feat(Amount): refactor

ilkomeacb8c6051f56
diff --git a/components/amount/Amount.vue b/components/amount/Amount.vue
index 86eed4a0..102298ba 100644
--- a/components/amount/Amount.vue
+++ b/components/amount/Amount.vue
@@ -1,232 +1,64 @@
-<script>
+<script setup lang="ts">
import useAmount from '~/components/amount/useAmount'
-export default {
- props: {
- currency: { type: String, required: true },
- isAltColor: { type: Boolean, default: false },
- isColorize: { type: Boolean, default: true },
- isShowPrefix: { type: Boolean, default: false },
- showBase: { type: Boolean, default: true },
- size: { type: String, default: null },
- type: { type: Number, default: null },
- value: { type: Number, required: true },
- vertical: { type: String, default: null },
- },
-
- setup() {
- const { getAmountInBaseCurrency, formatAmount } = useAmount()
- return {
- getAmountInBaseCurrency,
- formatAmount,
- }
- },
-
- computed: {
- className() {
- return {
- _altColor: this.isAltColor,
- _expenses: this.isColorize && this.type === 0,
- _incomes: this.isColorize && this.type === 1,
- [`_${this.vertical}`]: this.vertical,
- [`_size_${this.size}`]: this.size,
- }
- },
-
- amountInBaseCurrency() {
- return this.getAmountInBaseCurrency({
- amount: this.value,
- currency: this.currency,
- })
- },
- },
-
- methods: {
- getCurrencySymbol(currency) {
- switch (currency) {
- case 'USD':
- return '$'
- case 'RUB':
- return '₽'
- case 'EUR':
- return '€'
- case 'IDR':
- return 'Rp'
- case 'THB':
- return '฿'
- default:
- return currency
- }
- },
- },
-}
+const props = withDefaults(defineProps<{
+ amount: number
+ currency: string
+ colorize: string
+ type: number
+ align: string
+ isShowBaseRate?: boolean
+ isShowSign?: boolean
+}>(), {
+ isShowBaseRate: true,
+ isShowSign: true,
+})
+
+const { baseCurrency, formatAmount, getCurrencySymbol, getAmountInBaseCurrency } = useAmount()
+const sign = props.type === 0 ? '-' : '+'
+
+const alignClasses = computed(() => ({
+ 'justify-end': !props.align,
+ 'justify-start': props.align === 'left',
+ 'justify-center': props.align === 'center',
+}))
+
+const amountClasses = computed(() => ([{
+ 'text-income': props.colorize === 'income' && props.type === 1,
+}, {
+ 'text-expense': props.colorize === 'expense' && props.type === 0,
+}]))
</script>
<template lang="pug">
-.amount(:class="className")
- .amountItem._original.flex.items-baseline.whitespace-nowrap(:class="className")
- .amountItem__prefix(v-if="isShowPrefix && value !== 0") {{ type === 0 ? '-' : '+' }}
- .amountItem__value.leading-none {{ formatAmount(value) }}
- .amountItem__symbol.leading-none {{ getCurrencySymbol(currency) }}
-
- template(v-if="showBase && (value !== 0) && (currency !== $store.state.currencies.base)")
- .amountItem._base.pt-1.flex.items-baseline.whitespace-nowrap(:class="className")
- .amountItem__prefix(v-if="isShowPrefix && value !== 0") {{ type === 0 ? '-' : '+' }}
- .amountItem__value.leading-none {{ amountInBaseCurrency }}
- .amountItem__symbol.leading-none {{ getCurrencySymbol($store.state.currencies.base) }}
+.font-unica.gap-1.flex.flex-col(
+ @click="event => $emit('click', event)"
+)
+ //- Amount
+ template(v-if="amount !== 0")
+ div(:class="amountClasses")
+ //- Original
+ .gap-1.flex.items-baseline.whitespace-nowrap(
+ :class="alignClasses"
+ )
+ .text-md.leading-none(v-if="isShowSign && sign === '-'") {{ sign }}
+ .text-md.leading-none {{ formatAmount(amount) }}
+ .text-xs.leading-none {{ getCurrencySymbol(currency) }}
+
+ //- Base
+ .text-neutral-400.gap-1.flex.items-baseline.whitespace-nowrap.opacity-80(
+ v-if="isShowBaseRate && currency !== baseCurrency"
+ :class="alignClasses"
+ )
+ .text-xs.leading-none(v-if="isShowSign && sign === '-'") {{ sign }}
+ .text-xs.leading-none {{ getAmountInBaseCurrency({ amount, currency }) }}
+ .text-2xs.leading-none {{ getCurrencySymbol(baseCurrency) }}
+
+ //- 0
+ template(v-if="amount === 0")
+ .gap-1.flex.items-baseline.whitespace-nowrap(
+ :class="alignClasses"
+ )
+ .text-md.leading-none.flex.items-baseline 0
+ .text-xs.leading-none {{ getCurrencySymbol(currency) }}
</template>
-
-<style lang="stylus" scoped>
-.amount
- color var(--c-font-2)
- typo-money()
-
- &._altColor
- /.light &
- color var(--c-font-1)
-
- &._incomes
- color var(--c-incomes-1)
-
- &._expenses
- color var(--c-expenses-1)
-
- @media $media-laptop
- font-size 16px
-
- &._big
- font-size 20px
- font-weight 600
-
- &._small
- font-size 14px
- font-weight 600
-
- &__wrap
- display flex
- flex-flow row nowrap
- align-items flex-end
- justify-content flex-end
-
- ^[0]._center &
- justify-content center
-
- &__price
- &:first-child
- margin-right $m3
-
- &:last-child
- margin-left $m3
-
- &__symbol
- font-primary()
- font-size 14px
- font-weight normal
-
- ^[0]._small &
- font-size 11px
-
-.amountItem
- display flex
- justify-content flex-end
-
- &._left
- justify-content flex-start
-
- &._center
- justify-content center
-
- &._original
- font-size 16px
-
- &._base
- opacity .6
-
- &._base._size_xl
- padding-top 4px
-
- &._base._size_md
- padding-top 3px
-
- &__prefix
- align-self center
- padding-right $m2
- font-weight 400
-
- ~/._size_xl &
- padding-top 2px
- padding-right $m4
- font-size 26px
-
- ~/._base &
- font-size 12px
-
- ~/._base._size_xl &
- padding-top 1px
-
- ~/._base._size_md &
- padding-top 2px
-
- &__value
- font-secondary()
- font-size 16px
- font-weight 400
-
- ~/._base &
- font-size 12px
-
- ~/._size_md &
- font-size 16px
- font-weight 500
-
- ~/._size_xl &
- font-size 36px
- font-weight 500
-
- ~/._size_xl._base &
- padding-top 0
- font-size 18px
-
- ~/._size_md._base &
- padding-top 0
- font-size 14px
-
- &__symbol
- padding-bottom 0px
- padding-left 2px
- font-weight 400
-
- ~/._original &
- font-size 11px
-
- ~/._base &
- font-size 10px
-
- ~/._size_lg &
- padding-bottom 3px
-
- ~/._size_xl &
- padding-bottom 5px
- font-size 18px
- font-weight 300
-
- ~/._size_xl._base &
- padding-bottom 2px
- font-size 12px
-
- ~/._size_md._base &
- padding-bottom 1px
- font-size 10px
-
-.amount._size_lg
- .amountItem__value
- font-size 22px
- font-weight 500
-
- .amountItem__symbol
- font-size 16px
-
-.amount._size_md
- .amountItem__symbol
- font-size 12px
-</style>
diff --git a/components/amount/Amount2.vue b/components/amount/Amount2.vue
deleted file mode 100644
index ec851433..00000000
--- a/components/amount/Amount2.vue
+++ /dev/null
@@ -1,48 +0,0 @@
-<script setup lang="ts">
-import useAmount from '~/components/amount/useAmount'
-
-const props = defineProps<{
- amount: Number
- currency: String
- colorize: String
- type: Number
- align: String
-}>()
-
-const { baseCurrency, formatAmount, getCurrencySymbol, getAmountInBaseCurrency } = useAmount()
-const sign = props.type === 0 ? '-' : '+'
-
-const classes = computed(() => ({
- 'justify-end': !props.align,
- 'justify-start': props.align === 'left',
-}))
-</script>
-
-<template lang="pug">
-.font-unica.gap-1.flex.flex-col(
- @click="event => $emit('click', event)"
-)
- //- Amount
- template(v-if="amount !== 0")
- div(:class="[{ 'text-green-600 dark_text-green-500': colorize === 'incomes' && type === 1 }]")
- //- Original
- .gap-1.flex.items-baseline.whitespace-nowrap(
- :class="classes"
- )
- .text-md.leading-none {{ sign }}
- .text-md.leading-none {{ formatAmount(amount) }}
- .text-xs.leading-none {{ getCurrencySymbol(currency) }}
-
- //- Base
- .text-neutral-400.gap-1.flex.items-baseline.whitespace-nowrap(
- v-if="currency !== baseCurrency"
- :class="classes"
- )
- .text-md.leading-none {{ sign }}
- .text-md.leading-none {{ getAmountInBaseCurrency({ amount, currency }) }}
- .text-xs.leading-none {{ getCurrencySymbol(baseCurrency) }}
-
- //- 0
- template(v-if="amount === 0")
- .text-md.leading-none.flex.items-baseline 0
-</template>
diff --git a/components/amount/useAmount.ts b/components/amount/useAmount.ts
index 4ab442cc..cfab2a81 100644
--- a/components/amount/useAmount.ts
+++ b/components/amount/useAmount.ts
@@ -29,7 +29,11 @@ const formatAmount = (value, separator = ' ', precision = 2) =>
export default function useAmount() {
const { $store } = useNuxtApp()
- function getAmountInBaseCurrency({ amount, currency, noFormat }) {
+ function getAmountInBaseCurrency({ amount, currency, noFormat }: {
+ amount: number
+ currency: string // TODO: add typings
+ noFormat?: boolean
+ }) {
const rates = $store.state.currencies.rates
const baseRate = $store.state.currencies.base
@@ -41,7 +45,7 @@ export default function useAmount() {
})
if (noFormat)
- return amountInBaseRate
+ return +amountInBaseRate
return formatAmount(amountInBaseRate)
}
diff --git a/components/layout/Sidebar.vue b/components/layout/Sidebar.vue
index 17b79d91..2c48728f 100644
--- a/components/layout/Sidebar.vue
+++ b/components/layout/Sidebar.vue
@@ -31,8 +31,6 @@ function setWalletFilter(walletId: WalletID) {
LayoutSidebarMenu
.pb-12
- WalletsTotal
-
WalletsList(
:limit="6"
isShowToogle
@@ -56,13 +54,12 @@ function setWalletFilter(walletId: WalletID) {
.grow.text-sm.text-skin-item-base {{ walletItem.name }}
//- Amount
- Amount(
- :currency="walletItem.currency"
- :value="walletItem.amount"
- :showBase="false"
- alwaysShowSymbol
- vertical="right"
- )
+ .text-skin-item-base
+ Amount(
+ :amount="walletItem.amount"
+ :currency="walletItem.currency"
+ :isShowSign="false"
+ )
template(#toogle="{ stateLimit, limit, toogle }")
.cursor-pointer.py-3.px-3.text-xs.text-center.hocus_text-skin-item-base-up.hocus_bg-skin-item-main-hover(
diff --git a/components/stat/Filter.vue b/components/stat/Filter.vue
index db4215bb..c64a3232 100644
--- a/components/stat/Filter.vue
+++ b/components/stat/Filter.vue
@@ -54,14 +54,15 @@ const onClearFilter = () => {
.absolute.top-0.left-0.w-full(:style="{ height: '2px', background: walletItem.color }")
.pr-2
.text-xs {{ walletItem.name }}
- .text-sm
+ .text-sm.text-skin-item-base
Amount(
- :alwaysShowSymbol="false"
+ :amount="$store.getters['wallets/walletsTotal'][walletId].base"
:currency="walletItem.currency"
- :showBase="false"
- :value="$store.getters['wallets/walletsTotal'][walletId].base"
- vertical="left"
+ :type="3"
+ :isShowBaseRate="false"
+ :isShowSign="false"
)
+
.absolute.top-1.right-1
.text-sm.mdi.mdi-close
diff --git a/components/stat/StatItem.vue b/components/stat/StatItem.vue
index ee9ca8bb..7056b8a3 100644
--- a/components/stat/StatItem.vue
+++ b/components/stat/StatItem.vue
@@ -90,10 +90,12 @@ export default {
.overflow-hidden.truncate.grow.space-x-2.flex.items-baseline.text-neutral-700(class="dark_text-neutral-400")
.overflow-hidden.text-sm {{ category.name }}{{ isCategoryHasChildren ? '...' : '' }}
- .statItem__amount
+ .statItem__amount.text-skin-item-base
Amount(
+ :amount="total"
:currency="currency"
- :value="total"
+ :type="type"
+ :isShowBaseRate="false"
)
.pt-1.statItem__graph.mt-1: .statItem__graph__in(:style="styles")
diff --git a/components/stat/StatItemChildCatsItem.vue b/components/stat/StatItemChildCatsItem.vue
index 1b1e1096..e0b89cf6 100644
--- a/components/stat/StatItemChildCatsItem.vue
+++ b/components/stat/StatItemChildCatsItem.vue
@@ -58,13 +58,12 @@ export default {
.space-x-3.flex
.grow.statItem__name {{ category.name }}
- .statItem__amount
+ .statItem__amount.text-skin-item-base
Amount(
+ :amount="total"
:currency="$store.state.currencies.base"
- :value="total"
:type="type"
- :isColorize="false"
- isShowPrefix
+ :isShowBaseRate="false"
)
.statItemChild__trns(
@@ -96,7 +95,6 @@ export default {
</style>
<style lang="stylus" scoped>
-
.ins2
position relative
background var(--c-item2-bg-hover)
diff --git a/components/stat/StatItemRound.vue b/components/stat/StatItemRound.vue
index a511ab8c..d89d7891 100644
--- a/components/stat/StatItemRound.vue
+++ b/components/stat/StatItemRound.vue
@@ -46,13 +46,12 @@ export default {
): div(:class="category.icon")
.statItemRound__name.js-getWidth(:class="{ _isCategoryHasChildren: isCategoryHasChildren }") {{ category.name }}{{ isCategoryHasChildren ? '...' : '' }}
- .statItemRound__amount.js-getWidth
+ .statItemRound__amount.js-getWidth.text-skin-item-base
Amount(
+ :amount="total"
:currency="currency"
- :isColorize="false"
:type="type"
- :value="total"
- size="md"
+ :isShowBaseRate="false"
)
</template>
@@ -67,6 +66,7 @@ export default {
.icon__image
font-size 22px
</style>
+
<style lang="stylus" scoped>
.statItemRound
cursor pointer
diff --git a/components/stat/SummaryRowItemView.vue b/components/stat/SummaryRowItemView.vue
index 93c00c89..74e6f18c 100644
--- a/components/stat/SummaryRowItemView.vue
+++ b/components/stat/SummaryRowItemView.vue
@@ -1,20 +1,9 @@
<script>
export default {
- name: 'StatSummaryRowItemView',
-
props: {
- amount: {
- type: Number,
- required: true,
- },
- type: {
- type: Number,
- default: 3,
- },
- title: {
- type: String,
- required: true,
- },
+ amount: { type: Number, required: true },
+ type: { type: Number, default: 3 },
+ title: { type: String, required: true },
},
computed: {
@@ -31,13 +20,14 @@ export default {
<template lang="pug">
.summaryItem(:class="className")
.summaryItem__title.pb-1 {{ title }}
- .summaryItem__amount
+ .summaryItem__amount.text-skin-item-base
Amount(
+ :amount="amount"
:currency="$store.state.currencies.base"
:type="type"
- :value="amount"
- size="md"
- vertical="left"
+ :colorize="type === 0 ? 'expense' : 'income'"
+ :isShowBaseRate="false"
+ :isShowSign="false"
)
.summaryItem__line
</template>
diff --git a/components/stat/group/Sum2.vue b/components/stat/group/Sum2.vue
index b0bc7a8d..aaf1c984 100644
--- a/components/stat/group/Sum2.vue
+++ b/components/stat/group/Sum2.vue
@@ -12,56 +12,44 @@ const total = computed(() => $store.getters['trns/getTotalOfTrnsIds'](props.trns
</script>
<template lang="pug">
-div
- .py-3
- .overflow-hidden.overflow-x-auto.scrollbar
- .flex.items-center.gap-6
- //- Income
- div
- .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base {{ $t('money.expense') }}
+.py-3
+ .overflow-hidden.overflow-x-auto.scrollbar
+ .flex.items-center.gap-6
+ //- Expense
+ div
+ .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base
+ | {{ $t('money.expense') }}
+ .text-xl
Amount(
+ :amount="total.expense"
:currency="$store.state.currencies.base"
:type="0"
- :value="total.expense"
- size="lg"
- vertical="left"
+ :isShowBaseRate="false"
+ colorize="expense"
)
- //- Expense
- div
- .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base {{ $t('money.income') }}
+ //- Income
+ div
+ .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base
+ | {{ $t('money.income') }}
+ .text-xl
Amount(
+ :amount="total.income"
:currency="$store.state.currencies.base"
:type="1"
- :value="total.income"
- size="lg"
- vertical="left"
+ :isShowBaseRate="false"
+ colorize="income"
)
- //- Sum
- div
- .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base {{ $t('money.sum') }}
+ //- Sum
+ div
+ .pb-2.text-lg.leading-none.font-nunito.font-semibold.text-skin-item-base
+ | {{ $t('money.sum') }}
+ .text-xl
Amount(
+ :amount="total.sum"
:currency="$store.state.currencies.base"
:type="3"
- :value="total.sum"
- size="lg"
- vertical="left"
+ :isShowBaseRate="false"
)
-
- //- //- Average
- //- LazyStatSummaryRowItemView(
- //- v-if="statPage.average[typeText] !== 0"
- //- :amount="statPage.average[typeText]"
- //- :title="$t(`money.average.${typeText}`)"
- //- :type="typeNumber"
- //- )
-
- //- //- Today
- //- LazyStatSummaryRowItemView(
- //- v-if="statToday && statToday[typeText].total !== 0"
- //- :amount="statToday[typeText].total"
- //- :title="$t('dates.day.today')"
- //- :type="typeNumber"
- //- )
</template>
diff --git a/components/stat/sum/Group.vue b/components/stat/sum/Group.vue
index 9982bf76..40969118 100644
--- a/components/stat/sum/Group.vue
+++ b/components/stat/sum/Group.vue
@@ -17,13 +17,13 @@ const typeNumber = computed(() => moneyTypes.find(t => t.id === `${props.typeTex
.overflow-hidden.overflow-x-auto.scrollbar
.flex.items-center
//- Total
- .pr-6
+ .pr-6.text-3xl
Amount(
+ :amount="statPage.current[typeText].total"
+ :colorize="typeNumber === 1 ? 'income': 'expense'"
:currency="$store.state.currencies.base"
+ :isShowBaseRate="false"
:type="typeNumber"
- :value="statPage.current[typeText].total"
- size="xl"
- vertical="left"
)
//- Average
diff --git a/components/stat/sum/Total.vue b/components/stat/sum/Total.vue
index 3a21ce0b..6ced78ff 100644
--- a/components/stat/sum/Total.vue
+++ b/components/stat/sum/Total.vue
@@ -10,13 +10,14 @@ const statAverage = computed(() => $store.getters['stat/statAverage'])
.overflow-hidden.overflow-x-auto.scrollbar
.flex.items-center
//- Total
- .pr-6
+ .pr-6.text-4xl
Amount(
+ :amount="statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total"
+ :colorize="(statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total) > 0 ? 'income' : 'expense'"
:currency="$store.state.currencies.base"
+ :isShowBaseRate="false"
+ :isShowSign="false"
:type="(statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total) > 0 ? 1 : 0"
- :value="statCurrentPeriod.incomes.total - statCurrentPeriod.expenses.total"
- size="xl"
- vertical="left"
)
LazyStatSummaryRowItemView(
@@ -24,5 +25,5 @@ const statAverage = computed(() => $store.getters['stat/statAverage'])
:type="(statAverage.incomes - statAverage.expenses) > 0 ? 1 : 0"
:amount="statAverage.incomes - statAverage.expenses"
:title="$t('money.averageTotal')"
- )
+ )
</template>
diff --git a/components/summary/SummaryAverage.vue b/components/summary/SummaryAverage.vue
deleted file mode 100644
index 75c74ba0..00000000
--- a/components/summary/SummaryAverage.vue
+++ /dev/null
@@ -1,59 +0,0 @@
-<script>
-export default {
- name: 'SummaryAverage',
-
- computed: {
- statCurrentPeriod() {
- return this.$store.getters['stat/statCurrentPeriod']
- },
-
- statAverage() {
- return this.$store.getters['stat/statAverage']
- },
- },
-}
-</script>
-
-<template lang="pug">
-.summary
- .summary__name {{ $t('stat.title') }} {{ $t('for') }} {{ Object.keys($store.getters['stat/statByPeriods']).length }} {{ $t(`dates.${$store.state.filter.period}.simple`) }}
- .summary__content
- SummaryRowItem(
- v-if="statAverage.incomes !== 0"
- :amount="statAverage.incomes"
- :type="1"
- :name="$t('money.average.incomes')"
- )
- SummaryRowItem(
- v-if="statAverage.expenses !== 0"
- :amount="statAverage.expenses"
- :type="0"
- :name="$t('money.average.expenses')"
- )
- SummaryRowItem(
- v-if="statAverage.total !== 0"
- :amount="statAverage.total"
- :name="$t('money.averageTotal')"
- )
-</template>
-
-<style lang="stylus" scoped>
-@import "~assets/stylus/variables"
-
-.summary
- padding 0 $m7
- padding-bottom $m9
-
- &__name
- padding-bottom $m6
- color var(--c-font-2)
- font-size 18px
- font-weight 600
- white-space nowrap
- text-transform uppercase
- letter-spacing .5px
- font-secondary()
-
- &__content
- display flex
-</style>
diff --git a/components/summary/SummaryRowItem.vue b/components/summary/SummaryRowItem.vue
deleted file mode 100644
index bd69a358..00000000
--- a/components/summary/SummaryRowItem.vue
+++ /dev/null
@@ -1,60 +0,0 @@
-<script>
-export default {
- name: 'SummaryRowItem',
-
- props: {
- name: {
- type: String,
- required: true,
- },
-
- amount: {
- type: Number,
- required: true,
- },
-
- type: {
- type: Number,
- required: true,
- },
- },
-
- computed: {
- className() {
- return {
- _expenses: this.type === 0,
- _incomes: this.type === 1,
- }
- },
- },
-}
-</script>
-
-<template lang="pug">
-.summaryRowItem(:class="className")
- .summaryRowItem__title {{ name }}
- .summaryRowItem__amount
- Amount(
- :currency="$store.state.currencies.base"
- :type="type"
- :value="amount || 0"
- size="md"
- vertical="left"
- )
-</template>
-
-<style lang="stylus" scoped>
-.summaryRowItem
- flex 1 0 0
- position relative
- display flex
- justify-content center
- flex-flow column
- // padding-right 32px
- // text-align center
-
- &__title
- padding-bottom $m5
- color var(--c-font-4)
- font-size 12px
-</style>
diff --git a/components/trnForm/ModalWallets.vue b/components/trnForm/ModalWallets.vue
index d49acffc..94dc2784 100644
--- a/components/trnForm/ModalWallets.vue
+++ b/components/trnForm/ModalWallets.vue
@@ -1,12 +1,10 @@
<script setup lang="ts">
import { useWindowSize } from '@vueuse/core'
-const { height } = useWindowSize()
-
defineProps<{
title: string
}>()
-
const emit = defineEmits(['click', 'closed'])
+const { height } = useWindowSize()
function onClickWallet(walletId, close) {
emit('click', walletId)
@@ -48,11 +46,10 @@ BaseBottomSheet(
.grow.text-sm.text-skin-item-base {{ walletItem.name }}
//- Amount
- Amount(
- :currency="walletItem.currency"
- :value="walletItem.amount"
- alwaysShowSymbol
- showBase
- vertical="right"
- )
+ .text-skin-item-base
+ Amount(
+ :amount="walletItem.amount"
+ :currency="walletItem.currency"
+ :isShowSign="false"
+ )
</template>
diff --git a/components/trnForm/SelectedWallet.vue b/components/trnForm/SelectedWallet.vue
index 15f7d176..53e5eee2 100644
--- a/components/trnForm/SelectedWallet.vue
+++ b/components/trnForm/SelectedWallet.vue
@@ -27,13 +27,14 @@ const wallet = computed(() => walletsItemsSorted.value[props.walletId])
.text-sm.text-skin-item-base {{ wallet.name }}
//- Amount
- Amount(
- :currency="wallet.currency"
- :value="wallet.amount"
- :showBase="false"
- alwaysShowSymbol
- vertical="left"
- )
+ .text-skin-item-base
+ Amount(
+ :amount="wallet.amount"
+ :currency="wallet.currency"
+ :isShowBaseRate="false"
+ :isShowSign="false"
+ align="left"
+ )
.mdi.mdi-dots-vertical.-mr-1.text-lg.text-skin-item-base-down
</template>
diff --git a/components/trnForm/TrnForm.vue b/components/trnForm/TrnForm.vue
index e1892df1..f8c910e5 100644
--- a/components/trnForm/TrnForm.vue
+++ b/components/trnForm/TrnForm.vue
@@ -9,14 +9,14 @@ import useCalculator from '~/components/trnForm/calculator/useCalculator'
import useTrnFormValidate from '~/components/trnForm/useTrnFormValidate'
import { random, successEmo } from '~/assets/js/emo'
-SwiperCore.use([Pagination])
-
const props = withDefaults(defineProps<{
show: boolean
}>(), {
show: true,
})
+SwiperCore.use([Pagination])
+
const { $store } = useNuxtApp()
// Expense
@@ -261,13 +261,13 @@ function handleSubmitForm() {
.text-sm.text-skin-item-base {{ walletItem.name }}
//- Amount
- Amount(
- :currency="walletItem.currency"
- :value="walletItem.amount"
- :showBase="false"
- alwaysShowSymbol
- vertical="left"
- )
+ .text-sm
+ Amount(
+ :amount="walletItem.amount"
+ :currency="walletItem.currency"
+ :isShowBaseRate="false"
+ align="left"
+ )
//- Favorite categories
.pb-7(v-if="$store.getters['categories/quickSelectorCategoriesIds'] && $store.getters['categories/quickSelectorCategoriesIds'].length > 0")
diff --git a/components/trns/item/Details.vue b/components/trns/item/Details.vue
new file mode 100644
index 00000000..a6fb2005
--- /dev/null
+++ b/components/trns/item/Details.vue
@@ -0,0 +1,225 @@
+<script>
+import useCalculator from '~/components/trnForm/calculator/useCalculator'
+import { formatDate } from '~/utils/formatDate'
+
+export default {
+ props: {
+ category: { type: Object, required: true },
+ isActive: { type: Boolean, default: false },
+ showCategory: { type: Boolean, default: false },
+ trn: { type: Object, required: true },
+ trnId: { type: String, required: true },
+ ui: { type: String, default: 'history' },
+ wallet: { type: Object, required: true },
+ },
+
+ computed: {
+ className() {
+ return {
+ _active: this.isActive,
+ _detailed: this.ui === 'detailed',
+ _history: this.ui === 'history' || (this.ui === 'stat' && this.showCategory),
+ _stat: this.ui === 'stat',
+ }
+ },
+ formatedDate() {
+ const date = formatDate(this.trn.date, 'full')
+ return `${date.weekday}, ${date.day} ${date.month} ${date.year}`
+ },
+ formatedDateDay() {
+ return formatDate(this.trn.date, 'trnItem')
+ },
+ formatedDateDay2() {
+ return formatDate(this.trn.date, 'trnItem')
+ },
+ },
+
+ methods: {
+ handleClick() {
+ if (!this.$store.state.trns.modal.show) {
+ this.$store.commit('trns/showTrnModal')
+ this.$store.commit('trns/setTrnModalId', this.trnId)
+ }
+ },
+
+ setTrnEdit() {
+ const trnId = this.trnId
+ const { setExpression } = useCalculator()
+ setExpression(this.trn.type === 2 && this.trn.incomeAmount ? this.trn.incomeAmount : this.trn.amount)
+ this.$store.dispatch('trnForm/openTrnForm', { action: 'edit', trnId })
+ this.$store.commit('stat/setCategoryModal', { id: null, type: null })
+ this.$emit('onClickEdit', this.trnId)
+ },
+ },
+}
+</script>
+
+<template lang="pug">
+.trnItem.py-3.px-3(
+ v-if="(category && wallet) || trn.type === 2"
+ :class="{ ...className, 'py-2.5': true, '!cursor-default': trn.type === 2 && trn.incomeAmount && trn.expenseAmount }"
+ @click="handleClick"
+)
+ //- Transfer
+ template(v-if="trn.type === 2 && trn.incomeAmount && trn.expenseAmount")
+ .trnItem__categoryIcon
+ Icon(
+ :background="category.color"
+ :icon="category.icon"
+ big
+ round
+ )
+ .trnItem__categoryName {{ $t('trnForm.transferTitle') }}
+ .trnItem__date {{ formatedDate }}
+ .flex.gap-5.items-center
+ //- Expense
+ div
+ .pb-2
+ WalletsItem(
+ :id="trn.expenseWalletId"
+ :isShowAmount="false"
+ )
+ .text-2xl.text-skin-item-base
+ Amount(
+ :amount="trn.expenseAmount"
+ :currency="$store.state.wallets.items[trn.expenseWalletId].currency"
+ :type="0"
+ align="center"
+ colorize="expense"
+ )
+
+ //- Separator
+ .mdi.mdi-chevron-right.text-2xl
+
+ //- Income
+ div
+ .pb-2
+ WalletsItem(
+ :id="trn.incomeWalletId"
+ :isShowAmount="false"
+ )
+ .text-2xl.text-skin-item-base
+ Amount(
+ :amount="trn.incomeAmount"
+ :currency="$store.state.wallets.items[trn.incomeWalletId].currency"
+ :type="1"
+ align="center"
+ colorize="income"
+ )
+
+ .trnItem__desc.whitespace-pre.font-roboto.leading-none(
+ v-if="trn.description"
+ class="!dark_text-white/80 !text-xs"
+ ) {{ trn.description }}
+
+ //- Transaction
+ template(v-else)
+ .trnItem__categoryIcon
+ Icon(
+ :background="category.color"
+ :icon="category.icon"
+ big
+ round
+ )
+ .trnItem__categoryName {{ category.name }}
+ .trnItem__wallet
+ .walletIcon
+ Icon(
+ :abbr="wallet.name"
+ :background="wallet.color"
+ small
+ )
+
+ .walletName {{ wallet.name }}
+
+ .trnItem__date {{ formatedDate }}
+ .trnItem__amount.text-4xl(
+ @click.stop="setTrnEdit"
+ )
+ Amount(
+ :amount="trn.amount"
+ :currency="wallet.currency"
+ :colorize="trn.type === 0 ? 'expense' : 'income'"
+ :type="trn.type"
+ align="center"
+ )
+
+ .trnItem__desc(v-if="trn.description") {{ trn.description }}
+</template>
+
+<style lang="stylus" scoped>
+.transfer
+ padding-top $m5
+ font-size 14px
+
+ span
+ padding-right 2px
+ color var(--c-font-3)
+ font-size 11px
+
+.trnFormHeaderSeparator
+ color var(--c-font-1)
+ font-size 32px
+
+.trnItem
+ position relative
+ color var(--c-font-4)
+ display flex
+ flex-flow column
+ align-items center
+ justify-content center
+ margin-bottom -10px
+ text-align center
+
+ &__amount
+ align-self center
+ padding-top $m5
+
+ &__categoryIcon
+ margin-top -38px
+ padding-bottom 12px
+
+ &__categoryName
+ white-space nowrap
+ overflow hidden
+ text-overflow ellipsis
+ padding-bottom $m6
+ color var(--c-font-2)
+ font-size 22px
+ fontFamilyNunito()
+
+ &__date
+ font-size 13px
+ padding-bottom $m8
+ font-size 14px
+
+ &__desc
+ color var(--c-font-2)
+ font-size 14px
+ padding-top $m7
+
+ &__statWrap
+ display flex
+ align-items center
+ padding-bottom 10px
+
+ &__wallet
+ display flex
+ align-items center
+ padding-bottom $m6
+
+ .walletIcon
+ margin-right 8px
+
+ .walletName
+ font-size 14px
+ white-space nowrap
+
+ .walletName
+ font-size 16px
+
+ &__groups
+ display inline-block
+ padding-left 10px
+ font-size 10px
+</style>
diff --git a/components/trns/item/History.vue b/components/trns/item/History.vue
index 5d93b87e..d4c60464 100644
--- a/components/trns/item/History.vue
+++ b/components/trns/item/History.vue
@@ -85,40 +85,46 @@ const actions = {
div {{ $t('trnForm.transfer.from') }}:
.text-neutral-500(class="dark_text-neutral-400") {{ trnItem.expenseWallet.name }}
- Amount2.text-base(
- :amount="trnItem.expenseAmount || trnItem.amount"
- :currency="trnItem.expenseWallet.currency"
- :type="0"
- verti
- colorize="expenses"
+ .text-base(
@click="actions.onOpenEdit"
)
+ Amount(
+ :amount="trnItem.expenseAmount || trnItem.amount"
+ :currency="trnItem.expenseWallet.currency"
+ :type="0"
+ verti
+ colorize="expenses"
+ )
+
+ //- Income
div
- //- Income
.space-x-1.items-center.flex
div {{ $t('trnForm.transfer.to') }}:
.text-neutral-500(class="dark_text-neutral-400") {{ trnItem.incomeWallet.name }}
- Amount2.text-base(
- :amount="trnItem.incomeAmount || trnItem.amount"
- :currency="trnItem.incomeWallet.currency"
- :type="1"
- colorize="incomes"
+ .text-base(
@click="actions.onOpenEdit"
)
+ Amount(
+ :amount="trnItem.incomeAmount || trnItem.amount"
+ :currency="trnItem.incomeWallet.currency"
+ :type="1"
+ colorize="incomes"
+ )
//- Amount
- .cursor-pointer(v-if="trnItem.type !== 2")
- Amount2(
+ .cursor-pointer(
+ v-if="trnItem.type !== 2"
+ @click="actions.onOpenEdit"
+ )
+ Amount(
:amount="trnItem.amount"
:currency="trnItem.wallet.currency"
:type="trnItem.type"
colorize="incomes"
- @click="actions.onOpenEdit"
)
//- Description
- .pt-2.text-neutral-500.text-xs.leading-none(
- v-if="trnItem.description"
- ) {{ trnItem.description }}
+ .pt-2.text-neutral-500.text-xs.leading-none(v-if="trnItem.description")
+ | {{ trnItem.description }}
</template>
diff --git a/components/trns/item/Modal.vue b/components/trns/item/Modal.vue
index 44bce1e6..1d343c68 100644
--- a/components/trns/item/Modal.vue
+++ b/components/trns/item/Modal.vue
@@ -1,6 +1,7 @@
<script lang="ts">
import useFilter from '~/modules/filter/useFilter'
import useCalculator from '~/components/trnForm/calculator/useCalculator'
+import useTrn from '~/components/trns/item/useTrn'
export default {
setup() {
@@ -12,7 +13,11 @@ export default {
$store.commit('trns/setTrnModalId', null)
}
+ const { formatTrnItem } = useTrn()
+ const trnItem = computed(() => formatTrnItem($store.state.trns.modal.id))
+
return {
+ trnItem,
setFilterCatsId,
setFilterWalletsId,
closed,
@@ -31,10 +36,6 @@ export default {
return this.$store.state.trns.modal.id
},
- trn() {
- return this.$store.state.trns.items[this.trnId]
- },
-
category() {
return this.$store.state.categories.items[this.$store.state.trns.items[this.trnId].categoryId]
},
@@ -71,7 +72,7 @@ export default {
},
handleEditClick() {
- const trn = this.trn
+ const trn = this.trnItem
const trnId = this.trnId
this.$store.dispatch('trnForm/openTrnForm', { action: 'edit', trnId })
this.$store.commit('trns/hideTrnModal')
@@ -115,9 +116,9 @@ Portal(
template(#header)
.header
.header__category
- TrnsItemTrnItem(
+ TrnsItemDetails(
:category="category"
- :trn="trn"
+ :trn="trnItem"
:trnId="trnId"
:wallet="wallet"
ui="detailed"
diff --git a/components/trns/item/TrnItem.vue b/components/trns/item/TrnItem.vue
deleted file mode 100644
index 5b1eaad9..00000000
--- a/components/trns/item/TrnItem.vue
+++ /dev/null
@@ -1,442 +0,0 @@
-<script>
-import useCalculator from '~/components/trnForm/calculator/useCalculator'
-import { formatDate } from '~/utils/formatDate'
-
-export default {
- props: {
- category: { type: Object, required: true },
- isActive: { type: Boolean, default: false },
- showCategory: { type: Boolean, default: false },
- trn: { type: Object, required: true },
- trnId: { type: String, required: true },
- ui: { type: String, default: 'history' },
- wallet: { type: Object, required: true },
- },
-
- computed: {
- className() {
- return {
- _active: this.isActive,
- _detailed: this.ui === 'detailed',
- _history: this.ui === 'history' || (this.ui === 'stat' && this.showCategory),
- _stat: this.ui === 'stat',
- }
- },
- formatedDate() {
- const date = formatDate(this.trn.date, 'full')
- return `${date.weekday}, ${date.day} ${date.month} ${date.year}`
- },
- formatedDateDay() {
- return formatDate(this.trn.date, 'trnItem')
- },
- formatedDateDay2() {
- return formatDate(this.trn.date, 'trnItem')
- },
- },
-
- methods: {
- handleClick() {
- if (!this.$store.state.trns.modal.show) {
- this.$store.commit('trns/showTrnModal')
- this.$store.commit('trns/setTrnModalId', this.trnId)
- }
- },
-
- setTrnEdit() {
- const trnId = this.trnId
- const { setExpression } = useCalculator()
- setExpression(this.trn.type === 2 && this.trn.incomeAmount ? this.trn.incomeAmount : this.trn.amount)
- this.$store.dispatch('trnForm/openTrnForm', { action: 'edit', trnId })
- this.$store.commit('stat/setCategoryModal', { id: null, type: null })
- this.$emit('onClickEdit', this.trnId)
- },
- },
-}
-</script>
-
-<template lang="pug">
-.trnItem.py-3.px-3(
- v-if="(category && wallet) || trn.type === 2"
- :class="{ ...className, 'py-2.5': true, '!cursor-default': trn.type === 2 && trn.incomeAmount && trn.expenseAmount }"
- @click="handleClick"
-)
- //- Transfer@next
- template(v-if="trn.type === 2 && trn.incomeAmount && trn.expenseAmount")
- .trnItem__categoryIcon
- Icon(
- :background="category.color"
- :icon="category.icon"
- big
- round
- )
- .trnItem__categoryName {{ $t('trnForm.transferTitle') }}
- .trnItem__date {{ formatedDate }}
- .trnItem__wallet
- WalletsItem(
- :id="trn.expenseWalletId"
- isAltColor
- ui="tile"
- )
- .trnFormHeaderSeparator: .mdi.mdi-chevron-right
- WalletsItem(
- :id="trn.incomeWalletId"
- isAltColor
- ui="tile"
- )
- .trnItem__amount.flex.gap-3(@click.stop="setTrnEdit")
- Amount(
- :currency="$store.state.wallets.items[trn.expenseWalletId].currency"
- :value="trn.expenseAmount"
- :type="2"
- vertical="center"
- size="xl"
- )
- .trnFormHeaderSeparator: .mdi.mdi-chevron-right
- Amount(
- :currency="$store.state.wallets.items[trn.incomeWalletId].currency"
- :value="trn.incomeAmount"
- :type="2"
- vertical="center"
- size="xl"
- )
- .trnItem__desc.whitespace-pre.font-roboto.leading-none(
- class="!dark_text-white/80 !text-xs"
- v-if="trn.description"
- ) {{ trn.description }}
-
- //- Transfer@deprecated
- template(v-else-if="trn.type === 2")
- //- Transfer: Detailed
- template(v-if="ui === 'detailed'")
- .trnItem__categoryIcon
- Icon(
- :background="category.color"
- :icon="category.icon"
- big
- round
- )
- .trnItem__categoryName {{ $t('trnForm.transferTitle') }}
- .trnItem__date {{ formatedDate }}
- .trnItem__wallet
- WalletsItem(
- :id="trn.walletFromId"
- isAltColor
- ui="tile"
- )
- .trnFormHeaderSeparator: .mdi.mdi-chevron-right
- WalletsItem(
- :id="trn.walletToId"
- isAltColor
- ui="tile"
- )
- .trnItem__amount(@click.stop="setTrnEdit")
- Amount(
- :currency="$store.state.wallets.items[trn.walletFromId].currency"
- :value="trn.amountFrom"
- :type="2"
- vertical="center"
- size="xl"
- )
-
- .trnItem__desc(v-if="trn.description") {{ trn.description }}
-
- //- Transfer: History
- template(v-else)
- .trnItem__left
- .trnItem__categoryIcon
- Icon(
- :color="category.color"
- :icon="category.icon"
- background="var(--c-item-stat-bg)"
- round
- )
-
- .trnItem__center
- .trnItem__categoryName
- div {{ $t('trnForm.transferTitle') }}
- .transfer
- div
- span {{ $t('trnForm.transfer.from') }}:
- | {{ $store.state.wallets.items[trn.walletFromId].name }}
- div
- span {{ $t('trnForm.transfer.to') }}:
- | {{ $store.state.wallets.items[trn.walletToId].name }}
-
- .trnItem__desc(v-if="trn.description") {{ trn.description }}
-
- .trnItem__right
- .trnItem__amount(@click.stop="setTrnEdit")
- Amount(
- :currency="$store.state.wallets.items[trn.walletFromId].currency"
- :isColorize="false"
- :type="2"
- :value="trn.amountFrom"
- )
-
- //- Transaction
- template(v-else)
- //- Detailed
- template(v-if="ui === 'detailed'")
- .trnItem__categoryIcon
- Icon(
- :background="category.color"
- :icon="category.icon"
- big
- round
- )
- .trnItem__categoryName {{ category.name }}
- .trnItem__wallet
- .walletIcon
- Icon(
- :abbr="wallet.name"
- :background="wallet.color"
- small
- )
-
- .walletName {{ wallet.name }}
-
- .trnItem__date {{ formatedDate }}
- .trnItem__amount(@click.stop="setTrnEdit")
- Amount(
- :currency="wallet.currency"
- :type="trn.type"
- :value="trn.amount"
- vertical="center"
- size="xl"
- isShowPrefix
- )
-
- .trnItem__desc(v-if="trn.description") {{ trn.description }}
-
- //- Stat no category
- template(v-else-if="ui === 'stat' && !showCategory")
- .trnItem__statWrap
- .trnItem__date {{ $t(formatedDateDay) }}
-
- .trnItem__wallet
- .walletIcon
- Icon(
- :abbr="wallet.name"
- :background="wallet.color"
- small
- )
- .walletName {{ wallet.name }}
- .trnItem__desc(v-if="trn.description") {{ trn.description }}
- .trnItem__amount(@click.stop="setTrnEdit")
- Amount(
- :currency="wallet.currency"
- :value="trn.amount"
- :type="trn.type"
- isShowPrefix
- )
-
- //- History
- template(v-else)
- .trnItem__left
- .trnItem__categoryIcon
- Icon(
- :color="category.color"
- :icon="category.icon"
- background="var(--c-item-stat-bg)"
- round
- )
-
- .trnItem__center
- .trnItem__categoryName
- | {{ category.name }}
- .trnItem__groups(v-if="trn.groups") In group
-
- .trnItem__wallet
- .trnItem__walletIcon
- Icon(
- :abbr="wallet.name"
- :background="wallet.color"
- :small="true"
- )
- .trnItem__walletName {{ wallet.name }}
-
- .trnItem__desc(v-if="trn.description") {{ trn.description }}
-
- .trnItem__right
- .trnItem__amount(@click.stop="setTrnEdit")
- Amount(
- :currency="wallet.currency"
- :value="trn.amount"
- :type="trn.type"
- size="md"
- :isColorize="trn.type === 1"
- isShowPrefix
- )
-</template>
-
-<style lang="stylus" scoped>
-.transfer
- padding-top $m5
- font-size 14px
-
- span
- padding-right 2px
- color var(--c-font-3)
- font-size 11px
-
-.trnFormHeaderSeparator
- color var(--c-font-1)
- font-size 32px
-
-.trnItem
- position relative
- color var(--c-font-4)
-
- &._detailed
- display flex
- flex-flow column
- align-items center
- justify-content center
- margin-bottom -10px
- text-align center
-
- &._stat
- margin-top -1px
- padding-top $m6
- border-bottom $m2
-
- +media-hover(true)
- &._history
- &._stat
- background var(--c-item-bg-hover)
-
- &__amount
- align-self center
- padding-top $m5
-
- ^[0]._stat &
- margin-left auto
- padding-top 0
-
- &__categoryIcon
- ^[0]._detailed &
- margin-top -38px
- padding-bottom 12px
-
- &__categoryName
- white-space nowrap
- overflow hidden
- text-overflow ellipsis
-
- ^[0]._detailed &
- padding-bottom $m6
- color var(--c-font-2)
- font-size 22px
- fontFamilyNunito()
-
- &__date
- font-size 13px
-
- ^[0]._detailed &
- padding-bottom $m8
- font-size 14px
-
- ^[0]._stat &
- padding-right $m7
-
- &__desc
- color var(--c-font-2)
- font-size 14px
-
- ^[0]._detailed &
- padding-top $m7
-
- ^[0]._stat &
- overflow hidden
- padding-right 0
- white-space nowrap
- text-overflow ellipsis
-
- &__statWrap
- display flex
- align-items center
- padding-bottom 10px
- // border-bottom 1px solid var(--c-bg-6)
-
- ^[0]._stat:hover &
- @media $media-laptop
- border-color transparent
-
- ^[0]._stat:last-child &
- border-color transparent
-
- &__wallet
- ^[0]._detailed &
- ^[0]._stat &
- display flex
- align-items center
-
- .walletIcon
- margin-right 8px
-
- .walletName
- font-size 14px
- white-space nowrap
-
- ^[0]._detailed &
- padding-bottom $m6
-
- .walletName
- font-size 16px
-
- ^[0]._stat &
- padding-right 20px
-
- &__groups
- display inline-block
- padding-left 10px
- font-size 10px
-
-// Stat
-// ----------------------------------------------------------------------------
-.trnItem._stat._history
- padding 0
-
-// History
-// ----------------------------------------------------------------------------
-.trnItem
- &._history
- display grid
- grid-template-columns minmax(10px, max-content) 1fr minmax(10px, max-content)
- grid-column-gap $m7
-
- &__wallet
- display flex
- align-items center
- font-size 12px
-
- &__walletIcon
- padding-right $m4
-
- &__walletName
- font-size 12px
-
- &__desc
- ^[0]._history &
- padding-top $m6
- color var(--c-font-3)
- font-size 11px
-
- &__categoryName
- ^[0]._history &
- padding-bottom $m4
- color var(--c-font-2)
- font-size 14px
-
- &._active
- &._trnForm
- margin-right - ($m7)
- margin-left - ($m7)
- padding-right ($m7)
- padding-left ($m7)
-
- &._active
- background var(--c-bg-1)
- border-top 1px solid var(--c-blue-1)
- border-bottom 1px solid var(--c-blue-1)
-</style>
diff --git a/components/trns/item/WithoutCat.vue b/components/trns/item/WithoutCat.vue
index ad7b60aa..a995b0fa 100644
--- a/components/trns/item/WithoutCat.vue
+++ b/components/trns/item/WithoutCat.vue
@@ -1,4 +1,3 @@
-
<script lang="ts">
import useTrn from '~/components/trns/item/useTrn'
@@ -55,7 +54,7 @@ export default defineComponent({
//- Amount
.cursor-pointer
- Amount2(
+ Amount(
:amount="trnItem.amount"
:currency="trnItem.wallet.currency"
:type="trnItem.type"
diff --git a/components/wallets/Item.vue b/components/wallets/Item.vue
index b5b56dfa..69a26fb8 100644
--- a/components/wallets/Item.vue
+++ b/components/wallets/Item.vue
@@ -6,6 +6,7 @@ export default defineComponent({
vertical: { type: String, default: 'left' },
size: { type: String, default: null },
activeItemId: { type: String, default: null },
+ isShowAmount: { type: Boolean, default: true },
},
computed: {
@@ -19,7 +20,8 @@ export default defineComponent({
methods: {
handleClick() {
- if (this.$listeners.onClick) this.$listeners.onClick(this.id)
+ if (this.$listeners.onClick)
+ this.$listeners.onClick(this.id)
},
},
})
@@ -31,7 +33,7 @@ export default defineComponent({
@click="handleClick"
)
div.bg-red-300.h-8(v-if="activeItemId === id")
- .gap-x-3.flex
+ .gap-x-3.flex.items-center
.text-neutral-50.text-xs.leading-none.w-6.h-6.rounded-md.justify-center.items-center.flex(
:style="{ background: wallet.color }"
class="mt-[2px]"
@@ -39,11 +41,10 @@ export default defineComponent({
div
.text-sm.text-neutral-500(class="dark_text-neutral-400") {{ wallet.name }}
- Amount(
- :currency="wallet.currency"
- :value="wallet.total"
- alwaysShowSymbol
- showBase
- vertical="right"
- )
+ template(v-if="isShowAmount")
+ Amount(
+ :amount="wallet.total"
+ :currency="wallet.currency"
+ align="right"
+ )
</template>
diff --git a/components/wallets/ItemAlt.vue b/components/wallets/ItemAlt.vue
deleted file mode 100644
index 00b1cd4a..00000000
--- a/components/wallets/ItemAlt.vue
+++ /dev/null
@@ -1,63 +0,0 @@
-<script lang="ts">
-import useFilter from '~/modules/filter/useFilter'
-
-export default defineComponent({
- props: {
- id: { type: String, required: true },
- activeItemId: { type: String, default: null },
- },
-
- setup(props) {
- const { $store } = useNuxtApp()
- const { setFilterWalletsId } = useFilter()
-
- const onClickFilterWallet = () => {
- setFilterWalletsId(props.id)
- $store.dispatch('ui/setActiveTabStat', 'details')
- }
-
- return {
- onClickFilterWallet,
- }
- },
-
- computed: {
- wallet() {
- return {
- ...this.$store.state.wallets.items[this.id],
- total: this.$store.getters['wallets/walletsTotal'][this.id].base,
- }
- },
- },
-
- methods: {
- handleClick() {
- if (this.$listeners.onClick) this.$listeners.onClick(this.id)
- },
- },
-})
-</script>
-
-<template lang="pug">
-.cursor-pointer.py-1.px-5.gap-x-3.flex.items-center.hocus_bg-gray-200.dark_hocus_bg-neutral-800.border-b.border-gray-200.dark_border-neutral-800(
- :class="[{ _active: activeItemId === id }]"
- @click="handleClick"
-)
- //- Icon
- .w-6.h-6.flex-center.rounded-md.text-skin-icon-base.text-xs.leading-none(
- :style="{ background: wallet.color }"
- @click.stop="onClickFilterWallet"
- ) {{ wallet.name.substring(0, 2) }}
-
- .grow
- .py-1.items-center.flex
- .grow.text-xs.text-skin-item-base-down
- | {{ wallet.name }}
-
- Amount(
- :currency="wallet.currency"
- :value="wallet.total"
- alwaysShowSymbol
- vertical="right"
- )
-</template>
diff --git a/components/wallets/Total.vue b/components/wallets/Total.vue
index 500373d1..9af30889 100644
--- a/components/wallets/Total.vue
+++ b/components/wallets/Total.vue
@@ -1,141 +1,102 @@
-<script>
+<script setup lang="ts">
import useAmount from '~/components/amount/useAmount'
-export default {
- props: {
- isShowCredits: { type: Boolean, default: false },
- isShowSavings: { type: Boolean, default: false },
- },
+const { $store } = useNuxtApp()
+const { getAmountInBaseCurrency } = useAmount()
- setup() {
- const { getAmountInBaseCurrency } = useAmount()
- return { getAmountInBaseCurrency }
- },
+const totalInWallets = computed(() => {
+ const walletsItems = $store.state.wallets.items
+ const walletsTotal = $store.getters['wallets/walletsTotal']
+ const total = {
+ counted: 0,
+ savings: 0,
+ credits: 0,
+ }
- computed: {
- totalInWallets() {
- const walletsItems = this.$store.state.wallets.items
- const walletsTotal = this.$store.getters['wallets/walletsTotal']
- const total = {
- counted: 0,
- savings: 0,
- credits: 0,
- }
+ for (const walletId in walletsItems) {
+ let walletTotal = 0
+ if (walletsItems[walletId].currency === $store.state.currencies.base) {
+ walletTotal = walletsTotal[walletId].base
+ }
+ else {
+ walletTotal = getAmountInBaseCurrency({
+ amount: walletsTotal[walletId].base,
+ currency: walletsItems[walletId].currency,
+ noFormat: true,
+ })
+ }
- for (const walletId in walletsItems) {
- let walletTotal = 0
- if (walletsItems[walletId].currency === this.$store.state.currencies.base) {
- walletTotal = walletsTotal[walletId].base
- }
- else {
- walletTotal = this.getAmountInBaseCurrency({
- amount: walletsTotal[walletId].base,
- currency: walletsItems[walletId].currency,
- noFormat: true,
- })
- }
+ if (walletsItems[walletId].countTotal)
+ total.counted = total.counted + walletTotal
+ else if (walletsItems[walletId].isCredit)
+ total.credits = total.credits + walletTotal
+ else
+ total.savings = total.savings + walletTotal
+ }
+ return total
+})
- if (walletsItems[walletId].countTotal)
- total.counted = total.counted + walletTotal
- else if (walletsItems[walletId].isCredit)
- total.credits = total.credits + walletTotal
- else
- total.savings = total.savings + walletTotal
- }
- return total
- },
+const counts = computed(() => ({
+ credit: {
+ titleId: 'credits',
+ isShow: totalInWallets.value.credits !== 0,
+ value: totalInWallets.value.credits,
},
-}
+ savings: {
+ titleId: 'savings',
+ isShow: totalInWallets.value.savings !== 0,
+ value: totalInWallets.value.savings,
+ },
+ withdraw: {
+ titleId: 'withdrawal',
+ isShow: totalInWallets.value.counted !== totalInWallets.value.counted + totalInWallets.value.savings - Math.abs(totalInWallets.value.credits),
+ value: totalInWallets.value.counted,
+ icon: 'UiIconWalletWithdrawal',
+ },
+ total: {
+ titleId: 'total',
+ isShow: true,
+ value: totalInWallets.value.counted + totalInWallets.value.savings,
+ },
+ withCredit: {
+ titleId: 'withCredit',
+ isShow: totalInWallets.value.credits !== 0,
+ value: totalInWallets.value.counted + totalInWallets.value.savings - Math.abs(totalInWallets.value.credits),
+ },
+}))
</script>
<template lang="pug">
-.walletsTotal(
+.px-3.py-1.bg-skin-item-main-bg.rounded-md(
v-if="$store.getters['wallets/hasWallets']"
)
- //- Credits
- .walletsTotal__item(v-if="isShowCredits && totalInWallets.credits !== 0")
- .walletsTotal__title {{ $t('credits') }}
- .walletsTotal__value
- Amount(
- :currency="$store.state.currencies.base"
- :value="totalInWallets.credits"
- size="lg"
- vertical="center"
- )
-
- //- Savings
- .walletsTotal__item(v-if="totalInWallets.savings !== 0 && isShowSavings")
- .walletsTotal__title {{ $t('savings') }}
- .walletsTotal__value
- Amount(
- :currency="$store.state.currencies.base"
- :value="totalInWallets.savings"
- size="lg"
- vertical="center"
- )
+ template(v-for="item in counts")
+ .py-2.flex.items-center.border-b.border-skin-item-main-hover.last_border-0(
+ v-if="item.isShow"
+ )
+ .grow.flex.items-center.gap-3
+ .text-sm.leading-none {{ $t(item.titleId) }}
- //- Total
- .walletsTotal__item
- .walletsTotal__title {{ $t('total') }}
- .walletsTotal__value
- Amount(
- :currency="$store.state.currencies.base"
- :value="totalInWallets.counted + totalInWallets.savings - Math.abs(totalInWallets.credits)"
- size="lg"
- vertical="center"
- )
-
- //- Avaliable
- .walletsTotal__item(v-if="totalInWallets.counted !== totalInWallets.counted + totalInWallets.savings - Math.abs(totalInWallets.credits)")
- .walletsTotal__title {{ $t('avaliable') }}
- .walletsTotal__value
- Amount(
- :currency="$store.state.currencies.base"
- :value="totalInWallets.counted"
- size="lg"
- vertical="center"
- )
+ .text-skin-item-base
+ Amount(
+ :currency="$store.state.currencies.base"
+ :amount="item.value"
+ )
</template>
-<style lang="stylus" scoped>
-.walletsTotal
- display flex
- flex-wrap wrap
- align-items center
- justify-content center
- gap $m8
- padding 0 $m8
- padding-bottom $m8
-
- +media(600px)
- gap $m8
- padding 0 $m8
- padding-bottom $m8
-
- &__item
- flex 0 0 0
- align-self start
- justify-self start
-
- &__title
- opacity .6
- padding-right 0
- padding-bottom 6px
- font-size 12px
- text-align center
-</style>
-
<i18n lang="json5">
{
"en": {
- "avaliable": "Avaliable",
+ "withdrawal": "Withdrawal",
"credits": "Credits",
+ "withCredit": "Total with credit",
"savings": "Savings",
"total": "Total"
},
"ru": {
- "avaliable": "Доступные",
+ "withdrawal": "Доступные",
"credits": "Кредиты",
+ "withCredit": "Всего с учетом кредита",
"savings": "Вложения",
"total": "Всего"
}
diff --git a/components/wallets/TotalAlt.vue b/components/wallets/TotalAlt.vue
deleted file mode 100644
index 085702cf..00000000
--- a/components/wallets/TotalAlt.vue
+++ /dev/null
@@ -1,114 +0,0 @@
-<script setup lang="ts">
-import useAmount from '~/components/amount/useAmount'
-
-const props = withDefaults(defineProps<{
- isShowCredits?: boolean
- isShowSavings?: boolean
-}>(), {
- isShowCredits: false,
- isShowSavings: false,
-})
-
-const { $store } = useNuxtApp()
-const { getAmountInBaseCurrency } = useAmount()
-
-const totalInWallets = computed(() => {
- const walletsItems = $store.state.wallets.items
- const walletsTotal = $store.getters['wallets/walletsTotal']
- const total = {
- counted: 0,
- savings: 0,
- credits: 0,
- }
-
- for (const walletId in walletsItems) {
- let walletTotal = 0
- if (walletsItems[walletId].currency === $store.state.currencies.base) {
- walletTotal = walletsTotal[walletId].base
- }
- else {
- walletTotal = getAmountInBaseCurrency({
- amount: walletsTotal[walletId].base,
- currency: walletsItems[walletId].currency,
- noFormat: true,
- })
- }
-
- if (walletsItems[walletId].countTotal)
- total.counted = total.counted + walletTotal
- else if (walletsItems[walletId].isCredit)
- total.credits = total.credits + walletTotal
- else
- total.savings = total.savings + walletTotal
- }
- return total
-})
-
-const counts = computed(() => ({
- credit: {
- titleId: 'credits',
- isShow: props.isShowCredits && totalInWallets.value.credits !== 0,
- value: totalInWallets.value.credits,
- },
- savings: {
- titleId: 'savings',
- isShow: totalInWallets.value.savings !== 0 && props.isShowSavings,
- value: totalInWallets.value.savings,
- },
- withdraw: {
- titleId: 'withdrawal',
- isShow: totalInWallets.value.counted !== totalInWallets.value.counted + totalInWallets.value.savings - Math.abs(totalInWallets.value.credits),
- value: totalInWallets.value.counted,
- icon: 'UiIconWalletWithdrawal',
- },
- total: {
- titleId: 'total',
- isShow: true,
- value: totalInWallets.value.counted + totalInWallets.value.savings,
- },
- withCredit: {
- titleId: 'withCredit',
- isShow: totalInWallets.value.credits !== 0,
- value: totalInWallets.value.counted + totalInWallets.value.savings - Math.abs(totalInWallets.value.credits),
- },
-}))
-</script>
-
-<template lang="pug">
-.px-3.py-1.bg-skin-item-main-bg.rounded-md(
- v-if="$store.getters['wallets/hasWallets']"
-)
- template(
- v-for="item in counts"
- )
- .py-2.flex.items-center.border-b.border-skin-item-main-hover.last_border-0(
- v-if="item.isShow"
- )
- .grow.flex.items-center.gap-3
- .text-sm.leading-none {{ $t(item.titleId) }}
-
- Amount(
- :currency="$store.state.currencies.base"
- :value="item.value"
- vertical="right"
- )
-</template>
-
-<i18n lang="json5">
-{
- "en": {
- "withdrawal": "Withdrawal",
- "credits": "Credits",
- "withCredit": "Total with credit",
- "savings": "Savings",
- "total": "Total"
- },
- "ru": {
- "withdrawal": "Доступные",
- "credits": "Кредиты",
- "withCredit": "Всего с учетом кредита",
- "savings": "Вложения",
- "total": "Всего"
- }
-}
-</i18n>
diff --git a/components/wallets/page/List.vue b/components/wallets/page/List.vue
index d18ae6d9..1ecab4a1 100644
--- a/components/wallets/page/List.vue
+++ b/components/wallets/page/List.vue
@@ -31,10 +31,7 @@ UiPage
WalletsCurrenciesChanger
.pb-12.px-3
- WalletsTotalAlt(
- isShowCredits
- isShowSavings
- )
+ WalletsTotal
//- List
//---------------------------------
@@ -64,11 +61,8 @@ UiPage
//- Amount
Amount(
+ :amount="walletItem.amount"
:currency="walletItem.currency"
- :value="walletItem.amount"
- alwaysShowSymbol
- showBase
- vertical="right"
)
template(#bottom)
diff --git a/components/wallets/page/id/Index.vue b/components/wallets/page/id/Index.vue
index f5a48536..7e29ec99 100644
--- a/components/wallets/page/id/Index.vue
+++ b/components/wallets/page/id/Index.vue
@@ -61,19 +61,16 @@ UiPage(v-if="wallet")
.pb-1.text-xs.font-medium.text-skin-item-base-down
| {{ $t("wallets.title") }}
- .flex.items-center.gap-3.pb-3
+ .flex.items-center.gap-3.pb-4
.text-skin-item-base-up.text-2xl.font-semibold
| {{ wallet.name }}
.p-1.flex-center.rounded.text-skin-icon-base.text-2xs(:style="{ background: wallet.color }")
| {{ wallet.currency }}
- .flex
+ .flex.text-3xl.font-normal
Amount(
+ :amount="total"
:currency="wallet.currency"
- :value="total"
- showBase
- size="lg"
- vertical="right"
)
template(#actions)