export const prerender = false;

import type { APIRoute } from 'astro';
import { supabase } from '../../../../lib/supabase';

export const DELETE: APIRoute = async ({ params }) => {
  const { id } = params;

  if (!id) {
    return new Response(JSON.stringify({ 
      success: false, 
      error: 'Override ID is required' 
    }), { status: 400 });
  }

  try {
    const { error } = await supabase
      .from('event_pricing_overrides')
      .delete()
      .eq('id', id);

    if (error) {

      return new Response(JSON.stringify({ 
        success: false, 
        error: 'Failed to delete pricing override' 
      }), { status: 500 });
    }

    return new Response(JSON.stringify({ 
      success: true 
    }), { status: 200 });

  } catch (error) {

    return new Response(JSON.stringify({ 
      success: false, 
      error: 'Internal server error' 
    }), { status: 500 });
  }
};