<%@ page language="VB" masterpagefile="~/Template/Master.master" autoeventwireup="false" inherits="PCC_DC_ListDomainOrgs, MachSol.MachPanel.Web" %>

<asp:Content ID="Content4" ContentPlaceHolderID="CPH_Content" runat="Server">

    <script type="module">

        import { createApp } from 'vue'
        import ADOrgsList from '/Components/DC/ADOrgsList.js?v=3.4'
        import LogonHoursTemplate from '/Components/DC/LogonHoursTemplate.js?v=3.4'
        import { getLabelText } from '/Components/Common/utils.js?v=3.4'
        import TabContainer from '/Components/Common/TabContainer.js?v=3.4'

        createApp({
            data() {
                return {
                    readOnly: <%= Helper.ReadOnlyRole.ToString().ToLower() %>,
                    isSubReseller: <%= Helper.IsSubReseller.ToString().Tolower() %>,
                    isProviderLogin: <%= Helper.IsLoggedInAsProvider.ToString().Tolower() %>,
                    isLoggedInAsCustomer: <%= Helper.IsLoggedInAsCustomer.ToString().ToLower() %>,
                    isLoggedInAsReseller: <%= Helper.IsLoggedInAsReseller.ToString().ToLower() %>,
                    isEgyptBenyaTechPlatform: <%= MachSol.MachPanel.DBCore.SystemSettings.IsEgyptBenyaTechPlatform.ToString().ToLower() %>,
                    dcId: <%= DCId %>,
                    hostedOrgId: <%= HostedOrgID %>,
                    packageTypeId: <%= PackageTypeId %>,
                    serviceHostingId: <%= ServiceHostingID %>,
                    showDeleteOption: <%= ShowDeleteOption.ToString().ToLower() %>,
                    currentTab: 0,
                    tabPanels: []
                }
            },
            methods: {
                getLabelText,
                activeTabChanged: function (newTabIndex) {
                    this.currentTab = vueActiveTabChanged(newTabIndex, this.currentTab, this.tabPanels);
                },
            },
            components: {
                TabContainer,
                ADOrgsList,
                LogonHoursTemplate
            },
            created: function () {
                var vm = this;
                this.tabPanels = [{ text: this.getLabelText('MD203'), enabled: true },
                    { text: this.getLabelText('strLogonHoursTemplate'), enabled: (!vm.isSubReseller && vm.packageTypeId != '22' && vm.packageTypeId != '23' && !vm.isEgyptBenyaTechPlatform) }];

                let urlParams = new URLSearchParams(window.location.search);

                if (urlParams.has('M')) {
                    if (urlParams.get('M') == 1)
                        displaySuccessMsg(this.getLabelText('EGN0000011'));
                }
                if (urlParams.has('TI')) {
                    this.activeTabChanged(urlParams.get('TI'));
                }
            },
            template: ` 
<TabContainer :id="'adOrgs'" :tabPanels="tabPanels" :activeTabIndex="currentTab" @onActiveTabChanged="activeTabChanged"></TabContainer>
                    
<ADOrgsList v-if="currentTab == 0" :readOnly="readOnly" :isSubReseller="isSubReseller" :isProviderLogin="isProviderLogin" :isLoggedInAsCustomer="isLoggedInAsCustomer"
    :isLoggedInAsReseller="isLoggedInAsReseller" :serviceHostingId="serviceHostingId" :packageTypeId="packageTypeId" :hostedOrgId="hostedOrgId"
    :showDeleteOption="showDeleteOption" :isEgyptBenyaTechPlatform="isEgyptBenyaTechPlatform" />
<LogonHoursTemplate v-if="currentTab == 1" :readOnly="readOnly" :isProviderLogin="isProviderLogin" :isLoggedInAsCustomer="isLoggedInAsCustomer"
    :isLoggedInAsReseller="isLoggedInAsReseller" ></LogonHoursTemplate>
                
`
        }).mount('#app');

    </script>

    <div id="app">
    </div>

</asp:Content>
