<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$order_id = $args['p_id'] ?? '';

if ( ! $order_id ) {
	return;
}
$freelancer_profile_id                = gigneo_post_meta( $order_id, '_gigneo_pm_freelancer_profile_id' );
$freelancer_profile_name              = gigneo_profile_name( $freelancer_profile_id );
$country_state_list                   = gigneo_countries_with_states( 'active' );
$freelancer_profile_image             = gigneo_profile_avatar_url( $freelancer_profile_id, 'freelancer' );
$freelancer_profile_country_state_raw = gigneo_post_meta( $freelancer_profile_id, '_gigneo_pm_country_state' );
$freelancer_profile_tagline           = gigneo_post_meta( $freelancer_profile_id, '_gigneo_pm_tagline' );
$freelancer_profile_country_state     = ! empty( $country_state_list[ $freelancer_profile_country_state_raw ] ) ? $country_state_list[ $freelancer_profile_country_state_raw ] : '—';
?>
<div class="gn-order-section gn-order-participent-info">
	<div class="gn-head">
		<div class="gn-participent-profile-info">
			<figure
				class="gn-avatar gn-<?php echo esc_attr( gigneo_online_status( $freelancer_profile_id ) ? 'online' : 'offline' ); ?>">
				<img src="<?php echo esc_url( $freelancer_profile_image ); ?>"
					alt="<?php echo esc_attr( $freelancer_profile_name ); ?>" />
			</figure>
			<div class="gn-info">
				<div class="gn-name-wrapper">
					<h6 class="gn-name"><?php echo esc_html( $freelancer_profile_name ); ?></h6>
					<?php gigneo_verification_badge( $freelancer_profile_id, true ); ?>
				</div>
				<p class="gn-tagline">
					<?php echo esc_html( ! empty( $freelancer_profile_tagline ) ? $freelancer_profile_tagline : gigneo_freelancer_singular() ); ?>
				</p>
			</div>
		</div>
	</div>
	<div class="gn-body">
		<ul class="gn-additional-info">
			<li class="gn-ratings">
				<span class="gn-label"><?php echo esc_html__( 'Ratings', 'gigneo' ); ?></span>
				<span class="gn-value">
					<i class="hi hi-star-alt gn-filled" aria-hidden="true"></i>
					<?php echo esc_html( gigneo_profile_rating( $freelancer_profile_id, 'average' ) ); ?>
					<em
						class="gn-count">(<?php echo esc_html( gigneo_profile_rating( $freelancer_profile_id ) ); ?>)</em>
				</span>
			</li>
			<li class="gn-orders-completed">
				<span class="gn-label"><?php echo esc_html__( 'Orders completed', 'gigneo' ); ?></span>
				<?php $orders_data = gigneo_profile_stat( 'completed_orders_count', $freelancer_profile_id ); ?>
				<span class="gn-value"><?php echo esc_html( $orders_data['lifetime'] ); ?></span>
			</li>
			<li class="gn-total-earn">
				<span class="gn-label"><?php echo esc_html__( 'Total earns', 'gigneo' ); ?></span>
				<?php $earnings_data = gigneo_profile_stat( 'total_earning', $freelancer_profile_id ); ?>
				<span
					class="gn-value"><?php echo esc_html( gigneo_price_format( $earnings_data['lifetime'], true ) ); ?></span>
			</li>
			<li class="gn-country-state">
				<span class="gn-label"><?php echo esc_html__( 'Country / State', 'gigneo' ); ?></span>
				<span class="gn-value"><?php echo esc_html( $freelancer_profile_country_state ); ?></span>
			</li>
		</ul>
		<div class="gn-actions">
			<a href="<?php echo esc_url( get_permalink( $freelancer_profile_id ) ); ?>"
				class="gn-btn gn-btn-outline-grey gn-btn-md gn-view-profile-btn">
				<?php echo esc_html__( 'View profile', 'gigneo' ); ?>
				<i class="hi hi-arrow-up-right" aria-hidden="true"></i>
			</a>
		</div>
	</div>
</div>