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'}>Refresh_tokens User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>TokenHash</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                                
                                <th>RevokedAt</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.refresh_tokens_user && Array.isArray(users.refresh_tokens_user) &&
                              users.refresh_tokens_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/refresh_tokens/refresh_tokens-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="token_hash">
                                        { item.token_hash }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="revoked_at">
                                        { dataFormatter.dateTimeFormatter(item.revoked_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.refresh_tokens_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Businesses OwnerUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Name</th>
                                
                                
                                
                                <th>Slug</th>
                                
                                
                                
                                
                                
                                <th>Phone</th>
                                
                                
                                
                                <th>Email</th>
                                
                                
                                
                                <th>Website</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                <th>City</th>
                                
                                
                                
                                <th>State</th>
                                
                                
                                
                                <th>ZIP</th>
                                
                                
                                
                                <th>Latitude</th>
                                
                                
                                
                                <th>Longitude</th>
                                
                                
                                
                                <th>HoursJSON</th>
                                
                                
                                
                                <th>AvailabilityStatus</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                                
                                <th>ReliabilityScore</th>
                                
                                
                                
                                <th>ReliabilityBreakdownJSON</th>
                                
                                
                                
                                <th>ResponseTimeMedianMinutes</th>
                                
                                
                                
                                <th>TenantKey</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                                
                                <th>UpdatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.businesses_owner_user && Array.isArray(users.businesses_owner_user) &&
                              users.businesses_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/businesses/businesses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="slug">
                                        { item.slug }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="email">
                                        { item.email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="website">
                                        { item.website }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="state">
                                        { item.state }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="zip">
                                        { item.zip }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lat">
                                        { item.lat }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lng">
                                        { item.lng }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="hours_json">
                                        { item.hours_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="availability_status">
                                        { item.availability_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reliability_score">
                                        { item.reliability_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reliability_breakdown_json">
                                        { item.reliability_breakdown_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="response_time_median_minutes">
                                        { item.response_time_median_minutes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tenant_key">
                                        { item.tenant_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="updated_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.updated_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.businesses_owner_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Leads User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Keyword</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>Urgency</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ContactName</th>
                                
                                
                                
                                <th>ContactPhone</th>
                                
                                
                                
                                <th>ContactEmail</th>
                                
                                
                                
                                <th>Address</th>
                                
                                
                                
                                <th>City</th>
                                
                                
                                
                                <th>State</th>
                                
                                
                                
                                <th>ZIP</th>
                                
                                
                                
                                <th>Latitude</th>
                                
                                
                                
                                <th>Longitude</th>
                                
                                
                                
                                <th>InferredTagsJSON</th>
                                
                                
                                
                                <th>TenantKey</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                                
                                <th>UpdatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.leads_user && Array.isArray(users.leads_user) &&
                              users.leads_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/leads/leads-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="keyword">
                                        { item.keyword }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="urgency">
                                        { item.urgency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contact_name">
                                        { item.contact_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contact_phone">
                                        { item.contact_phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="contact_email">
                                        { item.contact_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address">
                                        { item.address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="state">
                                        { item.state }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="zip">
                                        { item.zip }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lat">
                                        { item.lat }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lng">
                                        { item.lng }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="inferred_tags_json">
                                        { item.inferred_tags_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tenant_key">
                                        { item.tenant_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="updated_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.updated_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.leads_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Messages SenderUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Body</th>
                                
                                
                                
                                <th>ReadAt</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.messages_sender_user && Array.isArray(users.messages_sender_user) &&
                              users.messages_sender_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/messages/messages-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_at">
                                        { dataFormatter.dateTimeFormatter(item.read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.messages_sender_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Messages ReceiverUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Body</th>
                                
                                
                                
                                <th>ReadAt</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.messages_receiver_user && Array.isArray(users.messages_receiver_user) &&
                              users.messages_receiver_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/messages/messages-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_at">
                                        { dataFormatter.dateTimeFormatter(item.read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.messages_receiver_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Lead_events ActorUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>EventType</th>
                                
                                
                                
                                <th>FromValue</th>
                                
                                
                                
                                <th>ToValue</th>
                                
                                
                                
                                <th>MetaJSON</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.lead_events_actor_user && Array.isArray(users.lead_events_actor_user) &&
                              users.lead_events_actor_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/lead_events/lead_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="from_value">
                                        { item.from_value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="to_value">
                                        { item.to_value }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="meta_json">
                                        { item.meta_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.lead_events_actor_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Reviews User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Rating</th>
                                
                                
                                
                                <th>Text</th>
                                
                                
                                
                                <th>IsVerifiedJob</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ModerationNotes</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                                
                                <th>UpdatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.reviews_user && Array.isArray(users.reviews_user) &&
                              users.reviews_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/reviews/reviews-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="rating">
                                        { item.rating }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="text">
                                        { item.text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_verified_job">
                                        { dataFormatter.booleanFormatter(item.is_verified_job) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="moderation_notes">
                                        { item.moderation_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="updated_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.updated_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.reviews_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Disputes OpenedByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ResolutionNotes</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                                
                                <th>UpdatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.disputes_opened_by_user && Array.isArray(users.disputes_opened_by_user) &&
                              users.disputes_opened_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/disputes/disputes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resolution_notes">
                                        { item.resolution_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="updated_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.updated_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.disputes_opened_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs ActorUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Action</th>
                                
                                
                                
                                <th>EntityType</th>
                                
                                
                                
                                <th>EntityKey</th>
                                
                                
                                
                                <th>MetaJSON</th>
                                
                                
                                
                                <th>TenantKey</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.audit_logs_actor_user && Array.isArray(users.audit_logs_actor_user) &&
                              users.audit_logs_actor_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_type">
                                        { item.entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="meta_json">
                                        { item.meta_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tenant_key">
                                        { item.tenant_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.audit_logs_actor_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Trust_adjustments AdminUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Delta</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>CreatedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.trust_adjustments_admin_user && Array.isArray(users.trust_adjustments_admin_user) &&
                              users.trust_adjustments_admin_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/trust_adjustments/trust_adjustments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="delta">
                                        { item.delta }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_ts">
                                        { dataFormatter.dateTimeFormatter(item.created_at_ts) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.trust_adjustments_admin_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;