#!/usr/bin/env node

// Update task status to 'review' via Supabase API
const SUPABASE_URL = 'https://qnatchrjlpehiijwtreh.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFuYXRjaHJqbHBlaGlpand0cmVoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzE2NDA0MzYsImV4cCI6MjA4NzIxNjQzNn0.47XOMrQBzcQEh71phQflPoO4v79Jk3rft7BC72KHDvA';
const TASK_ID = '66f1146e-41c4-4b03-a292-9358b7f9bedb';

async function updateTaskStatus() {
  try {
    console.log('Updating task status to review...');
    
    const response = await fetch(`${SUPABASE_URL}/rest/v1/tasks?id=eq.${TASK_ID}`, {
      method: 'PATCH',
      headers: {
        'Content-Type': 'application/json',
        'apikey': SUPABASE_ANON_KEY,
        'Authorization': `Bearer ${SUPABASE_ANON_KEY}`,
        'Prefer': 'return=minimal'
      },
      body: JSON.stringify({
        status: 'review',
        updated_at: new Date().toISOString()
      })
    });

    if (response.ok) {
      console.log('✅ Task status updated to review successfully!');
    } else {
      const errorText = await response.text();
      console.error('❌ Failed to update task status:', response.status, errorText);
      process.exit(1);
    }
  } catch (error) {
    console.error('❌ Error updating task:', error);
    process.exit(1);
  }
}

updateTaskStatus();
