/****************************************************************************
 * 페이지 데이터 렌더링
 ****************************************************************************/
function fn_setReserveData(){
    $('#reserveDate').text(`${reserveDate}, ${reserveTime}`);
    $('#treatmentName').text(treatmentName);
    $('#procedureName').text(procedureName);
}
/****************************************************************************
 * 예약 등록
 ****************************************************************************/
function fn_insertReserve(){
    let etc = $('textarea').val();
    let formData = new FormData();
    formData.append("reserveDate",reserveDate)
    formData.append("reserveTime",reserveTime)
    formData.append("muTreatmentId",muTreatmentId)
    formData.append("treatmentName",treatmentName)
    formData.append("muProcedureId",muProcedureId)
    formData.append("procedureName",procedureName)
    formData.append("etc",etc)

    $.ajax({
        url: encodeURI('/mobilereservation/insertReserve.do'),
        data: formData,
        dataType: "json",
        processData: false,
        contentType: false,
        type: 'POST',
        async: false,
        success: function(data){
            const param = {

            }
            if('0'==data.msgCode) {
                modalEvent.success("등록 성공","예약이 완료되었습니다.", function(){
                    location.href ='/reservation'
                });
            }
            else{
                modalEvent.danger("등록 오류", "등록 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
            }
        },
        error : function(xhr, status, error) {
            modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
        },
        beforeSend:function(){

        },
        complete:function(){

        }
    });
}
/****************************************************************************
 * 페이지 init
 ****************************************************************************/
function fn_pageInit(){
    fn_setReserveData();
}

/****************************************************************************
 * 페이지 event
 ****************************************************************************/
function fn_pageEvent(){
    $('.next_btn').on('click', ()=>fn_insertReserve());

}

$(function(){
    // 페이지 init
    fn_pageInit();

    // 페이지 event
    fn_pageEvent();
});
