package infra

import "fmt"

// MetabaseCreateDashboard crea un nuevo dashboard en Metabase.
// name: nombre del dashboard (obligatorio).
// description: descripcion opcional (vacio = sin descripcion).
// collectionID: ID de la coleccion/carpeta (0 = root).
func MetabaseCreateDashboard(client MetabaseClient, name, description string, collectionID int) (map[string]any, error) {
	body := map[string]any{
		"name": name,
	}
	if description != "" {
		body["description"] = description
	}
	if collectionID > 0 {
		body["collection_id"] = collectionID
	}

	result, err := metabaseRequest("POST", client.BaseURL, client.Token, "/api/dashboard", body)
	if err != nil {
		return nil, fmt.Errorf("metabase create dashboard: %w", err)
	}

	return result, nil
}
