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'}>User_profiles organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>CPF</th>
                                
                                
                                
                                <th>Datadenascimento</th>
                                
                                
                                
                                <th>Estadocivil</th>
                                
                                
                                
                                <th>CPFdocônjuge</th>
                                
                                
                                
                                <th>Nomedocônjuge</th>
                                
                                
                                
                                <th>Nomedamãe</th>
                                
                                
                                
                                <th>CEP</th>
                                
                                
                                
                                <th>Logradouro</th>
                                
                                
                                
                                <th>Número</th>
                                
                                
                                
                                <th>Complemento</th>
                                
                                
                                
                                <th>Bairro</th>
                                
                                
                                
                                <th>Cidade</th>
                                
                                
                                
                                <th>UF</th>
                                
                                
                                
                                <th>Telefone</th>
                                
                                
                                
                                <th>Ocupação</th>
                                
                                
                                
                                <th>Naturezadaocupação(código)</th>
                                
                                
                                
                                <th>Ocupaçãoprincipal(CBO)</th>
                                
                                
                                
                                <th>CNPJdafonteprincipal</th>
                                
                                
                                
                                <th>Títulodeeleitor</th>
                                
                                
                                
                                <th>Zonaeleitoral</th>
                                
                                
                                
                                <th>Seçãoeleitoral</th>
                                
                                
                                
                                <th>NIT/PIS/PASEP</th>
                                
                                
                                
                                <th>CAEPF</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.user_profiles_organizations && Array.isArray(organizations.user_profiles_organizations) &&
                              organizations.user_profiles_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_profiles/user_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="cpf">
                                        { item.cpf }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="birth_date">
                                        { dataFormatter.dateTimeFormatter(item.birth_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="marital_status">
                                        { item.marital_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="spouse_cpf">
                                        { item.spouse_cpf }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="spouse_name">
                                        { item.spouse_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mother_name">
                                        { item.mother_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cep">
                                        { item.cep }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="street">
                                        { item.street }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="house_number">
                                        { item.house_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address_complement">
                                        { item.address_complement }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="neighborhood">
                                        { item.neighborhood }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="state_uf">
                                        { item.state_uf }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occupation_text">
                                        { item.occupation_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occupation_code">
                                        { item.occupation_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cbo_code">
                                        { item.cbo_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="main_source_cnpj">
                                        { item.main_source_cnpj }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="voter_title">
                                        { item.voter_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="voter_zone">
                                        { item.voter_zone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="voter_section">
                                        { item.voter_section }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nit_pis_pasep">
                                        { item.nit_pis_pasep }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="caepf_number">
                                        { item.caepf_number }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.user_profiles_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_profile_types organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipodeperfil</th>
                                
                                
                                
                                <th>Ativo</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.user_profile_types_organizations && Array.isArray(organizations.user_profile_types_organizations) &&
                              organizations.user_profile_types_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_profile_types/user_profile_types-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="profile_type">
                                        { item.profile_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="enabled">
                                        { dataFormatter.booleanFormatter(item.enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.user_profile_types_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Declarations organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Ano-base</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Modelodetributação</th>
                                
                                
                                
                                <th>Tipodedeclaração</th>
                                
                                
                                
                                <th>Númerodoreciboanterior</th>
                                
                                
                                
                                <th>Impostocalculado</th>
                                
                                
                                
                                <th>IRretidonafonte</th>
                                
                                
                                
                                <th>Saldoarestituir</th>
                                
                                
                                
                                <th>Saldoapagar</th>
                                
                                
                                
                                <th>Riskscore</th>
                                
                                
                                
                                <th>Detalhesderisco(JSON)</th>
                                
                                
                                
                                <th>URLdoarquivoDEC</th>
                                
                                
                                
                                <th>Datadeenvio</th>
                                
                                
                                
                                <th>Últimocálculo</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.declarations_organizations && Array.isArray(organizations.declarations_organizations) &&
                              organizations.declarations_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/declarations/declarations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="base_year">
                                        { item.base_year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_model">
                                        { item.tax_model }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="declaration_type">
                                        { item.declaration_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="previous_receipt_number">
                                        { item.previous_receipt_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_calculated">
                                        { item.tax_calculated }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_withheld">
                                        { item.tax_withheld }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="refund_amount">
                                        { item.refund_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payable_amount">
                                        { item.payable_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="risk_score">
                                        { item.risk_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="risk_details_json">
                                        { item.risk_details_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="dec_file_url">
                                        { item.dec_file_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_calculated_at">
                                        { dataFormatter.dateTimeFormatter(item.last_calculated_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.declarations_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Dependents organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Nome</th>
                                
                                
                                
                                <th>CPF</th>
                                
                                
                                
                                <th>Datadenascimento</th>
                                
                                
                                
                                <th>Códigodeparentesco</th>
                                
                                
                                
                                <th>Estudante</th>
                                
                                
                                
                                <th>Planodesaúde</th>
                                
                                
                                
                                <th>Rendaprópria</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.dependents_organizations && Array.isArray(organizations.dependents_organizations) &&
                              organizations.dependents_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/dependents/dependents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cpf">
                                        { item.cpf }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="birth_date">
                                        { dataFormatter.dateTimeFormatter(item.birth_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="relationship_code">
                                        { item.relationship_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="student">
                                        { dataFormatter.booleanFormatter(item.student) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="health_plan">
                                        { dataFormatter.booleanFormatter(item.health_plan) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="own_income">
                                        { item.own_income }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.dependents_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Data_sources organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipo</th>
                                
                                
                                
                                <th>Instituição</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Dadosimportados(JSON)</th>
                                
                                
                                
                                <th>Datadeimportação</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.data_sources_organizations && Array.isArray(organizations.data_sources_organizations) &&
                              organizations.data_sources_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/data_sources/data_sources-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="source_type">
                                        { item.source_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="institution_name">
                                        { item.institution_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="imported_payload_json">
                                        { item.imported_payload_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="imported_at">
                                        { dataFormatter.dateTimeFormatter(item.imported_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.data_sources_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Transactions organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Data</th>
                                
                                
                                
                                <th>Descrição</th>
                                
                                
                                
                                <th>Valor</th>
                                
                                
                                
                                <th>Tipo</th>
                                
                                
                                
                                <th>Categoria(IA)</th>
                                
                                
                                
                                <th>CampoIR</th>
                                
                                
                                
                                <th>FichaIR</th>
                                
                                
                                
                                <th>Tributação</th>
                                
                                
                                
                                <th>Confiança(0-100)</th>
                                
                                
                                
                                <th>Revisadopelousuário</th>
                                
                                
                                
                                <th>Requerrevisãohumana</th>
                                
                                
                                
                                <th>Motivodarevisão</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.transactions_organizations && Array.isArray(organizations.transactions_organizations) &&
                              organizations.transactions_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/transactions/transactions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="transaction_date">
                                        { dataFormatter.dateTimeFormatter(item.transaction_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="direction">
                                        { item.direction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ai_category">
                                        { item.ai_category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ir_field">
                                        { item.ir_field }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ir_form">
                                        { item.ir_form }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="taxation_type">
                                        { item.taxation_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="confidence_score">
                                        { item.confidence_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reviewed_by_user">
                                        { dataFormatter.booleanFormatter(item.reviewed_by_user) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requires_human_review">
                                        { dataFormatter.booleanFormatter(item.requires_human_review) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="review_reason">
                                        { item.review_reason }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.transactions_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>Tipodedocumento</th>
                                
                                
                                
                                <th>Nomedoarquivo</th>
                                
                                
                                
                                <th>URLnostorage</th>
                                
                                
                                
                                <th>Statusdeextração</th>
                                
                                
                                
                                <th>Confiançaextração(0-100)</th>
                                
                                
                                
                                <th>Dadosextraídos(JSON)</th>
                                
                                
                                
                                <th>Revisado</th>
                                
                                
                                
                                <th>Emissor</th>
                                
                                
                                
                                <th>CNPJdoemissor</th>
                                
                                
                                
                                <th>Anodereferência</th>
                                
                                
                                
                                <th>Datadeupload</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="document_type">
                                        { item.document_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="file_name">
                                        { item.file_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="storage_url">
                                        { item.storage_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="extraction_status">
                                        { item.extraction_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="extraction_confidence">
                                        { item.extraction_confidence }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="extracted_data_json">
                                        { item.extracted_data_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reviewed">
                                        { dataFormatter.booleanFormatter(item.reviewed) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issuer_name">
                                        { item.issuer_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issuer_cnpj">
                                        { item.issuer_cnpj }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reference_year">
                                        { item.reference_year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="uploaded_at">
                                        { dataFormatter.dateTimeFormatter(item.uploaded_at) }
                                    </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'}>Income_payers_pj organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>CNPJdafonte</th>
                                
                                
                                
                                <th>Nomedafonte</th>
                                
                                
                                
                                <th>Rendimentostributáveis</th>
                                
                                
                                
                                <th>Deduçõesoficiais</th>
                                
                                
                                
                                <th>INSSretido</th>
                                
                                
                                
                                <th>Impostoretido</th>
                                
                                
                                
                                <th>13ºsalário</th>
                                
                                
                                
                                <th>URLdoinforme</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.income_payers_pj_organizations && Array.isArray(organizations.income_payers_pj_organizations) &&
                              organizations.income_payers_pj_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/income_payers_pj/income_payers_pj-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="payer_cnpj">
                                        { item.payer_cnpj }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payer_name">
                                        { item.payer_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="taxable_income">
                                        { item.taxable_income }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="official_deductions">
                                        { item.official_deductions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="inss_withheld">
                                        { item.inss_withheld }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_withheld">
                                        { item.tax_withheld }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="thirteenth_salary">
                                        { item.thirteenth_salary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="informe_document_url">
                                        { item.informe_document_url }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.income_payers_pj_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Income_carne_leao_monthly organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Ano</th>
                                
                                
                                
                                <th>Mês</th>
                                
                                
                                
                                <th>Receitabruta</th>
                                
                                
                                
                                <th>Deduçõeslivro-caixa</th>
                                
                                
                                
                                <th>Basedecálculo</th>
                                
                                
                                
                                <th>Impostodevido</th>
                                
                                
                                
                                <th>DARFpago</th>
                                
                                
                                
                                <th>ComprovanteDARF(URL)</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.income_carne_leao_monthly_organizations && Array.isArray(organizations.income_carne_leao_monthly_organizations) &&
                              organizations.income_carne_leao_monthly_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/income_carne_leao_monthly/income_carne_leao_monthly-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="year">
                                        { item.year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="month">
                                        { item.month }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="gross_revenue">
                                        { item.gross_revenue }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bookkeeping_deductions">
                                        { item.bookkeeping_deductions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="taxable_base">
                                        { item.taxable_base }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_due">
                                        { item.tax_due }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="darf_paid">
                                        { dataFormatter.booleanFormatter(item.darf_paid) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="darf_document_url">
                                        { item.darf_document_url }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.income_carne_leao_monthly_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Exempt_incomes organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipoderendimentoisento</th>
                                
                                
                                
                                <th>Fonte</th>
                                
                                
                                
                                <th>CPF/CNPJdafonte</th>
                                
                                
                                
                                <th>Valor</th>
                                
                                
                                
                                <th>Competência</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.exempt_incomes_organizations && Array.isArray(organizations.exempt_incomes_organizations) &&
                              organizations.exempt_incomes_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/exempt_incomes/exempt_incomes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="income_type">
                                        { item.income_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_name">
                                        { item.source_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_document">
                                        { item.source_document }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="competence">
                                        { item.competence }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.exempt_incomes_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Exclusive_incomes organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipoderendimentoexclusivo</th>
                                
                                
                                
                                <th>Fonte</th>
                                
                                
                                
                                <th>CPF/CNPJdafonte</th>
                                
                                
                                
                                <th>Valor</th>
                                
                                
                                
                                <th>Impostoretido</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.exclusive_incomes_organizations && Array.isArray(organizations.exclusive_incomes_organizations) &&
                              organizations.exclusive_incomes_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/exclusive_incomes/exclusive_incomes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="income_type">
                                        { item.income_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_name">
                                        { item.source_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_document">
                                        { item.source_document }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_withheld">
                                        { item.tax_withheld }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.exclusive_incomes_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Assets organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Grupo</th>
                                
                                
                                
                                <th>Código</th>
                                
                                
                                
                                <th>Discriminação</th>
                                
                                
                                
                                <th>País</th>
                                
                                
                                
                                <th>Inscrição/Registro</th>
                                
                                
                                
                                <th>Situaçãoem31/12anoanterior</th>
                                
                                
                                
                                <th>Situaçãoem31/12anoatual</th>
                                
                                
                                
                                <th>Alienadonoano</th>
                                
                                
                                
                                <th>Valordealienação</th>
                                
                                
                                
                                <th>CPF/CNPJdocomprador</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.assets_organizations && Array.isArray(organizations.assets_organizations) &&
                              organizations.assets_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/assets/assets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="group_code">
                                        { item.group_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="item_code">
                                        { item.item_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description_text">
                                        { item.description_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="country">
                                        { item.country }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="registration_number">
                                        { item.registration_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value_previous_year">
                                        { item.value_previous_year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value_current_year">
                                        { item.value_current_year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="disposed_in_year">
                                        { dataFormatter.booleanFormatter(item.disposed_in_year) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="disposal_value">
                                        { item.disposal_value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="buyer_document">
                                        { item.buyer_document }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.assets_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Debts organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Código</th>
                                
                                
                                
                                <th>Nomedocredor</th>
                                
                                
                                
                                <th>CPF/CNPJdocredor</th>
                                
                                
                                
                                <th>Discriminação</th>
                                
                                
                                
                                <th>Saldoem31/12anoanterior</th>
                                
                                
                                
                                <th>Saldoem31/12anoatual</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.debts_organizations && Array.isArray(organizations.debts_organizations) &&
                              organizations.debts_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/debts/debts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="debt_code">
                                        { item.debt_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="creditor_name">
                                        { item.creditor_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="creditor_document">
                                        { item.creditor_document }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description_text">
                                        { item.description_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="balance_previous_year">
                                        { item.balance_previous_year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="balance_current_year">
                                        { item.balance_current_year }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.debts_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Deductible_payments organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Código</th>
                                
                                
                                
                                <th>Beneficiário</th>
                                
                                
                                
                                <th>CPF/CNPJdobeneficiário</th>
                                
                                
                                
                                <th>Valorpago</th>
                                
                                
                                
                                <th>Observações</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.deductible_payments_organizations && Array.isArray(organizations.deductible_payments_organizations) &&
                              organizations.deductible_payments_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/deductible_payments/deductible_payments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="payment_code">
                                        { item.payment_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="beneficiary_name">
                                        { item.beneficiary_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="beneficiary_document">
                                        { item.beneficiary_document }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_paid">
                                        { item.amount_paid }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.deductible_payments_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Investment_positions organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Ticker</th>
                                
                                
                                
                                <th>Nome</th>
                                
                                
                                
                                <th>Tipo</th>
                                
                                
                                
                                <th>Corretora/Exchange</th>
                                
                                
                                
                                <th>Quantidade</th>
                                
                                
                                
                                <th>Preçomédio/custo</th>
                                
                                
                                
                                <th>Valoranoanterior</th>
                                
                                
                                
                                <th>Valoranoatual</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.investment_positions_organizations && Array.isArray(organizations.investment_positions_organizations) &&
                              organizations.investment_positions_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/investment_positions/investment_positions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="ticker">
                                        { item.ticker }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="asset_name">
                                        { item.asset_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="asset_type">
                                        { item.asset_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="brokerage_name">
                                        { item.brokerage_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="avg_cost">
                                        { item.avg_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value_previous_year">
                                        { item.value_previous_year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value_current_year">
                                        { item.value_current_year }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.investment_positions_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Trades organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Data</th>
                                
                                
                                
                                <th>Ticker</th>
                                
                                
                                
                                <th>Operação</th>
                                
                                
                                
                                <th>Quantidade</th>
                                
                                
                                
                                <th>Preçounitário</th>
                                
                                
                                
                                <th>Taxas</th>
                                
                                
                                
                                <th>TipoIR</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.trades_organizations && Array.isArray(organizations.trades_organizations) &&
                              organizations.trades_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/trades/trades-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="trade_date">
                                        { dataFormatter.dateTimeFormatter(item.trade_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ticker">
                                        { item.ticker }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="operation">
                                        { item.operation }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit_price">
                                        { item.unit_price }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fees">
                                        { item.fees }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ir_operation_type">
                                        { item.ir_operation_type }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.trades_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Monthly_capital_gains organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Ano</th>
                                
                                
                                
                                <th>Mês</th>
                                
                                
                                
                                <th>Tipodeativo</th>
                                
                                
                                
                                <th>Ganhobruto</th>
                                
                                
                                
                                <th>Prejuízo</th>
                                
                                
                                
                                <th>Prejuízoacumulado</th>
                                
                                
                                
                                <th>Ganholíquido</th>
                                
                                
                                
                                <th>Alíquota</th>
                                
                                
                                
                                <th>Impostodevido</th>
                                
                                
                                
                                <th>DARFpago</th>
                                
                                
                                
                                <th>CódigoDARF</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.monthly_capital_gains_organizations && Array.isArray(organizations.monthly_capital_gains_organizations) &&
                              organizations.monthly_capital_gains_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/monthly_capital_gains/monthly_capital_gains-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="year">
                                        { item.year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="month">
                                        { item.month }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="asset_type">
                                        { item.asset_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="gross_gain">
                                        { item.gross_gain }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="gross_loss">
                                        { item.gross_loss }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="carryforward_loss">
                                        { item.carryforward_loss }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="net_gain">
                                        { item.net_gain }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_rate">
                                        { item.tax_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_due">
                                        { item.tax_due }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="darf_paid">
                                        { dataFormatter.booleanFormatter(item.darf_paid) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="darf_code">
                                        { item.darf_code }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.monthly_capital_gains_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Risk_analyses organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Scoregeral</th>
                                
                                
                                
                                <th>Fatores(JSON)</th>
                                
                                
                                
                                <th>Sugestões(JSON)</th>
                                
                                
                                
                                <th>Datadaanálise</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.risk_analyses_organizations && Array.isArray(organizations.risk_analyses_organizations) &&
                              organizations.risk_analyses_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/risk_analyses/risk_analyses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="overall_score">
                                        { item.overall_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="factors_json">
                                        { item.factors_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="optimization_suggestions_json">
                                        { item.optimization_suggestions_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="analyzed_at">
                                        { dataFormatter.dateTimeFormatter(item.analyzed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.risk_analyses_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>Tipo</th>
                                
                                
                                
                                <th>Título</th>
                                
                                
                                
                                <th>Mensagem</th>
                                
                                
                                
                                <th>Lida</th>
                                
                                
                                
                                <th>Enviadaem</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="notification_type">
                                        { item.notification_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title_text">
                                        { item.title_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message_text">
                                        { item.message_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read">
                                        { dataFormatter.booleanFormatter(item.read) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </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'}>Organization_memberships Organização</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Papelnaorganização</th>
                                
                                
                                
                                <th>Ativo</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.organization_memberships_organization && Array.isArray(organizations.organization_memberships_organization) &&
                              organizations.organization_memberships_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/organization_memberships/organization_memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="member_role">
                                        { item.member_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="active">
                                        { dataFormatter.booleanFormatter(item.active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.organization_memberships_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Accountant_client_accesses organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Acessoliberado</th>
                                
                                
                                
                                <th>Liberadoem</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.accountant_client_accesses_organizations && Array.isArray(organizations.accountant_client_accesses_organizations) &&
                              organizations.accountant_client_accesses_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/accountant_client_accesses/accountant_client_accesses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="access_granted">
                                        { dataFormatter.booleanFormatter(item.access_granted) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted_at">
                                        { dataFormatter.dateTimeFormatter(item.granted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.accountant_client_accesses_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipodeevento</th>
                                
                                
                                
                                <th>Entidade</th>
                                
                                
                                
                                <th>Chavedaentidade</th>
                                
                                
                                
                                <th>IP</th>
                                
                                
                                
                                <th>Useragent</th>
                                
                                
                                
                                <th>Detalhes(JSON)</th>
                                
                                
                                
                                <th>Datadoevento</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.audit_logs_organizations && Array.isArray(organizations.audit_logs_organizations) &&
                              organizations.audit_logs_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="details_json">
                                        { item.details_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_at">
                                        { dataFormatter.dateTimeFormatter(item.event_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.audit_logs_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Consents organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipodeconsentimento</th>
                                
                                
                                
                                <th>Versão</th>
                                
                                
                                
                                <th>Concedido</th>
                                
                                
                                
                                <th>Concedidoem</th>
                                
                                
                                
                                <th>Contexto(JSON)</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.consents_organizations && Array.isArray(organizations.consents_organizations) &&
                              organizations.consents_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/consents/consents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="consent_type">
                                        { item.consent_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="version">
                                        { item.version }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted">
                                        { dataFormatter.booleanFormatter(item.granted) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted_at">
                                        { dataFormatter.dateTimeFormatter(item.granted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="context_json">
                                        { item.context_json }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.consents_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Job_runs organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipodejob</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Tentativa</th>
                                
                                
                                
                                <th>Entrada(JSON)</th>
                                
                                
                                
                                <th>Saída(JSON)</th>
                                
                                
                                
                                <th>Erro</th>
                                
                                
                                
                                <th>Início</th>
                                
                                
                                
                                <th>Fim</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.job_runs_organizations && Array.isArray(organizations.job_runs_organizations) &&
                              organizations.job_runs_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/job_runs/job_runs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="job_type">
                                        { item.job_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="attempt">
                                        { item.attempt }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="input_json">
                                        { item.input_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="output_json">
                                        { item.output_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.job_runs_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;