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";

import {hasPermission} from "../../helpers/userPermissions";


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

    const { id } = router.query;
    
    function removeLastCharacter(str) {
      console.log(str,`str`)
      return str.slice(0, -1);
    }

    useEffect(() => {
        dispatch(fetch({ id }));
    }, [dispatch, id]);


    return (
      <>
          <Head>
              <title>{getPageTitle('View 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>
                </>
              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_invitations InvitedByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>InviteeEmail</th>
                                
                                
                                
                                <th>InviteeName</th>
                                
                                
                                
                                <th>Role</th>
                                
                                
                                
                                
                                
                                <th>InviteTokenHash</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>AcceptedAt</th>
                                
                                
                                
                                <th>RevokedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.user_invitations_invited_by_user && Array.isArray(users.user_invitations_invited_by_user) &&
                              users.user_invitations_invited_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_invitations/user_invitations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="invitee_email">
                                        { item.invitee_email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="invitee_name">
                                        { item.invitee_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="role">
                                        { item.role }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="invite_token_hash">
                                        { item.invite_token_hash }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expires_at">
                                        { dataFormatter.dateTimeFormatter(item.expires_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="accepted_at">
                                        { dataFormatter.dateTimeFormatter(item.accepted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="revoked_at">
                                        { dataFormatter.dateTimeFormatter(item.revoked_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.user_invitations_invited_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Artifacts CollectedBy</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ArtifactName</th>
                                
                                
                                
                                <th>ArtifactType</th>
                                
                                
                                
                                <th>ArtifactReference</th>
                                
                                
                                
                                
                                
                                <th>CollectedAt</th>
                                
                                
                                
                                <th>EventTimestamp</th>
                                
                                
                                
                                <th>SubjectUser</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ValidationNotes</th>
                                
                                
                                
                                <th>EvidenceStrengthScore</th>
                                
                                
                                
                                <th>ChainIntegrityScore</th>
                                
                                
                                
                                <th>RetentionExpiry</th>
                                
                                
                                
                                <th>Tags</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.artifacts_collected_by_user && Array.isArray(users.artifacts_collected_by_user) &&
                              users.artifacts_collected_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/artifacts/artifacts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="artifact_name">
                                        { item.artifact_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="artifact_type">
                                        { item.artifact_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="artifact_reference">
                                        { item.artifact_reference }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="collected_at">
                                        { dataFormatter.dateTimeFormatter(item.collected_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_timestamp">
                                        { dataFormatter.dateTimeFormatter(item.event_timestamp) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject_user">
                                        { item.subject_user }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="validation_notes">
                                        { item.validation_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="evidence_strength_score">
                                        { item.evidence_strength_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="chain_integrity_score">
                                        { item.chain_integrity_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="retention_expiry">
                                        { dataFormatter.dateTimeFormatter(item.retention_expiry) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tags">
                                        { item.tags }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.artifacts_collected_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Artifacts ApproverUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>ArtifactName</th>
                                
                                
                                
                                <th>ArtifactType</th>
                                
                                
                                
                                <th>ArtifactReference</th>
                                
                                
                                
                                
                                
                                <th>CollectedAt</th>
                                
                                
                                
                                <th>EventTimestamp</th>
                                
                                
                                
                                <th>SubjectUser</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ValidationNotes</th>
                                
                                
                                
                                <th>EvidenceStrengthScore</th>
                                
                                
                                
                                <th>ChainIntegrityScore</th>
                                
                                
                                
                                <th>RetentionExpiry</th>
                                
                                
                                
                                <th>Tags</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.artifacts_approver_user && Array.isArray(users.artifacts_approver_user) &&
                              users.artifacts_approver_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/artifacts/artifacts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="artifact_name">
                                        { item.artifact_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="artifact_type">
                                        { item.artifact_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="artifact_reference">
                                        { item.artifact_reference }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="collected_at">
                                        { dataFormatter.dateTimeFormatter(item.collected_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_timestamp">
                                        { dataFormatter.dateTimeFormatter(item.event_timestamp) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject_user">
                                        { item.subject_user }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="validation_notes">
                                        { item.validation_notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="evidence_strength_score">
                                        { item.evidence_strength_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="chain_integrity_score">
                                        { item.chain_integrity_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="retention_expiry">
                                        { dataFormatter.dateTimeFormatter(item.retention_expiry) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tags">
                                        { item.tags }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.artifacts_approver_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Proof_packets Owner</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>PacketName</th>
                                
                                
                                
                                <th>PacketType</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>PacketStatus</th>
                                
                                
                                
                                <th>ReadinessScore</th>
                                
                                
                                
                                <th>GeneratedOn</th>
                                
                                
                                
                                <th>DueDate</th>
                                
                                
                                
                                <th>Summary</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.proof_packets_owner_user && Array.isArray(users.proof_packets_owner_user) &&
                              users.proof_packets_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/proof_packets/proof_packets-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="packet_name">
                                        { item.packet_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="packet_type">
                                        { item.packet_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="packet_status">
                                        { item.packet_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="readiness_score">
                                        { item.readiness_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="generated_on">
                                        { dataFormatter.dateTimeFormatter(item.generated_on) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_date">
                                        { dataFormatter.dateTimeFormatter(item.due_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="summary">
                                        { item.summary }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.proof_packets_owner_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Remediation_items Owner</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                <th>Severity</th>
                                
                                
                                
                                <th>Category</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>DueDate</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>RemediationPlan</th>
                                
                                
                                
                                <th>CompletedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.remediation_items_owner_user && Array.isArray(users.remediation_items_owner_user) &&
                              users.remediation_items_owner_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/remediation_items/remediation_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="severity">
                                        { item.severity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="category">
                                        { item.category }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="due_date">
                                        { dataFormatter.dateTimeFormatter(item.due_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="remediation_plan">
                                        { item.remediation_plan }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.remediation_items_owner_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Access_reviews Reviewer</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ReviewName</th>
                                
                                
                                
                                <th>ReviewScope</th>
                                
                                
                                
                                <th>ReviewType</th>
                                
                                
                                
                                
                                
                                <th>StartDate</th>
                                
                                
                                
                                <th>DueDate</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>CompletionPercentage</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.access_reviews_reviewer_user && Array.isArray(users.access_reviews_reviewer_user) &&
                              users.access_reviews_reviewer_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/access_reviews/access_reviews-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="review_name">
                                        { item.review_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="review_scope">
                                        { item.review_scope }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="review_type">
                                        { item.review_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="start_date">
                                        { dataFormatter.dateTimeFormatter(item.start_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="due_date">
                                        { dataFormatter.dateTimeFormatter(item.due_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completion_percentage">
                                        { item.completion_percentage }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.access_reviews_reviewer_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Exceptions Approver</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ExceptionName</th>
                                
                                
                                
                                <th>ExceptionType</th>
                                
                                
                                
                                <th>Subject</th>
                                
                                
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>GrantedAt</th>
                                
                                
                                
                                <th>ExpiresAt</th>
                                
                                
                                
                                <th>RevokedAt</th>
                                
                                
                                
                                <th>Follow-upReviewRequired</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.exceptions_approver_user && Array.isArray(users.exceptions_approver_user) &&
                              users.exceptions_approver_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/exceptions/exceptions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="exception_name">
                                        { item.exception_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="exception_type">
                                        { item.exception_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted_at">
                                        { dataFormatter.dateTimeFormatter(item.granted_at) }
                                    </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="followup_review_required">
                                        { dataFormatter.booleanFormatter(item.followup_review_required) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.exceptions_approver_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs Actor</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>ActionType</th>
                                
                                
                                
                                <th>TargetEntityType</th>
                                
                                
                                
                                <th>TargetEntityKey</th>
                                
                                
                                
                                <th>Timestamp</th>
                                
                                
                                
                                <th>BeforeStateSummary</th>
                                
                                
                                
                                <th>AfterStateSummary</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                                
                                <th>Notes</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_type">
                                        { item.action_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_type">
                                        { item.target_entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_key">
                                        { item.target_entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="timestamp">
                                        { dataFormatter.dateTimeFormatter(item.timestamp) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="before_state_summary">
                                        { item.before_state_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="after_state_summary">
                                        { item.after_state_summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </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'}>Notifications Recipient</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>NotificationType</th>
                                
                                
                                
                                <th>Title</th>
                                
                                
                                
                                <th>Message</th>
                                
                                
                                
                                <th>Priority</th>
                                
                                
                                
                                <th>ReadFlag</th>
                                
                                
                                
                                <th>ReadAt</th>
                                
                                
                                
                                <th>TargetEntityType</th>
                                
                                
                                
                                <th>TargetEntityKey</th>
                                
                                
                                
                                <th>ScheduledFor</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.notifications_recipient_user && Array.isArray(users.notifications_recipient_user) &&
                              users.notifications_recipient_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notifications/notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notification_type">
                                        { item.notification_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message">
                                        { item.message }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="priority">
                                        { item.priority }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_flag">
                                        { dataFormatter.booleanFormatter(item.read_flag) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_at">
                                        { dataFormatter.dateTimeFormatter(item.read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_type">
                                        { item.target_entity_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="target_entity_key">
                                        { item.target_entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduled_for">
                                        { dataFormatter.dateTimeFormatter(item.scheduled_for) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.notifications_recipient_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;