Handle live strategy stop states gracefully

This commit is contained in:
Thigazhezhilan J 2026-04-01 09:49:42 +05:30
parent fb9a5dbb18
commit 5577de7b9e

View File

@ -901,8 +901,27 @@ export default function PortfolioSection() {
const handleStop = async () => { const handleStop = async () => {
setIsStopping(true); setIsStopping(true);
try { try {
await stopStrategy(); const result = await stopStrategy();
if (result?.status === "stopped") {
setFreshStartRequested(false); setFreshStartRequested(false);
if (result?.warning) {
toast({
title: "Strategy stopped",
description: `Stopped with warning: ${result.warning}`,
});
}
} else if (result?.status === "already_stopped") {
setFreshStartRequested(false);
toast({
title: "Strategy already stopped",
description: "The live strategy was already inactive.",
});
} else {
toast({
title: "Stop failed",
description: result?.message || result?.status || "Unable to stop strategy.",
});
}
} catch (error: any) { } catch (error: any) {
toast({ toast({
title: "Stop failed", title: "Stop failed",