Update the position count and initiator
This commit is contained in:
@@ -60,7 +60,7 @@ const TradesModal: React.FC<TradesModalProps> = ({
|
||||
// Use BotClient instead of fetch
|
||||
const botClient = new BotClient({}, apiUrl)
|
||||
const request: ClosePositionRequest = {
|
||||
identifier: strategyName,
|
||||
identifier: position.initiatorIdentifier,
|
||||
positionId: position.identifier
|
||||
}
|
||||
|
||||
|
||||
@@ -4011,6 +4011,7 @@ export interface Position {
|
||||
identifier: string;
|
||||
initiator: PositionInitiator;
|
||||
user: User;
|
||||
initiatorIdentifier: string;
|
||||
}
|
||||
|
||||
export enum TradeDirection {
|
||||
|
||||
@@ -366,6 +366,7 @@ export interface Position {
|
||||
identifier: string;
|
||||
initiator: PositionInitiator;
|
||||
user: User;
|
||||
initiatorIdentifier: string;
|
||||
}
|
||||
|
||||
export enum TradeDirection {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import React from 'react'
|
||||
import {useQuery} from '@tanstack/react-query'
|
||||
import {useQuery, useQueryClient} from '@tanstack/react-query'
|
||||
import useApiUrlStore from '../../app/store/apiStore'
|
||||
import {fetchPlatformData} from '../../services/platformService'
|
||||
|
||||
function PlatformSummary({index}: { index: number }) {
|
||||
const {apiUrl} = useApiUrlStore()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const {
|
||||
data,
|
||||
@@ -26,11 +27,11 @@ function PlatformSummary({index}: { index: number }) {
|
||||
|
||||
const formatCurrency = (value: number) => {
|
||||
if (value >= 1000000) {
|
||||
return `$${(value / 1000000).toFixed(1)}M`
|
||||
return `$${(value / 1000000).toFixed(2)}M`
|
||||
} else if (value >= 1000) {
|
||||
return `$${(value / 1000).toFixed(1)}K`
|
||||
return `$${(value / 1000).toFixed(2)}K`
|
||||
}
|
||||
return `$${value.toFixed(0)}`
|
||||
return `$${value.toFixed(2)}`
|
||||
}
|
||||
|
||||
const formatNumber = (value: number) => {
|
||||
@@ -67,6 +68,12 @@ function PlatformSummary({index}: { index: number }) {
|
||||
return `${percentage >= 0 ? '+' : ''}${percentage.toFixed(1)}%`
|
||||
}
|
||||
|
||||
const handleForceRefresh = async () => {
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ['platformData', apiUrl]
|
||||
})
|
||||
}
|
||||
|
||||
// Show loading spinner only on initial load
|
||||
if (isLoading && !data) {
|
||||
return (
|
||||
@@ -366,14 +373,36 @@ function PlatformSummary({index}: { index: number }) {
|
||||
{/* Data Freshness Indicator */}
|
||||
<div className="bg-base-200 rounded-lg p-4">
|
||||
<div className="flex items-center justify-between text-sm text-gray-400">
|
||||
<div className="flex items-center gap-2">
|
||||
<span>Last updated: {platformData?.lastUpdated ? new Date(platformData.lastUpdated).toLocaleString() : 'Unknown'}</span>
|
||||
{isFetching && (
|
||||
<div className="flex items-center gap-1 text-blue-400">
|
||||
<div className="loading loading-spinner loading-xs"></div>
|
||||
<span>Refreshing...</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<span>Last updated: {platformData?.lastUpdated ? new Date(platformData.lastUpdated).toLocaleString() : 'Unknown'}</span>
|
||||
{isFetching && (
|
||||
<div className="flex items-center gap-1 text-blue-400">
|
||||
<div className="loading loading-spinner loading-xs"></div>
|
||||
<span>Refreshing...</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={handleForceRefresh}
|
||||
disabled={isFetching}
|
||||
className="btn btn-xs btn-outline btn-primary disabled:loading"
|
||||
title="Force refresh data"
|
||||
>
|
||||
{isFetching ? (
|
||||
<>
|
||||
<span className="loading loading-spinner loading-xs"></span>
|
||||
Refreshing...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-3 h-3">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" />
|
||||
</svg>
|
||||
Refresh
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
<span>24h snapshot: {platformData?.last24HourSnapshot ? new Date(platformData.last24HourSnapshot).toLocaleString() : 'Unknown'}</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user