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'}>Requisitions Requerant</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Numerorequisition</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Titre</th>
                                
                                
                                
                                
                                
                                <th>Quantite</th>
                                
                                
                                
                                <th>BudgetestimeUSD</th>
                                
                                
                                
                                <th>Devise</th>
                                
                                
                                
                                <th>Budgetestimedevise</th>
                                
                                
                                
                                <th>TauxversUSD</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                <th>Datesoumission</th>
                                
                                
                                
                                <th>Dateapprobation</th>
                                
                                
                                
                                <th>Datecloture</th>
                                
                                
                                
                                
                                
                                <th>Motifderetour</th>
                                
                                
                                
                                <th>Motifderejet</th>
                                
                                
                                
                                <th>Transactionelevee</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.requisitions_requester && Array.isArray(users.requisitions_requester) &&
                              users.requisitions_requester.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/requisitions/requisitions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="req_number">
                                        { item.req_number }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quantity">
                                        { item.quantity }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="estimated_budget_usd">
                                        { item.estimated_budget_usd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currency">
                                        { item.currency }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="estimated_budget_original">
                                        { item.estimated_budget_original }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fx_rate_to_usd">
                                        { item.fx_rate_to_usd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="approved_at">
                                        { dataFormatter.dateTimeFormatter(item.approved_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="closed_at">
                                        { dataFormatter.dateTimeFormatter(item.closed_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="return_reason">
                                        { item.return_reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reject_reason">
                                        { item.reject_reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_high_value">
                                        { dataFormatter.booleanFormatter(item.is_high_value) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.requisitions_requester?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Approval_steps Approbateurassigne</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Niveau</th>
                                
                                
                                
                                
                                
                                <th>Decision</th>
                                
                                
                                
                                <th>Commentaire</th>
                                
                                
                                
                                <th>Dateassignation</th>
                                
                                
                                
                                <th>Datedecision</th>
                                
                                
                                
                                <th>EcheanceSLA</th>
                                
                                
                                
                                <th>SLAdepasse</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.approval_steps_assigned_approver && Array.isArray(users.approval_steps_assigned_approver) &&
                              users.approval_steps_assigned_approver.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/approval_steps/approval_steps-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="level">
                                        { item.level }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="decision">
                                        { item.decision }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="comment">
                                        { item.comment }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="assigned_at">
                                        { dataFormatter.dateTimeFormatter(item.assigned_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="decided_at">
                                        { dataFormatter.dateTimeFormatter(item.decided_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sla_due_at">
                                        { dataFormatter.dateTimeFormatter(item.sla_due_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sla_breached">
                                        { dataFormatter.booleanFormatter(item.sla_breached) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.approval_steps_assigned_approver?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Procurement_cases Responsableachats</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Classification</th>
                                
                                
                                
                                <th>Justification</th>
                                
                                
                                
                                <th>Etapepipeline</th>
                                
                                
                                
                                
                                
                                <th>Datedemarrage</th>
                                
                                
                                
                                <th>EcheanceSLA</th>
                                
                                
                                
                                <th>Dateattribution</th>
                                
                                
                                
                                <th>Datecloture</th>
                                
                                
                                
                                <th>Overridesinglesource</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.procurement_cases_owner && Array.isArray(users.procurement_cases_owner) &&
                              users.procurement_cases_owner.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/procurement_cases/procurement_cases-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="classification">
                                        { item.classification }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="classification_justification">
                                        { item.classification_justification }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pipeline_stage">
                                        { item.pipeline_stage }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="started_at">
                                        { dataFormatter.dateTimeFormatter(item.started_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sla_due_at">
                                        { dataFormatter.dateTimeFormatter(item.sla_due_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="awarded_at">
                                        { dataFormatter.dateTimeFormatter(item.awarded_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="closed_at">
                                        { dataFormatter.dateTimeFormatter(item.closed_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="admin_override_single_source">
                                        { dataFormatter.booleanFormatter(item.admin_override_single_source) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.procurement_cases_owner?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Supplier_diligence_checks Controlepar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Typedecontrole</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Datecontrole</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.supplier_diligence_checks_checked_by && Array.isArray(users.supplier_diligence_checks_checked_by) &&
                              users.supplier_diligence_checks_checked_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/supplier_diligence_checks/supplier_diligence_checks-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="check_type">
                                        { item.check_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="checked_at">
                                        { dataFormatter.dateTimeFormatter(item.checked_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.supplier_diligence_checks_checked_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Offer_scores Evaluepar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Score</th>
                                
                                
                                
                                <th>Commentaire</th>
                                
                                
                                
                                
                                
                                <th>Dateevaluation</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.offer_scores_scored_by && Array.isArray(users.offer_scores_scored_by) &&
                              users.offer_scores_scored_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/offer_scores/offer_scores-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="score">
                                        { item.score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="comment">
                                        { item.comment }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="scored_at">
                                        { dataFormatter.dateTimeFormatter(item.scored_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.offer_scores_scored_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Awards Attribuepar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>MontantattribueUSD</th>
                                
                                
                                
                                <th>Justificationattribution</th>
                                
                                
                                
                                
                                
                                <th>Dateattribution</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.awards_awarded_by && Array.isArray(users.awards_awarded_by) &&
                              users.awards_awarded_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/awards/awards-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="awarded_amount_usd">
                                        { item.awarded_amount_usd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="award_rationale">
                                        { item.award_rationale }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="awarded_at">
                                        { dataFormatter.dateTimeFormatter(item.awarded_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.awards_awarded_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Goods_receipt_notes Receptionpar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>NumeroGRN</th>
                                
                                
                                
                                <th>Datereception</th>
                                
                                
                                
                                
                                
                                <th>Controlequalite</th>
                                
                                
                                
                                <th>Observations</th>
                                
                                
                                
                                
                                
                                <th>Signaturerecepteur</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.goods_receipt_notes_received_by && Array.isArray(users.goods_receipt_notes_received_by) &&
                              users.goods_receipt_notes_received_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/goods_receipt_notes/goods_receipt_notes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="grn_number">
                                        { item.grn_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="received_at">
                                        { dataFormatter.dateTimeFormatter(item.received_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="quality_check">
                                        { item.quality_check }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="observations">
                                        { item.observations }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="receiver_signature">
                                        { item.receiver_signature }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.goods_receipt_notes_received_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Service_acceptance_notes Acceptepar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>NumeroSAN</th>
                                
                                
                                
                                <th>Dateacceptation</th>
                                
                                
                                
                                
                                
                                <th>Checklistlivrables</th>
                                
                                
                                
                                <th>Criteresacceptation</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.service_acceptance_notes_accepted_by && Array.isArray(users.service_acceptance_notes_accepted_by) &&
                              users.service_acceptance_notes_accepted_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/service_acceptance_notes/service_acceptance_notes-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="san_number">
                                        { item.san_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="acceptance_date">
                                        { dataFormatter.dateTimeFormatter(item.acceptance_date) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="deliverable_checklist">
                                        { item.deliverable_checklist }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="acceptance_criteria">
                                        { item.acceptance_criteria }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.service_acceptance_notes_accepted_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Discrepancy_cases Signalepar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>Type</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                
                                
                                <th>Datesignalement</th>
                                
                                
                                
                                <th>Dateresolution</th>
                                
                                
                                
                                <th>Notesderesolution</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.discrepancy_cases_reported_by && Array.isArray(users.discrepancy_cases_reported_by) &&
                              users.discrepancy_cases_reported_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/discrepancy_cases/discrepancy_cases-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="type">
                                        { item.type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="reported_at">
                                        { dataFormatter.dateTimeFormatter(item.reported_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resolved_at">
                                        { dataFormatter.dateTimeFormatter(item.resolved_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resolution_notes">
                                        { item.resolution_notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.discrepancy_cases_reported_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Archive_items Archivepar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Typeressource</th>
                                
                                
                                
                                <th>Referenceressource</th>
                                
                                
                                
                                <th>Visibilite</th>
                                
                                
                                
                                <th>Titrearchive</th>
                                
                                
                                
                                <th>Motscles</th>
                                
                                
                                
                                <th>MontantUSD</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                <th>Datearchivage</th>
                                
                                
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.archive_items_archived_by && Array.isArray(users.archive_items_archived_by) &&
                              users.archive_items_archived_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/archive_items/archive_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="resource_type">
                                        { item.resource_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resource_reference">
                                        { item.resource_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="visibility_scope">
                                        { item.visibility_scope }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title">
                                        { item.title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="keywords">
                                        { item.keywords }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount_usd">
                                        { item.amount_usd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="archived_at">
                                        { dataFormatter.dateTimeFormatter(item.archived_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.archive_items_archived_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Access_logs Utilisateur</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>Typeressource</th>
                                
                                
                                
                                <th>Reference</th>
                                
                                
                                
                                <th>AdresseIP</th>
                                
                                
                                
                                <th>Useragent</th>
                                
                                
                                
                                <th>Horodatage</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.access_logs_user && Array.isArray(users.access_logs_user) &&
                              users.access_logs_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/access_logs/access_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resource_type">
                                        { item.resource_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resource_reference">
                                        { item.resource_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.access_logs_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications Utilisateur</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Canal</th>
                                
                                
                                
                                <th>Objet</th>
                                
                                
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                <th>Dateenvoi</th>
                                
                                
                                
                                <th>Datelecture</th>
                                
                                
                                
                                <th>Referenceliee</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.notifications_user && Array.isArray(users.notifications_user) &&
                              users.notifications_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notifications/notifications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="channel">
                                        { item.channel }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read_at">
                                        { dataFormatter.dateTimeFormatter(item.read_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="related_reference">
                                        { item.related_reference }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.notifications_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_events Acteur</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>IDevenement</th>
                                
                                
                                
                                <th>Horodatage</th>
                                
                                
                                
                                
                                
                                <th>Typeevenement</th>
                                
                                
                                
                                <th>Typeressource</th>
                                
                                
                                
                                <th>Referenceressource</th>
                                
                                
                                
                                <th>Resume</th>
                                
                                
                                
                                <th>AdresseIP</th>
                                
                                
                                
                                <th>Hashintegrite</th>
                                
                                
                                
                                <th>Hashprecedent</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.audit_events_actor && Array.isArray(users.audit_events_actor) &&
                              users.audit_events_actor.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_events/audit_events-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_id">
                                        { item.event_id }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occurred_at">
                                        { dataFormatter.dateTimeFormatter(item.occurred_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resource_type">
                                        { item.resource_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resource_reference">
                                        { item.resource_reference }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="summary">
                                        { item.summary }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="integrity_hash">
                                        { item.integrity_hash }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="previous_hash">
                                        { item.previous_hash }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.audit_events_actor?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Export_jobs Demandepar</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Typeexport</th>
                                
                                
                                
                                <th>Statut</th>
                                
                                
                                
                                <th>Parametres</th>
                                
                                
                                
                                
                                
                                <th>Datedemande</th>
                                
                                
                                
                                <th>Datefin</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.export_jobs_requested_by && Array.isArray(users.export_jobs_requested_by) &&
                              users.export_jobs_requested_by.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/export_jobs/export_jobs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="type">
                                        { item.type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="parameters_json">
                                        { item.parameters_json }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="requested_at">
                                        { dataFormatter.dateTimeFormatter(item.requested_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="completed_at">
                                        { dataFormatter.dateTimeFormatter(item.completed_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.export_jobs_requested_by?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Sessions Utilisateur</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Hashrefreshtoken</th>
                                
                                
                                
                                <th>Creele</th>
                                
                                
                                
                                <th>Expirele</th>
                                
                                
                                
                                <th>Revoquele</th>
                                
                                
                                
                                <th>AdresseIP</th>
                                
                                
                                
                                <th>Useragent</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.sessions_user && Array.isArray(users.sessions_user) &&
                              users.sessions_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/sessions/sessions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="refresh_token_hash">
                                        { item.refresh_token_hash }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="created_at_time">
                                        { dataFormatter.dateTimeFormatter(item.created_at_time) }
                                    </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>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.sessions_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;