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'}>Role_permissions organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>IsAllowed</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.role_permissions_organizations && Array.isArray(organizations.role_permissions_organizations) &&
                              organizations.role_permissions_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/role_permissions/role_permissions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_allowed">
                                        { dataFormatter.booleanFormatter(item.is_allowed) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.role_permissions_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Role_assignments Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>AssignedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.role_assignments_organization && Array.isArray(organizations.role_assignments_organization) &&
                              organizations.role_assignments_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/role_assignments/role_assignments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="assigned_at">
                                        { dataFormatter.dateTimeFormatter(item.assigned_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.role_assignments_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Teams Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>TeamName</th>
                                
                                
                                
                                <th>TeamCode</th>
                                
                                
                                
                                
                                
                                <th>Description</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.teams_organization && Array.isArray(organizations.teams_organization) &&
                              organizations.teams_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/teams/teams-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="team_name">
                                        { item.team_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="team_code">
                                        { item.team_code }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.teams_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Team_memberships organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>MembershipRole</th>
                                
                                
                                
                                <th>JoinedAt</th>
                                
                                
                                
                                <th>LeftAt</th>
                                
                                
                                
                                <th>IsPrimaryTeam</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.team_memberships_organizations && Array.isArray(organizations.team_memberships_organizations) &&
                              organizations.team_memberships_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/team_memberships/team_memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="membership_role">
                                        { item.membership_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="joined_at">
                                        { dataFormatter.dateTimeFormatter(item.joined_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="left_at">
                                        { dataFormatter.dateTimeFormatter(item.left_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_primary_team">
                                        { dataFormatter.booleanFormatter(item.is_primary_team) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.team_memberships_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Programs Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ProgramName</th>
                                
                                
                                
                                <th>ProgramType</th>
                                
                                
                                
                                
                                
                                <th>IsPublished</th>
                                
                                
                                
                                <th>PublishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.programs_organization && Array.isArray(organizations.programs_organization) &&
                              organizations.programs_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/programs/programs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="program_name">
                                        { item.program_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="program_type">
                                        { item.program_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_published">
                                        { dataFormatter.booleanFormatter(item.is_published) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="published_at">
                                        { dataFormatter.dateTimeFormatter(item.published_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.programs_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Learning_paths organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PathName</th>
                                
                                
                                
                                <th>Audience</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.learning_paths_organizations && Array.isArray(organizations.learning_paths_organizations) &&
                              organizations.learning_paths_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/learning_paths/learning_paths-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="path_name">
                                        { item.path_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="audience">
                                        { item.audience }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.learning_paths_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Missions organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>MissionTitle</th>
                                
                                
                                
                                <th>MissionCode</th>
                                
                                
                                
                                <th>MissionType</th>
                                
                                
                                
                                <th>SequenceOrder</th>
                                
                                
                                
                                <th>EstimatedMinutes</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>VideoURL</th>
                                
                                
                                
                                <th>IsRequired</th>
                                
                                
                                
                                <th>PointsAwarded</th>
                                
                                
                                
                                <th>CoinsAwarded</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.missions_organizations && Array.isArray(organizations.missions_organizations) &&
                              organizations.missions_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/missions/missions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="mission_title">
                                        { item.mission_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mission_code">
                                        { item.mission_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mission_type">
                                        { item.mission_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sequence_order">
                                        { item.sequence_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="estimated_minutes">
                                        { item.estimated_minutes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="video_url">
                                        { item.video_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_required">
                                        { dataFormatter.booleanFormatter(item.is_required) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="points_awarded">
                                        { item.points_awarded }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coins_awarded">
                                        { item.coins_awarded }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.missions_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Checklists organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ChecklistName</th>
                                
                                
                                
                                <th>ChecklistStage</th>
                                
                                
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.checklists_organizations && Array.isArray(organizations.checklists_organizations) &&
                              organizations.checklists_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/checklists/checklists-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="checklist_name">
                                        { item.checklist_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="checklist_stage">
                                        { item.checklist_stage }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.checklists_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Checklist_items organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ItemTitle</th>
                                
                                
                                
                                <th>SequenceOrder</th>
                                
                                
                                
                                <th>ItemType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>LinkURL</th>
                                
                                
                                
                                <th>IsRequired</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.checklist_items_organizations && Array.isArray(organizations.checklist_items_organizations) &&
                              organizations.checklist_items_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/checklist_items/checklist_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="item_title">
                                        { item.item_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sequence_order">
                                        { item.sequence_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="item_type">
                                        { item.item_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="link_url">
                                        { item.link_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_required">
                                        { dataFormatter.booleanFormatter(item.is_required) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.checklist_items_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Enrollments Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>EnrollmentStatus</th>
                                
                                
                                
                                <th>AssignedAt</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>DueAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.enrollments_organization && Array.isArray(organizations.enrollments_organization) &&
                              organizations.enrollments_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/enrollments/enrollments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="enrollment_status">
                                        { item.enrollment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="assigned_at">
                                        { dataFormatter.dateTimeFormatter(item.assigned_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_at">
                                        { dataFormatter.dateTimeFormatter(item.due_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.enrollments_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Mission_attempts organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>AttemptStatus</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>SubmittedAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>Score</th>
                                
                                
                                
                                <th>PointsEarned</th>
                                
                                
                                
                                <th>CoinsEarned</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.mission_attempts_organizations && Array.isArray(organizations.mission_attempts_organizations) &&
                              organizations.mission_attempts_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/mission_attempts/mission_attempts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="attempt_status">
                                        { item.attempt_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="score">
                                        { item.score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="points_earned">
                                        { item.points_earned }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coins_earned">
                                        { item.coins_earned }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.mission_attempts_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quizzes organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>QuizTitle</th>
                                
                                
                                
                                <th>GradingMethod</th>
                                
                                
                                
                                <th>PassingScore</th>
                                
                                
                                
                                <th>ShuffleQuestions</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.quizzes_organizations && Array.isArray(organizations.quizzes_organizations) &&
                              organizations.quizzes_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quizzes/quizzes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="quiz_title">
                                        { item.quiz_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="grading_method">
                                        { item.grading_method }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="passing_score">
                                        { item.passing_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="shuffle_questions">
                                        { dataFormatter.booleanFormatter(item.shuffle_questions) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.quizzes_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quiz_questions organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>QuestionType</th>
                                
                                
                                
                                
                                
                                <th>SequenceOrder</th>
                                
                                
                                
                                <th>Points</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.quiz_questions_organizations && Array.isArray(organizations.quiz_questions_organizations) &&
                              organizations.quiz_questions_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quiz_questions/quiz_questions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="question_type">
                                        { item.question_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sequence_order">
                                        { item.sequence_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="points">
                                        { item.points }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.quiz_questions_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quiz_choices organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ChoiceText</th>
                                
                                
                                
                                <th>IsCorrect</th>
                                
                                
                                
                                <th>SequenceOrder</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.quiz_choices_organizations && Array.isArray(organizations.quiz_choices_organizations) &&
                              organizations.quiz_choices_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quiz_choices/quiz_choices-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="choice_text">
                                        { item.choice_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_correct">
                                        { dataFormatter.booleanFormatter(item.is_correct) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sequence_order">
                                        { item.sequence_order }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.quiz_choices_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quiz_submissions organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>SubmittedAt</th>
                                
                                
                                
                                <th>Score</th>
                                
                                
                                
                                <th>IsPassed</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.quiz_submissions_organizations && Array.isArray(organizations.quiz_submissions_organizations) &&
                              organizations.quiz_submissions_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quiz_submissions/quiz_submissions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="score">
                                        { item.score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_passed">
                                        { dataFormatter.booleanFormatter(item.is_passed) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.quiz_submissions_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quiz_answers organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>AnswerText</th>
                                
                                
                                
                                <th>IsCorrect</th>
                                
                                
                                
                                <th>PointsEarned</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.quiz_answers_organizations && Array.isArray(organizations.quiz_answers_organizations) &&
                              organizations.quiz_answers_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quiz_answers/quiz_answers-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="answer_text">
                                        { item.answer_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_correct">
                                        { dataFormatter.booleanFormatter(item.is_correct) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="points_earned">
                                        { item.points_earned }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.quiz_answers_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Simulations organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>SimulationTitle</th>
                                
                                
                                
                                <th>SimulationType</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.simulations_organizations && Array.isArray(organizations.simulations_organizations) &&
                              organizations.simulations_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/simulations/simulations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="simulation_title">
                                        { item.simulation_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="simulation_type">
                                        { item.simulation_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.simulations_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Simulation_steps organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>SequenceOrder</th>
                                
                                
                                
                                <th>Speaker</th>
                                
                                
                                
                                
                                
                                <th>ExpectedResponseHint</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.simulation_steps_organizations && Array.isArray(organizations.simulation_steps_organizations) &&
                              organizations.simulation_steps_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/simulation_steps/simulation_steps-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="sequence_order">
                                        { item.sequence_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="speaker">
                                        { item.speaker }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="expected_response_hint">
                                        { item.expected_response_hint }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.simulation_steps_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Content_assets Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>AssetTitle</th>
                                
                                
                                
                                <th>AssetType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>AssetURL</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.content_assets_organization && Array.isArray(organizations.content_assets_organization) &&
                              organizations.content_assets_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/content_assets/content_assets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="asset_title">
                                        { item.asset_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="asset_type">
                                        { item.asset_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="asset_url">
                                        { item.asset_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.content_assets_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ai_content_requests Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>RequestType</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.ai_content_requests_organization && Array.isArray(organizations.ai_content_requests_organization) &&
                              organizations.ai_content_requests_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ai_content_requests/ai_content_requests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="request_type">
                                        { item.request_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.ai_content_requests_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Knowledge_gap_assessments Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>AssessmentType</th>
                                
                                
                                
                                <th>AssessedAt</th>
                                
                                
                                
                                <th>OverallScore</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.knowledge_gap_assessments_organization && Array.isArray(organizations.knowledge_gap_assessments_organization) &&
                              organizations.knowledge_gap_assessments_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/knowledge_gap_assessments/knowledge_gap_assessments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="assessment_type">
                                        { item.assessment_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="assessed_at">
                                        { dataFormatter.dateTimeFormatter(item.assessed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overall_score">
                                        { item.overall_score }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.knowledge_gap_assessments_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Badges Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>BadgeName</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>AwardRuleType</th>
                                
                                
                                
                                <th>ThresholdValue</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.badges_organization && Array.isArray(organizations.badges_organization) &&
                              organizations.badges_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/badges/badges-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="badge_name">
                                        { item.badge_name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="award_rule_type">
                                        { item.award_rule_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="threshold_value">
                                        { item.threshold_value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.badges_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_badges organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>AwardedAt</th>
                                
                                
                                
                                
                                
                                <th>AwardNote</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.user_badges_organizations && Array.isArray(organizations.user_badges_organizations) &&
                              organizations.user_badges_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_badges/user_badges-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="awarded_at">
                                        { dataFormatter.dateTimeFormatter(item.awarded_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="award_note">
                                        { item.award_note }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.user_badges_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Point_ledger_entries Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>EntryType</th>
                                
                                
                                
                                <th>PointsDelta</th>
                                
                                
                                
                                <th>CoinsDelta</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>OccurredAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.point_ledger_entries_organization && Array.isArray(organizations.point_ledger_entries_organization) &&
                              organizations.point_ledger_entries_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/point_ledger_entries/point_ledger_entries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="entry_type">
                                        { item.entry_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="points_delta">
                                        { item.points_delta }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coins_delta">
                                        { item.coins_delta }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.point_ledger_entries_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Challenges Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ChallengeName</th>
                                
                                
                                
                                <th>ChallengeType</th>
                                
                                
                                
                                <th>MetricType</th>
                                
                                
                                
                                
                                
                                <th>TargetValue</th>
                                
                                
                                
                                <th>RewardPoints</th>
                                
                                
                                
                                <th>RewardCoins</th>
                                
                                
                                
                                <th>StartsAt</th>
                                
                                
                                
                                <th>EndsAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.challenges_organization && Array.isArray(organizations.challenges_organization) &&
                              organizations.challenges_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/challenges/challenges-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="challenge_name">
                                        { item.challenge_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="challenge_type">
                                        { item.challenge_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="metric_type">
                                        { item.metric_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="target_value">
                                        { item.target_value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reward_points">
                                        { item.reward_points }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reward_coins">
                                        { item.reward_coins }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="starts_at">
                                        { dataFormatter.dateTimeFormatter(item.starts_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ends_at">
                                        { dataFormatter.dateTimeFormatter(item.ends_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.challenges_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Challenge_participants organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ParticipantType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>CurrentValue</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>RankPosition</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.challenge_participants_organizations && Array.isArray(organizations.challenge_participants_organizations) &&
                              organizations.challenge_participants_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/challenge_participants/challenge_participants-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="participant_type">
                                        { item.participant_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="current_value">
                                        { item.current_value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rank_position">
                                        { item.rank_position }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.challenge_participants_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reward_catalog_items Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ItemName</th>
                                
                                
                                
                                <th>ItemType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>CostCoins</th>
                                
                                
                                
                                <th>InventoryQuantity</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.reward_catalog_items_organization && Array.isArray(organizations.reward_catalog_items_organization) &&
                              organizations.reward_catalog_items_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reward_catalog_items/reward_catalog_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="item_name">
                                        { item.item_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="item_type">
                                        { item.item_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="cost_coins">
                                        { item.cost_coins }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="inventory_quantity">
                                        { item.inventory_quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.reward_catalog_items_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reward_redemptions Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Quantity</th>
                                
                                
                                
                                <th>CoinsSpent</th>
                                
                                
                                
                                <th>FulfillmentStatus</th>
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>FulfilledAt</th>
                                
                                
                                
                                <th>FulfillmentNote</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.reward_redemptions_organization && Array.isArray(organizations.reward_redemptions_organization) &&
                              organizations.reward_redemptions_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reward_redemptions/reward_redemptions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coins_spent">
                                        { item.coins_spent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fulfillment_status">
                                        { item.fulfillment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fulfilled_at">
                                        { dataFormatter.dateTimeFormatter(item.fulfilled_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fulfillment_note">
                                        { item.fulfillment_note }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.reward_redemptions_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Recognition_posts Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>RecognitionType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>PointsAwarded</th>
                                
                                
                                
                                <th>CoinsAwarded</th>
                                
                                
                                
                                <th>PostedAt</th>
                                
                                
                                
                                <th>IsPublic</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.recognition_posts_organization && Array.isArray(organizations.recognition_posts_organization) &&
                              organizations.recognition_posts_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/recognition_posts/recognition_posts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="recognition_type">
                                        { item.recognition_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="points_awarded">
                                        { item.points_awarded }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="coins_awarded">
                                        { item.coins_awarded }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="posted_at">
                                        { dataFormatter.dateTimeFormatter(item.posted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_public">
                                        { dataFormatter.booleanFormatter(item.is_public) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.recognition_posts_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Coaching_sessions Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>SessionType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ScheduledAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>FollowUpAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.coaching_sessions_organization && Array.isArray(organizations.coaching_sessions_organization) &&
                              organizations.coaching_sessions_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/coaching_sessions/coaching_sessions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="session_type">
                                        { item.session_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_at">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="follow_up_at">
                                        { dataFormatter.dateTimeFormatter(item.follow_up_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.coaching_sessions_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Kpi_definitions Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>KPIName</th>
                                
                                
                                
                                <th>KPIKey</th>
                                
                                
                                
                                <th>Unit</th>
                                
                                
                                
                                <th>Direction</th>
                                
                                
                                
                                <th>TargetValue</th>
                                
                                
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.kpi_definitions_organization && Array.isArray(organizations.kpi_definitions_organization) &&
                              organizations.kpi_definitions_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/kpi_definitions/kpi_definitions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="kpi_name">
                                        { item.kpi_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="kpi_key">
                                        { item.kpi_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unit">
                                        { item.unit }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="direction">
                                        { item.direction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_value">
                                        { item.target_value }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.kpi_definitions_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Kpi_measurements Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>MeasuredAt</th>
                                
                                
                                
                                <th>Value</th>
                                
                                
                                
                                <th>Source</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.kpi_measurements_organization && Array.isArray(organizations.kpi_measurements_organization) &&
                              organizations.kpi_measurements_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/kpi_measurements/kpi_measurements-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="measured_at">
                                        { dataFormatter.dateTimeFormatter(item.measured_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="value">
                                        { item.value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source">
                                        { item.source }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.kpi_measurements_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Qa_evaluations Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Channel</th>
                                
                                
                                
                                <th>InteractionReference</th>
                                
                                
                                
                                <th>InteractionAt</th>
                                
                                
                                
                                <th>EvaluatedAt</th>
                                
                                
                                
                                <th>OverallScore</th>
                                
                                
                                
                                <th>Result</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.qa_evaluations_organization && Array.isArray(organizations.qa_evaluations_organization) &&
                              organizations.qa_evaluations_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/qa_evaluations/qa_evaluations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="channel">
                                        { item.channel }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="interaction_reference">
                                        { item.interaction_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="interaction_at">
                                        { dataFormatter.dateTimeFormatter(item.interaction_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="evaluated_at">
                                        { dataFormatter.dateTimeFormatter(item.evaluated_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overall_score">
                                        { item.overall_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="result">
                                        { item.result }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.qa_evaluations_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Qa_scorecards organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>CategoryName</th>
                                
                                
                                
                                <th>CategoryScore</th>
                                
                                
                                
                                <th>MaxScore</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.qa_scorecards_organizations && Array.isArray(organizations.qa_scorecards_organizations) &&
                              organizations.qa_scorecards_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/qa_scorecards/qa_scorecards-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="category_name">
                                        { item.category_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="category_score">
                                        { item.category_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_score">
                                        { item.max_score }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.qa_scorecards_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Surveys Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>SurveyName</th>
                                
                                
                                
                                <th>SurveyType</th>
                                
                                
                                
                                
                                
                                <th>IsAnonymous</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>OpensAt</th>
                                
                                
                                
                                <th>ClosesAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.surveys_organization && Array.isArray(organizations.surveys_organization) &&
                              organizations.surveys_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/surveys/surveys-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="survey_name">
                                        { item.survey_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="survey_type">
                                        { item.survey_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_anonymous">
                                        { dataFormatter.booleanFormatter(item.is_anonymous) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="opens_at">
                                        { dataFormatter.dateTimeFormatter(item.opens_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="closes_at">
                                        { dataFormatter.dateTimeFormatter(item.closes_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.surveys_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Survey_questions organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>QuestionType</th>
                                
                                
                                
                                
                                
                                <th>SequenceOrder</th>
                                
                                
                                
                                <th>IsRequired</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.survey_questions_organizations && Array.isArray(organizations.survey_questions_organizations) &&
                              organizations.survey_questions_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/survey_questions/survey_questions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="question_type">
                                        { item.question_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sequence_order">
                                        { item.sequence_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_required">
                                        { dataFormatter.booleanFormatter(item.is_required) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.survey_questions_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Survey_responses Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>SubmittedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.survey_responses_organization && Array.isArray(organizations.survey_responses_organization) &&
                              organizations.survey_responses_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/survey_responses/survey_responses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.survey_responses_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Survey_response_items organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>AnswerValue</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.survey_response_items_organizations && Array.isArray(organizations.survey_response_items_organizations) &&
                              organizations.survey_response_items_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/survey_response_items/survey_response_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="answer_value">
                                        { item.answer_value }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.survey_response_items_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reports Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ReportName</th>
                                
                                
                                
                                <th>ReportType</th>
                                
                                
                                
                                <th>PeriodType</th>
                                
                                
                                
                                <th>PeriodStartAt</th>
                                
                                
                                
                                <th>PeriodEndAt</th>
                                
                                
                                
                                <th>FiltersJSON</th>
                                
                                
                                
                                <th>GeneratedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.reports_organization && Array.isArray(organizations.reports_organization) &&
                              organizations.reports_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reports/reports-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="report_name">
                                        { item.report_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="report_type">
                                        { item.report_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="period_type">
                                        { item.period_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="period_start_at">
                                        { dataFormatter.dateTimeFormatter(item.period_start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="period_end_at">
                                        { dataFormatter.dateTimeFormatter(item.period_end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="filters_json">
                                        { item.filters_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="generated_at">
                                        { dataFormatter.dateTimeFormatter(item.generated_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.reports_organization?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_events Organization</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>EventName</th>
                                
                                
                                
                                <th>EntityName</th>
                                
                                
                                
                                <th>EntityReference</th>
                                
                                
                                
                                <th>EventPayloadJSON</th>
                                
                                
                                
                                <th>OccurredAt</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.audit_events_organization && Array.isArray(organizations.audit_events_organization) &&
                              organizations.audit_events_organization.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_events/audit_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_name">
                                        { item.event_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_reference">
                                        { item.entity_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_payload_json">
                                        { item.event_payload_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.audit_events_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;