// /app/api/categories/[id]/options/route.js
import { NextRequest } from 'next/server';
export async function POST(request: Request | NextRequest, { params }:  { params: Promise<{ id: string }> }) {
    try {
      const { id } = await params;
      const data = await request.json();
  
      console.log("Received options data for update:", data);
  
      // Sending data to the backend
      const response = await fetch(`${process.env.BACKEND_URL}/api/v1/categories/${id}/options`, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          // Other required headers such as authentication token
        },
        body: JSON.stringify(data),
      });
  
      if (!response.ok) {
        const errorData = await response.json();
        return Response.json(errorData, { status: response.status });
      }
  
      const result = await response.json();
      return Response.json(result);
    } catch (error) {
      console.error('Error updating category options:', error);
      return Response.json({ message: 'Internal server error' }, { status: 500 });
    }
  }