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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user