<?php
/**
 * @var string $menu_slug
 * @var string $action
 * @var array<string, string> $pnp_types
 * @var string $selected_date
 * @var string $selected_type
 * @var array{type: string, message: string}|null $notice
 *
 * @package DhlPolska\Admin
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

?>

<div class="wrap">
	<h1><?php esc_html_e( 'Potwierdzenie nadania', 'dhl-polska' ); ?></h1>

	<?php if ( $notice ) : ?>
		<div class="notice notice-<?php echo esc_attr( $notice['type'] ); ?> is-dismissible">
			<p><?php echo esc_html( $notice['message'] ); ?></p>
		</div>
	<?php endif; ?>

	<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
		<?php wp_nonce_field( $action ); ?>
		<input type="hidden" name="action" value="<?php echo esc_attr( $action ); ?>">

		<table class="form-table" role="presentation">
			<tbody>
				<tr>
					<th scope="row">
						<label for="shipment_date"><?php esc_html_e( 'Data nadania', 'dhl-polska' ); ?></label>
					</th>
					<td>
						<input type="date" id="shipment_date" name="shipment_date" value="<?php echo esc_attr( $selected_date ); ?>" required>
					</td>
				</tr>
				<tr>
					<th scope="row">
						<label for="shipment_type"><?php esc_html_e( 'Typ przesyłki', 'dhl-polska' ); ?></label>
					</th>
					<td>
						<select id="shipment_type" name="shipment_type" required>
							<?php foreach ( $pnp_types as $pnp_type => $label ) : ?>
								<option value="<?php echo esc_attr( $pnp_type ); ?>" <?php selected( $pnp_type, $selected_type ); ?>>
									<?php echo esc_html( $label ); ?>
								</option>
							<?php endforeach; ?>
						</select>
					</td>
				</tr>
			</tbody>
		</table>

		<?php submit_button( __( 'Generuj potwierdzenie nadania', 'dhl-polska' ) ); ?>
	</form>
</div>
