<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
	$menu_items = array(
		'reviews' => __( 'Given Reviews', 'academy' ),
	);

	if ( current_user_can( 'manage_academy_instructor' ) ) {
		$menu_items['received-reviews'] = __( 'Received Reviews', 'academy' );
	}

	\Academy\Helper::get_template(
		'frontend-dashboard/pages/partials/sub-menu.php', [
			'menu' => apply_filters( 'academy/templates/frontend-dashboard/given-reviews-content-menu', $menu_items )
		]
	);

	?>

<div class="academy-dashboard-reviews academy-dashboard__content">
		<div class="academy-dashboard-mini-tabs">
			<div id="tab-panel-0-given-view" role="tabpanel" aria-labelledby="tab-panel-0-given" class="components-tab-panel__tab-content" tabindex="0">
				<div class="academy-tab-content">
					<?php if ( ! empty( $reviews ) ) : ?>
						<?php foreach ( $reviews as $review ) : ?>
							<?php
							$post_title     = get_the_title( $review->comment_post_ID );
							$post_permalink = esc_url( get_the_permalink( $review->comment_post_ID ) );
							?>
						<div class="academy-dashboard-reviews__given">
						<div class="academy-dashboard-review">
							<div class="academy-dashboard-review__header">Course:<a href="<?php echo esc_html( $post_permalink ); ?>"><?php echo esc_html( $post_title ); ?></a></div>
							<div class="academy-dashboard-review__content"><div>
									<?php echo wp_kses_post( \Academy\Helper::star_rating_generator( $review->rating ) ); ?>
								<span class="time"><?php echo esc_html( $review->comment_date ); ?> </span>
							</div>
							<p><?php echo esc_html( $review->comment_content ); ?></p>
						</div>
						</div>
						<?php endforeach; ?>
						<?php else : ?>
						<div class="academy-not-found"><?php echo esc_html__( 'You havent given any reviews yet.', 'academy' ); ?></div>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>
</div>
