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'}>Clubs organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>ClubName</th>
                                
                                
                                
                                <th>Slug</th>
                                
                                
                                
                                <th>City</th>
                                
                                
                                
                                <th>Country</th>
                                
                                
                                
                                
                                
                                <th>DefaultLanguage</th>
                                
                                
                                
                                <th>DefaultTargetHeadcount</th>
                                
                                
                                
                                <th>PaymentReminderDays</th>
                                
                                
                                
                                <th>InactiveNudgeLastGames</th>
                                
                                
                                
                                <th>MessengerGroupThread</th>
                                
                                
                                
                                <th>MessengerAccessToken</th>
                                
                                
                                
                                <th>StripeAccountReference</th>
                                
                                
                                
                                <th>StripeConnected</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.clubs_organizations && Array.isArray(organizations.clubs_organizations) &&
                              organizations.clubs_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/clubs/clubs-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="slug">
                                        { item.slug }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="country">
                                        { item.country }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="default_language">
                                        { item.default_language }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="default_target_headcount">
                                        { item.default_target_headcount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payment_reminder_days">
                                        { item.payment_reminder_days }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="inactive_nudge_last_games">
                                        { item.inactive_nudge_last_games }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="messenger_group_thread">
                                        { item.messenger_group_thread }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="messenger_access_token">
                                        { item.messenger_access_token }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="stripe_account_reference">
                                        { item.stripe_account_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="stripe_connected">
                                        { dataFormatter.booleanFormatter(item.stripe_connected) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.clubs_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Club_memberships organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ClubRole</th>
                                
                                
                                
                                <th>MemberCode</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                                
                                <th>MemberSince</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.club_memberships_organizations && Array.isArray(organizations.club_memberships_organizations) &&
                              organizations.club_memberships_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/club_memberships/club_memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="club_role">
                                        { item.club_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="member_code">
                                        { item.member_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="member_since_at">
                                        { dataFormatter.dateTimeFormatter(item.member_since_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.club_memberships_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Players organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>PlayerName</th>
                                
                                
                                
                                
                                
                                <th>SeedTier</th>
                                
                                
                                
                                <th>PreferredPositions</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.players_organizations && Array.isArray(organizations.players_organizations) &&
                              organizations.players_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/players/players-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="display_name">
                                        { item.display_name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="seed_tier">
                                        { item.seed_tier }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="preferred_positions">
                                        { item.preferred_positions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.players_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Seed_votes organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Direction</th>
                                
                                
                                
                                <th>VotedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.seed_votes_organizations && Array.isArray(organizations.seed_votes_organizations) &&
                              organizations.seed_votes_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/seed_votes/seed_votes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="direction">
                                        { item.direction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="voted_at">
                                        { dataFormatter.dateTimeFormatter(item.voted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.seed_votes_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Venues organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>VenueName</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                <th>MapURL</th>
                                
                                
                                
                                <th>DefaultFieldCost</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.venues_organizations && Array.isArray(organizations.venues_organizations) &&
                              organizations.venues_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/venues/venues-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="map_url">
                                        { item.map_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="default_field_cost">
                                        { item.default_field_cost }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.venues_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Leagues organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>LeagueName</th>
                                
                                
                                
                                <th>SeasonLabel</th>
                                
                                
                                
                                <th>StartDate</th>
                                
                                
                                
                                <th>EndDate</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>RostersLocked</th>
                                
                                
                                
                                <th>RegistrationFee</th>
                                
                                
                                
                                <th>RulesNotes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.leagues_organizations && Array.isArray(organizations.leagues_organizations) &&
                              organizations.leagues_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/leagues/leagues-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="season_label">
                                        { item.season_label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_at">
                                        { dataFormatter.dateTimeFormatter(item.start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_at">
                                        { dataFormatter.dateTimeFormatter(item.end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rosters_locked">
                                        { dataFormatter.booleanFormatter(item.rosters_locked) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="registration_fee">
                                        { item.registration_fee }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rules_notes">
                                        { item.rules_notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.leagues_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>League_teams organizations</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>ColorLabel</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.league_teams_organizations && Array.isArray(organizations.league_teams_organizations) &&
                              organizations.league_teams_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/league_teams/league_teams-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="color_label">
                                        { item.color_label }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.league_teams_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>League_team_players organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>JoinedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.league_team_players_organizations && Array.isArray(organizations.league_team_players_organizations) &&
                              organizations.league_team_players_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/league_team_players/league_team_players-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="joined_at">
                                        { dataFormatter.dateTimeFormatter(item.joined_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.league_team_players_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Games organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>GameTitle</th>
                                
                                
                                
                                <th>GameType</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>StartTime</th>
                                
                                
                                
                                <th>EndTime</th>
                                
                                
                                
                                <th>TargetHeadcount</th>
                                
                                
                                
                                <th>TeamCount</th>
                                
                                
                                
                                <th>FieldCost</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                <th>MessengerBroadcastSent</th>
                                
                                
                                
                                <th>FinalizedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.games_organizations && Array.isArray(organizations.games_organizations) &&
                              organizations.games_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/games/games-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="game_type">
                                        { item.game_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_at">
                                        { dataFormatter.dateTimeFormatter(item.start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_at">
                                        { dataFormatter.dateTimeFormatter(item.end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_headcount">
                                        { item.target_headcount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="team_count">
                                        { item.team_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="field_cost">
                                        { item.field_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="messenger_broadcast_sent">
                                        { dataFormatter.booleanFormatter(item.messenger_broadcast_sent) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finalized_at">
                                        { dataFormatter.dateTimeFormatter(item.finalized_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.games_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Game_rsvps organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>RSVPStatus</th>
                                
                                
                                
                                <th>RespondedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.game_rsvps_organizations && Array.isArray(organizations.game_rsvps_organizations) &&
                              organizations.game_rsvps_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/game_rsvps/game_rsvps-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="rsvp_status">
                                        { item.rsvp_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="responded_at">
                                        { dataFormatter.dateTimeFormatter(item.responded_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.game_rsvps_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Game_guests organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Nickname</th>
                                
                                
                                
                                <th>RSVPStatus</th>
                                
                                
                                
                                <th>AttendanceStatus</th>
                                
                                
                                
                                <th>PaymentStatus</th>
                                
                                
                                
                                <th>SeedTierForBalance</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.game_guests_organizations && Array.isArray(organizations.game_guests_organizations) &&
                              organizations.game_guests_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/game_guests/game_guests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="nickname">
                                        { item.nickname }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rsvp_status">
                                        { item.rsvp_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="attendance_status">
                                        { item.attendance_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payment_status">
                                        { item.payment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="seed_tier_for_balance">
                                        { item.seed_tier_for_balance }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.game_guests_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Game_teams organizations</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>ColorLabel</th>
                                
                                
                                
                                <th>SortOrder</th>
                                
                                
                                
                                <th>FinalScore</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.game_teams_organizations && Array.isArray(organizations.game_teams_organizations) &&
                              organizations.game_teams_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/game_teams/game_teams-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="color_label">
                                        { item.color_label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="final_score">
                                        { item.final_score }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.game_teams_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Game_team_assignments organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>SeedScoreSnapshot</th>
                                
                                
                                
                                <th>SortOrder</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.game_team_assignments_organizations && Array.isArray(organizations.game_team_assignments_organizations) &&
                              organizations.game_team_assignments_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/game_team_assignments/game_team_assignments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="seed_score_snapshot">
                                        { item.seed_score_snapshot }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sort_order">
                                        { item.sort_order }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.game_team_assignments_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Game_attendances organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>AttendanceStatus</th>
                                
                                
                                
                                <th>RecordedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.game_attendances_organizations && Array.isArray(organizations.game_attendances_organizations) &&
                              organizations.game_attendances_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/game_attendances/game_attendances-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="attendance_status">
                                        { item.attendance_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="recorded_at">
                                        { dataFormatter.dateTimeFormatter(item.recorded_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.game_attendances_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Game_player_stats organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Goals</th>
                                
                                
                                
                                <th>Assists</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.game_player_stats_organizations && Array.isArray(organizations.game_player_stats_organizations) &&
                              organizations.game_player_stats_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/game_player_stats/game_player_stats-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="goals">
                                        { item.goals }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="assists">
                                        { item.assists }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.game_player_stats_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Game_payments organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>FeeAmount</th>
                                
                                
                                
                                <th>PaymentStatus</th>
                                
                                
                                
                                <th>PaymentMethod</th>
                                
                                
                                
                                <th>StripePaymentReference</th>
                                
                                
                                
                                <th>PaidAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.game_payments_organizations && Array.isArray(organizations.game_payments_organizations) &&
                              organizations.game_payments_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/game_payments/game_payments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="fee_amount">
                                        { item.fee_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payment_status">
                                        { item.payment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payment_method">
                                        { item.payment_method }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="stripe_payment_reference">
                                        { item.stripe_payment_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="paid_at">
                                        { dataFormatter.dateTimeFormatter(item.paid_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.game_payments_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>League_payments organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>FeeAmount</th>
                                
                                
                                
                                <th>AmountPaid</th>
                                
                                
                                
                                <th>PaymentStatus</th>
                                
                                
                                
                                <th>LastPaidAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.league_payments_organizations && Array.isArray(organizations.league_payments_organizations) &&
                              organizations.league_payments_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/league_payments/league_payments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="fee_amount">
                                        { item.fee_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_paid">
                                        { item.amount_paid }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payment_status">
                                        { item.payment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_paid_at">
                                        { dataFormatter.dateTimeFormatter(item.last_paid_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.league_payments_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>League_standings organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Played</th>
                                
                                
                                
                                <th>Wins</th>
                                
                                
                                
                                <th>Draws</th>
                                
                                
                                
                                <th>Losses</th>
                                
                                
                                
                                <th>GoalsFor</th>
                                
                                
                                
                                <th>GoalsAgainst</th>
                                
                                
                                
                                <th>GoalDifference</th>
                                
                                
                                
                                <th>Points</th>
                                
                                
                                
                                <th>Rank</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.league_standings_organizations && Array.isArray(organizations.league_standings_organizations) &&
                              organizations.league_standings_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/league_standings/league_standings-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="played">
                                        { item.played }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="wins">
                                        { item.wins }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="draws">
                                        { item.draws }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="losses">
                                        { item.losses }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="goals_for">
                                        { item.goals_for }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="goals_against">
                                        { item.goals_against }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="goal_difference">
                                        { item.goal_difference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="points">
                                        { item.points }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="rank">
                                        { item.rank }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.league_standings_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>League_finish_awards organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>FinishRank</th>
                                
                                
                                
                                <th>BonusPoints</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.league_finish_awards_organizations && Array.isArray(organizations.league_finish_awards_organizations) &&
                              organizations.league_finish_awards_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/league_finish_awards/league_finish_awards-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="finish_rank">
                                        { item.finish_rank }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bonus_points">
                                        { item.bonus_points }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.league_finish_awards_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Category</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Message</th>
                                
                                
                                
                                <th>DeepLink</th>
                                
                                
                                
                                <th>IsRead</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.notifications_organizations && Array.isArray(organizations.notifications_organizations) &&
                              organizations.notifications_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notifications/notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="category">
                                        { item.category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message">
                                        { item.message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="deep_link">
                                        { item.deep_link }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_read">
                                        { dataFormatter.booleanFormatter(item.is_read) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.notifications_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_events organizations</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Action</th>
                                
                                
                                
                                <th>EntityName</th>
                                
                                
                                
                                <th>EntityReference</th>
                                
                                
                                
                                <th>Details</th>
                                
                                
                                
                                <th>OccurredAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {organizations.audit_events_organizations && Array.isArray(organizations.audit_events_organizations) &&
                              organizations.audit_events_organizations.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_events/audit_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_reference">
                                        { item.entity_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="details">
                                        { item.details }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!organizations?.audit_events_organizations?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                

                <BaseDivider />

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

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

export default OrganizationsView;