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_invitations Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>InviteeEmail</th>
                                
                                
                                
                                <th>InviteeName</th>
                                
                                
                                
                                <th>Role</th>
                                
                                
                                
                                
                                
                                <th>InviteTokenHash</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>AcceptedAt</th>
                                
                                
                                
                                <th>RevokedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.user_invitations_organization && Array.isArray(organizations.user_invitations_organization) &&
                              organizations.user_invitations_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_invitations/user_invitations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="invitee_email">
                                        { item.invitee_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="invitee_name">
                                        { item.invitee_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="role">
                                        { item.role }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="invite_token_hash">
                                        { item.invite_token_hash }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="accepted_at">
                                        { dataFormatter.dateTimeFormatter(item.accepted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="revoked_at">
                                        { dataFormatter.dateTimeFormatter(item.revoked_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.user_invitations_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Connected_systems Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>SystemName</th>
                                
                                
                                
                                <th>SystemType</th>
                                
                                
                                
                                <th>Vendor</th>
                                
                                
                                
                                <th>Environment</th>
                                
                                
                                
                                <th>Owner</th>
                                
                                
                                
                                <th>ConnectionStatus</th>
                                
                                
                                
                                <th>LastSuccessfulSyncAt</th>
                                
                                
                                
                                <th>ConnectionHealthNotes</th>
                                
                                
                                
                                <th>SourceofTruthFlag</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.connected_systems_organization && Array.isArray(organizations.connected_systems_organization) &&
                              organizations.connected_systems_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/connected_systems/connected_systems-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="system_name">
                                        { item.system_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="system_type">
                                        { item.system_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="vendor">
                                        { item.vendor }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="environment">
                                        { item.environment }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="owner">
                                        { item.owner }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="connection_status">
                                        { item.connection_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_successful_sync_at">
                                        { dataFormatter.dateTimeFormatter(item.last_successful_sync_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="connection_health_notes">
                                        { item.connection_health_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_of_truth_flag">
                                        { dataFormatter.booleanFormatter(item.source_of_truth_flag) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.connected_systems_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Control_frameworks organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>FrameworkName</th>
                                
                                
                                
                                <th>Version</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>ActiveFlag</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.control_frameworks_organizations && Array.isArray(organizations.control_frameworks_organizations) &&
                              organizations.control_frameworks_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/control_frameworks/control_frameworks-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="framework_name">
                                        { item.framework_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="version">
                                        { item.version }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="active_flag">
                                        { dataFormatter.booleanFormatter(item.active_flag) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.control_frameworks_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Control_requirements organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ControlCode</th>
                                
                                
                                
                                <th>ControlFamily</th>
                                
                                
                                
                                <th>ControlTitle</th>
                                
                                
                                
                                <th>ControlDescription</th>
                                
                                
                                
                                <th>EvidenceExpectationSummary</th>
                                
                                
                                
                                <th>ActiveFlag</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.control_requirements_organizations && Array.isArray(organizations.control_requirements_organizations) &&
                              organizations.control_requirements_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/control_requirements/control_requirements-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="control_code">
                                        { item.control_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="control_family">
                                        { item.control_family }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="control_title">
                                        { item.control_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="control_description">
                                        { item.control_description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="evidence_expectation_summary">
                                        { item.evidence_expectation_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="active_flag">
                                        { dataFormatter.booleanFormatter(item.active_flag) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.control_requirements_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Identity_workflows Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>WorkflowName</th>
                                
                                
                                
                                <th>WorkflowType</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>RiskLevel</th>
                                
                                
                                
                                <th>OwnerRole</th>
                                
                                
                                
                                <th>SourceTriggerType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>RecurrenceType</th>
                                
                                
                                
                                <th>TargetSLAHours</th>
                                
                                
                                
                                <th>CoverageGapNotes</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.identity_workflows_organization && Array.isArray(organizations.identity_workflows_organization) &&
                              organizations.identity_workflows_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/identity_workflows/identity_workflows-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="workflow_name">
                                        { item.workflow_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="workflow_type">
                                        { item.workflow_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="risk_level">
                                        { item.risk_level }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="owner_role">
                                        { item.owner_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_trigger_type">
                                        { item.source_trigger_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recurrence_type">
                                        { item.recurrence_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_sla_hours">
                                        { item.target_sla_hours }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coverage_gap_notes">
                                        { item.coverage_gap_notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.identity_workflows_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Evidence_models Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>EvidenceClaim</th>
                                
                                
                                
                                
                                
                                <th>ArtifactType</th>
                                
                                
                                
                                <th>RequiredFields</th>
                                
                                
                                
                                <th>ApprovalRequiredFlag</th>
                                
                                
                                
                                <th>RetentionPeriod</th>
                                
                                
                                
                                <th>EvidenceStrength</th>
                                
                                
                                
                                <th>CollectionMethod</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.evidence_models_organization && Array.isArray(organizations.evidence_models_organization) &&
                              organizations.evidence_models_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/evidence_models/evidence_models-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="evidence_claim">
                                        { item.evidence_claim }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="artifact_type">
                                        { item.artifact_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="required_fields">
                                        { item.required_fields }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="approval_required_flag">
                                        { dataFormatter.booleanFormatter(item.approval_required_flag) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="retention_period">
                                        { item.retention_period }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="evidence_strength">
                                        { item.evidence_strength }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="collection_method">
                                        { item.collection_method }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.evidence_models_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Artifacts Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ArtifactName</th>
                                
                                
                                
                                <th>ArtifactType</th>
                                
                                
                                
                                <th>ArtifactReference</th>
                                
                                
                                
                                
                                
                                <th>CollectedAt</th>
                                
                                
                                
                                <th>EventTimestamp</th>
                                
                                
                                
                                <th>SubjectUser</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ValidationNotes</th>
                                
                                
                                
                                <th>EvidenceStrengthScore</th>
                                
                                
                                
                                <th>ChainIntegrityScore</th>
                                
                                
                                
                                <th>RetentionExpiry</th>
                                
                                
                                
                                <th>Tags</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.artifacts_organization && Array.isArray(organizations.artifacts_organization) &&
                              organizations.artifacts_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/artifacts/artifacts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="artifact_name">
                                        { item.artifact_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="artifact_type">
                                        { item.artifact_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="artifact_reference">
                                        { item.artifact_reference }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="collected_at">
                                        { dataFormatter.dateTimeFormatter(item.collected_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_timestamp">
                                        { dataFormatter.dateTimeFormatter(item.event_timestamp) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject_user">
                                        { item.subject_user }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="validation_notes">
                                        { item.validation_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="evidence_strength_score">
                                        { item.evidence_strength_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="chain_integrity_score">
                                        { item.chain_integrity_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="retention_expiry">
                                        { dataFormatter.dateTimeFormatter(item.retention_expiry) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tags">
                                        { item.tags }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.artifacts_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Sampled_subjects Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>SampleType</th>
                                
                                
                                
                                <th>DisplayName</th>
                                
                                
                                
                                <th>Identifier</th>
                                
                                
                                
                                <th>Department</th>
                                
                                
                                
                                <th>Role</th>
                                
                                
                                
                                <th>Manager</th>
                                
                                
                                
                                <th>EventDate</th>
                                
                                
                                
                                <th>RiskTier</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.sampled_subjects_organization && Array.isArray(organizations.sampled_subjects_organization) &&
                              organizations.sampled_subjects_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/sampled_subjects/sampled_subjects-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="sample_type">
                                        { item.sample_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="display_name">
                                        { item.display_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="identifier">
                                        { item.identifier }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="department">
                                        { item.department }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="role_name">
                                        { item.role_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="manager">
                                        { item.manager }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_date">
                                        { dataFormatter.dateTimeFormatter(item.event_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="risk_tier">
                                        { item.risk_tier }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.sampled_subjects_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Proof_packets Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PacketName</th>
                                
                                
                                
                                <th>PacketType</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>PacketStatus</th>
                                
                                
                                
                                <th>ReadinessScore</th>
                                
                                
                                
                                <th>GeneratedOn</th>
                                
                                
                                
                                <th>DueDate</th>
                                
                                
                                
                                <th>Summary</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.proof_packets_organization && Array.isArray(organizations.proof_packets_organization) &&
                              organizations.proof_packets_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/proof_packets/proof_packets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="packet_name">
                                        { item.packet_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="packet_type">
                                        { item.packet_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="packet_status">
                                        { item.packet_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="readiness_score">
                                        { item.readiness_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="generated_on">
                                        { dataFormatter.dateTimeFormatter(item.generated_on) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_date">
                                        { dataFormatter.dateTimeFormatter(item.due_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="summary">
                                        { item.summary }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.proof_packets_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Remediation_items Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>Severity</th>
                                
                                
                                
                                <th>Category</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>DueDate</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>RemediationPlan</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.remediation_items_organization && Array.isArray(organizations.remediation_items_organization) &&
                              organizations.remediation_items_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/remediation_items/remediation_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="severity">
                                        { item.severity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="category">
                                        { item.category }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="due_date">
                                        { dataFormatter.dateTimeFormatter(item.due_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="remediation_plan">
                                        { item.remediation_plan }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.remediation_items_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Access_reviews Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ReviewName</th>
                                
                                
                                
                                <th>ReviewScope</th>
                                
                                
                                
                                <th>ReviewType</th>
                                
                                
                                
                                
                                
                                <th>StartDate</th>
                                
                                
                                
                                <th>DueDate</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>CompletionPercentage</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.access_reviews_organization && Array.isArray(organizations.access_reviews_organization) &&
                              organizations.access_reviews_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/access_reviews/access_reviews-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="review_name">
                                        { item.review_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="review_scope">
                                        { item.review_scope }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="review_type">
                                        { item.review_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="start_date">
                                        { dataFormatter.dateTimeFormatter(item.start_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_date">
                                        { dataFormatter.dateTimeFormatter(item.due_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completion_percentage">
                                        { item.completion_percentage }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.access_reviews_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Access_review_items Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>SubjectDisplayName</th>
                                
                                
                                
                                <th>SubjectIdentifier</th>
                                
                                
                                
                                <th>SystemName</th>
                                
                                
                                
                                <th>EntitlementsReviewed</th>
                                
                                
                                
                                <th>ReviewerDecision</th>
                                
                                
                                
                                <th>Justification</th>
                                
                                
                                
                                <th>ActionRequired</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.access_review_items_organization && Array.isArray(organizations.access_review_items_organization) &&
                              organizations.access_review_items_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/access_review_items/access_review_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="subject_display_name">
                                        { item.subject_display_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject_identifier">
                                        { item.subject_identifier }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="system_name">
                                        { item.system_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entitlements_reviewed">
                                        { item.entitlements_reviewed }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reviewer_decision">
                                        { item.reviewer_decision }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="justification">
                                        { item.justification }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="action_required">
                                        { dataFormatter.booleanFormatter(item.action_required) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.access_review_items_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Exceptions Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ExceptionName</th>
                                
                                
                                
                                <th>ExceptionType</th>
                                
                                
                                
                                <th>Subject</th>
                                
                                
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>GrantedAt</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                                
                                <th>RevokedAt</th>
                                
                                
                                
                                <th>Follow-upReviewRequired</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.exceptions_organization && Array.isArray(organizations.exceptions_organization) &&
                              organizations.exceptions_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/exceptions/exceptions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="exception_name">
                                        { item.exception_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="exception_type">
                                        { item.exception_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted_at">
                                        { dataFormatter.dateTimeFormatter(item.granted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="revoked_at">
                                        { dataFormatter.dateTimeFormatter(item.revoked_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="followup_review_required">
                                        { dataFormatter.booleanFormatter(item.followup_review_required) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.exceptions_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ActionType</th>
                                
                                
                                
                                <th>TargetEntityType</th>
                                
                                
                                
                                <th>TargetEntityKey</th>
                                
                                
                                
                                <th>Timestamp</th>
                                
                                
                                
                                <th>BeforeStateSummary</th>
                                
                                
                                
                                <th>AfterStateSummary</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.audit_logs_organization && Array.isArray(organizations.audit_logs_organization) &&
                              organizations.audit_logs_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="action_type">
                                        { item.action_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_type">
                                        { item.target_entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_key">
                                        { item.target_entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="timestamp">
                                        { dataFormatter.dateTimeFormatter(item.timestamp) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="before_state_summary">
                                        { item.before_state_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="after_state_summary">
                                        { item.after_state_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.audit_logs_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>NotificationType</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Message</th>
                                
                                
                                
                                <th>Priority</th>
                                
                                
                                
                                <th>ReadFlag</th>
                                
                                
                                
                                <th>ReadAt</th>
                                
                                
                                
                                <th>TargetEntityType</th>
                                
                                
                                
                                <th>TargetEntityKey</th>
                                
                                
                                
                                <th>ScheduledFor</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.notifications_organization && Array.isArray(organizations.notifications_organization) &&
                              organizations.notifications_organization.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">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message">
                                        { item.message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="priority">
                                        { item.priority }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_flag">
                                        { dataFormatter.booleanFormatter(item.read_flag) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_at">
                                        { dataFormatter.dateTimeFormatter(item.read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_type">
                                        { item.target_entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_key">
                                        { item.target_entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_for">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_for) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.notifications_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Organization_settings Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>DefaultRetentionPeriod</th>
                                
                                
                                
                                <th>RequireMFAForAllUsers</th>
                                
                                
                                
                                <th>EnableGlobalSearch</th>
                                
                                
                                
                                <th>EnableControlFrameworkLibrary</th>
                                
                                
                                
                                <th>DateFormat</th>
                                
                                
                                
                                <th>BrandingPrimaryColor</th>
                                
                                
                                
                                
                                
                                <th>NotificationEmailFromName</th>
                                
                                
                                
                                <th>NotificationEmailFromAddress</th>
                                
                                
                                
                                <th>SlackWebhookURL</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.organization_settings_organization && Array.isArray(organizations.organization_settings_organization) &&
                              organizations.organization_settings_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/organization_settings/organization_settings-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="default_retention_period">
                                        { item.default_retention_period }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="require_mfa_for_all_users">
                                        { dataFormatter.booleanFormatter(item.require_mfa_for_all_users) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="enable_global_search">
                                        { dataFormatter.booleanFormatter(item.enable_global_search) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="enable_control_framework_library">
                                        { dataFormatter.booleanFormatter(item.enable_control_framework_library) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="date_format">
                                        { item.date_format }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="branding_primary_color">
                                        { item.branding_primary_color }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notification_email_from_name">
                                        { item.notification_email_from_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notification_email_from_address">
                                        { item.notification_email_from_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="slack_webhook_url">
                                        { item.slack_webhook_url }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.organization_settings_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Artifact_type_catalog Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>TypeName</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>ActiveFlag</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.artifact_type_catalog_organization && Array.isArray(organizations.artifact_type_catalog_organization) &&
                              organizations.artifact_type_catalog_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/artifact_type_catalog/artifact_type_catalog-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="type_name">
                                        { item.type_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="active_flag">
                                        { dataFormatter.booleanFormatter(item.active_flag) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.artifact_type_catalog_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Workflow_templates Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>TemplateName</th>
                                
                                
                                
                                <th>WorkflowType</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>RiskLevel</th>
                                
                                
                                
                                <th>OwnerRole</th>
                                
                                
                                
                                <th>SourceTriggerType</th>
                                
                                
                                
                                <th>RecurrenceType</th>
                                
                                
                                
                                <th>DefaultRequiredFields</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.workflow_templates_organization && Array.isArray(organizations.workflow_templates_organization) &&
                              organizations.workflow_templates_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/workflow_templates/workflow_templates-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="template_name">
                                        { item.template_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="workflow_type">
                                        { item.workflow_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="risk_level">
                                        { item.risk_level }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="owner_role">
                                        { item.owner_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_trigger_type">
                                        { item.source_trigger_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recurrence_type">
                                        { item.recurrence_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="default_required_fields">
                                        { item.default_required_fields }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.workflow_templates_organization?.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;