<?php
include "includes/header.php";

// Carregar o arquivo JSON
$jsonPath = 'img/api.json';
if (file_exists($jsonPath)) {
    $jsonData = file_get_contents($jsonPath);
    $dataArray = json_decode($jsonData, true);

    // Verificar se os dados são válidos
    if ($dataArray && isset($dataArray['data'][0])) {
        $data = $dataArray['data'][0];
        $name = $data['name'] ?? '';
    } else {
        echo "Erro: JSON inválido ou vazio.";
        exit;
    }
} else {
    echo "Erro: Arquivo JSON não encontrado.";
    exit;
}
?>


    <div class="row justify-content-center">
        <div class="card radius-10">
            <h1 class="text-center mb-4">Editar Nome</h1>

            <!-- Exibir informações -->
            <form method="post" action="atualizar.php" class="shadow p-4 rounded bg-light">
                <div class="form-group mb-3">
                    <label for="name" class="form-label">Nome:</label>
                    <input type="text" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" class="form-control" placeholder="Digite o nome" />
                </div>
                <div class="text-center">
                    <button type="submit" class="btn btn-primary w-100">Salvar Alterações</button>
                </div>
            </form>
        </div>
    </div>
</div>

<?php
include "includes/footer.php";
?>
