diff --git a/apps/admin/data/fitai.db b/apps/admin/data/fitai.db index 4b2a8ee..69cf707 100644 Binary files a/apps/admin/data/fitai.db and b/apps/admin/data/fitai.db differ diff --git a/apps/admin/src/app/recommendations/page.tsx b/apps/admin/src/app/recommendations/page.tsx index d8eea63..4cf3c91 100644 --- a/apps/admin/src/app/recommendations/page.tsx +++ b/apps/admin/src/app/recommendations/page.tsx @@ -98,6 +98,41 @@ export default function RecommendationsPage() { } }; + const handleEdit = async (rec: Recommendation) => { + const newContent = prompt("Edit Advice:", rec.content); + const newActivityPlan = prompt("Edit Activity Plan:", rec.activityPlan); + const newDietPlan = prompt("Edit Diet Plan:", rec.dietPlan); + + if (newContent === null || newActivityPlan === null || newDietPlan === null) { + // User cancelled one of the prompts + return; + } + + try { + const res = await fetch("/api/recommendations", { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + id: rec.id, + content: newContent, + activityPlan: newActivityPlan, + dietPlan: newDietPlan, + }), + }); + + if (!res.ok) { + const errorData = await res.json(); + alert(`Failed to update recommendation: ${errorData.error || 'Unknown error'}`); + } else { + alert("Recommendation updated successfully!"); + fetchData(); // Refresh data + } + } catch (error) { + console.error("Error updating recommendation:", error); + alert("Failed to update recommendation."); + } + }; + if (loading) { return (
@@ -171,6 +206,12 @@ export default function RecommendationsPage() {
+