Fix hydration error by handling time display on client-side and add stop-loss/take-profit to trading system
This commit is contained in:
@@ -15,6 +15,16 @@ interface Trade {
|
||||
export default function TradingHistory() {
|
||||
const [trades, setTrades] = useState<Trade[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [isClient, setIsClient] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setIsClient(true)
|
||||
}, [])
|
||||
|
||||
const formatTime = (dateString: string) => {
|
||||
if (!isClient) return '--:--:--'
|
||||
return new Date(dateString).toLocaleTimeString()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchTrades() {
|
||||
@@ -146,7 +156,7 @@ export default function TradingHistory() {
|
||||
</span>
|
||||
</td>
|
||||
<td className="py-4 px-4 text-right text-xs text-gray-400">
|
||||
{new Date(trade.executedAt).toLocaleTimeString()}
|
||||
{formatTime(trade.executedAt)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user