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/users/usersSlice'
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";


const UsersView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { users } = useAppSelector((state) => state.users)
    

    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 users')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View users')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/users/users-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>First Name</p>
                    <p>{users?.firstName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Last Name</p>
                    <p>{users?.lastName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Phone Number</p>
                    <p>{users?.phoneNumber}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>E-Mail</p>
                    <p>{users?.email}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='Disabled'>
                    <SwitchField
                      field={{name: 'disabled', value: users?.disabled}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Avatar</p>
                    {users?.avatar?.length
                      ? (
                        <ImageField
                          name={'avatar'}
                          image={users?.avatar}
                          className='w-20 h-20'
                        />
                      ) : <p>No Avatar</p>
                    }
                </div>
              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>App Role</p>
                    
                    
                    
                    
                        <p>{users?.app_role?.name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              
                <>
                    <p className={'block font-bold mb-2'}>Custom Permissions</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                    <th>Name</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.custom_permissions && Array.isArray(users.custom_permissions) &&
                              users.custom_permissions.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/permissions/permissions-view/?id=${item.id}`)}>
                                  
                                    
                                    
                                  
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.custom_permissions?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
              

              

              
              

                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Avatar_customizations User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ProfileName</th>
                                
                                
                                
                                <th>BaseColor</th>
                                
                                
                                
                                <th>CustomColorHex</th>
                                
                                
                                
                                <th>FaceStyle</th>
                                
                                
                                
                                <th>PatternStyle</th>
                                
                                
                                
                                <th>PatternColor</th>
                                
                                
                                
                                <th>PatternCustomHex</th>
                                
                                
                                
                                <th>HatStyle</th>
                                
                                
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.avatar_customizations_user && Array.isArray(users.avatar_customizations_user) &&
                              users.avatar_customizations_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/avatar_customizations/avatar_customizations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="profile_name">
                                        { item.profile_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_color">
                                        { item.base_color }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="custom_color_hex">
                                        { item.custom_color_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="face_style">
                                        { item.face_style }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pattern_style">
                                        { item.pattern_style }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pattern_color">
                                        { item.pattern_color }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pattern_custom_hex">
                                        { item.pattern_custom_hex }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="hat_style">
                                        { item.hat_style }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.avatar_customizations_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Purchases User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PurchaseType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Amount(YUX)</th>
                                
                                
                                
                                <th>PurchasedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.purchases_user && Array.isArray(users.purchases_user) &&
                              users.purchases_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/purchases/purchases-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="purchase_type">
                                        { item.purchase_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="amount_yux">
                                        { item.amount_yux }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="purchased_at">
                                        { dataFormatter.dateTimeFormatter(item.purchased_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.purchases_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Inventory_items User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ItemKind</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Quantity</th>
                                
                                
                                
                                <th>UnlockedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.inventory_items_user && Array.isArray(users.inventory_items_user) &&
                              users.inventory_items_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/inventory_items/inventory_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="item_kind">
                                        { item.item_kind }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="unlocked_at">
                                        { dataFormatter.dateTimeFormatter(item.unlocked_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.inventory_items_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_achievements User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ProgressValue</th>
                                
                                
                                
                                <th>IsCompleted</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.user_achievements_user && Array.isArray(users.user_achievements_user) &&
                              users.user_achievements_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_achievements/user_achievements-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="progress_value">
                                        { item.progress_value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_completed">
                                        { dataFormatter.booleanFormatter(item.is_completed) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.user_achievements_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Quizzes Owner</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>QuizType</th>
                                
                                
                                
                                
                                
                                <th>Visibility</th>
                                
                                
                                
                                <th>IsVerified</th>
                                
                                
                                
                                <th>VerifiedBadgeText</th>
                                
                                
                                
                                <th>Subject</th>
                                
                                
                                
                                <th>AgeGroup</th>
                                
                                
                                
                                <th>Difficulty</th>
                                
                                
                                
                                
                                
                                <th>AllowImagesInQuestions</th>
                                
                                
                                
                                <th>PublishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.quizzes_owner && Array.isArray(users.quizzes_owner) &&
                              users.quizzes_owner.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/quizzes/quizzes-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quiz_type">
                                        { item.quiz_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="visibility">
                                        { item.visibility }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_verified">
                                        { dataFormatter.booleanFormatter(item.is_verified) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="verified_badge_text">
                                        { item.verified_badge_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="age_group">
                                        { item.age_group }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="difficulty">
                                        { item.difficulty }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="allow_images_in_questions">
                                        { dataFormatter.booleanFormatter(item.allow_images_in_questions) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="published_at">
                                        { dataFormatter.dateTimeFormatter(item.published_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.quizzes_owner?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Orbix_quiz_assistant_sessions User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Topic</th>
                                
                                
                                
                                <th>TargetQuestionCount</th>
                                
                                
                                
                                <th>AgeGroup</th>
                                
                                
                                
                                <th>Difficulty</th>
                                
                                
                                
                                <th>IncludeImages</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>FinishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.orbix_quiz_assistant_sessions_user && Array.isArray(users.orbix_quiz_assistant_sessions_user) &&
                              users.orbix_quiz_assistant_sessions_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/orbix_quiz_assistant_sessions/orbix_quiz_assistant_sessions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="topic">
                                        { item.topic }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_question_count">
                                        { item.target_question_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="age_group">
                                        { item.age_group }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="difficulty">
                                        { item.difficulty }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="include_images">
                                        { dataFormatter.booleanFormatter(item.include_images) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.orbix_quiz_assistant_sessions_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Matches Host</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>GameCode</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>IsLocked</th>
                                
                                
                                
                                <th>MaxPlayers</th>
                                
                                
                                
                                <th>QuestionCount</th>
                                
                                
                                
                                <th>RandomizeQuestions</th>
                                
                                
                                
                                <th>RandomizeAnswers</th>
                                
                                
                                
                                <th>WheelEventEveryNQuestions</th>
                                
                                
                                
                                <th>CatInteractionEveryNQuestions</th>
                                
                                
                                
                                <th>StartingSpeed(km/h)</th>
                                
                                
                                
                                <th>RaceMap</th>
                                
                                
                                
                                <th>ScheduledStartAt</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>EndedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.matches_host && Array.isArray(users.matches_host) &&
                              users.matches_host.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/matches/matches-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="game_code">
                                        { item.game_code }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_locked">
                                        { dataFormatter.booleanFormatter(item.is_locked) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="max_players">
                                        { item.max_players }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="question_count">
                                        { item.question_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="randomize_questions">
                                        { dataFormatter.booleanFormatter(item.randomize_questions) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="randomize_answers">
                                        { dataFormatter.booleanFormatter(item.randomize_answers) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="wheel_event_every_n_questions">
                                        { item.wheel_event_every_n_questions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cat_interaction_every_n_questions">
                                        { item.cat_interaction_every_n_questions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="starting_speed_kmh">
                                        { item.starting_speed_kmh }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="race_map">
                                        { item.race_map }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_start_at">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ended_at">
                                        { dataFormatter.dateTimeFormatter(item.ended_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.matches_host?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Match_players User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>DisplayName</th>
                                
                                
                                
                                
                                
                                <th>PlayerStatus</th>
                                
                                
                                
                                <th>ScorePoints</th>
                                
                                
                                
                                <th>CorrectCount</th>
                                
                                
                                
                                <th>IncorrectCount</th>
                                
                                
                                
                                <th>YUXEarned</th>
                                
                                
                                
                                <th>RaceDistance(km)</th>
                                
                                
                                
                                <th>JoinedAt</th>
                                
                                
                                
                                <th>LeftAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.match_players_user && Array.isArray(users.match_players_user) &&
                              users.match_players_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/match_players/match_players-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="display_name">
                                        { item.display_name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="player_status">
                                        { item.player_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="score_points">
                                        { item.score_points }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="correct_count">
                                        { item.correct_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="incorrect_count">
                                        { item.incorrect_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="yux_earned">
                                        { item.yux_earned }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="race_distance_km">
                                        { item.race_distance_km }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="joined_at">
                                        { dataFormatter.dateTimeFormatter(item.joined_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="left_at">
                                        { dataFormatter.dateTimeFormatter(item.left_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.match_players_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Moderation_reports Reporter</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>TargetType</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ReportedAt</th>
                                
                                
                                
                                <th>ResolvedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.moderation_reports_reporter && Array.isArray(users.moderation_reports_reporter) &&
                              users.moderation_reports_reporter.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/moderation_reports/moderation_reports-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="target_type">
                                        { item.target_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reported_at">
                                        { dataFormatter.dateTimeFormatter(item.reported_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resolved_at">
                                        { dataFormatter.dateTimeFormatter(item.resolved_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.moderation_reports_reporter?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Community_modes Creator</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>ModeName</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>IsUnofficial</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>PublishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.community_modes_creator && Array.isArray(users.community_modes_creator) &&
                              users.community_modes_creator.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/community_modes/community_modes-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_unofficial">
                                        { dataFormatter.booleanFormatter(item.is_unofficial) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="published_at">
                                        { dataFormatter.dateTimeFormatter(item.published_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.community_modes_creator?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Community_mode_build_sessions User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Concept</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>FinishedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.community_mode_build_sessions_user && Array.isArray(users.community_mode_build_sessions_user) &&
                              users.community_mode_build_sessions_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/community_mode_build_sessions/community_mode_build_sessions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="concept">
                                        { item.concept }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="finished_at">
                                        { dataFormatter.dateTimeFormatter(item.finished_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.community_mode_build_sessions_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Leaderboard_entries User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Scope</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>RankPosition</th>
                                
                                
                                
                                <th>ScoreValue</th>
                                
                                
                                
                                <th>PeriodStartAt</th>
                                
                                
                                
                                <th>PeriodEndAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.leaderboard_entries_user && Array.isArray(users.leaderboard_entries_user) &&
                              users.leaderboard_entries_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/leaderboard_entries/leaderboard_entries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="scope">
                                        { item.scope }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="rank_position">
                                        { item.rank_position }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="score_value">
                                        { item.score_value }
                                    </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>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.leaderboard_entries_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                

                <BaseDivider />

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

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

export default UsersView;