import Ajax from "../../components/ajax.js"
import { alertError, alertSuccess } from "../../components/alerts/sweetAlert.js"
import ListSortable from "../../components/listSortable.js"
$(() => {

    const menuSectionList = new ListSortable('#menu-inner-list')
    menuSectionList.onEnd(updateWikiSectionOrder)

})

const updateWikiSectionOrder = (evt) => 
{
    let list = new ListSortable('#menu-inner-list')

    const ajax = new Ajax('/wiki/section/update/order',
        {
            orders : list.getArray()
         },
         null,
         (response) => alertSuccess(response.message).fire(),
         (error) => alertError(error.message).fire(),
    )
    ajax.post();
}

