Profit-desc should correspond to selected mode

This commit is contained in:
Matthias 2023-03-08 20:22:36 +01:00
parent 7e0c92b545
commit 72083b2449

View File

@ -14,16 +14,26 @@ import ProfitPill from '@/components/general/ProfitPill.vue';
import { computed, PropType } from 'vue';
type modes = 'default' | 'total' | 'realized';
const props = defineProps({
trade: { required: true, type: Object as () => Trade },
mode: {
required: false,
default: 'default',
type: String as PropType<'default' | 'total' | 'realized'>,
type: String as PropType<modes>,
},
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const modeDescs: { [key in modes]: string } = {
default: 'Current profit',
total: 'Total profit',
realized: 'Realized profit',
};
const profitDesc = computed((): string => {
let profit = `Current profit: ${formatPercent(props.trade.profit_ratio)} (${
let profit = `${modeDescs[props.mode]}: ${formatPercent(props.trade.profit_ratio)} (${
props.trade.profit_abs
})`;
profit += `\nOpen since: ${timestampms(props.trade.open_timestamp)}`;