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'}>Projects Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ProjectName</th>
                                
                                
                                
                                <th>ProjectCode</th>
                                
                                
                                
                                <th>LocationName</th>
                                
                                
                                
                                <th>Latitude</th>
                                
                                
                                
                                <th>Longitude</th>
                                
                                
                                
                                <th>Commodity</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>StartDate</th>
                                
                                
                                
                                <th>TargetCompletionDate</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.projects_organization && Array.isArray(organizations.projects_organization) &&
                              organizations.projects_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/projects/projects-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="project_code">
                                        { item.project_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="location_name">
                                        { item.location_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="latitude">
                                        { item.latitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="longitude">
                                        { item.longitude }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="commodity">
                                        { item.commodity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_date">
                                        { dataFormatter.dateTimeFormatter(item.start_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_completion_date">
                                        { dataFormatter.dateTimeFormatter(item.target_completion_date) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.projects_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Project_phases organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PhaseType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>StartDate</th>
                                
                                
                                
                                <th>TargetDate</th>
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.project_phases_organizations && Array.isArray(organizations.project_phases_organizations) &&
                              organizations.project_phases_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/project_phases/project_phases-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="phase_type">
                                        { item.phase_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_date">
                                        { dataFormatter.dateTimeFormatter(item.start_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_date">
                                        { dataFormatter.dateTimeFormatter(item.target_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="approved_at">
                                        { dataFormatter.dateTimeFormatter(item.approved_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.project_phases_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Milestones organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>DueDate</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.milestones_organizations && Array.isArray(organizations.milestones_organizations) &&
                              organizations.milestones_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/milestones/milestones-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_date">
                                        { dataFormatter.dateTimeFormatter(item.due_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.milestones_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ore_bodies organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>OreBodyName</th>
                                
                                
                                
                                <th>Classification</th>
                                
                                
                                
                                <th>OreType</th>
                                
                                
                                
                                <th>HeadGradeAu(g/t)</th>
                                
                                
                                
                                <th>Tonnage(Mt)</th>
                                
                                
                                
                                <th>MineralogyJSON</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.ore_bodies_organizations && Array.isArray(organizations.ore_bodies_organizations) &&
                              organizations.ore_bodies_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ore_bodies/ore_bodies-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="classification">
                                        { item.classification }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ore_type">
                                        { item.ore_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="head_grade_au_gpt">
                                        { item.head_grade_au_gpt }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tonnage_mt">
                                        { item.tonnage_mt }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mineralogy_json">
                                        { item.mineralogy_json }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.ore_bodies_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Samples organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>SampleCode</th>
                                
                                
                                
                                <th>SampleType</th>
                                
                                
                                
                                <th>DrillholeID</th>
                                
                                
                                
                                <th>DepthFrom(m)</th>
                                
                                
                                
                                <th>DepthTo(m)</th>
                                
                                
                                
                                <th>CollectionDate</th>
                                
                                
                                
                                <th>Lithology</th>
                                
                                
                                
                                <th>Alteration</th>
                                
                                
                                
                                <th>GeometDomain</th>
                                
                                
                                
                                
                                
                                <th>PrepProtocol</th>
                                
                                
                                
                                <th>QAQCType</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.samples_organizations && Array.isArray(organizations.samples_organizations) &&
                              organizations.samples_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/samples/samples-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sample_code">
                                        { item.sample_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sample_type">
                                        { item.sample_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="drillhole_id">
                                        { item.drillhole_id }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="depth_from_m">
                                        { item.depth_from_m }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="depth_to_m">
                                        { item.depth_to_m }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="collection_date">
                                        { dataFormatter.dateTimeFormatter(item.collection_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lithology">
                                        { item.lithology }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="alteration">
                                        { item.alteration }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="geomet_domain">
                                        { item.geomet_domain }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="prep_protocol">
                                        { item.prep_protocol }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="qaqc_type">
                                        { item.qaqc_type }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.samples_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Chain_of_custody_events organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>EventTime</th>
                                
                                
                                
                                <th>EventType</th>
                                
                                
                                
                                <th>FromParty</th>
                                
                                
                                
                                <th>ToParty</th>
                                
                                
                                
                                <th>Location</th>
                                
                                
                                
                                <th>ShippingReference</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.chain_of_custody_events_organizations && Array.isArray(organizations.chain_of_custody_events_organizations) &&
                              organizations.chain_of_custody_events_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/chain_of_custody_events/chain_of_custody_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_time">
                                        { dataFormatter.dateTimeFormatter(item.event_time) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="from_party">
                                        { item.from_party }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="to_party">
                                        { item.to_party }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="location">
                                        { item.location }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shipping_reference">
                                        { item.shipping_reference }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.chain_of_custody_events_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Laboratories Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>LaboratoryName</th>
                                
                                
                                
                                <th>Country</th>
                                
                                
                                
                                <th>City</th>
                                
                                
                                
                                <th>ContactEmail</th>
                                
                                
                                
                                <th>ContactPhone</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.laboratories_organization && Array.isArray(organizations.laboratories_organization) &&
                              organizations.laboratories_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/laboratories/laboratories-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="country">
                                        { item.country }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contact_email">
                                        { item.contact_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contact_phone">
                                        { item.contact_phone }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.laboratories_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Test_type_schemas organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>TestCategory</th>
                                
                                
                                
                                <th>TestType</th>
                                
                                
                                
                                <th>DisplayName(EN)</th>
                                
                                
                                
                                <th>DisplayName(FR)</th>
                                
                                
                                
                                <th>ParametersSchemaJSON</th>
                                
                                
                                
                                <th>ResultsSchemaJSON</th>
                                
                                
                                
                                <th>CalculationRulesJSON</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.test_type_schemas_organizations && Array.isArray(organizations.test_type_schemas_organizations) &&
                              organizations.test_type_schemas_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/test_type_schemas/test_type_schemas-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="test_category">
                                        { item.test_category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="test_type">
                                        { item.test_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="display_name_en">
                                        { item.display_name_en }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="display_name_fr">
                                        { item.display_name_fr }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="parameters_schema_json">
                                        { item.parameters_schema_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="results_schema_json">
                                        { item.results_schema_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="calculation_rules_json">
                                        { item.calculation_rules_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.test_type_schemas_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Metallurgical_tests organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>LabReference</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>DateSubmitted</th>
                                
                                
                                
                                <th>DateCompleted</th>
                                
                                
                                
                                <th>DataSource</th>
                                
                                
                                
                                <th>ParametersJSON</th>
                                
                                
                                
                                <th>ResultsJSON</th>
                                
                                
                                
                                <th>QAQCStatus</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ReviewedAt</th>
                                
                                
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                                
                                <th>IsDeleted</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.metallurgical_tests_organizations && Array.isArray(organizations.metallurgical_tests_organizations) &&
                              organizations.metallurgical_tests_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/metallurgical_tests/metallurgical_tests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="lab_reference">
                                        { item.lab_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="date_submitted">
                                        { dataFormatter.dateTimeFormatter(item.date_submitted) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="date_completed">
                                        { dataFormatter.dateTimeFormatter(item.date_completed) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="data_source">
                                        { item.data_source }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="parameters_json">
                                        { item.parameters_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="results_json">
                                        { item.results_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="qaqc_status">
                                        { item.qaqc_status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reviewed_at">
                                        { dataFormatter.dateTimeFormatter(item.reviewed_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="approved_at">
                                        { dataFormatter.dateTimeFormatter(item.approved_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_deleted">
                                        { dataFormatter.booleanFormatter(item.is_deleted) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.metallurgical_tests_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Test_result_points organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>MeasuredAt</th>
                                
                                
                                
                                <th>ParameterName</th>
                                
                                
                                
                                <th>Value</th>
                                
                                
                                
                                <th>Unit</th>
                                
                                
                                
                                <th>ConfidenceLevel</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.test_result_points_organizations && Array.isArray(organizations.test_result_points_organizations) &&
                              organizations.test_result_points_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/test_result_points/test_result_points-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="measured_at">
                                        { dataFormatter.dateTimeFormatter(item.measured_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="parameter_name">
                                        { item.parameter_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value">
                                        { item.value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit">
                                        { item.unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence_level">
                                        { item.confidence_level }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.test_result_points_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Flowsheets organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>FlowsheetName</th>
                                
                                
                                
                                <th>VersionNumber</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                <th>LayoutJSON</th>
                                
                                
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.flowsheets_organizations && Array.isArray(organizations.flowsheets_organizations) &&
                              organizations.flowsheets_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/flowsheets/flowsheets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="version_number">
                                        { item.version_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="layout_json">
                                        { item.layout_json }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="approved_at">
                                        { dataFormatter.dateTimeFormatter(item.approved_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.flowsheets_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Equipment_items Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>EquipmentType</th>
                                
                                
                                
                                <th>Manufacturer</th>
                                
                                
                                
                                <th>Model</th>
                                
                                
                                
                                <th>Capacity</th>
                                
                                
                                
                                <th>CapacityUnit</th>
                                
                                
                                
                                <th>Power(kW)</th>
                                
                                
                                
                                <th>BaseCAPEX(USD)</th>
                                
                                
                                
                                <th>InstallFactor</th>
                                
                                
                                
                                <th>OPEXPerUnit</th>
                                
                                
                                
                                <th>OPEXUnit</th>
                                
                                
                                
                                <th>VendorQuoteReference</th>
                                
                                
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.equipment_items_organization && Array.isArray(organizations.equipment_items_organization) &&
                              organizations.equipment_items_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/equipment_items/equipment_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="equipment_type">
                                        { item.equipment_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="manufacturer">
                                        { item.manufacturer }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="model">
                                        { item.model }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="capacity">
                                        { item.capacity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="capacity_unit">
                                        { item.capacity_unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="power_kw">
                                        { item.power_kw }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_capex_usd">
                                        { item.base_capex_usd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="install_factor">
                                        { item.install_factor }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="opex_per_unit">
                                        { item.opex_per_unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="opex_unit">
                                        { item.opex_unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="vendor_quote_reference">
                                        { item.vendor_quote_reference }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.equipment_items_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Flowsheet_nodes organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>NodeKey</th>
                                
                                
                                
                                <th>NodeType</th>
                                
                                
                                
                                <th>UnitOperation</th>
                                
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>PositionX</th>
                                
                                
                                
                                <th>PositionY</th>
                                
                                
                                
                                <th>ParametersJSON</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.flowsheet_nodes_organizations && Array.isArray(organizations.flowsheet_nodes_organizations) &&
                              organizations.flowsheet_nodes_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/flowsheet_nodes/flowsheet_nodes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="node_key">
                                        { item.node_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="node_type">
                                        { item.node_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit_operation">
                                        { item.unit_operation }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="position_x">
                                        { item.position_x }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="position_y">
                                        { item.position_y }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="parameters_json">
                                        { item.parameters_json }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.flowsheet_nodes_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Flowsheet_streams organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>StreamType</th>
                                
                                
                                
                                <th>MassFlow(t/h)</th>
                                
                                
                                
                                <th>WaterFlow(m3/h)</th>
                                
                                
                                
                                <th>Solids(%)</th>
                                
                                
                                
                                <th>AuGrade(g/t)</th>
                                
                                
                                
                                <th>AuRecovery(%)</th>
                                
                                
                                
                                <th>ComponentsJSON</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.flowsheet_streams_organizations && Array.isArray(organizations.flowsheet_streams_organizations) &&
                              organizations.flowsheet_streams_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/flowsheet_streams/flowsheet_streams-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="stream_type">
                                        { item.stream_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mass_flow_tph">
                                        { item.mass_flow_tph }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="water_flow_m3h">
                                        { item.water_flow_m3h }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="solids_pct">
                                        { item.solids_pct }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="au_grade_gpt">
                                        { item.au_grade_gpt }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="au_recovery_pct">
                                        { item.au_recovery_pct }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="components_json">
                                        { item.components_json }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.flowsheet_streams_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Design_criteria_items organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Parameter</th>
                                
                                
                                
                                <th>Value</th>
                                
                                
                                
                                <th>Unit</th>
                                
                                
                                
                                <th>Confidence</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.design_criteria_items_organizations && Array.isArray(organizations.design_criteria_items_organizations) &&
                              organizations.design_criteria_items_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/design_criteria_items/design_criteria_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="parameter">
                                        { item.parameter }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value">
                                        { item.value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit">
                                        { item.unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence">
                                        { item.confidence }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.design_criteria_items_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Economic_models organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ModelName</th>
                                
                                
                                
                                <th>Currency</th>
                                
                                
                                
                                <th>GoldPrice</th>
                                
                                
                                
                                <th>DiscountRate(%)</th>
                                
                                
                                
                                <th>Throughput(tpd)</th>
                                
                                
                                
                                <th>Recovery(%)</th>
                                
                                
                                
                                <th>MineLife(years)</th>
                                
                                
                                
                                <th>TotalCAPEX</th>
                                
                                
                                
                                <th>OPEXPerTonne</th>
                                
                                
                                
                                <th>NPV</th>
                                
                                
                                
                                <th>IRR(%)</th>
                                
                                
                                
                                <th>Payback(years)</th>
                                
                                
                                
                                <th>AssumptionsJSON</th>
                                
                                
                                
                                <th>SensitivityJSON</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.economic_models_organizations && Array.isArray(organizations.economic_models_organizations) &&
                              organizations.economic_models_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/economic_models/economic_models-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="gold_price">
                                        { item.gold_price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="discount_rate_pct">
                                        { item.discount_rate_pct }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="throughput_tpd">
                                        { item.throughput_tpd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recovery_pct">
                                        { item.recovery_pct }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mine_life_years">
                                        { item.mine_life_years }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="capex_total">
                                        { item.capex_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="opex_per_tonne">
                                        { item.opex_per_tonne }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="npv">
                                        { item.npv }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="irr_pct">
                                        { item.irr_pct }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payback_years">
                                        { item.payback_years }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="assumptions_json">
                                        { item.assumptions_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sensitivity_json">
                                        { item.sensitivity_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.economic_models_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Capex_items organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>CostCategory</th>
                                
                                
                                
                                
                                
                                <th>Quantity</th>
                                
                                
                                
                                <th>UnitCost</th>
                                
                                
                                
                                <th>InstallFactor</th>
                                
                                
                                
                                <th>TotalCost</th>
                                
                                
                                
                                <th>EstimateClass</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.capex_items_organizations && Array.isArray(organizations.capex_items_organizations) &&
                              organizations.capex_items_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/capex_items/capex_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="cost_category">
                                        { item.cost_category }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit_cost">
                                        { item.unit_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="install_factor">
                                        { item.install_factor }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="total_cost">
                                        { item.total_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="estimate_class">
                                        { item.estimate_class }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.capex_items_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Opex_items organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>OPEXType</th>
                                
                                
                                
                                
                                
                                <th>Rate</th>
                                
                                
                                
                                <th>RateUnit</th>
                                
                                
                                
                                <th>UnitCost</th>
                                
                                
                                
                                <th>CostUnit</th>
                                
                                
                                
                                <th>AnnualCost</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.opex_items_organizations && Array.isArray(organizations.opex_items_organizations) &&
                              organizations.opex_items_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/opex_items/opex_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="opex_type">
                                        { item.opex_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="rate">
                                        { item.rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rate_unit">
                                        { item.rate_unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit_cost">
                                        { item.unit_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cost_unit">
                                        { item.cost_unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="annual_cost">
                                        { item.annual_cost }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.opex_items_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Monte_carlo_runs organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>FinishedAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Iterations</th>
                                
                                
                                
                                <th>InputsJSON</th>
                                
                                
                                
                                <th>ResultsJSON</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.monte_carlo_runs_organizations && Array.isArray(organizations.monte_carlo_runs_organizations) &&
                              organizations.monte_carlo_runs_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/monte_carlo_runs/monte_carlo_runs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="iterations">
                                        { item.iterations }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="inputs_json">
                                        { item.inputs_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="results_json">
                                        { item.results_json }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.monte_carlo_runs_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Documents organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>DocumentType</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>VersionNumber</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                <th>Tags</th>
                                
                                
                                
                                
                                
                                <th>UploadedAt</th>
                                
                                
                                
                                
                                
                                <th>WatermarkEnabled</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.documents_organizations && Array.isArray(organizations.documents_organizations) &&
                              organizations.documents_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/documents/documents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="doc_type">
                                        { item.doc_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="version_number">
                                        { item.version_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="tags">
                                        { item.tags }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="uploaded_at">
                                        { dataFormatter.dateTimeFormatter(item.uploaded_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="watermark_enabled">
                                        { dataFormatter.booleanFormatter(item.watermark_enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.documents_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Entity_links organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>SourceEntityType</th>
                                
                                
                                
                                <th>SourceEntityKey</th>
                                
                                
                                
                                <th>TargetEntityType</th>
                                
                                
                                
                                <th>TargetEntityKey</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.entity_links_organizations && Array.isArray(organizations.entity_links_organizations) &&
                              organizations.entity_links_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/entity_links/entity_links-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="source_entity_type">
                                        { item.source_entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_entity_key">
                                        { item.source_entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_type">
                                        { item.target_entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_key">
                                        { item.target_entity_key }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.entity_links_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Comments organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>EntityType</th>
                                
                                
                                
                                <th>EntityKey</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>PostedAt</th>
                                
                                
                                
                                
                                
                                <th>IsResolved</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.comments_organizations && Array.isArray(organizations.comments_organizations) &&
                              organizations.comments_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/comments/comments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="entity_type">
                                        { item.entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="posted_at">
                                        { dataFormatter.dateTimeFormatter(item.posted_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_resolved">
                                        { dataFormatter.booleanFormatter(item.is_resolved) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.comments_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tasks organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Priority</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>DueAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                
                                
                                <th>EntityType</th>
                                
                                
                                
                                <th>EntityKey</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.tasks_organizations && Array.isArray(organizations.tasks_organizations) &&
                              organizations.tasks_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/tasks/tasks-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="priority">
                                        { item.priority }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="due_at">
                                        { dataFormatter.dateTimeFormatter(item.due_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="entity_type">
                                        { item.entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.tasks_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Channel</th>
                                
                                
                                
                                <th>NotificationType</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Message</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                                
                                <th>ReadAt</th>
                                
                                
                                
                                <th>IsRead</th>
                                
                                
                                
                                <th>EntityType</th>
                                
                                
                                
                                <th>EntityKey</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.notifications_organizations && Array.isArray(organizations.notifications_organizations) &&
                              organizations.notifications_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notifications/notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="channel">
                                        { item.channel }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notification_type">
                                        { item.notification_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message">
                                        { item.message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_at">
                                        { dataFormatter.dateTimeFormatter(item.read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_read">
                                        { dataFormatter.booleanFormatter(item.is_read) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_type">
                                        { item.entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.notifications_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>EventTime</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Action</th>
                                
                                
                                
                                <th>EntityType</th>
                                
                                
                                
                                <th>EntityKey</th>
                                
                                
                                
                                <th>OldValueJSON</th>
                                
                                
                                
                                <th>NewValueJSON</th>
                                
                                
                                
                                <th>ChangeSummary</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                                
                                <th>SessionKey</th>
                                
                                
                                
                                <th>Checksum</th>
                                
                                
                                
                                <th>PreviousChecksum</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.audit_logs_organization && Array.isArray(organizations.audit_logs_organization) &&
                              organizations.audit_logs_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="event_time">
                                        { dataFormatter.dateTimeFormatter(item.event_time) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_type">
                                        { item.entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="old_value_json">
                                        { item.old_value_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="new_value_json">
                                        { item.new_value_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="change_summary">
                                        { item.change_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="session_key">
                                        { item.session_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="checksum">
                                        { item.checksum }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="previous_checksum">
                                        { item.previous_checksum }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.audit_logs_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Integrations Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>IntegrationType</th>
                                
                                
                                
                                <th>IntegrationName</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ConfigJSON</th>
                                
                                
                                
                                <th>LastSyncAt</th>
                                
                                
                                
                                <th>LastError</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.integrations_organization && Array.isArray(organizations.integrations_organization) &&
                              organizations.integrations_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/integrations/integrations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="integration_type">
                                        { item.integration_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="config_json">
                                        { item.config_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_sync_at">
                                        { dataFormatter.dateTimeFormatter(item.last_sync_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_error">
                                        { item.last_error }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.integrations_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Offline_sync_batches organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>CreatedAtLocal</th>
                                
                                
                                
                                <th>SyncedAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ItemsCount</th>
                                
                                
                                
                                <th>PayloadJSON</th>
                                
                                
                                
                                <th>ErrorDetails</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.offline_sync_batches_organizations && Array.isArray(organizations.offline_sync_batches_organizations) &&
                              organizations.offline_sync_batches_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/offline_sync_batches/offline_sync_batches-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="created_at_local">
                                        { dataFormatter.dateTimeFormatter(item.created_at_local) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="synced_at">
                                        { dataFormatter.dateTimeFormatter(item.synced_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="items_count">
                                        { item.items_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payload_json">
                                        { item.payload_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_details">
                                        { item.error_details }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.offline_sync_batches_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;