import React, { ReactElement, useEffect } from 'react';
import Head from 'next/head'
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import dayjs from "dayjs";
import {useAppDispatch, useAppSelector} from "../../stores/hooks";
import {useRouter} from "next/router";
import { fetch } from '../../stores/tenants/tenantsSlice'
import {saveFile} from "../../helpers/fileSaver";
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from "../../components/ImageField";
import LayoutAuthenticated from "../../layouts/Authenticated";
import {getPageTitle} from "../../config";
import SectionTitleLineWithButton from "../../components/SectionTitleLineWithButton";
import SectionMain from "../../components/SectionMain";
import CardBox from "../../components/CardBox";
import BaseButton from "../../components/BaseButton";
import BaseDivider from "../../components/BaseDivider";
import {mdiChartTimelineVariant} from "@mdi/js";
import {SwitchField} from "../../components/SwitchField";
import FormField from "../../components/FormField";

import {hasPermission} from "../../helpers/userPermissions";


const TenantsView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { tenants } = useAppSelector((state) => state.tenants)
    
    const { currentUser } = useAppSelector((state) => state.auth);
    

    const { id } = router.query;
    
    function removeLastCharacter(str) {
      console.log(str,`str`)
      return str.slice(0, -1);
    }

    useEffect(() => {
        dispatch(fetch({ id }));
    }, [dispatch, id]);


    return (
      <>
          <Head>
              <title>{getPageTitle('View tenants')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View tenants')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/tenants/tenants-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>TenantName</p>
                    <p>{tenants?.name}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Slug</p>
                    <p>{tenants?.slug}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PlanTier</p>
                    <p>{tenants?.plan_tier ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>TenantStatus</p>
                    <p>{tenants?.tenant_status ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='ActivatedAt'>
                    {tenants.activated_at ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={tenants.activated_at ?
                        new Date(
                          dayjs(tenants.activated_at).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No ActivatedAt</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='SuspendedAt'>
                    {tenants.suspended_at ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={tenants.suspended_at ?
                        new Date(
                          dayjs(tenants.suspended_at).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No SuspendedAt</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>DefaultRegion</p>
                    <p>{tenants?.default_region}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='E2EEDefaultEnabled'>
                    <SwitchField
                      field={{name: 'e2ee_default_enabled', value: tenants?.e2ee_default_enabled}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='EducationModuleEnabled'>
                    <SwitchField
                      field={{name: 'education_module_enabled', value: tenants?.education_module_enabled}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='MarketplaceEnabled'>
                    <SwitchField
                      field={{name: 'marketplace_enabled', value: tenants?.marketplace_enabled}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              

              
                <FormField label='Multi Text' hasTextareaHeight>
                  <textarea className={'w-full'} disabled value={tenants?.data_retention_policy} />
                </FormField>
              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>organizations</p>
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{tenants?.organizations?.name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Identity_providers Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ProviderType</th>
                                
                                
                                
                                <th>ProviderName</th>
                                
                                
                                
                                <th>IssuerURL</th>
                                
                                
                                
                                <th>ClientID</th>
                                
                                
                                
                                <th>SSOMetadataURL</th>
                                
                                
                                
                                <th>JITProvisioningEnabled</th>
                                
                                
                                
                                <th>SCIMEnabled</th>
                                
                                
                                
                                <th>IdPStatus</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.identity_providers_tenant && Array.isArray(tenants.identity_providers_tenant) &&
                              tenants.identity_providers_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/identity_providers/identity_providers-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="provider_type">
                                        { item.provider_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issuer_url">
                                        { item.issuer_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="client_id">
                                        { item.client_id }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sso_metadata_url">
                                        { item.sso_metadata_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="jit_provisioning_enabled">
                                        { dataFormatter.booleanFormatter(item.jit_provisioning_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scim_enabled">
                                        { dataFormatter.booleanFormatter(item.scim_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="idp_status">
                                        { item.idp_status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.identity_providers_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Policy_rules Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PolicyName</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>PolicyScope</th>
                                
                                
                                
                                <th>RegoModule</th>
                                
                                
                                
                                <th>PolicyStatus</th>
                                
                                
                                
                                <th>EffectiveFrom</th>
                                
                                
                                
                                <th>EffectiveUntil</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.policy_rules_tenant && Array.isArray(tenants.policy_rules_tenant) &&
                              tenants.policy_rules_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/policy_rules/policy_rules-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="policy_scope">
                                        { item.policy_scope }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rego_module">
                                        { item.rego_module }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="policy_status">
                                        { item.policy_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="effective_from">
                                        { dataFormatter.dateTimeFormatter(item.effective_from) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="effective_until">
                                        { dataFormatter.dateTimeFormatter(item.effective_until) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.policy_rules_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Kms_configs Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>KMSType</th>
                                
                                
                                
                                <th>KMSName</th>
                                
                                
                                
                                <th>KeyURI</th>
                                
                                
                                
                                <th>KMSStatus</th>
                                
                                
                                
                                <th>LastRotatedAt</th>
                                
                                
                                
                                <th>AutoRotateEnabled</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.kms_configs_tenant && Array.isArray(tenants.kms_configs_tenant) &&
                              tenants.kms_configs_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/kms_configs/kms_configs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="kms_type">
                                        { item.kms_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="key_uri">
                                        { item.key_uri }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="kms_status">
                                        { item.kms_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_rotated_at">
                                        { dataFormatter.dateTimeFormatter(item.last_rotated_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="auto_rotate_enabled">
                                        { dataFormatter.booleanFormatter(item.auto_rotate_enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.kms_configs_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Conference_templates Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>TemplateName</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>E2EEEnabled</th>
                                
                                
                                
                                <th>LobbyEnabled</th>
                                
                                
                                
                                <th>RecordingEnabled</th>
                                
                                
                                
                                <th>TranscriptionEnabled</th>
                                
                                
                                
                                <th>CanvasEnabled</th>
                                
                                
                                
                                <th>DefaultLayoutMode</th>
                                
                                
                                
                                <th>MaxParticipants</th>
                                
                                
                                
                                <th>TemplateStatus</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.conference_templates_tenant && Array.isArray(tenants.conference_templates_tenant) &&
                              tenants.conference_templates_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/conference_templates/conference_templates-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="e2ee_enabled">
                                        { dataFormatter.booleanFormatter(item.e2ee_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lobby_enabled">
                                        { dataFormatter.booleanFormatter(item.lobby_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recording_enabled">
                                        { dataFormatter.booleanFormatter(item.recording_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="transcription_enabled">
                                        { dataFormatter.booleanFormatter(item.transcription_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="canvas_enabled">
                                        { dataFormatter.booleanFormatter(item.canvas_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="default_layout_mode">
                                        { item.default_layout_mode }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_participants">
                                        { item.max_participants }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="template_status">
                                        { item.template_status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.conference_templates_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Files Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>FileName</th>
                                
                                
                                
                                <th>FileKind</th>
                                
                                
                                
                                <th>Size(MB)</th>
                                
                                
                                
                                <th>MIMEType</th>
                                
                                
                                
                                <th>StorageURI</th>
                                
                                
                                
                                <th>ChecksumSHA256</th>
                                
                                
                                
                                <th>ScanStatus</th>
                                
                                
                                
                                <th>UploadedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.files_tenant && Array.isArray(tenants.files_tenant) &&
                              tenants.files_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/files/files-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="file_name">
                                        { item.file_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="file_kind">
                                        { item.file_kind }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="size_mb">
                                        { item.size_mb }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mime_type">
                                        { item.mime_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="storage_uri">
                                        { item.storage_uri }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="checksum_sha256">
                                        { item.checksum_sha256 }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scan_status">
                                        { item.scan_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="uploaded_at">
                                        { dataFormatter.dateTimeFormatter(item.uploaded_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.files_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Layout_models Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ModelName</th>
                                
                                
                                
                                <th>ModelType</th>
                                
                                
                                
                                <th>DeploymentStage</th>
                                
                                
                                
                                <th>ModelVersion</th>
                                
                                
                                
                                <th>ArtifactURI</th>
                                
                                
                                
                                <th>TrainedAt</th>
                                
                                
                                
                                <th>DeployedAt</th>
                                
                                
                                
                                <th>RollbackTriggerRate</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.layout_models_tenant && Array.isArray(tenants.layout_models_tenant) &&
                              tenants.layout_models_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/layout_models/layout_models-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="model_type">
                                        { item.model_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="deployment_stage">
                                        { item.deployment_stage }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="model_version">
                                        { item.model_version }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="artifact_uri">
                                        { item.artifact_uri }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="trained_at">
                                        { dataFormatter.dateTimeFormatter(item.trained_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="deployed_at">
                                        { dataFormatter.dateTimeFormatter(item.deployed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rollback_trigger_rate">
                                        { item.rollback_trigger_rate }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.layout_models_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>External_integrations Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>IntegrationType</th>
                                
                                
                                
                                <th>IntegrationName</th>
                                
                                
                                
                                <th>IntegrationStatus</th>
                                
                                
                                
                                <th>AuthReference</th>
                                
                                
                                
                                <th>AutoCreateTasksEnabled</th>
                                
                                
                                
                                <th>AutoScheduleFollowupsEnabled</th>
                                
                                
                                
                                <th>LastSyncAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.external_integrations_tenant && Array.isArray(tenants.external_integrations_tenant) &&
                              tenants.external_integrations_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/external_integrations/external_integrations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="integration_type">
                                        { item.integration_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="integration_status">
                                        { item.integration_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="auth_reference">
                                        { item.auth_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="auto_create_tasks_enabled">
                                        { dataFormatter.booleanFormatter(item.auto_create_tasks_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="auto_schedule_followups_enabled">
                                        { dataFormatter.booleanFormatter(item.auto_schedule_followups_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_sync_at">
                                        { dataFormatter.dateTimeFormatter(item.last_sync_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.external_integrations_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Courses Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>CourseName</th>
                                
                                
                                
                                <th>CourseCode</th>
                                
                                
                                
                                <th>CourseStatus</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.courses_tenant && Array.isArray(tenants.courses_tenant) &&
                              tenants.courses_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/courses/courses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="course_code">
                                        { item.course_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="course_status">
                                        { item.course_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.courses_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Marketplace_apps Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>AppName</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>AppCategory</th>
                                
                                
                                
                                <th>Runtime</th>
                                
                                
                                
                                <th>Version</th>
                                
                                
                                
                                <th>WASMArtifactURI</th>
                                
                                
                                
                                <th>ReliabilityScore</th>
                                
                                
                                
                                <th>VettingStatus</th>
                                
                                
                                
                                <th>SubmittedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.marketplace_apps_tenant && Array.isArray(tenants.marketplace_apps_tenant) &&
                              tenants.marketplace_apps_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/marketplace_apps/marketplace_apps-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="app_category">
                                        { item.app_category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="runtime">
                                        { item.runtime }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="version">
                                        { item.version }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="wasm_artifact_uri">
                                        { item.wasm_artifact_uri }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reliability_score">
                                        { item.reliability_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="vetting_status">
                                        { item.vetting_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.marketplace_apps_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_events Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>EventCategory</th>
                                
                                
                                
                                <th>Action</th>
                                
                                
                                
                                <th>TargetType</th>
                                
                                
                                
                                <th>TargetKey</th>
                                
                                
                                
                                <th>EventAt</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                                
                                <th>Details</th>
                                
                                
                                
                                <th>LegalHold</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.audit_events_tenant && Array.isArray(tenants.audit_events_tenant) &&
                              tenants.audit_events_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_events/audit_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_category">
                                        { item.event_category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_type">
                                        { item.target_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_key">
                                        { item.target_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_at">
                                        { dataFormatter.dateTimeFormatter(item.event_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="details">
                                        { item.details }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="legal_hold">
                                        { dataFormatter.booleanFormatter(item.legal_hold) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.audit_events_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Data_subject_requests Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>RequestType</th>
                                
                                
                                
                                <th>RequestStatus</th>
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>DueAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.data_subject_requests_tenant && Array.isArray(tenants.data_subject_requests_tenant) &&
                              tenants.data_subject_requests_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/data_subject_requests/data_subject_requests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="request_type">
                                        { item.request_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="request_status">
                                        { item.request_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_at">
                                        { dataFormatter.dateTimeFormatter(item.due_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.data_subject_requests_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Feature_flags Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>FlagName</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>Enabled</th>
                                
                                
                                
                                <th>TargetScope</th>
                                
                                
                                
                                <th>RolloutPercentage</th>
                                
                                
                                
                                <th>EnabledAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.feature_flags_tenant && Array.isArray(tenants.feature_flags_tenant) &&
                              tenants.feature_flags_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/feature_flags/feature_flags-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="enabled">
                                        { dataFormatter.booleanFormatter(item.enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_scope">
                                        { item.target_scope }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rollout_percentage">
                                        { item.rollout_percentage }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="enabled_at">
                                        { dataFormatter.dateTimeFormatter(item.enabled_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.feature_flags_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Event_streams Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>StreamType</th>
                                
                                
                                
                                <th>StreamName</th>
                                
                                
                                
                                <th>SubjectOrTopic</th>
                                
                                
                                
                                <th>RetentionPolicy</th>
                                
                                
                                
                                <th>RetentionDays</th>
                                
                                
                                
                                <th>StreamStatus</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.event_streams_tenant && Array.isArray(tenants.event_streams_tenant) &&
                              tenants.event_streams_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/event_streams/event_streams-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="stream_type">
                                        { item.stream_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject_or_topic">
                                        { item.subject_or_topic }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="retention_policy">
                                        { item.retention_policy }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="retention_days">
                                        { item.retention_days }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="stream_status">
                                        { item.stream_status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.event_streams_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                

                <BaseDivider />

                <BaseButton
                    color='info'
                    label='Back'
                    onClick={() => router.push('/tenants/tenants-list')}
                />
              </CardBox>
          </SectionMain>
      </>
    );
};

TenantsView.getLayout = function getLayout(page: ReactElement) {
    return (
      <LayoutAuthenticated
        
        permission={'READ_TENANTS'}
        
      >
          {page}
      </LayoutAuthenticated>
    )
}

export default TenantsView;