<?php
/**
 * @var $data array
 */
use auctionforge\inc\helpers\LotHelper;
use auctionforge\inc\helpers\SettingsHelper;

$acceptPrivacyData = SettingsHelper::getOption('accept_privacy_data', 'off');
$pageAuctionListId = SettingsHelper::getOption('profile', 0);
$pageAuthorizationId = SettingsHelper::getOption('authorization', 0);
$pageRegistrationId = SettingsHelper::getOption('registration', 0);
$pageAuthorization = "";
if ($pageAuthorizationId) {
    $pageAuthorization = get_permalink($pageAuthorizationId);
}
$id = uniqid();
$idForm = (!empty($data['name'])) ? $data['name'] : "registerSection";

$hiddenClass = apply_filters('bp_hidden_class', 'hidden');
if (is_page($pageRegistrationId)) {
    $hiddenClass = "";
}
?>
<form id="<?= $idForm ?>" name="<?= $idForm ?>" action="<?= LotHelper::getPolyLangPermalink($pageAuctionListId) ?>"
      class="bp-from bp-register-api" data-accept-privacy="<?= $acceptPrivacyData ?>">
    <div class="errors-group bp-text-red hidden"></div>
    <div class="bp-form-group">
        <div class="bp-form-group__inner">
            <input type="text" required placeholder="<?= __('First name', 'auctionforge') ?>" class="bp-form-control" name="firstName" id="registerFirstName">
            <span class="bp-form-error hidden"></span>
        </div>
    </div>
    <div class="bp-form-group">
        <div class="bp-form-group__inner">
            <input type="text" required placeholder="<?= __('Last name', 'auctionforge') ?>" class="bp-form-control" name="lastName" id="registerLastName">
            <span class="bp-form-error hidden"></span>
        </div>
    </div>
    <div class="bp-form-group">
        <div class="bp-form-group__inner">
            <input type="text" required placeholder="<?= __('Email', 'auctionforge') ?>" class="bp-form-control" name="email" id="registerEmail">
            <span class="bp-form-error hidden"></span>
        </div>
    </div>
    <div class="bp-form-group">
        <div class="bp-form-group__inner bp-form-group__inline bp-form-group__list bp-form-group__phone">
            <select style="width: 100%" class="phoneCodeSelect countryCodeField hidden" name="phoneCountryCode"></select>
            <input type="text" class="bp-form-control" name="phone" id="registerPhone" placeholder="<?= __('Phone number', 'auctionforge') ?>">
            <span class="bp-form-error hidden"></span>
        </div>
    </div>
    <div class="bp-form-group bp-form-group_svg bp_show_password-action">
        <div class="bp-form-group__inner">
            <div class="bp-form-group__inner">
                <input type="password" required placeholder="<?= __('Password', 'auctionforge') ?>" class="bp-form-control bp-form-control_eye"
                       name="password" id="registerPassword">
                <i class="bp_show_password svg-icon svg-eye"></i>
            </div>
            <span class="bp-form-error hidden"></span>
        </div>
    </div>
    <?php if ($acceptPrivacyData === 'on') { ?>
        <div class="bp-form-group bp-form-check bp-form-jc-start">
            <input class="bp-form-check-input" name="personal-data" id="personal-data_<?= $id ?>" type="checkbox">
            <label class="bp-form-check-label" for="personal-data_<?= $id ?>"><?= __('I consent and accept the conditions on the processing of personal data', 'auctionforge') ?></label>
        </div>
    <?php } ?>
    <div class="bp-form-group bp-form-check bp-form-jc-start">
        <input class="bp-form-check-input" checked="checked" name="allowInvitations" id="allowInvitations-field_<?= $id ?>" type="checkbox">
        <label class="bp-form-check-label" for="allowInvitations-field_<?= $id ?>"><?= sprintf(__('Allow "%s" to send me invitation for new auctions', 'auctionforge'), get_option('blogname')) ?></label>
    </div>
    <div class="bp-form-group">
        <button id="sendRegister" type="submit" class="bp-btn bp-btn-black"><?= __('Register', 'auctionforge') ?></button>
    </div>
    <?php if ($pageAuthorization != "") { ?>
        <div class="bp-form-group separate-page-group bp-d-flex bp-f-center bp-f-wrap <?= $hiddenClass ?>">
            <a class="" href="<?= $pageAuthorization ?>"><?= __('Already registered? Log in', 'auctionforge') ?></a>
        </div>
    <?php } ?>
</form>