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'}>Public_profiles 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>Headline</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Location</th>
                                
                                
                                
                                <th>PublicSlug</th>
                                
                                
                                
                                <th>IsPublic</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.public_profiles_user && Array.isArray(users.public_profiles_user) &&
                              users.public_profiles_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/public_profiles/public_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="display_name">
                                        { item.display_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="headline">
                                        { item.headline }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="location">
                                        { item.location }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="public_slug">
                                        { item.public_slug }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_public">
                                        { dataFormatter.booleanFormatter(item.is_public) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.public_profiles_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Private_profiles User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PrimaryRole</th>
                                
                                
                                
                                <th>GoalsSummary</th>
                                
                                
                                
                                <th>FocusArea</th>
                                
                                
                                
                                <th>TimeCommitment</th>
                                
                                
                                
                                <th>ConstraintsNotes</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>OnboardingCompletedAt</th>
                                
                                
                                
                                <th>LinkedAccountsIntent</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.private_profiles_user && Array.isArray(users.private_profiles_user) &&
                              users.private_profiles_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/private_profiles/private_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="primary_role">
                                        { item.primary_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="goals_summary">
                                        { item.goals_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="focus_area">
                                        { item.focus_area }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="time_commitment">
                                        { item.time_commitment }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="constraints_notes">
                                        { item.constraints_notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="onboarding_completed_at">
                                        { dataFormatter.dateTimeFormatter(item.onboarding_completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="linked_accounts_intent">
                                        { dataFormatter.booleanFormatter(item.linked_accounts_intent) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.private_profiles_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Memberships User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>CurrentPeriodEndAt</th>
                                
                                
                                
                                <th>CanceledAt</th>
                                
                                
                                
                                <th>StripeCustomerRef</th>
                                
                                
                                
                                <th>StripeSubscriptionRef</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.memberships_user && Array.isArray(users.memberships_user) &&
                              users.memberships_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/memberships/memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="current_period_end_at">
                                        { dataFormatter.dateTimeFormatter(item.current_period_end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="canceled_at">
                                        { dataFormatter.dateTimeFormatter(item.canceled_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="stripe_customer_ref">
                                        { item.stripe_customer_ref }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="stripe_subscription_ref">
                                        { item.stripe_subscription_ref }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.memberships_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Stripe_events User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>EventRef</th>
                                
                                
                                
                                <th>EventType</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>ReceivedAt</th>
                                
                                
                                
                                <th>Processed</th>
                                
                                
                                
                                <th>ProcessingNotes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.stripe_events_user && Array.isArray(users.stripe_events_user) &&
                              users.stripe_events_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/stripe_events/stripe_events-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="event_ref">
                                        { item.event_ref }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="processed">
                                        { dataFormatter.booleanFormatter(item.processed) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="processing_notes">
                                        { item.processing_notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.stripe_events_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Enrollments User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>EnrolledAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.enrollments_user && Array.isArray(users.enrollments_user) &&
                              users.enrollments_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/enrollments/enrollments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="enrolled_at">
                                        { dataFormatter.dateTimeFormatter(item.enrolled_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.enrollments_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Lesson_progress User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ProgressPercent</th>
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>LastCheckpoint</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.lesson_progress_user && Array.isArray(users.lesson_progress_user) &&
                              users.lesson_progress_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/lesson_progress/lesson_progress-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="progress_percent">
                                        { item.progress_percent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_checkpoint">
                                        { item.last_checkpoint }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.lesson_progress_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Artifacts User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ArtifactType</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>IsPublic</th>
                                
                                
                                
                                <th>SubmittedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.artifacts_user && Array.isArray(users.artifacts_user) &&
                              users.artifacts_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/artifacts/artifacts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="artifact_type">
                                        { item.artifact_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="is_public">
                                        { dataFormatter.booleanFormatter(item.is_public) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.artifacts_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_trophies User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>AwardStatus</th>
                                
                                
                                
                                <th>AwardReason</th>
                                
                                
                                
                                <th>AwardedAt</th>
                                
                                
                                
                                <th>IsVisibleOnProfile</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.user_trophies_user && Array.isArray(users.user_trophies_user) &&
                              users.user_trophies_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_trophies/user_trophies-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="award_status">
                                        { item.award_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="award_reason">
                                        { item.award_reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="awarded_at">
                                        { dataFormatter.dateTimeFormatter(item.awarded_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_visible_on_profile">
                                        { dataFormatter.booleanFormatter(item.is_visible_on_profile) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.user_trophies_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ai_requests User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>RequestedAt</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                                
                                <th>PromptTokens</th>
                                
                                
                                
                                <th>CompletionTokens</th>
                                
                                
                                
                                <th>EstimatedCost</th>
                                
                                
                                
                                <th>ModelUsed</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                                
                                <th>ContainsPrivateData</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.ai_requests_user && Array.isArray(users.ai_requests_user) &&
                              users.ai_requests_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ai_requests/ai_requests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="prompt_tokens">
                                        { item.prompt_tokens }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completion_tokens">
                                        { item.completion_tokens }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="estimated_cost">
                                        { item.estimated_cost }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="model_used">
                                        { item.model_used }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contains_private_data">
                                        { dataFormatter.booleanFormatter(item.contains_private_data) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.ai_requests_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Ai_outputs User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Visibility</th>
                                
                                
                                
                                <th>OutputTitle</th>
                                
                                
                                
                                
                                
                                <th>GeneratedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.ai_outputs_user && Array.isArray(users.ai_outputs_user) &&
                              users.ai_outputs_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/ai_outputs/ai_outputs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="visibility">
                                        { item.visibility }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="output_title">
                                        { item.output_title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="generated_at">
                                        { dataFormatter.dateTimeFormatter(item.generated_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.ai_outputs_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Coaching_sessions User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>CoachType</th>
                                
                                
                                
                                <th>SessionStatus</th>
                                
                                
                                
                                <th>Topic</th>
                                
                                
                                
                                
                                
                                <th>StartedAt</th>
                                
                                
                                
                                <th>EndedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.coaching_sessions_user && Array.isArray(users.coaching_sessions_user) &&
                              users.coaching_sessions_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/coaching_sessions/coaching_sessions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="coach_type">
                                        { item.coach_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="session_status">
                                        { item.session_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="topic">
                                        { item.topic }
                                    </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?.coaching_sessions_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Messages User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>SenderRole</th>
                                
                                
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.messages_user && Array.isArray(users.messages_user) &&
                              users.messages_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/messages/messages-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sender_role">
                                        { item.sender_role }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.messages_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Resume_documents User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>DocumentType</th>
                                
                                
                                
                                <th>DocumentName</th>
                                
                                
                                
                                
                                
                                <th>ExtractedText</th>
                                
                                
                                
                                <th>UploadedAt</th>
                                
                                
                                
                                <th>IsDeleted</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.resume_documents_user && Array.isArray(users.resume_documents_user) &&
                              users.resume_documents_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/resume_documents/resume_documents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="document_type">
                                        { item.document_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="document_name">
                                        { item.document_name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="extracted_text">
                                        { item.extracted_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="uploaded_at">
                                        { dataFormatter.dateTimeFormatter(item.uploaded_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_deleted">
                                        { dataFormatter.booleanFormatter(item.is_deleted) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.resume_documents_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Feedback_entries User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>FeedbackType</th>
                                
                                
                                
                                <th>Score</th>
                                
                                
                                
                                <th>Comment</th>
                                
                                
                                
                                <th>SourceSurface</th>
                                
                                
                                
                                <th>SubmittedAt</th>
                                
                                
                                
                                <th>NeedsFollowUp</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.feedback_entries_user && Array.isArray(users.feedback_entries_user) &&
                              users.feedback_entries_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/feedback_entries/feedback_entries-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="feedback_type">
                                        { item.feedback_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="score">
                                        { item.score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="comment">
                                        { item.comment }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source_surface">
                                        { item.source_surface }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="needs_follow_up">
                                        { dataFormatter.booleanFormatter(item.needs_follow_up) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.feedback_entries_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Tracking_events User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>EventName</th>
                                
                                
                                
                                <th>EventLabel</th>
                                
                                
                                
                                <th>PagePath</th>
                                
                                
                                
                                <th>OccurredAt</th>
                                
                                
                                
                                <th>MetadataJSON</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.tracking_events_user && Array.isArray(users.tracking_events_user) &&
                              users.tracking_events_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/tracking_events/tracking_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_name">
                                        { item.event_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_label">
                                        { item.event_label }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="page_path">
                                        { item.page_path }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="metadata_json">
                                        { item.metadata_json }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.tracking_events_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;