<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Prevent direct access to the script.
}
$profile_id    = ! empty( $args['profile_id'] ) ? $args['profile_id'] : '';
$profile_type  = ! empty( $args['profile_type'] ) ? $args['profile_type'] : '';
$platform_type = ! empty( $args['platform_type'] ) ? $args['platform_type'] : '';
$credit_system = ! empty( $args['credit_system'] ) ? $args['credit_system'] : '';

$profile_payouts = gigneo_profile_payouts( $profile_id );
?>
<div id="gn-earning-payouts" class="gn-dashboard-section gn-payout-methods gn-h-100">
	<div class="gn-head">
		<h3 class="gn-title"><?php echo esc_html__( 'Payouts', 'gigneo' ); ?></h3>
	</div>
	<div class="gn-body">
		<?php
		if ( ! empty( $profile_payouts ) && is_array( $profile_payouts ) ) {
			?>
			<div class="gn-payout-list-wrapper">
				<ul class="gn-payout-list">
					<?php foreach ( $profile_payouts as $p => $payout ) { ?>
						<li class="gn-payout gn-payout-<?php echo esc_attr( $payout['type'] ); ?>">
							<div class="gn-payout-inner">
								<figure class="gn-payout-image">
									<img src="<?php echo esc_url( $payout['logo'] ); ?>" alt="<?php echo esc_attr( $payout['type'] ); ?>">
								</figure>
								<div class="gn-payout-info">
									<h4 class="gn-title">
										<?php
										echo esc_attr( $payout['title'] );
										if ( ! empty( $payout['label'] ) ) {
											?>
											<span class="gn-label"><?php echo esc_attr( $payout['label'] ); ?></span>
											<?php
										}
										?>
										<span class="gn-status-tag gn-<?php echo esc_attr( 'active' === $payout['status'] ? 'success' : 'warning' ); ?>"><?php echo 'active' === $payout['status'] ? esc_html__( 'Active', 'gigneo' ) : esc_html__( 'Inactive', 'gigneo' ); ?></span>
									</h4>
									<p class="gn-description"><?php echo esc_html( $payout['description'] ); ?></p>
								</div>
							</div>
						</li>
					<?php } ?>
				</ul>
			</div>
			<?php
		} else {
			$not_found_args = array(
				'title'       => esc_html__( 'No payouts', 'gigneo' ),
				'description' => esc_html__( 'You have not set up any payout method yet.', 'gigneo' ),
			);
			gigneo_not_found( 'account_earning_payout', $not_found_args );
		}
		?>
	</div>
	<div class="gn-footer">
		<a href="<?php echo esc_url( gigneo_dashboard_url( 'setting', 'billing' ) ); ?>" class="gn-btn gn-btn-md gn-btn-block gn-btn-outline-grey">
			<i class="hi hi-plus" aria-hidden="true"></i>
			<?php esc_html_e( 'Add payout', 'gigneo' ); ?>
		</a>
	</div>
</div>
