diff --git a/.kiro/specs/ultimate-lists-app/tasks.md b/.kiro/specs/ultimate-lists-app/tasks.md new file mode 100644 index 0000000..6be9eb3 --- /dev/null +++ b/.kiro/specs/ultimate-lists-app/tasks.md @@ -0,0 +1,234 @@ +# Implementation Plan: Ultimate Lists App + +- [x] 1. Enhance database schema with missing fields + - Update Prisma schema to add tags (JSON array) and notes fields to Item model + - Run database migration to apply schema changes + - Regenerate Prisma client with updated types + - _Requirements: 5.3, 5.4_ + +- [ ]* 1.1 Write property test for metadata round-trip + - **Property 4: Task metadata round-trip** + - **Validates: Requirements 1.4, 5.1, 5.2, 5.3, 5.4** + +- [x] 2. Implement core server actions for enhanced task operations + - Add updateItem server action with support for all metadata fields + - Add deleteItem server action with proper revalidation + - Add deleteList server action with cascade behavior + - Add updateList server action for renaming + - _Requirements: 1.2, 1.3, 2.4, 2.5_ + +- [ ]* 2.1 Write property test for task updates preserve identity + - **Property 2: Task updates preserve identity** + - **Validates: Requirements 1.2** + +- [ ]* 2.2 Write property test for task deletion + - **Property 3: Task deletion removes from queries** + - **Validates: Requirements 1.3** + +- [ ]* 2.3 Write property test for cascade deletion + - **Property 9: Cascade deletion** + - **Validates: Requirements 2.4** + +- [ ]* 2.4 Write property test for list rename preserves items + - **Property 10: List rename preserves items** + - **Validates: Requirements 2.5** + +- [ ] 3. Implement search functionality + - Create searchItems server action that searches across title, description, notes, and tags + - Add support for list-scoped search vs global search + - Implement text highlighting utility function + - _Requirements: 8.1, 8.2, 8.5_ + +- [ ]* 3.1 Write property test for search result completeness + - **Property 21: Search result completeness** + - **Validates: Requirements 8.1** + +- [ ]* 3.2 Write property test for search highlight correctness + - **Property 22: Search highlight correctness** + - **Validates: Requirements 8.2** + +- [ ]* 3.3 Write property test for search scope correctness + - **Property 24: Search scope correctness** + - **Validates: Requirements 8.5** + +- [ ] 4. Implement filtering and sorting + - Create getItemsByFilter server action with support for priority, completed, tags, and due date filters + - Implement compound filter logic (AND conditions) + - Add sorting by createdAt, dueDate, priority, and title + - Handle null due dates in sorting (place at end) + - _Requirements: 6.1, 6.2, 6.3, 6.5_ + +- [ ]* 4.1 Write property test for sort order correctness + - **Property 15: Sort order correctness** + - **Validates: Requirements 6.1** + +- [ ]* 4.2 Write property test for filter matching correctness + - **Property 16: Filter matching correctness** + - **Validates: Requirements 6.2** + +- [ ]* 4.3 Write property test for compound filter conjunction + - **Property 17: Compound filter conjunction** + - **Validates: Requirements 6.3** + +- [ ]* 4.4 Write property test for null due date sorting + - **Property 19: Null due date sorting** + - **Validates: Requirements 6.5** + +- [ ] 5. Create item detail page and form components + - Build /list/[id]/item/[itemId] page for viewing full item details + - Create ItemForm component with fields for all metadata (priority, due date, tags, notes) + - Create ItemDetail component to display all item information + - Add form validation for item inputs + - _Requirements: 1.1, 1.2, 5.1, 5.2, 5.3, 5.4_ + +- [ ]* 5.1 Write property test for task creation preserves description + - **Property 1: Task creation preserves description** + - **Validates: Requirements 1.1** + +- [ ] 6. Enhance list management UI + - Add ListForm component for creating and editing lists + - Implement list deletion with confirmation dialog + - Add list renaming functionality + - Update ListCard to show accurate item counts + - _Requirements: 2.1, 2.2, 2.4, 2.5_ + +- [ ]* 6.1 Write property test for list creation with unique identifiers + - **Property 6: List creation with unique identifiers** + - **Validates: Requirements 2.1** + +- [ ]* 6.2 Write property test for list retrieval completeness + - **Property 7: List retrieval completeness** + - **Validates: Requirements 2.2** + +- [ ] 7. Build list detail page with item management + - Create /list/[id] page showing all items in a list + - Add ItemCard component with completion toggle, priority badge, and due date display + - Implement inline item creation + - Add item deletion functionality + - Show overdue indicators for past due dates + - _Requirements: 1.3, 1.5, 2.3, 5.5_ + +- [ ]* 7.1 Write property test for task completion toggle + - **Property 5: Task completion toggle** + - **Validates: Requirements 1.5** + +- [ ]* 7.2 Write property test for list filtering correctness + - **Property 8: List filtering correctness** + - **Validates: Requirements 2.3** + +- [ ]* 7.3 Write property test for overdue task identification + - **Property 14: Overdue task identification** + - **Validates: Requirements 5.5** + +- [ ] 8. Add search and filter UI components + - Create SearchBar component with debounced input + - Build FilterPanel component with controls for priority, completion, tags, and due date + - Add sort controls (field and direction) + - Implement filter clear functionality + - Display search results with highlighted text + - _Requirements: 6.1, 6.2, 6.3, 6.4, 8.1, 8.2, 8.3_ + +- [ ]* 8.1 Write property test for filter clear restoration + - **Property 18: Filter clear restoration** + - **Validates: Requirements 6.4** + +- [ ]* 8.2 Write property test for search clear restoration + - **Property 23: Search clear restoration** + - **Validates: Requirements 8.3** + +- [ ] 9. Implement client-side state management + - Create useSearch hook for search state and debouncing + - Create useFilters hook for filter state management + - Create useOptimisticUpdate hook for optimistic UI updates + - Add scroll position preservation logic + - _Requirements: 6.4, 7.4, 8.3_ + +- [ ]* 9.1 Write property test for scroll position preservation + - **Property 20: Scroll position preservation** + - **Validates: Requirements 7.4** + +- [ ] 10. Checkpoint - Ensure all tests pass + - Ensure all tests pass, ask the user if questions arise. + +- [ ] 11. Set up PWA infrastructure + - Create service worker (public/sw.js) with caching strategies + - Implement cache-first strategy for static assets + - Implement stale-while-revalidate for API responses + - Add offline fallback page + - Update manifest.json with complete metadata + - Add service worker registration in app layout + - _Requirements: 4.1, 4.3, 4.4_ + +- [ ]* 11.1 Write property test for offline resource availability + - **Property 12: Offline resource availability** + - **Validates: Requirements 4.4** + +- [ ] 12. Implement offline synchronization + - Create useOfflineSync hook for detecting connectivity + - Implement mutation queue for offline operations + - Add background sync for pending mutations + - Show offline indicator in UI + - Handle sync conflicts gracefully + - _Requirements: 4.5_ + +- [ ]* 12.1 Write property test for offline mutation synchronization + - **Property 13: Offline mutation synchronization** + - **Validates: Requirements 4.5** + +- [ ] 13. Add PWA assets and metadata + - Generate app icons in multiple sizes (192x192, 512x512) + - Create favicon and apple-touch-icon + - Add meta tags for PWA in app layout + - Configure theme color and background color + - Test "Add to Home Screen" functionality in Safari + - _Requirements: 4.1, 4.2_ + +- [ ] 14. Implement responsive design enhancements + - Ensure all components are mobile-responsive + - Add touch-optimized controls (larger tap targets) + - Test on various screen sizes + - Optimize layout for mobile and desktop + - _Requirements: 7.1, 7.2_ + +- [ ] 15. Add visual feedback and polish + - Implement loading states for async operations + - Add success/error toast notifications + - Create smooth transitions between views + - Add empty states for lists and items + - Implement skeleton loaders + - _Requirements: 7.3_ + +- [ ] 16. Implement error handling + - Add try-catch blocks to all server actions + - Implement error boundaries in React components + - Add user-friendly error messages + - Handle database connection failures gracefully + - Implement retry logic for failed operations + - _Requirements: All (error handling is cross-cutting)_ + +- [ ] 17. Add input validation + - Validate all form inputs before submission + - Add inline validation errors + - Prevent empty task/list creation + - Validate date formats + - Sanitize user inputs + - _Requirements: 1.1, 2.1_ + +- [ ] 18. Optimize performance + - Add database indexes for frequently queried fields + - Implement pagination for large lists + - Optimize bundle size with code splitting + - Add loading states to prevent layout shift + - Use React.memo for expensive components + - _Requirements: All (performance is cross-cutting)_ + +- [ ] 19. Final checkpoint - Ensure all tests pass + - Ensure all tests pass, ask the user if questions arise. + +- [ ] 20. End-to-end testing and polish + - Test complete user flows from list creation to task completion + - Verify PWA installation on iOS Safari + - Test offline functionality in real scenarios + - Check accessibility with screen readers + - Verify all requirements are met + - _Requirements: All_ diff --git a/lib/actions.ts b/lib/actions.ts index d8e6ab0..c56c24b 100644 --- a/lib/actions.ts +++ b/lib/actions.ts @@ -60,4 +60,62 @@ export async function toggleItem(itemId: string) { }) revalidatePath(`/list/${item.listId}`) return updated +} + +export async function updateItem( + itemId: string, + data: { + title?: string + description?: string | null + completed?: boolean + priority?: 'low' | 'medium' | 'high' + dueDate?: Date | null + tags?: string[] + notes?: string | null + } +) { + const item = await prisma.item.findUnique({ where: { id: itemId } }) + if (!item) return null + + const updated = await prisma.item.update({ + where: { id: itemId }, + data, + }) + revalidatePath(`/list/${item.listId}`) + return updated +} + +export async function deleteItem(itemId: string) { + const item = await prisma.item.findUnique({ where: { id: itemId } }) + if (!item) return null + + await prisma.item.delete({ + where: { id: itemId }, + }) + revalidatePath(`/list/${item.listId}`) + return { success: true } +} + +export async function deleteList(listId: string) { + await prisma.list.delete({ + where: { id: listId }, + }) + revalidatePath('/') + return { success: true } +} + +export async function updateList( + listId: string, + data: { + title?: string + color?: string + } +) { + const updated = await prisma.list.update({ + where: { id: listId }, + data, + }) + revalidatePath('/') + revalidatePath(`/list/${listId}`) + return updated } \ No newline at end of file