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 () => {
|
const handleStop = async () => {
|
||||||
setIsStopping(true);
|
setIsStopping(true);
|
||||||
try {
|
try {
|
||||||
await stopStrategy();
|
const result = await stopStrategy();
|
||||||
setFreshStartRequested(false);
|
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) {
|
} catch (error: any) {
|
||||||
toast({
|
toast({
|
||||||
title: "Stop failed",
|
title: "Stop failed",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user