<?php
/**
 * Formulaire onboarding B2B post-Stripe — shortcode [avision_btob_onboarding].
 *
 * Variables (définies par avision_render_btob_onboarding_shortcode) :
 * - string $avision_btob_agency_name_value
 * - string $avision_btob_error_message
 * - string $avision_btob_success_message
 * - string $avision_btob_extra_class
 *
 * @package Avision
 */

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

$avision_btob_agency_name_value = isset( $avision_btob_agency_name_value ) ? (string) $avision_btob_agency_name_value : '';
$avision_btob_error_message     = isset( $avision_btob_error_message ) ? (string) $avision_btob_error_message : '';
$avision_btob_success_message   = isset( $avision_btob_success_message ) ? (string) $avision_btob_success_message : '';
$avision_btob_extra_class       = isset( $avision_btob_extra_class ) ? (string) $avision_btob_extra_class : '';
?>
<div class="avi-btob-onboarding<?php echo $avision_btob_extra_class !== '' ? ' ' . esc_attr( $avision_btob_extra_class ) : ''; ?>">
	<div class="avi-btob-onboarding__card">
		<h2 class="avi-btob-onboarding__title"><?php echo esc_html__( 'Configuration agence', 'avision-dashboard' ); ?></h2>
		<p class="avi-btob-onboarding__intro"><?php echo esc_html__( 'Indiquez le nom de votre agence, puis connectez votre compte Google Business pour piloter vos fiches.', 'avision-dashboard' ); ?></p>

		<?php if ( $avision_btob_error_message !== '' ) : ?>
			<div class="avi-btob-onboarding__notice avi-btob-onboarding__notice--error" role="alert"><?php echo esc_html( $avision_btob_error_message ); ?></div>
		<?php endif; ?>
		<?php if ( $avision_btob_success_message !== '' ) : ?>
			<div class="avi-btob-onboarding__notice avi-btob-onboarding__notice--success" role="status"><?php echo esc_html( $avision_btob_success_message ); ?></div>
		<?php endif; ?>

		<form method="post" action="" class="avi-btob-onboarding__form" novalidate>
			<?php wp_nonce_field( 'avision_btob_onboarding_save', 'avision_btob_onboarding_nonce' ); ?>
			<input type="hidden" name="avision_btob_onboarding_submit" value="1" />

			<label class="avi-btob-onboarding__label" for="avi_btob_agency_name"><?php echo esc_html__( 'Nom de l’agence', 'avision-dashboard' ); ?></label>
			<input
				type="text"
				id="avi_btob_agency_name"
				name="avi_btob_agency_name"
				class="avi-btob-onboarding__input"
				value="<?php echo esc_attr( $avision_btob_agency_name_value ); ?>"
				autocomplete="organization"
				required
				maxlength="200"
				placeholder="<?php echo esc_attr__( 'Ex. Agence Dupont & Associés', 'avision-dashboard' ); ?>"
			/>

			<?php
			$avi_lang = function_exists( 'avi_get_current_lang' ) ? avi_get_current_lang() : 'en';
			if ( ! in_array( $avi_lang, array( 'en', 'fr', 'es' ), true ) ) {
				$avi_lang = 'en';
			}
			$avi_terms_mode = 'standard';
			include __DIR__ . '/partials/avi-terms-checkbox.php';
			?>

			<button type="submit" class="avi-btob-onboarding__submit">
				<?php echo esc_html__( 'Save & Connect Google', 'avision-dashboard' ); ?>
			</button>
		</form>
	</div>
</div>
