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/organizations/organizationsSlice'
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 OrganizationsView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { organizations } = useAppSelector((state) => state.organizations)
    
    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 organizations')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View organizations')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/organizations/organizations-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

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

              

              

              

              

              

              

              

              

              

              

              

              
              

                
                <>
                    <p className={'block font-bold mb-2'}>Users Organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>First Name</th>
                                
                                
                                
                                <th>Last Name</th>
                                
                                
                                
                                <th>Phone Number</th>
                                
                                
                                
                                <th>E-Mail</th>
                                
                                
                                
                                <th>Disabled</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.users_organizations && Array.isArray(organizations.users_organizations) &&
                              organizations.users_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/users/users-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="firstName">
                                        { item.firstName }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lastName">
                                        { item.lastName }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phoneNumber">
                                        { item.phoneNumber }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="email">
                                        { item.email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="disabled">
                                        { dataFormatter.booleanFormatter(item.disabled) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.users_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tenants organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>TenantName</th>
                                
                                
                                
                                <th>Slug</th>
                                
                                
                                
                                <th>TenantType</th>
                                
                                
                                
                                <th>ContactEmail</th>
                                
                                
                                
                                <th>ContactPhone</th>
                                
                                
                                
                                <th>BillingAddress</th>
                                
                                
                                
                                <th>SubscriptionStatus</th>
                                
                                
                                
                                <th>TrialEndsAt</th>
                                
                                
                                
                                <th>IsEnabled</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.tenants_organizations && Array.isArray(organizations.tenants_organizations) &&
                              organizations.tenants_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/tenants/tenants-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="tenant_name">
                                        { item.tenant_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="slug">
                                        { item.slug }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tenant_type">
                                        { item.tenant_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contact_email">
                                        { item.contact_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contact_phone">
                                        { item.contact_phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="billing_address">
                                        { item.billing_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subscription_status">
                                        { item.subscription_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="trial_ends_at">
                                        { dataFormatter.dateTimeFormatter(item.trial_ends_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_enabled">
                                        { dataFormatter.booleanFormatter(item.is_enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.tenants_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_memberships organizations</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>
                            {organizations.user_memberships_organizations && Array.isArray(organizations.user_memberships_organizations) &&
                              organizations.user_memberships_organizations.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>
                        {!organizations?.user_memberships_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tenant_locations organizations</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>
                            {organizations.tenant_locations_organizations && Array.isArray(organizations.tenant_locations_organizations) &&
                              organizations.tenant_locations_organizations.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>
                        {!organizations?.tenant_locations_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ponds organizations</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>
                            {organizations.ponds_organizations && Array.isArray(organizations.ponds_organizations) &&
                              organizations.ponds_organizations.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>
                        {!organizations?.ponds_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Species organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>SpeciesName</th>
                                
                                
                                
                                <th>ScientificName</th>
                                
                                
                                
                                <th>TypicalHarvestSize</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.species_organizations && Array.isArray(organizations.species_organizations) &&
                              organizations.species_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/species/species-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="species_name">
                                        { item.species_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scientific_name">
                                        { item.scientific_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="typical_harvest_size">
                                        { item.typical_harvest_size }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.species_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Batches organizations</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>
                            {organizations.batches_organizations && Array.isArray(organizations.batches_organizations) &&
                              organizations.batches_organizations.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>
                        {!organizations?.batches_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Feed_products organizations</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>
                            {organizations.feed_products_organizations && Array.isArray(organizations.feed_products_organizations) &&
                              organizations.feed_products_organizations.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>
                        {!organizations?.feed_products_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Inventory_items organizations</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>
                            {organizations.inventory_items_organizations && Array.isArray(organizations.inventory_items_organizations) &&
                              organizations.inventory_items_organizations.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>
                        {!organizations?.inventory_items_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Inventory_movements organizations</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>
                            {organizations.inventory_movements_organizations && Array.isArray(organizations.inventory_movements_organizations) &&
                              organizations.inventory_movements_organizations.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>
                        {!organizations?.inventory_movements_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Feeding_logs organizations</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>
                            {organizations.feeding_logs_organizations && Array.isArray(organizations.feeding_logs_organizations) &&
                              organizations.feeding_logs_organizations.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>
                        {!organizations?.feeding_logs_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Water_quality_logs organizations</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>
                            {organizations.water_quality_logs_organizations && Array.isArray(organizations.water_quality_logs_organizations) &&
                              organizations.water_quality_logs_organizations.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>
                        {!organizations?.water_quality_logs_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Health_events organizations</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>
                            {organizations.health_events_organizations && Array.isArray(organizations.health_events_organizations) &&
                              organizations.health_events_organizations.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>
                        {!organizations?.health_events_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Harvests organizations</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>
                            {organizations.harvests_organizations && Array.isArray(organizations.harvests_organizations) &&
                              organizations.harvests_organizations.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>
                        {!organizations?.harvests_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Marketplace_listings organizations</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>
                            {organizations.marketplace_listings_organizations && Array.isArray(organizations.marketplace_listings_organizations) &&
                              organizations.marketplace_listings_organizations.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>
                        {!organizations?.marketplace_listings_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Orders organizations</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>
                            {organizations.orders_organizations && Array.isArray(organizations.orders_organizations) &&
                              organizations.orders_organizations.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>
                        {!organizations?.orders_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Order_items organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>QuantityKg</th>
                                
                                
                                
                                <th>UnitPrice</th>
                                
                                
                                
                                <th>LineTotal</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.order_items_organizations && Array.isArray(organizations.order_items_organizations) &&
                              organizations.order_items_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/order_items/order_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quantity_kg">
                                        { item.quantity_kg }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit_price">
                                        { item.unit_price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="line_total">
                                        { item.line_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.order_items_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payment_transactions organizations</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>
                            {organizations.payment_transactions_organizations && Array.isArray(organizations.payment_transactions_organizations) &&
                              organizations.payment_transactions_organizations.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>
                        {!organizations?.payment_transactions_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Shipment_updates organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ShipmentStatus</th>
                                
                                
                                
                                <th>Carrier</th>
                                
                                
                                
                                <th>TrackingNumber</th>
                                
                                
                                
                                <th>StatusAt</th>
                                
                                
                                
                                <th>StatusDetails</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.shipment_updates_organizations && Array.isArray(organizations.shipment_updates_organizations) &&
                              organizations.shipment_updates_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/shipment_updates/shipment_updates-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="shipment_status">
                                        { item.shipment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="carrier">
                                        { item.carrier }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tracking_number">
                                        { item.tracking_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status_at">
                                        { dataFormatter.dateTimeFormatter(item.status_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status_details">
                                        { item.status_details }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.shipment_updates_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Investments organizations</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>
                            {organizations.investments_organizations && Array.isArray(organizations.investments_organizations) &&
                              organizations.investments_organizations.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>
                        {!organizations?.investments_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Api_keys organizations</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>
                            {organizations.api_keys_organizations && Array.isArray(organizations.api_keys_organizations) &&
                              organizations.api_keys_organizations.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>
                        {!organizations?.api_keys_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Webhook_endpoints organizations</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>
                            {organizations.webhook_endpoints_organizations && Array.isArray(organizations.webhook_endpoints_organizations) &&
                              organizations.webhook_endpoints_organizations.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>
                        {!organizations?.webhook_endpoints_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Webhook_deliveries organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>EventType</th>
                                
                                
                                
                                <th>EventReference</th>
                                
                                
                                
                                <th>DeliveredAt</th>
                                
                                
                                
                                <th>DeliveryStatus</th>
                                
                                
                                
                                <th>HTTPStatus</th>
                                
                                
                                
                                <th>RequestPayload</th>
                                
                                
                                
                                <th>ResponseBody</th>
                                
                                
                                
                                <th>AttemptCount</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.webhook_deliveries_organizations && Array.isArray(organizations.webhook_deliveries_organizations) &&
                              organizations.webhook_deliveries_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/webhook_deliveries/webhook_deliveries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_reference">
                                        { item.event_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivered_at">
                                        { dataFormatter.dateTimeFormatter(item.delivered_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="delivery_status">
                                        { item.delivery_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="http_status">
                                        { item.http_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="request_payload">
                                        { item.request_payload }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="response_body">
                                        { item.response_body }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="attempt_count">
                                        { item.attempt_count }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.webhook_deliveries_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Email_notifications organizations</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>
                            {organizations.email_notifications_organizations && Array.isArray(organizations.email_notifications_organizations) &&
                              organizations.email_notifications_organizations.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>
                        {!organizations?.email_notifications_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs organizations</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>
                            {organizations.audit_logs_organizations && Array.isArray(organizations.audit_logs_organizations) &&
                              organizations.audit_logs_organizations.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>
                        {!organizations?.audit_logs_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Csv_jobs organizations</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>
                            {organizations.csv_jobs_organizations && Array.isArray(organizations.csv_jobs_organizations) &&
                              organizations.csv_jobs_organizations.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>
                        {!organizations?.csv_jobs_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                

                <BaseDivider />

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

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

export default OrganizationsView;