$(document).ready(() => {

  // called on DELETE/EDIT success- reloads only table
  function getAndRenderSchedule() {
    $.ajax({
      method: 'GET',
      url: '/schedule',
      success: 'success'
    })
  }

  // DELETE
  $("#schedule .delete").click((e) => {
    e.preventDefault()
    console.log(`delete ${e.target.id}`)
    $.ajax({
      url: `/schedule/${e.target.id}`,
      method: "DELETE",
      success: getAndRenderSchedule()
    })
      .then((data) => {
        $(e.target).closest('tr').hide()
      })
  })

  // UPDATE
  $("#editForm").submit((e) => {
    e.preventDefault()
    console.log('form submit')
    let id = $('input[name="id"]').val()

    $.ajax({
      url: `/schedule/${id}`,
      method: "PATCH",
      data: $('#editForm').serialize(),
      success: (res) => {
        console.log(res)
        window.location = '/schedule'
      }
    })
  })

  $("#editProfileForm").submit((e) => {
    e.preventDefault()
    console.log('form submit')
    let id = $('input[name="id"]').val()

    $.ajax({
      url: `/profile/${id}/editprofile`,
      method: "PATCH",
      data: $('#editProfileForm').serialize(),
      success: (res) => {
        console.log(res)
        window.location = '/profile'
      }
    })
  })
})

@@ -523,16 +523,391 @@
 )%0A  %7D)%0A%0A
+  // DELETE SUPERSCHEDULE%0A  $(%22#superSchedule .delete%22).click((e) =%3E %7B%0A    e.preventDefault()%0A    // console.log(%60delete $%7Be.target.id%7D%60)%0A    $.ajax(%7B%0A      url: %60/super/$%7Be.target.id%7D%60,%0A      method: %22DELETE%22,%0A      success: (response) =%3E %7B%0A        window.location.href = '/super'%0A      %7D%0A    %7D)%0A      // .then((res) =%3E %7B%0A      //   res.redirect('/super')%0A      // %7D)%0A  %7D)%0A%0A
   // UPD

delete btn works on accounts in super! (just dont delete yourself)