Skip to content

[GOOD FIRST ISSUE] Add 'Create Goal' form UI to GoalTracker #13

@Priyanshu-byte-coder

Description

@Priyanshu-byte-coder

What needs to be done

Add a form inside the GoalTracker component that lets users create a new weekly goal directly from the dashboard — no API client needed.

Why this matters

Currently GoalTracker only displays goals. Creating one requires hitting the API manually. This form is the missing UX piece.

Exact file to edit

src/components/GoalTracker.tsx (lines 38–70 — the return block)

What to build

Add a small form below the goals list (or a toggle button that reveals it):

// State to add at the top of the component
const [label, setLabel] = useState("");
const [target, setTarget] = useState(7);
const [creating, setCreating] = useState(false);

// Submit handler
async function handleCreate(e: React.FormEvent) {
  e.preventDefault();
  setCreating(true);
  await fetch("/api/goals", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ label, target }),
  });
  setLabel("");
  setTarget(7);
  setCreating(false);
  // re-fetch goals here
}

Form fields needed:

  • label — text input, e.g. "Commit every day"
  • target — number input, e.g. 7 (commits per week)
  • Submit button — shows spinner while creating === true

Acceptance criteria

  • Form renders below existing goals (or behind a "+ Add goal" toggle)
  • Submitting calls POST /api/goals with { label, target }
  • Goals list refreshes after successful creation
  • Empty state updates once first goal is created
  • npm run lint and npm run type-check pass

Setup

See DEVELOPMENT.md to get running locally.

Mentorship

Comment "I'd like to work on this" to get assigned.

Metadata

Metadata

Labels

good first issueGood for newcomersgssoc26GSSoC 2026 contributionlevel1GSSoC Level 1 - Beginner (10 points)~2hEstimated 2 hours

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions