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?.tenant_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'}>TenantType</p>
                    <p>{tenants?.tenant_type ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

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

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

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

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_memberships Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>MembershipStatus</th>
                                
                                
                                
                                <th>JoinedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.user_memberships_tenant && Array.isArray(tenants.user_memberships_tenant) &&
                              tenants.user_memberships_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_memberships/user_memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="membership_status">
                                        { item.membership_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="joined_at">
                                        { dataFormatter.dateTimeFormatter(item.joined_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.user_memberships_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tenant_locations Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>LocationName</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                <th>Latitude</th>
                                
                                
                                
                                <th>Longitude</th>
                                
                                
                                
                                <th>Timezone</th>
                                
                                
                                
                                <th>IsPrimary</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.tenant_locations_tenant && Array.isArray(tenants.tenant_locations_tenant) &&
                              tenants.tenant_locations_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/tenant_locations/tenant_locations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="location_name">
                                        { item.location_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="latitude">
                                        { item.latitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="longitude">
                                        { item.longitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="timezone">
                                        { item.timezone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_primary">
                                        { dataFormatter.booleanFormatter(item.is_primary) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.tenant_locations_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ponds Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>PondName</th>
                                
                                
                                
                                <th>PondType</th>
                                
                                
                                
                                <th>AreaSqM</th>
                                
                                
                                
                                <th>AverageDepthM</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.ponds_tenant && Array.isArray(tenants.ponds_tenant) &&
                              tenants.ponds_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ponds/ponds-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="pond_name">
                                        { item.pond_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pond_type">
                                        { item.pond_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="area_sq_m">
                                        { item.area_sq_m }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="avg_depth_m">
                                        { item.avg_depth_m }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.ponds_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Batches Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>BatchCode</th>
                                
                                
                                
                                <th>StockedAt</th>
                                
                                
                                
                                <th>InitialCount</th>
                                
                                
                                
                                <th>InitialAverageWeightG</th>
                                
                                
                                
                                <th>BatchStatus</th>
                                
                                
                                
                                <th>ExpectedHarvestAt</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.batches_tenant && Array.isArray(tenants.batches_tenant) &&
                              tenants.batches_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/batches/batches-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="batch_code">
                                        { item.batch_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="stocked_at">
                                        { dataFormatter.dateTimeFormatter(item.stocked_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="initial_count">
                                        { item.initial_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="initial_avg_weight_g">
                                        { item.initial_avg_weight_g }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="batch_status">
                                        { item.batch_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expected_harvest_at">
                                        { dataFormatter.dateTimeFormatter(item.expected_harvest_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.batches_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Feed_products Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ProductName</th>
                                
                                
                                
                                <th>Brand</th>
                                
                                
                                
                                <th>FeedType</th>
                                
                                
                                
                                <th>ProteinPercent</th>
                                
                                
                                
                                <th>FatPercent</th>
                                
                                
                                
                                <th>PelletSizeMm</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.feed_products_tenant && Array.isArray(tenants.feed_products_tenant) &&
                              tenants.feed_products_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/feed_products/feed_products-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="product_name">
                                        { item.product_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="brand">
                                        { item.brand }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="feed_type">
                                        { item.feed_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="protein_percent">
                                        { item.protein_percent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fat_percent">
                                        { item.fat_percent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pellet_size_mm">
                                        { item.pellet_size_mm }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.feed_products_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Inventory_items Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ItemCategory</th>
                                
                                
                                
                                <th>ItemName</th>
                                
                                
                                
                                <th>SKU</th>
                                
                                
                                
                                <th>Unit</th>
                                
                                
                                
                                <th>QuantityOnHand</th>
                                
                                
                                
                                <th>ReorderLevel</th>
                                
                                
                                
                                <th>UnitCost</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.inventory_items_tenant && Array.isArray(tenants.inventory_items_tenant) &&
                              tenants.inventory_items_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/inventory_items/inventory_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="item_category">
                                        { item.item_category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="item_name">
                                        { item.item_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sku">
                                        { item.sku }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit">
                                        { item.unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity_on_hand">
                                        { item.quantity_on_hand }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reorder_level">
                                        { item.reorder_level }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit_cost">
                                        { item.unit_cost }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.inventory_items_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Inventory_movements Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>MovementType</th>
                                
                                
                                
                                <th>Quantity</th>
                                
                                
                                
                                <th>MovedAt</th>
                                
                                
                                
                                
                                
                                <th>Reference</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.inventory_movements_tenant && Array.isArray(tenants.inventory_movements_tenant) &&
                              tenants.inventory_movements_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/inventory_movements/inventory_movements-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="movement_type">
                                        { item.movement_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="moved_at">
                                        { dataFormatter.dateTimeFormatter(item.moved_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reference">
                                        { item.reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.inventory_movements_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Feeding_logs Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>FedAt</th>
                                
                                
                                
                                <th>QuantityKg</th>
                                
                                
                                
                                <th>FeedingMethod</th>
                                
                                
                                
                                <th>Appetite</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.feeding_logs_tenant && Array.isArray(tenants.feeding_logs_tenant) &&
                              tenants.feeding_logs_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/feeding_logs/feeding_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="fed_at">
                                        { dataFormatter.dateTimeFormatter(item.fed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity_kg">
                                        { item.quantity_kg }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="feeding_method">
                                        { item.feeding_method }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="appetite">
                                        { item.appetite }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.feeding_logs_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Water_quality_logs Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>SampledAt</th>
                                
                                
                                
                                <th>TemperatureC</th>
                                
                                
                                
                                <th>pH</th>
                                
                                
                                
                                <th>DissolvedOxygenMgL</th>
                                
                                
                                
                                <th>SalinityPpt</th>
                                
                                
                                
                                <th>AmmoniaMgL</th>
                                
                                
                                
                                <th>NitriteMgL</th>
                                
                                
                                
                                <th>NitrateMgL</th>
                                
                                
                                
                                <th>TurbidityNTU</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.water_quality_logs_tenant && Array.isArray(tenants.water_quality_logs_tenant) &&
                              tenants.water_quality_logs_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/water_quality_logs/water_quality_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sampled_at">
                                        { dataFormatter.dateTimeFormatter(item.sampled_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="temperature_c">
                                        { item.temperature_c }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ph">
                                        { item.ph }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="dissolved_oxygen_mg_l">
                                        { item.dissolved_oxygen_mg_l }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="salinity_ppt">
                                        { item.salinity_ppt }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ammonia_mg_l">
                                        { item.ammonia_mg_l }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nitrite_mg_l">
                                        { item.nitrite_mg_l }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nitrate_mg_l">
                                        { item.nitrate_mg_l }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="turbidity_ntu">
                                        { item.turbidity_ntu }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.water_quality_logs_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Health_events Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ObservedAt</th>
                                
                                
                                
                                <th>EventType</th>
                                
                                
                                
                                <th>Severity</th>
                                
                                
                                
                                <th>MortalityCount</th>
                                
                                
                                
                                <th>Symptoms</th>
                                
                                
                                
                                <th>Treatment</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>ResolutionStatus</th>
                                
                                
                                
                                <th>ResolvedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.health_events_tenant && Array.isArray(tenants.health_events_tenant) &&
                              tenants.health_events_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/health_events/health_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="observed_at">
                                        { dataFormatter.dateTimeFormatter(item.observed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="severity">
                                        { item.severity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mortality_count">
                                        { item.mortality_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="symptoms">
                                        { item.symptoms }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="treatment">
                                        { item.treatment }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="resolution_status">
                                        { item.resolution_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resolved_at">
                                        { dataFormatter.dateTimeFormatter(item.resolved_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.health_events_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Harvests Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>HarvestedAt</th>
                                
                                
                                
                                <th>TotalWeightKg</th>
                                
                                
                                
                                <th>TotalCount</th>
                                
                                
                                
                                <th>AverageWeightG</th>
                                
                                
                                
                                <th>Grade</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.harvests_tenant && Array.isArray(tenants.harvests_tenant) &&
                              tenants.harvests_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/harvests/harvests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="harvested_at">
                                        { dataFormatter.dateTimeFormatter(item.harvested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_weight_kg">
                                        { item.total_weight_kg }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_count">
                                        { item.total_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="avg_weight_g">
                                        { item.avg_weight_g }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="grade">
                                        { item.grade }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.harvests_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Marketplace_listings SellerTenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ListingTitle</th>
                                
                                
                                
                                
                                
                                <th>ProductForm</th>
                                
                                
                                
                                <th>AvailableQuantityKg</th>
                                
                                
                                
                                <th>PricePerKg</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>AvailableFrom</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                                
                                <th>ListingStatus</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.marketplace_listings_seller_tenant && Array.isArray(tenants.marketplace_listings_seller_tenant) &&
                              tenants.marketplace_listings_seller_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/marketplace_listings/marketplace_listings-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="listing_title">
                                        { item.listing_title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="product_form">
                                        { item.product_form }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="available_quantity_kg">
                                        { item.available_quantity_kg }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="price_per_kg">
                                        { item.price_per_kg }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="available_from">
                                        { dataFormatter.dateTimeFormatter(item.available_from) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="listing_status">
                                        { item.listing_status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.marketplace_listings_seller_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Orders BuyerTenant</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>OrderedAt</th>
                                
                                
                                
                                <th>OrderStatus</th>
                                
                                
                                
                                <th>SubtotalAmount</th>
                                
                                
                                
                                <th>TaxAmount</th>
                                
                                
                                
                                <th>ShippingAmount</th>
                                
                                
                                
                                <th>TotalAmount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>DeliveryAddress</th>
                                
                                
                                
                                <th>BuyerNotes</th>
                                
                                
                                
                                <th>ExpectedDeliveryAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.orders_buyer_tenant && Array.isArray(tenants.orders_buyer_tenant) &&
                              tenants.orders_buyer_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/orders/orders-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="order_number">
                                        { item.order_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="ordered_at">
                                        { dataFormatter.dateTimeFormatter(item.ordered_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="order_status">
                                        { item.order_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal_amount">
                                        { item.subtotal_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_amount">
                                        { item.tax_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipping_amount">
                                        { item.shipping_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_amount">
                                        { item.total_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_address">
                                        { item.delivery_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="buyer_notes">
                                        { item.buyer_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expected_delivery_at">
                                        { dataFormatter.dateTimeFormatter(item.expected_delivery_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.orders_buyer_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Orders SellerTenant</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>OrderedAt</th>
                                
                                
                                
                                <th>OrderStatus</th>
                                
                                
                                
                                <th>SubtotalAmount</th>
                                
                                
                                
                                <th>TaxAmount</th>
                                
                                
                                
                                <th>ShippingAmount</th>
                                
                                
                                
                                <th>TotalAmount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>DeliveryAddress</th>
                                
                                
                                
                                <th>BuyerNotes</th>
                                
                                
                                
                                <th>ExpectedDeliveryAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.orders_seller_tenant && Array.isArray(tenants.orders_seller_tenant) &&
                              tenants.orders_seller_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/orders/orders-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="order_number">
                                        { item.order_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="ordered_at">
                                        { dataFormatter.dateTimeFormatter(item.ordered_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="order_status">
                                        { item.order_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subtotal_amount">
                                        { item.subtotal_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_amount">
                                        { item.tax_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipping_amount">
                                        { item.shipping_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_amount">
                                        { item.total_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_address">
                                        { item.delivery_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="buyer_notes">
                                        { item.buyer_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expected_delivery_at">
                                        { dataFormatter.dateTimeFormatter(item.expected_delivery_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.orders_seller_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payment_transactions BuyerTenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>TransactionType</th>
                                
                                
                                
                                <th>TransactionStatus</th>
                                
                                
                                
                                <th>Amount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Provider</th>
                                
                                
                                
                                <th>ProviderReference</th>
                                
                                
                                
                                <th>ProcessedAt</th>
                                
                                
                                
                                <th>FailureReason</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.payment_transactions_buyer_tenant && Array.isArray(tenants.payment_transactions_buyer_tenant) &&
                              tenants.payment_transactions_buyer_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payment_transactions/payment_transactions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="transaction_type">
                                        { item.transaction_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="transaction_status">
                                        { item.transaction_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider">
                                        { item.provider }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider_reference">
                                        { item.provider_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="processed_at">
                                        { dataFormatter.dateTimeFormatter(item.processed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="failure_reason">
                                        { item.failure_reason }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.payment_transactions_buyer_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Payment_transactions SellerTenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>TransactionType</th>
                                
                                
                                
                                <th>TransactionStatus</th>
                                
                                
                                
                                <th>Amount</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>Provider</th>
                                
                                
                                
                                <th>ProviderReference</th>
                                
                                
                                
                                <th>ProcessedAt</th>
                                
                                
                                
                                <th>FailureReason</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.payment_transactions_seller_tenant && Array.isArray(tenants.payment_transactions_seller_tenant) &&
                              tenants.payment_transactions_seller_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payment_transactions/payment_transactions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="transaction_type">
                                        { item.transaction_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="transaction_status">
                                        { item.transaction_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider">
                                        { item.provider }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider_reference">
                                        { item.provider_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="processed_at">
                                        { dataFormatter.dateTimeFormatter(item.processed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="failure_reason">
                                        { item.failure_reason }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.payment_transactions_seller_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Investments InvestorTenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>InvestmentName</th>
                                
                                
                                
                                <th>InstrumentType</th>
                                
                                
                                
                                <th>AmountCommitted</th>
                                
                                
                                
                                <th>AmountFunded</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>CommittedAt</th>
                                
                                
                                
                                <th>FundedAt</th>
                                
                                
                                
                                <th>InvestmentStatus</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.investments_investor_tenant && Array.isArray(tenants.investments_investor_tenant) &&
                              tenants.investments_investor_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/investments/investments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="investment_name">
                                        { item.investment_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="instrument_type">
                                        { item.instrument_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_committed">
                                        { item.amount_committed }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_funded">
                                        { item.amount_funded }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="committed_at">
                                        { dataFormatter.dateTimeFormatter(item.committed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="funded_at">
                                        { dataFormatter.dateTimeFormatter(item.funded_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="investment_status">
                                        { item.investment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.investments_investor_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Investments FarmTenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>InvestmentName</th>
                                
                                
                                
                                <th>InstrumentType</th>
                                
                                
                                
                                <th>AmountCommitted</th>
                                
                                
                                
                                <th>AmountFunded</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>CommittedAt</th>
                                
                                
                                
                                <th>FundedAt</th>
                                
                                
                                
                                <th>InvestmentStatus</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.investments_farm_tenant && Array.isArray(tenants.investments_farm_tenant) &&
                              tenants.investments_farm_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/investments/investments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="investment_name">
                                        { item.investment_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="instrument_type">
                                        { item.instrument_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_committed">
                                        { item.amount_committed }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_funded">
                                        { item.amount_funded }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="committed_at">
                                        { dataFormatter.dateTimeFormatter(item.committed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="funded_at">
                                        { dataFormatter.dateTimeFormatter(item.funded_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="investment_status">
                                        { item.investment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.investments_farm_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Api_keys Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>KeyName</th>
                                
                                
                                
                                <th>KeyPrefix</th>
                                
                                
                                
                                <th>AccessLevel</th>
                                
                                
                                
                                <th>LastUsedAt</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                                
                                <th>IsRevoked</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.api_keys_tenant && Array.isArray(tenants.api_keys_tenant) &&
                              tenants.api_keys_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/api_keys/api_keys-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="key_name">
                                        { item.key_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="key_prefix">
                                        { item.key_prefix }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="access_level">
                                        { item.access_level }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_used_at">
                                        { dataFormatter.dateTimeFormatter(item.last_used_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_revoked">
                                        { dataFormatter.booleanFormatter(item.is_revoked) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.api_keys_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Webhook_endpoints Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>EndpointName</th>
                                
                                
                                
                                <th>URL</th>
                                
                                
                                
                                <th>Secret</th>
                                
                                
                                
                                <th>IsEnabled</th>
                                
                                
                                
                                <th>EventTypes</th>
                                
                                
                                
                                <th>LastDeliveryAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.webhook_endpoints_tenant && Array.isArray(tenants.webhook_endpoints_tenant) &&
                              tenants.webhook_endpoints_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/webhook_endpoints/webhook_endpoints-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="endpoint_name">
                                        { item.endpoint_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="url">
                                        { item.url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="secret">
                                        { item.secret }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_enabled">
                                        { dataFormatter.booleanFormatter(item.is_enabled) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_types">
                                        { item.event_types }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_delivery_at">
                                        { dataFormatter.dateTimeFormatter(item.last_delivery_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.webhook_endpoints_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>ToEmail</th>
                                
                                
                                
                                <th>Subject</th>
                                
                                
                                
                                <th>TemplateKey</th>
                                
                                
                                
                                <th>Payload</th>
                                
                                
                                
                                <th>SendStatus</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                                
                                <th>FailureReason</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="to_email">
                                        { item.to_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="template_key">
                                        { item.template_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payload">
                                        { item.payload }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="send_status">
                                        { item.send_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="failure_reason">
                                        { item.failure_reason }
                                    </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'}>Audit_logs Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Action</th>
                                
                                
                                
                                <th>EntityName</th>
                                
                                
                                
                                <th>EntityReference</th>
                                
                                
                                
                                <th>OccurredAt</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                                
                                <th>ChangeSummary</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.audit_logs_tenant && Array.isArray(tenants.audit_logs_tenant) &&
                              tenants.audit_logs_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_reference">
                                        { item.entity_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="change_summary">
                                        { item.change_summary }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.audit_logs_tenant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Csv_jobs Tenant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>JobType</th>
                                
                                
                                
                                <th>EntityName</th>
                                
                                
                                
                                <th>JobStatus</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>TotalRows</th>
                                
                                
                                
                                <th>ProcessedRows</th>
                                
                                
                                
                                <th>ErrorRows</th>
                                
                                
                                
                                <th>ErrorReport</th>
                                
                                
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>FinishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {tenants.csv_jobs_tenant && Array.isArray(tenants.csv_jobs_tenant) &&
                              tenants.csv_jobs_tenant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/csv_jobs/csv_jobs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="job_type">
                                        { item.job_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="job_status">
                                        { item.job_status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="total_rows">
                                        { item.total_rows }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="processed_rows">
                                        { item.processed_rows }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_rows">
                                        { item.error_rows }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_report">
                                        { item.error_report }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!tenants?.csv_jobs_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;