require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');

const supabase = createClient(
  process.env.SUPABASE_URL,
  process.env.SUPABASE_SERVICE_KEY
);

const REQUESTER_ID = '97c472eb-7db6-4639-90f0-a48047b2e46e';

const aiEligibleTasks = [
  // RESEARCH (10 tasks)
  { title: 'Find top 5 coffee shops in Tokyo', category: 'research', budget: 150, description: 'Search online and list 5 highly-rated coffee shops in Tokyo with addresses.' },
  { title: 'Research Bitcoin price history 2025', category: 'research', budget: 200, description: 'Find and summarize Bitcoin price movements in 2025.' },
  { title: 'List 10 healthy breakfast ideas', category: 'research', budget: 100, description: 'Research 10 quick healthy breakfast options.' },
  { title: 'Find best budget laptops under $500', category: 'research', budget: 250, description: 'List 5 best-rated laptops under $500 with specs.' },
  { title: 'Research top AI tools for writers', category: 'research', budget: 200, description: 'Find 5 AI writing tools with features and pricing.' },
  { title: 'Find coworking spaces in London', category: 'research', budget: 150, description: 'List 5 popular coworking spaces in London.' },
  { title: 'Research electric cars 2026', category: 'research', budget: 300, description: 'Compare top 5 electric vehicles by range and price.' },
  { title: 'Find popular startup podcasts', category: 'research', budget: 100, description: 'List 5 highly-rated podcasts about startups.' },
  { title: 'Research protein powder brands', category: 'research', budget: 150, description: 'Compare 5 popular protein powder brands.' },
  { title: 'Find remote job boards', category: 'research', budget: 100, description: 'List 10 websites for remote work opportunities.' },
  // WRITING (10 tasks)
  { title: 'Write 3 sunset Instagram captions', category: 'writing', budget: 100, description: 'Write 3 engaging captions for sunset photos with hashtags.' },
  { title: 'Create coffee shop slogans', category: 'writing', budget: 150, description: 'Write 5 creative slogans for Bean Dreams coffee shop.' },
  { title: 'Write headphone product description', category: 'writing', budget: 200, description: 'Write 150-word description for wireless headphones.' },
  { title: 'Create email subject lines', category: 'writing', budget: 100, description: 'Write 10 subject lines for fitness app launch.' },
  { title: 'Write LinkedIn bio for developer', category: 'writing', budget: 150, description: 'Write professional 100-word LinkedIn bio.' },
  { title: 'Create eco brand taglines', category: 'writing', budget: 150, description: 'Write 5 taglines for eco-friendly brand GreenThread.' },
  { title: 'Write meditation app description', category: 'writing', budget: 250, description: 'Write 200-word app store description.' },
  { title: 'Create productivity Twitter thread', category: 'writing', budget: 100, description: 'Write 5-tweet thread about remote work tips.' },
  { title: 'Write Italian pasta descriptions', category: 'writing', budget: 200, description: 'Write descriptions for 5 Italian pasta dishes.' },
  { title: 'Create YouTube cooking titles', category: 'writing', budget: 100, description: 'Write 10 video titles for cooking channel.' },
  // CONTENT CREATION (5 tasks)
  { title: 'Write beach vacation captions', category: 'content_creation', budget: 100, description: 'Write 5 Instagram captions for beach photos.' },
  { title: 'Create gym motivation quotes', category: 'content_creation', budget: 75, description: 'Write 10 short motivational fitness quotes.' },
  { title: 'Write tech blog intro paragraph', category: 'content_creation', budget: 150, description: 'Write engaging intro for article about AI trends.' },
  { title: 'Create dating app bio examples', category: 'content_creation', budget: 100, description: 'Write 5 witty dating profile bio examples.' },
  { title: 'Write podcast episode descriptions', category: 'content_creation', budget: 150, description: 'Write descriptions for 3 podcast episodes about finance.' },
  // TRANSLATION (5 tasks)
  { title: 'Translate menu to Spanish', category: 'translation', budget: 200, description: 'Translate: Grilled Salmon, Caesar Salad, Mushroom Risotto, Chocolate Cake.' },
  { title: 'Translate UI strings to French', category: 'translation', budget: 250, description: 'Translate: Welcome, Settings, Log Out, Save, Cancel, Profile.' },
  { title: 'Translate categories to German', category: 'translation', budget: 150, description: 'Translate: Electronics, Clothing, Home and Garden, Sports, Books.' },
  { title: 'Translate greeting to 5 languages', category: 'translation', budget: 200, description: 'Translate Welcome to our store to Spanish, French, German, Italian, Portuguese.' },
  { title: 'Translate error messages to Japanese', category: 'translation', budget: 300, description: 'Translate: Invalid email, Password too short, Connection failed.' },
];

async function createTasks() {
  console.log('📌 Creating 30 AI-eligible tasks...\n');
  let created = 0;
  
  for (const task of aiEligibleTasks) {
    const { data, error } = await supabase
      .from('tasks')
      .insert({
        title: task.title,
        description: task.description,
        category: task.category,
        budget: task.budget,
        requester_id: REQUESTER_ID,
        max_workers: 2,
        current_workers: 0,
        status: 'active',
        is_local: false
      })
      .select('id, title, category, budget')
      .single();
      
    if (error) {
      console.log(`❌ ${task.title}: ${error.message}`);
    } else {
      console.log(`✅ ${data.title} (${data.category}, Ⓥ${data.budget})`);
      created++;
    }
  }
  
  console.log(`\n========================================`);
  console.log(`✅ Created ${created}/30 tasks`);
  console.log(`========================================`);
}

createTasks().then(() => process.exit(0));
