package corporate_mcudetail

import "cpone/component/modal"
import "cpone/models"
import "strconv"

templ DialogReport(
    IDComponent string,
    postLink string,
    hxTarget string,
    hxSwap string,
    hxInclude string,
    modalID string,
    modalTitle string,
    modalBody templ.Component,
    modalClose templ.Component,    
) {
    <div class="">
        <div
            id={ IDComponent }
            hx-include={ hxInclude }
        >
            @modalcomponent.ModalViewXL(modalID,
                modalTitle,
                modalBody,
                modalClose,
            )
        </div>
    </div>
}

templ ModalRptBody(
    IDComponent string,
    tabComponent templ.Component,
    hxOnLoad templ.ComponentScript,
) {
    <div id={ IDComponent } hx-on::load={ hxOnLoad }>
        @tabComponent
    </div>
}

script JsHideModal(modalID string) {
    $(modalID).modal('hide');
}

script JsShowModal(modalID string) {
    $(modalID).modal('show');
}

templ ModalClose(LinkClose string, hxTarget string, hxSwap string, modalID string) {
    <button 
        type="button"
        hx-on::after-request={ JsHideModal(modalID) }
        class="close"
        data-dismiss="modal"
        aria-label="Close"
    >
        <i aria-hidden="true" class="ki ki-close"></i>
    </button>
}

templ TabReportView(
    datamcu []models.TabViewReportMcu,
) {
    <div class="container-rpt">
        <ul class="nav nav-tabs nav-tabs-line">
            for i, v := range datamcu {
                if i == 0 {
                    <li class="nav-item">
                        <a class="nav-link active" data-toggle="tab" href={templ.URL("#kt_tab_pat_" + strconv.Itoa(i))}>{ v.Name }</a>
                    </li>
                } else {
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href={templ.URL("#kt_tab_pat_" + strconv.Itoa(i))}>{ v.Name }</a>
                    </li>  
                }
            }
        </ul>
    </div>
    <div class="tab-content mt-5" id="patTabContent">
        for i, v := range datamcu {
            if i == 0 {
                <div class="tab-pane fade show active" id={"kt_tab_pat_" + strconv.Itoa(i)} role="tabpanel" aria-labelledby={"kt_tab_pat_" + strconv.Itoa(i)} style="height: 700px;">
                    <object data={ v.Link } type="application/pdf" width="100%" height="100%"></object>
                </div>                
            } else {
                <div class="tab-pane fade show" id={"kt_tab_pat_" + strconv.Itoa(i)} role="tabpanel" aria-labelledby={"kt_tab_pat_" + strconv.Itoa(i)} style="height: 700px;">
                    <object data={ v.Link } type="application/pdf" width="100%" height="100%"></object>
                </div>
            }
        }
    </div>
}