Skip to content

Add Projects management feature with full CRUD#759

Open
devin-ai-integration[bot] wants to merge 5 commits into
mainfrom
devin/1778703164-add-projects-feature
Open

Add Projects management feature with full CRUD#759
devin-ai-integration[bot] wants to merge 5 commits into
mainfrom
devin/1778703164-add-projects-feature

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented May 13, 2026

Summary

Adds a complete "Projects" management feature to the timesheet application, following all existing codebase patterns. Each project has a name, description, client assignment, start date, and status (active/completed/on-hold).

Backend

  • Database: Added projects table in database/init.js with id, name, description, client_id (FK), start_date, status, user_email (FK), and timestamps. Added indexes on client_id, user_email, and status.
  • Validation: Added projectSchema and updateProjectSchema Joi schemas in validation/schemas.js with status constrained to active | completed | on-hold.
  • Routes: Created routes/projects.js with full CRUD — GET /, GET /:id, POST /, PUT /:id, DELETE /:id. Includes client ownership verification on create/update, dynamic SET clause for partial updates, and consistent response shapes. Uses extracted helpers (handleDbError, parseIdParam, findOwnedRecord, verifyClientOwnership, buildDynamicUpdate, fetchProject) to minimize duplication.
  • Registration: Added app.use('/api/projects', projectRoutes) in server.js.
  • Tests: 30 test cases covering all CRUD operations, validation, ownership checks, and error handling paths. Uses shared mock helpers and test.each for concise validation tests.

Frontend

  • Types: Added Project, CreateProjectRequest, UpdateProjectRequest interfaces in types/api.ts.
  • API client: Added getProjects, getProject, createProject, updateProject, deleteProject methods to ApiClient.
  • Page: Created ProjectsPage.tsx with MUI table, dialog form (name, client select, date picker, status select, description), status color chips, loading/empty/error states. Uses extracted extractApiError, formatLocalDate utilities, INITIAL_FORM constant, and isSaving derived state.
  • Routing: Added /projects route in App.tsx and sidebar nav entry with FolderSpecial icon in Layout.tsx.

Review & Testing Checklist for Human

  • Verify the Projects page renders correctly — create, edit, and delete a project via the UI
  • Confirm status values (active, completed, on-hold) display with correct chip colors
  • Test that creating a project requires an existing client (select dropdown)
  • Verify deleting a client cascades to its associated projects (via FK CASCADE)

Notes

  • All 196 backend tests pass (including 30 new project tests). Frontend lint and build pass cleanly. SonarCloud Quality Gate passes (duplication < 3%).
  • Follows the same patterns as the existing Clients and Work Entries features: user-scoped data, Joi validation, dynamic partial updates, React Query mutations with cache invalidation, MUI dialog forms.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/67bc01cacc714833a0ace61369709b40


Open in Devin Review

Backend:
- Add projects table with client FK, start_date, status, user_email scoping
- Add Joi validation schemas (projectSchema, updateProjectSchema)
- Add /api/projects routes (GET, GET/:id, POST, PUT/:id, DELETE/:id)
- Register project routes in server.js
- Add comprehensive test suite (30 tests)

Frontend:
- Add Project TypeScript interfaces
- Add project CRUD methods to ApiClient
- Add ProjectsPage with MUI table, dialog form, status chips
- Add route and sidebar navigation entry
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Extract PROJECT_SELECT, FIELD_MAP, verifyClientOwnership, buildDynamicUpdate,
  fetchProject helpers in routes/projects.js
- Extract mock helpers (mockGetReturns, mockRunSucceeds, etc.) and shared
  constants (SAMPLE_PROJECT, VALID_INPUT) in tests
- Use test.each for validation test cases
Backend: Extract handleDbError, parseIdParam, findOwnedRecord helpers
to eliminate repeated error handling and ID parsing patterns.

Frontend: Extract extractApiError utility and INITIAL_FORM constant,
consolidate mutation callbacks via invalidateAndClose/invalidateOnly.
devin-ai-integration[bot]

This comment was marked as resolved.

- Use projectId === null instead of !projectId to handle ID 0 correctly
- Send description as-is (empty string) to allow clearing descriptions
- Use local date extraction instead of toISOString() to avoid timezone off-by-one
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants