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_profiles Usuário</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>CPF</th>
                                
                                
                                
                                <th>Datadenascimento</th>
                                
                                
                                
                                <th>Estadocivil</th>
                                
                                
                                
                                <th>CPFdocônjuge</th>
                                
                                
                                
                                <th>Nomedocônjuge</th>
                                
                                
                                
                                <th>Nomedamãe</th>
                                
                                
                                
                                <th>CEP</th>
                                
                                
                                
                                <th>Logradouro</th>
                                
                                
                                
                                <th>Número</th>
                                
                                
                                
                                <th>Complemento</th>
                                
                                
                                
                                <th>Bairro</th>
                                
                                
                                
                                <th>Cidade</th>
                                
                                
                                
                                <th>UF</th>
                                
                                
                                
                                <th>Telefone</th>
                                
                                
                                
                                <th>Ocupação</th>
                                
                                
                                
                                <th>Naturezadaocupação(código)</th>
                                
                                
                                
                                <th>Ocupaçãoprincipal(CBO)</th>
                                
                                
                                
                                <th>CNPJdafonteprincipal</th>
                                
                                
                                
                                <th>Títulodeeleitor</th>
                                
                                
                                
                                <th>Zonaeleitoral</th>
                                
                                
                                
                                <th>Seçãoeleitoral</th>
                                
                                
                                
                                <th>NIT/PIS/PASEP</th>
                                
                                
                                
                                <th>CAEPF</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.user_profiles_user && Array.isArray(users.user_profiles_user) &&
                              users.user_profiles_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_profiles/user_profiles-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="cpf">
                                        { item.cpf }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="birth_date">
                                        { dataFormatter.dateTimeFormatter(item.birth_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="marital_status">
                                        { item.marital_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="spouse_cpf">
                                        { item.spouse_cpf }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="spouse_name">
                                        { item.spouse_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mother_name">
                                        { item.mother_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cep">
                                        { item.cep }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="street">
                                        { item.street }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="house_number">
                                        { item.house_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="address_complement">
                                        { item.address_complement }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="neighborhood">
                                        { item.neighborhood }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="city">
                                        { item.city }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="state_uf">
                                        { item.state_uf }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occupation_text">
                                        { item.occupation_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="occupation_code">
                                        { item.occupation_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="cbo_code">
                                        { item.cbo_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="main_source_cnpj">
                                        { item.main_source_cnpj }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="voter_title">
                                        { item.voter_title }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="voter_zone">
                                        { item.voter_zone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="voter_section">
                                        { item.voter_section }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nit_pis_pasep">
                                        { item.nit_pis_pasep }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="caepf_number">
                                        { item.caepf_number }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.user_profiles_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>User_profile_types Usuário</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipodeperfil</th>
                                
                                
                                
                                <th>Ativo</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.user_profile_types_user && Array.isArray(users.user_profile_types_user) &&
                              users.user_profile_types_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/user_profile_types/user_profile_types-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="profile_type">
                                        { item.profile_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="enabled">
                                        { dataFormatter.booleanFormatter(item.enabled) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.user_profile_types_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Declarations Usuário</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Ano-base</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Modelodetributação</th>
                                
                                
                                
                                <th>Tipodedeclaração</th>
                                
                                
                                
                                <th>Númerodoreciboanterior</th>
                                
                                
                                
                                <th>Impostocalculado</th>
                                
                                
                                
                                <th>IRretidonafonte</th>
                                
                                
                                
                                <th>Saldoarestituir</th>
                                
                                
                                
                                <th>Saldoapagar</th>
                                
                                
                                
                                <th>Riskscore</th>
                                
                                
                                
                                <th>Detalhesderisco(JSON)</th>
                                
                                
                                
                                <th>URLdoarquivoDEC</th>
                                
                                
                                
                                <th>Datadeenvio</th>
                                
                                
                                
                                <th>Últimocálculo</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.declarations_user && Array.isArray(users.declarations_user) &&
                              users.declarations_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/declarations/declarations-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="base_year">
                                        { item.base_year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_model">
                                        { item.tax_model }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="declaration_type">
                                        { item.declaration_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="previous_receipt_number">
                                        { item.previous_receipt_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_calculated">
                                        { item.tax_calculated }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tax_withheld">
                                        { item.tax_withheld }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="refund_amount">
                                        { item.refund_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payable_amount">
                                        { item.payable_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="risk_score">
                                        { item.risk_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="risk_details_json">
                                        { item.risk_details_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="dec_file_url">
                                        { item.dec_file_url }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="last_calculated_at">
                                        { dataFormatter.dateTimeFormatter(item.last_calculated_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.declarations_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notifications Usuário</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipo</th>
                                
                                
                                
                                <th>Título</th>
                                
                                
                                
                                <th>Mensagem</th>
                                
                                
                                
                                <th>Lida</th>
                                
                                
                                
                                <th>Enviadaem</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="notification_type">
                                        { item.notification_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="title_text">
                                        { item.title_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message_text">
                                        { item.message_text }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="read">
                                        { dataFormatter.booleanFormatter(item.read) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </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'}>Organization_memberships Usuário</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Papelnaorganização</th>
                                
                                
                                
                                <th>Ativo</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.organization_memberships_user && Array.isArray(users.organization_memberships_user) &&
                              users.organization_memberships_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/organization_memberships/organization_memberships-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="member_role">
                                        { item.member_role }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="active">
                                        { dataFormatter.booleanFormatter(item.active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.organization_memberships_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Accountant_client_accesses Contador</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Acessoliberado</th>
                                
                                
                                
                                <th>Liberadoem</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.accountant_client_accesses_accountant && Array.isArray(users.accountant_client_accesses_accountant) &&
                              users.accountant_client_accesses_accountant.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/accountant_client_accesses/accountant_client_accesses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="access_granted">
                                        { dataFormatter.booleanFormatter(item.access_granted) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted_at">
                                        { dataFormatter.dateTimeFormatter(item.granted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.accountant_client_accesses_accountant?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                <>
                    <p className={'block font-bold mb-2'}>Accountant_client_accesses Cliente</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Acessoliberado</th>
                                
                                
                                
                                <th>Liberadoem</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.accountant_client_accesses_client && Array.isArray(users.accountant_client_accesses_client) &&
                              users.accountant_client_accesses_client.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/accountant_client_accesses/accountant_client_accesses-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="access_granted">
                                        { dataFormatter.booleanFormatter(item.access_granted) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted_at">
                                        { dataFormatter.dateTimeFormatter(item.granted_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.accountant_client_accesses_client?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs Usuário</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipodeevento</th>
                                
                                
                                
                                <th>Entidade</th>
                                
                                
                                
                                <th>Chavedaentidade</th>
                                
                                
                                
                                <th>IP</th>
                                
                                
                                
                                <th>Useragent</th>
                                
                                
                                
                                <th>Detalhes(JSON)</th>
                                
                                
                                
                                <th>Datadoevento</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.audit_logs_user && Array.isArray(users.audit_logs_user) &&
                              users.audit_logs_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="event_type">
                                        { item.event_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="details_json">
                                        { item.details_json }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="event_at">
                                        { dataFormatter.dateTimeFormatter(item.event_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.audit_logs_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Consents Usuário</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Tipodeconsentimento</th>
                                
                                
                                
                                <th>Versão</th>
                                
                                
                                
                                <th>Concedido</th>
                                
                                
                                
                                <th>Concedidoem</th>
                                
                                
                                
                                <th>Contexto(JSON)</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.consents_user && Array.isArray(users.consents_user) &&
                              users.consents_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/consents/consents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="consent_type">
                                        { item.consent_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="version">
                                        { item.version }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted">
                                        { dataFormatter.booleanFormatter(item.granted) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="granted_at">
                                        { dataFormatter.dateTimeFormatter(item.granted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="context_json">
                                        { item.context_json }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.consents_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;