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'}>Timezone</p>
                    <p>{tenants?.timezone}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Memberships</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                    <th>Status</th>
                                
                                
                                
                                    <th>Invitedat</th>
                                
                                
                                
                                    <th>Joinedat</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.memberships && Array.isArray(tenants.memberships) &&
                              tenants.memberships.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/memberships/memberships-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                    
                                    
                                    
                                  
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="invited_at">
                                        { dataFormatter.dateTimeFormatter(item.invited_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="joined_at">
                                        { dataFormatter.dateTimeFormatter(item.joined_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.memberships?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <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'}>Memberships Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Invitedat</th>
                                
                                
                                
                                <th>Joinedat</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.memberships_tenant && Array.isArray(tenants.memberships_tenant) &&
                              tenants.memberships_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/memberships/memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="invited_at">
                                        { dataFormatter.dateTimeFormatter(item.invited_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="joined_at">
                                        { dataFormatter.dateTimeFormatter(item.joined_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.memberships_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Approval_workflows Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Workflowname</th>
                                
                                
                                
                                <th>Appliesto</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.approval_workflows_tenant && Array.isArray(tenants.approval_workflows_tenant) &&
                              tenants.approval_workflows_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/approval_workflows/approval_workflows-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="applies_to">
                                        { item.applies_to }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.approval_workflows_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Approval_requests Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Objecttype</th>
                                
                                
                                
                                <th>Objectreference</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                <th>Requestedat</th>
                                
                                
                                
                                <th>Resolvedat</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.approval_requests_tenant && Array.isArray(tenants.approval_requests_tenant) &&
                              tenants.approval_requests_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/approval_requests/approval_requests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="object_type">
                                        { item.object_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="object_ref">
                                        { item.object_ref }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resolved_at">
                                        { dataFormatter.dateTimeFormatter(item.resolved_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.approval_requests_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Companies Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Legalname</th>
                                
                                
                                
                                <th>Tradename</th>
                                
                                
                                
                                <th>TaxID</th>
                                
                                
                                
                                <th>Addressline1</th>
                                
                                
                                
                                <th>Addressline2</th>
                                
                                
                                
                                <th>City</th>
                                
                                
                                
                                <th>Region</th>
                                
                                
                                
                                <th>Postalcode</th>
                                
                                
                                
                                <th>Country</th>
                                
                                
                                
                                <th>Phone</th>
                                
                                
                                
                                <th>Website</th>
                                
                                
                                
                                <th>Isactive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.companies_tenant && Array.isArray(tenants.companies_tenant) &&
                              tenants.companies_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/companies/companies-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="legal_name">
                                        { item.legal_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="trade_name">
                                        { item.trade_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_id">
                                        { item.tax_id }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address_line1">
                                        { item.address_line1 }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address_line2">
                                        { item.address_line2 }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="region">
                                        { item.region }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="postal_code">
                                        { item.postal_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="country">
                                        { item.country }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="website">
                                        { item.website }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.companies_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Customers Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Customercode</th>
                                
                                
                                
                                <th>Customername</th>
                                
                                
                                
                                <th>Email</th>
                                
                                
                                
                                <th>Phone</th>
                                
                                
                                
                                <th>Billingaddress</th>
                                
                                
                                
                                <th>Shippingaddress</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.customers_tenant && Array.isArray(tenants.customers_tenant) &&
                              tenants.customers_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/customers/customers-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="customer_code">
                                        { item.customer_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="email">
                                        { item.email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="billing_address">
                                        { item.billing_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipping_address">
                                        { item.shipping_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.customers_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Suppliers Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Suppliercode</th>
                                
                                
                                
                                <th>Suppliername</th>
                                
                                
                                
                                <th>Email</th>
                                
                                
                                
                                <th>Phone</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.suppliers_tenant && Array.isArray(tenants.suppliers_tenant) &&
                              tenants.suppliers_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/suppliers/suppliers-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="supplier_code">
                                        { item.supplier_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="email">
                                        { item.email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.suppliers_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Uoms Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>UOMname</th>
                                
                                
                                
                                <th>Symbol</th>
                                
                                
                                
                                <th>Basefactor</th>
                                
                                
                                
                                <th>Isbase</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.uoms_tenant && Array.isArray(tenants.uoms_tenant) &&
                              tenants.uoms_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/uoms/uoms-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="symbol">
                                        { item.symbol }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_factor">
                                        { item.base_factor }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_base">
                                        { dataFormatter.booleanFormatter(item.is_base) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.uoms_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Item_categories Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Categoryname</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.item_categories_tenant && Array.isArray(tenants.item_categories_tenant) &&
                              tenants.item_categories_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/item_categories/item_categories-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.item_categories_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Items Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>SKU</th>
                                
                                
                                
                                <th>Itemname</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Itemtype</th>
                                
                                
                                
                                <th>Trackingmode</th>
                                
                                
                                
                                <th>Isactive</th>
                                
                                
                                
                                <th>Salesprice</th>
                                
                                
                                
                                <th>Purchasecost</th>
                                
                                
                                
                                <th>Reorderpoint</th>
                                
                                
                                
                                <th>Reorderquantity</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.items_tenant && Array.isArray(tenants.items_tenant) &&
                              tenants.items_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/items/items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="sku">
                                        { item.sku }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="item_type">
                                        { item.item_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tracking_mode">
                                        { item.tracking_mode }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sales_price">
                                        { item.sales_price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="purchase_cost">
                                        { item.purchase_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reorder_point">
                                        { item.reorder_point }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reorder_qty">
                                        { item.reorder_qty }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.items_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Warehouses Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Warehousename</th>
                                
                                
                                
                                <th>Code</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                <th>Isactive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.warehouses_tenant && Array.isArray(tenants.warehouses_tenant) &&
                              tenants.warehouses_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/warehouses/warehouses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="code">
                                        { item.code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.warehouses_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Lots Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Lotnumber</th>
                                
                                
                                
                                <th>Manufacturedat</th>
                                
                                
                                
                                <th>Expiresat</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.lots_tenant && Array.isArray(tenants.lots_tenant) &&
                              tenants.lots_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/lots/lots-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="lot_number">
                                        { item.lot_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="manufactured_at">
                                        { dataFormatter.dateTimeFormatter(item.manufactured_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.lots_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Serial_numbers Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Serialnumber</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Receivedat</th>
                                
                                
                                
                                <th>Soldat</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.serial_numbers_tenant && Array.isArray(tenants.serial_numbers_tenant) &&
                              tenants.serial_numbers_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/serial_numbers/serial_numbers-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="serial_number">
                                        { item.serial_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sold_at">
                                        { dataFormatter.dateTimeFormatter(item.sold_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.serial_numbers_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Inventory_transfers Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Transfernumber</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Requestedat</th>
                                
                                
                                
                                <th>Shippedat</th>
                                
                                
                                
                                <th>Receivedat</th>
                                
                                
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.inventory_transfers_tenant && Array.isArray(tenants.inventory_transfers_tenant) &&
                              tenants.inventory_transfers_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/inventory_transfers/inventory_transfers-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="transfer_number">
                                        { item.transfer_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipped_at">
                                        { dataFormatter.dateTimeFormatter(item.shipped_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.inventory_transfers_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Stock_movements Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Movementat</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Quantity</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Sourcetype</th>
                                
                                
                                
                                <th>Sourcereference</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.stock_movements_tenant && Array.isArray(tenants.stock_movements_tenant) &&
                              tenants.stock_movements_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stock_movements/stock_movements-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="movement_at">
                                        { dataFormatter.dateTimeFormatter(item.movement_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="source_type">
                                        { item.source_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_ref">
                                        { item.source_ref }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.stock_movements_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quotations Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Quotenumber</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Issuedat</th>
                                
                                
                                
                                <th>Validuntil</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>Taxtotal</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.quotations_tenant && Array.isArray(tenants.quotations_tenant) &&
                              tenants.quotations_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quotations/quotations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="quote_number">
                                        { item.quote_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issued_at">
                                        { dataFormatter.dateTimeFormatter(item.issued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="valid_until">
                                        { dataFormatter.dateTimeFormatter(item.valid_until) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_total">
                                        { item.tax_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total">
                                        { item.total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.quotations_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Sales_orders Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Ordernumber</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Orderdate</th>
                                
                                
                                
                                <th>Requestedshipdate</th>
                                
                                
                                
                                <th>Shippedat</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>Taxtotal</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Shippingaddress</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.sales_orders_tenant && Array.isArray(tenants.sales_orders_tenant) &&
                              tenants.sales_orders_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/sales_orders/sales_orders-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="order_number">
                                        { item.order_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="order_date">
                                        { dataFormatter.dateTimeFormatter(item.order_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_ship_date">
                                        { dataFormatter.dateTimeFormatter(item.requested_ship_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipped_at">
                                        { dataFormatter.dateTimeFormatter(item.shipped_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_total">
                                        { item.tax_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total">
                                        { item.total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipping_address">
                                        { item.shipping_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.sales_orders_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Invoices Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Invoicenumber</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Issuedat</th>
                                
                                
                                
                                <th>Dueat</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>Taxtotal</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Balancedue</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.invoices_tenant && Array.isArray(tenants.invoices_tenant) &&
                              tenants.invoices_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/invoices/invoices-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="invoice_number">
                                        { item.invoice_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issued_at">
                                        { dataFormatter.dateTimeFormatter(item.issued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_at">
                                        { dataFormatter.dateTimeFormatter(item.due_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_total">
                                        { item.tax_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total">
                                        { item.total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="balance_due">
                                        { item.balance_due }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.invoices_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Customer_returns Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Returnnumber</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Requestedat</th>
                                
                                
                                
                                <th>Receivedat</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>Refundtotal</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.customer_returns_tenant && Array.isArray(tenants.customer_returns_tenant) &&
                              tenants.customer_returns_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/customer_returns/customer_returns-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="return_number">
                                        { item.return_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="refund_total">
                                        { item.refund_total }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.customer_returns_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Purchase_orders Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>POnumber</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Orderdate</th>
                                
                                
                                
                                <th>Expectedat</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>Taxtotal</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Shiptoaddress</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.purchase_orders_tenant && Array.isArray(tenants.purchase_orders_tenant) &&
                              tenants.purchase_orders_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/purchase_orders/purchase_orders-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="po_number">
                                        { item.po_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="order_date">
                                        { dataFormatter.dateTimeFormatter(item.order_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expected_at">
                                        { dataFormatter.dateTimeFormatter(item.expected_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_total">
                                        { item.tax_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total">
                                        { item.total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ship_to_address">
                                        { item.ship_to_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.purchase_orders_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Receipts Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Receiptnumber</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Receivedat</th>
                                
                                
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.receipts_tenant && Array.isArray(tenants.receipts_tenant) &&
                              tenants.receipts_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/receipts/receipts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="receipt_number">
                                        { item.receipt_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.receipts_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Vendor_bills Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Billnumber</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Billdate</th>
                                
                                
                                
                                <th>Dueat</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Subtotal</th>
                                
                                
                                
                                <th>Taxtotal</th>
                                
                                
                                
                                <th>Total</th>
                                
                                
                                
                                <th>Balancedue</th>
                                
                                
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.vendor_bills_tenant && Array.isArray(tenants.vendor_bills_tenant) &&
                              tenants.vendor_bills_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/vendor_bills/vendor_bills-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="bill_number">
                                        { item.bill_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bill_date">
                                        { dataFormatter.dateTimeFormatter(item.bill_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_at">
                                        { dataFormatter.dateTimeFormatter(item.due_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal">
                                        { item.subtotal }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_total">
                                        { item.tax_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total">
                                        { item.total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="balance_due">
                                        { item.balance_due }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.vendor_bills_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Chart_of_accounts Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Accountcode</th>
                                
                                
                                
                                <th>Accountname</th>
                                
                                
                                
                                <th>Accounttype</th>
                                
                                
                                
                                <th>Normalbalance</th>
                                
                                
                                
                                <th>Isactive</th>
                                
                                
                                
                                <th>Iscontrolaccount</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.chart_of_accounts_tenant && Array.isArray(tenants.chart_of_accounts_tenant) &&
                              tenants.chart_of_accounts_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/chart_of_accounts/chart_of_accounts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="account_code">
                                        { item.account_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="account_type">
                                        { item.account_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="normal_balance">
                                        { item.normal_balance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_control_account">
                                        { dataFormatter.booleanFormatter(item.is_control_account) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.chart_of_accounts_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Fiscal_periods Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Periodname</th>
                                
                                
                                
                                <th>Startsat</th>
                                
                                
                                
                                <th>Endsat</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.fiscal_periods_tenant && Array.isArray(tenants.fiscal_periods_tenant) &&
                              tenants.fiscal_periods_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/fiscal_periods/fiscal_periods-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="starts_at">
                                        { dataFormatter.dateTimeFormatter(item.starts_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ends_at">
                                        { dataFormatter.dateTimeFormatter(item.ends_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.fiscal_periods_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Journal_entries Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Journalnumber</th>
                                
                                
                                
                                <th>Entrydate</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Memo</th>
                                
                                
                                
                                <th>Sourcetype</th>
                                
                                
                                
                                <th>Sourcereference</th>
                                
                                
                                
                                
                                
                                <th>Postedat</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.journal_entries_tenant && Array.isArray(tenants.journal_entries_tenant) &&
                              tenants.journal_entries_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/journal_entries/journal_entries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="journal_number">
                                        { item.journal_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entry_date">
                                        { dataFormatter.dateTimeFormatter(item.entry_date) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="memo">
                                        { item.memo }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_type">
                                        { item.source_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_ref">
                                        { item.source_ref }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="posted_at">
                                        { dataFormatter.dateTimeFormatter(item.posted_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.journal_entries_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payments Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Paymentnumber</th>
                                
                                
                                
                                <th>Direction</th>
                                
                                
                                
                                <th>Counterpartytype</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Paidat</th>
                                
                                
                                
                                <th>Amount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Method</th>
                                
                                
                                
                                <th>Reference</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.payments_tenant && Array.isArray(tenants.payments_tenant) &&
                              tenants.payments_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payments/payments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="payment_number">
                                        { item.payment_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="direction">
                                        { item.direction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="counterparty_type">
                                        { item.counterparty_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="paid_at">
                                        { dataFormatter.dateTimeFormatter(item.paid_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="method">
                                        { item.method }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reference">
                                        { item.reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.payments_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tax_rates Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Taxname</th>
                                
                                
                                
                                <th>Rate</th>
                                
                                
                                
                                <th>Jurisdiction</th>
                                
                                
                                
                                <th>Isactive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.tax_rates_tenant && Array.isArray(tenants.tax_rates_tenant) &&
                              tenants.tax_rates_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/tax_rates/tax_rates-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rate">
                                        { item.rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="jurisdiction">
                                        { item.jurisdiction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.tax_rates_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Webhooks Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Webhookname</th>
                                
                                
                                
                                <th>URL</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Secret</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.webhooks_tenant && Array.isArray(tenants.webhooks_tenant) &&
                              tenants.webhooks_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/webhooks/webhooks-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="url">
                                        { item.url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="secret">
                                        { item.secret }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.webhooks_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Webhook_deliveries Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Eventtype</th>
                                
                                
                                
                                <th>Queuedat</th>
                                
                                
                                
                                <th>Deliveredat</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Attempts</th>
                                
                                
                                
                                <th>HTTPstatus</th>
                                
                                
                                
                                <th>Requestbody</th>
                                
                                
                                
                                <th>Responsebody</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.webhook_deliveries_tenant && Array.isArray(tenants.webhook_deliveries_tenant) &&
                              tenants.webhook_deliveries_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/webhook_deliveries/webhook_deliveries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="queued_at">
                                        { dataFormatter.dateTimeFormatter(item.queued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivered_at">
                                        { dataFormatter.dateTimeFormatter(item.delivered_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="attempts">
                                        { item.attempts }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="http_status">
                                        { item.http_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="request_body">
                                        { item.request_body }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="response_body">
                                        { item.response_body }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.webhook_deliveries_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Email_notifications Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Subject</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Queuedat</th>
                                
                                
                                
                                <th>Sentat</th>
                                
                                
                                
                                <th>Errormessage</th>
                                
                                
                                
                                <th>Relatedtype</th>
                                
                                
                                
                                <th>Relatedreference</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.email_notifications_tenant && Array.isArray(tenants.email_notifications_tenant) &&
                              tenants.email_notifications_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/email_notifications/email_notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="queued_at">
                                        { dataFormatter.dateTimeFormatter(item.queued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="related_type">
                                        { item.related_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="related_ref">
                                        { item.related_ref }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.email_notifications_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Csv_import_jobs Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Jobname</th>
                                
                                
                                
                                <th>Targetentity</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Requestedat</th>
                                
                                
                                
                                <th>Completedat</th>
                                
                                
                                
                                <th>Totalrows</th>
                                
                                
                                
                                <th>Successrows</th>
                                
                                
                                
                                <th>Errorrows</th>
                                
                                
                                
                                <th>Errorreport</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.csv_import_jobs_tenant && Array.isArray(tenants.csv_import_jobs_tenant) &&
                              tenants.csv_import_jobs_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/csv_import_jobs/csv_import_jobs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="job_name">
                                        { item.job_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity">
                                        { item.target_entity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_rows">
                                        { item.total_rows }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="success_rows">
                                        { item.success_rows }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_rows">
                                        { item.error_rows }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_report">
                                        { item.error_report }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.csv_import_jobs_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reports Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Reportname</th>
                                
                                
                                
                                <th>Reporttype</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>Isfavorite</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.reports_tenant && Array.isArray(tenants.reports_tenant) &&
                              tenants.reports_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reports/reports-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="report_type">
                                        { item.report_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_favorite">
                                        { dataFormatter.booleanFormatter(item.is_favorite) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.reports_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Dashboards Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Dashboardname</th>
                                
                                
                                
                                <th>Visibility</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.dashboards_tenant && Array.isArray(tenants.dashboards_tenant) &&
                              tenants.dashboards_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/dashboards/dashboards-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="visibility">
                                        { item.visibility }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.dashboards_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;