File: components/MarketItemCard.jsx
Action: Add + button with Tailwind styling (e.g., bg-blue-500 hover:bg-blue-700 text-white)
Logic: On click, trigger project linking function
Output: Updated component with button and click handler
Create Utility Function for Project Name Generation
File: utils/supabase/projects.js
Action: Create generateProjectName function to:
Fetch user’s first name from profiles table
Return string: [First Name]'s First Project
Handle edge cases (e.g., missing first name: use "User's First Project")
Output: Reusable function for project naming
Implement Project Linking Logic
File: utils/supabase/projects.js
Action: Create linkToProject function to:
Check if user has existing project in projects table
Upsert projects record with:
user_id
market_item_id
project_name (from generateProjectName)
Input: user_id, market_item_id
Output: Updated or new project record
Ensure: RLS policy allows authenticated users to upsert their own projects
Develop Project Management UI and Logic
File: pages/projects/[id].jsx
Action: Update placeholder project page to:
Display linked market_item details (fetch from projects table)
Add "Remove" button to set market_item_id to NULL
Add "Swap" button to open modal for selecting new market_item_id
Implement Supabase update queries for remove/swap actions
Output: Functional project page with design management
Notes for Cursor Implementation
Use Next.js dynamic imports for performance (e.g., dynamic(() => import('../components/MarketItemCard')))
Ensure all Supabase queries handle errors and loading states
Test RLS policies locally using Supabase CLI
Validate UI responsiveness with Tailwind (mobile-first)
Commit changes incrementally with clear messages (e.g., "Add favorite button to MarketItemCard")
Assistant
Optimized Task Specification for Cursor
As your Expert Software Engineer, I've reviewed your draft and refined it to ensure maximum clarity, minimal ambiguity, and optimal build outcomes for Cursor. Here's the enhanced version:
Cursor, your mission is to implement project linking and management features across multiple components, utilities, and pages while ensuring performance, security, and responsiveness. Follow these tasks sequentially:
Task 1: Add Project Linking Button to MarketItemCard
File:components/MarketItemCard.jsx Objective: Embed a "+" button to link market items to projects. Specifications:
UI Requirements:
Add a circular + button at the bottom-right of the card.
Log errors with console.error and notify users with user-friendly alerts.
Testing:
Run local Supabase instance (supabase start) to validate RLS policies.
Test mobile responsiveness (320px, 768px, 1024px breakpoints).
Commits:
Follow the commit messages provided after each task.
Group related changes (e.g., all projects.js updates in one commit).
Code Quality:
Lint with ESLint (next lint).
Format with Prettier (prettier --write .).
Final Deliverables:
Fully functional project linking flow.
Dynamic project management page.
Tested RLS policies.
Mobile-responsive UI.
Estimated Time Breakdown:
Task 1: 30min
Task 2: 45min
Task 3: 1hr
Task 4: 30min
Task 5: 2hr
Total: ~5 hours
Cursor, you're now equipped with laser-focused tasks, clear acceptance criteria, and optimized implementation paths. Execute these steps sequentially, test rigorously, and deliver a production-ready feature set. Happy coding! 🚀