Skip to content

Feature/project edit, publish, and close actions #60

Description

@dcl10

Description

The project detail page is read-only. Users with the ManageProjects role should be able to edit a project's details, publish it from Draft to Open, and close it. All three backend endpoints already exist and are protected by the CanManageProjects policy.

Backend behaviour (already implemented):

Action Endpoint Returns Notes
Edit details PUT /api/projects/{id} Project Same fields as create (title, description, desiredTeamSize, timeline). 409 if invalid state.
Transition status PUT /api/projects/{id}/status Project Body: { "status": "Open" | "TeamConfirmed" | "Closed" }. 409 if transition not allowed.
Close DELETE /api/projects/{id} 204 No Content Convenience wrapper — transitions project to Closed.

Valid status transitions:

  • Draft → Open (publish)
  • Open → Closed
  • TeamConfirmed → Closed
  • Closed → (nothing)

Auth: All actions require currentUser.role === "ManageProjects". Controls should only render for users with this role.

Patterns to follow:

  • Server actions: app/projects/[projectId]/actions.ts (see existing submitForAnalysis action)
  • Edit form: mirror frontend/app/projects/new/_CreateProjectForm.tsx (same four fields, pre-populated)
  • API functions: add to frontend/lib/api/projects.ts using existing apiRequest / apiRequestNoContent helpers

Tasks

  • Add updateProject(projectId, request, token), transitionProjectStatus(projectId, status, token), and closeProject(projectId, token) to frontend/lib/api/projects.ts
  • Add updateProjectAction, publishProjectAction, and closeProjectAction server actions to frontend/app/projects/[projectId]/actions.ts; revalidate /projects/${projectId} on success
  • Create frontend/app/projects/[projectId]/_EditProjectForm.tsx — client component, pre-populated with current values, same field set as _CreateProjectForm.tsx
  • Update frontend/app/projects/[projectId]/page.tsx to fetch currentUser in parallel with project, derive canManage, and conditionally render:
    • Edit button / inline form (shown when project is Draft or Open)
    • "Publish" button (shown when status is Draft)
    • "Close project" button with a destructive confirmation (shown when status is not Closed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions