Action | Type | Resolved On |
|---|---|---|
| Create Monthly Goal in FE | feature | 2026-02-03 |
Implemented the ability to create monthly goals directly from the frontend UI when logged in. Users can now set their monthly goal from the Header component when the goal is “Undefined”.
Previously, monthly goals could only be created through direct database access or backend operations. Users had no way to set their monthly goal from the frontend interface, even when authenticated.
Added goal creation functionality to the Header components for both benben and hygge layouts. When a user is authenticated and viewing the current month’s Goal page with an “Undefined” goal, an editable input field appears allowing them to set the goal.
| File | Function | Description |
|---|---|---|
src/lib/new.ts | monthlyGoal(owner, year, month, goalText) | Creates a new monthly goal with due date set to last day of the month |
| Endpoint | Method | Description |
|---|---|---|
/api/new/goal | POST | Accepts owner, year, month, and goal text to create a monthly goal |
| File | Changes |
|---|---|
src/lib/new.ts | Added monthlyGoal() function for inserting new monthly goals |
src/pages/api/new/goal.ts | New API endpoint for creating monthly goals |
src/components/navigation/benben/Header.astro | Added authentication check, goal input form with Save button, and client-side JS for form submission |
src/components/navigation/hygge/Header.astro | Added authentication check, goal input form with Save button, and client-side JS for form submission |
Authentication Check:
const accessToken = Astro.cookies.get("sb-access-token");
const refreshToken = Astro.cookies.get("sb-refresh-token");
let auth = false;
if (accessToken && refreshToken) {
// Validate session with Supabase
auth = true;
}
Edit Condition (only for current month’s undefined goals):
const isCurrentMonth = index === 0; // No date prefix in URL
const isGoalPage = loc === "" && heading !== undefined;
const canEdit = auth && isGoalPage && isCurrentMonth && heading === "Undefined";
Goal Insert Logic:
const dueDate = format(
new Date(year, month, 0), // Day 0 of next month = last day of current month
"yyyy-MM-dd",
);
const { error } = await supabase
.from("Goals")
.insert({ goal: goalText, due: dueDate, owner: owner, monthly: true });
/benben or /hygge (current month’s Goal page)heading === "Undefined" - this is an insert-only operation