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
Here's an optimized version of your tasks for Cursor to build, test, and review. I've added more structure, clarity, and some best practices to ensure efficient execution.