<?php

require __DIR__ . '/../bootstrap.php';

use Pesisportaali\Core\Response;

if (!$pdo instanceof PDO) {
    Response::json([
        'success' => false,
        'error' => 'Tietokantayhteys ei muodostunut',
    ], 500);
}

$stmt = $pdo->query("SELECT slug, name, primary_color FROM pp_clubs WHERE active = 1");
$clubs = $stmt->fetchAll();

Response::json([
    'success' => true,
    'clubs' => $clubs,
]);
