<?php

use MintyPHP\Session;

$listPurgeEnabled = (bool) ($listPurgeEnabled ?? false);
if (!$listPurgeEnabled) {
  return;
}

$listPurgeFormId = trim((string) ($listPurgeFormId ?? ''));
$listPurgeAction = trim((string) ($listPurgeAction ?? ''));
$listPurgeConfirmMessage = (string) ($listPurgeConfirmMessage ?? '');
$listPurgeButtonLabel = (string) ($listPurgeButtonLabel ?? '');
$listPurgeButtonClass = trim((string) ($listPurgeButtonClass ?? 'outline secondary'));
$listPurgeButtonIconClass = trim((string) ($listPurgeButtonIconClass ?? 'bi bi-trash'));

if ($listPurgeFormId === '' || $listPurgeAction === '' || $listPurgeButtonLabel === '') {
  return;
}
?>
<form id="<?php e($listPurgeFormId); ?>" method="post" action="<?php e($listPurgeAction); ?>">
  <?php Session::getCsrfInput(); ?>
</form>
<button
  type="submit"
  form="<?php e($listPurgeFormId); ?>"
  class="<?php e($listPurgeButtonClass); ?>"
  <?php if ($listPurgeConfirmMessage !== ''): ?>data-confirm-message="<?php e($listPurgeConfirmMessage); ?>"<?php endif; ?>
>
  <i class="<?php e($listPurgeButtonIconClass); ?>"></i> <?php e($listPurgeButtonLabel); ?>
</button>
