<?php
/**
 * Status tab – Shift4 APM.
 *
 * @package flo-checkout
 *
 * @phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_print_r
 */

defined( 'ABSPATH' ) || exit;

/**
 * View file parameters.
 *
 * @var array $params
 */
?>
<h2 id="shift4-apm-general-tests"><?php esc_html_e( 'General tests', 'flo-checkout-plugin' ); ?></h2>
<table class="nmf-sync-table">
	<thead>
	<tr>
		<th>Test</th>
		<th>Result</th>
	</tr>
	</thead>
	<tbody>
		<?php foreach ( $params['general'] as $test => $result ) : ?>
			<tr>
				<td><?php echo esc_html( $test ); ?></td>
				<td><?php echo esc_html( $result ); ?></td>
			</tr>
		<?php endforeach; ?>
	</tbody>
</table>

<h2 id="shift4-apple-pay-tests"><?php esc_html_e( 'Apple Pay tests', 'flo-checkout-plugin' ); ?></h2>
<table class="nmf-sync-table">
	<thead>
	<tr>
		<th>Test</th>
		<th>Result</th>
	</tr>
	</thead>
	<tbody>
	<?php foreach ( $params['apple_pay'] as $test => $result ) : ?>
		<tr>
			<td><?php echo esc_html( $test ); ?></td>
			<td><?php echo esc_html( $result ); ?></td>
		</tr>
	<?php endforeach; ?>
	</tbody>
</table>

<h2 id="shift4-apm-health-checks"><?php esc_html_e( 'Health checks', 'flo-checkout-plugin' ); ?></h2>
<table class="nmf-sync-table">
	<thead>
		<tr>
			<th>API</th>
			<th>Available</th>
			<th>Last run</th>
			<th>Last success</th>
		</tr>
	</thead>
	<tbody>
	<?php foreach ( $params['health_checks'] as $health_check ) : ?>
		<tr>
			<td><?php echo esc_html( $health_check['name'] ); ?></td>
			<td><?php echo $health_check['unavailable'] ? '<span class="dashicons dashicons-no"></span>' : '<span class="dashicons dashicons-yes"></span>'; ?></td>
			<td><?php echo esc_html( $health_check['last_run'] ); ?></td>
			<td><?php echo esc_html( $health_check['last_success'] ); ?></td>
		</tr>
	<?php endforeach; ?>
	</tbody>
</table>
