<?php

declare(strict_types=1);

$ctx = require dirname(__DIR__) . '/bootstrap.php';
$container = $ctx['container'];

$page = isset($_GET['page']) ? (string) $_GET['page'] : 'feca-mailshots-mailshots';

$map = [
    'feca-mailshots-mailshots' => FecaMailshots\Admin\MailshotsAdminPage::class,
    'feca-mailshot-data-sources' => FecaMailshots\Admin\DataSourcesAdminPage::class,
    'feca-mailshots-attachments' => FecaMailshots\Admin\AttachmentsAdminPage::class,
    'feca-mailshots-pdf-assets' => FecaMailshots\Admin\PdfAssetsAdminPage::class,
    'feca-mailshots-setup' => FecaMailshots\Admin\SetupAdminPage::class,
    'feca-mailshots-profile' => FecaMailshots\Admin\ProfileAdminPage::class,
    'feca-mailshots-test' => FecaMailshots\Admin\MailshotTestAdminPage::class,
    'feca-mailshots-run' => FecaMailshots\Admin\RunMailshotAdminPage::class,
    'feca-mailshots-review-recipients' => FecaMailshots\Admin\ReviewRecipientsAdminPage::class,
    'feca-mailshots-download-pdf' => FecaMailshots\Admin\DownloadPdfAdminPage::class,
];

if (!isset($map[$page])) {
    http_response_code(404);
    echo 'Unknown admin page';
    exit;
}

$instance = $container->get($map[$page]);
$instance->render();
