You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Description
The project detail page is read-only. Users with the
ManageProjectsrole 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 theCanManageProjectspolicy.Backend behaviour (already implemented):
PUT /api/projects/{id}ProjectPUT /api/projects/{id}/statusProject{ "status": "Open" | "TeamConfirmed" | "Closed" }. 409 if transition not allowed.DELETE /api/projects/{id}Closed.Valid status transitions:
Draft → Open(publish)Open → ClosedTeamConfirmed → ClosedClosed → (nothing)Auth: All actions require
currentUser.role === "ManageProjects". Controls should only render for users with this role.Patterns to follow:
app/projects/[projectId]/actions.ts(see existingsubmitForAnalysisaction)frontend/app/projects/new/_CreateProjectForm.tsx(same four fields, pre-populated)frontend/lib/api/projects.tsusing existingapiRequest/apiRequestNoContenthelpersTasks
updateProject(projectId, request, token),transitionProjectStatus(projectId, status, token), andcloseProject(projectId, token)tofrontend/lib/api/projects.tsupdateProjectAction,publishProjectAction, andcloseProjectActionserver actions tofrontend/app/projects/[projectId]/actions.ts; revalidate/projects/${projectId}on successfrontend/app/projects/[projectId]/_EditProjectForm.tsx— client component, pre-populated with current values, same field set as_CreateProjectForm.tsxfrontend/app/projects/[projectId]/page.tsxto fetchcurrentUserin parallel withproject, derivecanManage, and conditionally render:DraftorOpen)Draft)Closed)