From 213b5c3af1f05bc39b091efcaf00cac55420ea92 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 6 Apr 2023 07:15:05 +0200 Subject: [PATCH] Update tradeList to fix types --- src/components/ftbot/TradeList.vue | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/ftbot/TradeList.vue b/src/components/ftbot/TradeList.vue index 4659e5ad..fa28d8c1 100644 --- a/src/components/ftbot/TradeList.vue +++ b/src/components/ftbot/TradeList.vue @@ -104,6 +104,7 @@ import ForceExitForm from '@/components/ftbot/ForceExitForm.vue'; import { ref, computed, watch } from 'vue'; import { useBotStore } from '@/stores/ftbotwrapper'; import { useRouter } from 'vue-router'; +import { TableField } from 'bootstrap-vue-next'; enum ModalReasons { removeTrade, @@ -134,8 +135,8 @@ const removeTradeVisible = ref(false); const confirmExitText = ref(''); const confirmExitValue = ref(null); -const openFields: Record[] = [{ key: 'actions' }]; -const closedFields: Record[] = [ +const openFields: TableField[] = [{ key: 'actions' }]; +const closedFields: TableField[] = [ { key: 'close_timestamp', label: 'Close date' }, { key: 'exit_reason', label: 'Close Reason' }, ]; @@ -146,8 +147,8 @@ const rows = computed(() => { return props.trades.length; }); -const tableFields: Record[] = [ - props.multiBotView ? { key: 'botName', label: 'Bot' } : {}, +const tableFields: TableField[] = [ + props.multiBotView ? { key: 'botName', label: 'Bot' } : { key: 'actions' }, { key: 'trade_id', label: 'ID' }, { key: 'pair', label: 'Pair' }, { key: 'amount', label: 'Amount' }, @@ -158,19 +159,24 @@ const tableFields: Record[] = [ { key: 'open_rate', label: 'Open rate', - formatter: (value: number) => formatPrice(value), + formatter: (value: unknown) => formatPrice(value as number), }, { key: props.activeTrades ? 'current_rate' : 'close_rate', label: props.activeTrades ? 'Current rate' : 'Close rate', - formatter: (value: number) => formatPrice(value), + formatter: (value: unknown) => formatPrice(value as number), }, { key: 'profit', label: props.activeTrades ? 'Current profit %' : 'Profit %', - formatter: (value: number, key, item: Trade) => { - const percent = formatPercent(item.profit_ratio, 2); - return `${percent} ${`(${formatPriceWithDecimals(item.profit_abs)})`}`; + + formatter: (value: unknown, key?: string, item?: unknown) => { + if (!item) { + return ''; + } + const typedItem = item as Trade; + const percent = formatPercent(typedItem.profit_ratio, 2); + return `${percent} ${`(${formatPriceWithDecimals(typedItem.profit_abs)})`}`; }, }, { key: 'open_timestamp', label: 'Open date' },