<?php
declare(strict_types=1);

require_once __DIR__ . '/../includes/api_auth.php';

$familyId = api_current_family_id();
$pdo = db();

$stmt = $pdo->prepare('SELECT id, family_id, name, username, is_active, last_login_at, created_at, updated_at
    FROM caregiver_accounts
    WHERE family_id = ?
    ORDER BY name ASC, id ASC');
$stmt->execute([$familyId]);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];

api_json([
    'success' => true,
    'caregivers' => $rows,
]);
