<?php

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

$awards = $args['awards'] ?? array();

if ( empty( $awards ) ) {
	return;
}

$date_format = get_option( 'date_format' );

?>
<div class="gn-section gn-awards-section">
	<div class="gn-head">
		<h3 class="gn-title"><?php esc_html_e( 'Awards', 'gigneo' ); ?></h3>
	</div>
	<div class="gn-body">
		<div class="gn-awards">
			<ul class="gn-info-list">
				<?php
				foreach ( $awards as $key => $award_item ) {
					$award_title = ! empty( $award_item['title'] ) ? $award_item['title'] : '';
					$award_by    = ! empty( $award_item['award_by'] ) ? $award_item['award_by'] : '';
					$award_date  = ! empty( $award_item['date'] ) ? date_i18n( $date_format, strtotime( $award_item['date'] ), true ) : '';

					if ( empty( $award_title ) || empty( $award_by ) ) {
						continue;
					}
					?>
					<li class="gn-info-list-item">
						<span class="gn-icon">
							<i class="hi hi-trophy" aria-hidden="true"></i>
						</span>
						<div class="gn-info">
							<?php if ( ! empty( $award_title ) ) { ?>
								<h4 class="gn-title"><?php echo esc_html( $award_title ); ?></h4>
							<?php } ?>
							<ul class="gn-meta">
								<li class="gn-award-by">
									<i class="hi hi-building-office" aria-hidden="true"></i>
									<?php echo esc_html( $award_by ); ?>
								</li>
								<?php if ( ! empty( $award_date ) ) { ?>
									<li class="gn-date">
										<i class="hi hi-calendar" aria-hidden="true"></i>
										<?php echo esc_html( $award_date ); ?>
									</li>
								<?php } ?>
							</ul>
						</div>
					</li>
				<?php } ?>
			</ul>
		</div>
	</div>
</div>
