<br><br>
<form method="POST" id="form-queryreview">
    <div class="row center-align">
      <ul class="collection with-header">
        <% for(const stepData of queryReviewTableData) { %>
          <li class="collection-item" >
            <div id="<%= stepData.id %>" ><%= stepData.title || '-' %>
              <a href="<%= stepData.url %>" class="kivi-color secondary-content">
                <i class="waves-effect material-icons">edit</i>
              </a>
            </div>
          </li>
        <% } %>
      </ul>
    </div>
    <div class="row center-align">
        <h6>Slanje obavještenja</h6>
        <span class="segmented">
                <label>
                    <input type="radio" name="emailFrequency" value="<%= EMAIL_FREQUENCY.ASAP.id %>"
                    <% if (selectedEmailFrequency === EMAIL_FREQUENCY.ASAP.id) { %>
                    checked
                    <% } %>>
                    <span class="label"><%= EMAIL_FREQUENCY.ASAP.title %></span>
                </label>

                <label>
                    <input type="radio" name="emailFrequency" value="<%= EMAIL_FREQUENCY.DAILY.id %>"
                    <% if (selectedEmailFrequency === EMAIL_FREQUENCY.DAILY.id) { %>
                    checked
                    <% } %>>
                    <span class="label"><%= EMAIL_FREQUENCY.DAILY.title %></span>
                </label>
		    </span>
    </div>
    <div class="row center-align">
        <div class="col">
            <input id="email" name="email" type="email" placeholder="vas.email@mail.com" <% if (email) { %>value="<%= email %>" <% } %> required size="250" />
        </div>
    </div>

    <div class="row center-align">
        <div class="col">
            <input id="confirmEmail" name="confirmEmail" type="email" placeholder="potvrdite.email@mail.com" <% if (email) { %>value="<%= email %>" <% } %> required size="250" />
        </div>
    </div>

    <div class="row center-align">
        <div class="col">
            <h6 id="error-label-email" style="color: red"><%= error %> </h6>
        </div>
    </div>

    <div class="row center-align">
        <div class="col">
            <p>* U svakom trenutku možete prekinuti slanje objava kroz link u e-mailu</p>
        </div>
    </div>

    <div class="row center-align">
        <div class="col s6 push-s3">
            <a id="submit" href="#" class="welcome-center-button waves-effect waves-light btn">
                Javi mi
            </a>
        </div>
    </div>
</form>

<script>

 $(document).ready(function() {
   $("#submit").click(function() {
       const simpleEmailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
       const email = $("#email").val();
       const confirmEmail = $("#confirmEmail").val();

       if (email !== confirmEmail){
           $("#error-label-email").text("Greška ! Unešeni emailovi nisu isti");
           return;
       }

       if (simpleEmailRegex.test(email)){
           $("#submit").attr("disabled", true);
           $("#form-queryreview").submit();
       }else{
           $("#error-label-email").text("Greška ! Unešeni email nije validan");
       }
   });
 });
</script>

