<?php
/**
 * Toast or alert notifications partial.
 *
 * @package    100Prints
 */

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

/**
 * Render an admin toast/notification.
 *
 * @param string $type        The type of notice (success, error, warning, info).
 * @param string $message     The text contents of the notice.
 * @param bool   $dismissible Whether the notice can be closed by the user.
 */
function render_100p_notice( $type, $message, $dismissible = true ) {
	$class = 'hundredp-notice--info';
	$icon  = 'ph-info';

	switch ( $type ) {
		Case 'success':
			$class = 'hundredp-notice--success';
			$icon  = 'ph-check-circle';
			Break;
		Case 'error':
			$class = 'hundredp-notice--error';
			$icon  = 'ph-x-circle';
			Break;
		Case 'warning':
			$class = 'hundredp-notice--warning';
			$icon  = 'ph-warning';
			Break;
	}
	?>
	<div class="hundredp-notice <?php echo esc_attr( $class ); ?>" role="alert">
		<i class="ph-bold <?php echo esc_attr( $icon ); ?>"></i>
		<span><?php echo esc_html( $message ); ?></span>
		<?php if ( $dismissible ) : ?>
			<button class="hundredp-notice__close" aria-label="Dismiss">
				<i class="ph-bold ph-x"></i>
			</button>
		<?php endif; ?>
	</div>
	<?php
}
