<?php

/**
 * Template part for contact form.
 * Accepted args: ["class", "textarea-rows"]
 */

$defaults = [
  "class" => "",
  "textarea-rows" => 10,
];

$args = array_replace_recursive($defaults, $args);

$form_id = uniqid("contact_form_");

$name_id = uniqid("contact_form_name");
$text_id = uniqid("contact_form_text");
$email_id = uniqid("contact_form_email");

$name_label = __("Vaša správa", "inoby");
$text_label = __("Meno a priezvisko alebo Názov organizácie", "inoby");
$email_label = __("E-mail", "inoby");
$gdpr_label =
  __("Súhlasím so ", "inoby") .
  " <a class='link gdpr-link privacy-policy-link' href='" .
  get_privacy_policy_url() .
  "'>" .
  __("spracovaním osobných údajov", "inoby") .
  "</a> " .
  __("na marketingové účely.", "inoby");
?>

<form class="contact-form <?= $args["class"] ?>" id="<?= $form_id ?>">
  <div class="form-group">
    <label for="<?= $name_id ?>" class="inplace-label"><?= $name_label ?></label>
    <textarea class="form-input" id="<?= $name_id ?>" name="message" rows="<?= $args["textarea-rows"] ?>"
      placeholder="<?= $name_label ?>"></textarea>
  </div>
  <div class="form-group">
    <label for="<?= $text_id ?>" class="inplace-label"><?= $text_label ?></label>
    <input class="form-input" id="<?= $text_id ?>" type="text" name="name" placeholder="<?= $text_label ?>">
  </div>
  <div class="form-group">
    <label for="<?= $email_id ?>" class="inplace-label"><?= $email_label ?></label>
    <input class="form-input" id="<?= $email_id ?>" type="email" name="email" placeholder="<?= $email_label ?>">
  </div>
  <div class="form-group checkbox">
    <input type="checkbox" name="gdpr" id="<?= $form_id . "_gdpr" ?>">
    <label for="<?= $form_id . "_gdpr" ?>" class="label gdpr-label">
      <span id="gdpr-label"><?= $gdpr_label ?></span>
    </label>
  </div>
  <button class="button" type="submit"><?= __("Odoslať", "inoby") ?></button>
  <div class="message-box"></div>
</form>