Save ticker and last decision to DB; add order suggestion UI; upsert stocks with execution details; ensure analysis saves ticker

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-05-16 14:06:45 +02:00
parent 3a681fa309
commit 24c7ee2bf1
3 changed files with 66 additions and 7 deletions
+20 -2
View File
@@ -23,8 +23,26 @@ export async function action({ request }: { request: Request }) {
return Response.json({ success: true });
}
const stock = await db.stock.create({
data: { ticker },
// Optional fields to save/update
const lastDecision = formData.get("lastDecision")?.toString();
const lastExplanation = formData.get("lastExplanation")?.toString();
const lastExecutionPlan = formData.get("lastExecutionPlan")?.toString();
// Upsert the stock record so ticker is ensured and optional fields are saved
const stock = await db.stock.upsert({
where: { ticker },
update: {
lastDecision: lastDecision ?? undefined,
lastExplanation: lastExplanation ?? undefined,
lastExecutionPlan: lastExecutionPlan ?? undefined,
},
create: {
ticker,
lastDecision: lastDecision ?? undefined,
lastExplanation: lastExplanation ?? undefined,
lastExecutionPlan: lastExecutionPlan ?? undefined,
},
});
return Response.json(stock);
}