<script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>
        
<script type="text/javascript">
    $(document).ready(function() {
      var saveBtn = document.getElementById('submit');
      $(saveBtn).on('click', function() {
        $('div[name="confirmation"]').removeAttr("hidden");
      });

      $('form[name="newNote"]').submit(function(e){
        e.preventDefault();
        $.ajax({
            type : 'POST',
            data: $('form[name="newNote"]').serialize(),
            url : '/dashboard/note/create'
        }).done(function() {
          $('button[name="goToDashboard"]').on('click', function() {
            window.location.replace('/dashboard');
          });
        });
      });
    });
</script>

<section>
  <div class="container col-lg-6 col-md-6 col-sm-12 text-center justify-content-center">
    <hr><h1>Create new note</h1><hr>
    <%- include ('./partials/messages') %>
    <form action="/dashboard/note/create" method="POST" name="newNote">
      <div class="form-group">
        <label for="title">Title</label>
        <input type="title" class="form-control" name="title" value="<%= typeof title != 'undefined' ? title : '' %>">
      </div>
      <div class="form-group">
        <label for="body">Body</label>
        <textarea type="body" class="form-control" name="body" rows="10" value="<%= typeof body != 'undefined' ? body : '' %>"></textarea>
      </div>
      <div class="form-group">
        <label for="priority">Priority</label>
        <select class="form-control" id="form-control" name="priority">
          <option>Low</option>
          <option>Medium</option>
          <option>High</option>
        </select>
      </div>
      <button type="submit" class="btn btn-primary" id="submit" data-toggle="modal" data-target=".modal">Submit note</button>
      <button type="reset" class="btn btn-info">Reset</button>
      <a class="btn btn-danger" role="button" href="/dashboard">Cancel</a>
    </form>
    <%- include('./partials/modals/new-note-modal.ejs') %>
  </div>
</section>
