Handle live strategy stop states gracefully
This commit is contained in:
parent
fb9a5dbb18
commit
5577de7b9e
@ -901,8 +901,27 @@ export default function PortfolioSection() {
|
||||
const handleStop = async () => {
|
||||
setIsStopping(true);
|
||||
try {
|
||||
await stopStrategy();
|
||||
setFreshStartRequested(false);
|
||||
const result = await stopStrategy();
|
||||
if (result?.status === "stopped") {
|
||||
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) {
|
||||
toast({
|
||||
title: "Stop failed",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user