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'}>Employees User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>EmployeeCode</th>
                                
                                
                                
                                <th>FullName</th>
                                
                                
                                
                                <th>Phone</th>
                                
                                
                                
                                <th>NIK</th>
                                
                                
                                
                                <th>NPWP</th>
                                
                                
                                
                                <th>BankName</th>
                                
                                
                                
                                <th>BankAccountNumber</th>
                                
                                
                                
                                <th>BankAccountName</th>
                                
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>EmploymentStatus</th>
                                
                                
                                
                                <th>JoinDate</th>
                                
                                
                                
                                <th>ResignDate</th>
                                
                                
                                
                                <th>BaseSalary(Monthly)</th>
                                
                                
                                
                                <th>PositionAllowance(Fixed)</th>
                                
                                
                                
                                <th>MealAllowance(Daily)</th>
                                
                                
                                
                                <th>TransportAllowance(Daily)</th>
                                
                                
                                
                                <th>ProratePositionAllowanceUnder20Days</th>
                                
                                
                                
                                <th>IsActive</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.employees_user && Array.isArray(users.employees_user) &&
                              users.employees_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/employees/employees-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="employee_code">
                                        { item.employee_code }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="full_name">
                                        { item.full_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="phone">
                                        { item.phone }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nik">
                                        { item.nik }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="npwp">
                                        { item.npwp }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bank_name">
                                        { item.bank_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bank_account_number">
                                        { item.bank_account_number }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="bank_account_name">
                                        { item.bank_account_name }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="employment_status">
                                        { item.employment_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="join_date">
                                        { dataFormatter.dateTimeFormatter(item.join_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="resign_date">
                                        { dataFormatter.dateTimeFormatter(item.resign_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_salary_monthly">
                                        { item.base_salary_monthly }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="position_allowance_fixed">
                                        { item.position_allowance_fixed }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="meal_allowance_daily">
                                        { item.meal_allowance_daily }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="transport_allowance_daily">
                                        { item.transport_allowance_daily }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="prorate_position_allowance_under_20_days">
                                        { dataFormatter.booleanFormatter(item.prorate_position_allowance_under_20_days) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="is_active">
                                        { dataFormatter.booleanFormatter(item.is_active) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.employees_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Attendance_requests DecidedByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>RequestType</th>
                                
                                
                                
                                <th>StartAt</th>
                                
                                
                                
                                <th>EndAt</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                
                                
                                <th>ApprovalStatus</th>
                                
                                
                                
                                <th>SubmittedAt</th>
                                
                                
                                
                                <th>DecidedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.attendance_requests_decided_by_user && Array.isArray(users.attendance_requests_decided_by_user) &&
                              users.attendance_requests_decided_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/attendance_requests/attendance_requests-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="request_type">
                                        { item.request_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_at">
                                        { dataFormatter.dateTimeFormatter(item.start_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_at">
                                        { dataFormatter.dateTimeFormatter(item.end_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="approval_status">
                                        { item.approval_status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="submitted_at">
                                        { dataFormatter.dateTimeFormatter(item.submitted_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="decided_at">
                                        { dataFormatter.dateTimeFormatter(item.decided_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.attendance_requests_decided_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Overtime_logs ApprovedByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>WorkDate</th>
                                
                                
                                
                                <th>OvertimeHours</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>ApprovalStatus</th>
                                
                                
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.overtime_logs_approved_by_user && Array.isArray(users.overtime_logs_approved_by_user) &&
                              users.overtime_logs_approved_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/overtime_logs/overtime_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="work_date">
                                        { dataFormatter.dateTimeFormatter(item.work_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="hours">
                                        { item.hours }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="approval_status">
                                        { item.approval_status }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="approved_at">
                                        { dataFormatter.dateTimeFormatter(item.approved_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.overtime_logs_approved_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Kpi_scores ScoredByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                
                                
                                <th>AbsensiScore</th>
                                
                                
                                
                                <th>DisiplinScore</th>
                                
                                
                                
                                <th>ProduktivitasScore</th>
                                
                                
                                
                                <th>AttitudeScore</th>
                                
                                
                                
                                <th>SOPScore</th>
                                
                                
                                
                                <th>FinalScore</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                                
                                <th>ScoredAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.kpi_scores_scored_by_user && Array.isArray(users.kpi_scores_scored_by_user) &&
                              users.kpi_scores_scored_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/kpi_scores/kpi_scores-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="absensi_score">
                                        { item.absensi_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="disiplin_score">
                                        { item.disiplin_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="produktif_score">
                                        { item.produktif_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="attitude_score">
                                        { item.attitude_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sop_score">
                                        { item.sop_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="final_score">
                                        { item.final_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="scored_at">
                                        { dataFormatter.dateTimeFormatter(item.scored_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.kpi_scores_scored_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Outlet_revenues InputByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>RevenueDate</th>
                                
                                
                                
                                <th>GrossRevenue</th>
                                
                                
                                
                                <th>NetRevenue</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.outlet_revenues_input_by_user && Array.isArray(users.outlet_revenues_input_by_user) &&
                              users.outlet_revenues_input_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/outlet_revenues/outlet_revenues-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="revenue_date">
                                        { dataFormatter.dateTimeFormatter(item.revenue_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="gross_revenue">
                                        { item.gross_revenue }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="net_revenue">
                                        { item.net_revenue }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.outlet_revenues_input_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payroll_periods GeneratedByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>PeriodName</th>
                                
                                
                                
                                <th>PeriodStart</th>
                                
                                
                                
                                <th>PeriodEnd</th>
                                
                                
                                
                                
                                
                                <th>StandardWorkdays</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>GeneratedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.payroll_periods_generated_by_user && Array.isArray(users.payroll_periods_generated_by_user) &&
                              users.payroll_periods_generated_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payroll_periods/payroll_periods-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="name">
                                        { item.name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="period_start">
                                        { dataFormatter.dateTimeFormatter(item.period_start) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="period_end">
                                        { dataFormatter.dateTimeFormatter(item.period_end) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="standard_workdays">
                                        { item.standard_workdays }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="generated_at">
                                        { dataFormatter.dateTimeFormatter(item.generated_at) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.payroll_periods_generated_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payroll_adjustments CreatedByUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Category</th>
                                
                                
                                
                                <th>AdjustmentType</th>
                                
                                
                                
                                <th>Amount</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                                
                                <th>EffectiveAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.payroll_adjustments_created_by_user && Array.isArray(users.payroll_adjustments_created_by_user) &&
                              users.payroll_adjustments_created_by_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payroll_adjustments/payroll_adjustments-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="category">
                                        { item.category }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="adjustment_type">
                                        { item.adjustment_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="amount">
                                        { item.amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="effective_at">
                                        { dataFormatter.dateTimeFormatter(item.effective_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.payroll_adjustments_created_by_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Notification_messages User</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                <th>Channel</th>
                                
                                
                                
                                <th>MessageType</th>
                                
                                
                                
                                
                                
                                <th>Recipient</th>
                                
                                
                                
                                <th>Subject</th>
                                
                                
                                
                                <th>Body</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>QueuedAt</th>
                                
                                
                                
                                <th>SentAt</th>
                                
                                
                                
                                <th>ProviderMessageID</th>
                                
                                
                                
                                <th>ErrorMessage</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.notification_messages_user && Array.isArray(users.notification_messages_user) &&
                              users.notification_messages_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/notification_messages/notification_messages-view/?id=${item.id}`)}>
                                    
                                    
                                    <td data-label="channel">
                                        { item.channel }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="message_type">
                                        { item.message_type }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="recipient">
                                        { item.recipient }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="subject">
                                        { item.subject }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="body">
                                        { item.body }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="queued_at">
                                        { dataFormatter.dateTimeFormatter(item.queued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sent_at">
                                        { dataFormatter.dateTimeFormatter(item.sent_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="provider_message_id">
                                        { item.provider_message_id }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="error_message">
                                        { item.error_message }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.notification_messages_user?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Audit_logs ActorUser</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>Action</th>
                                
                                
                                
                                <th>EntityName</th>
                                
                                
                                
                                <th>EntityKey</th>
                                
                                
                                
                                <th>BeforeData</th>
                                
                                
                                
                                <th>AfterData</th>
                                
                                
                                
                                <th>IPAddress</th>
                                
                                
                                
                                <th>UserAgent</th>
                                
                                
                                
                                <th>LoggedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {users.audit_logs_actor_user && Array.isArray(users.audit_logs_actor_user) &&
                              users.audit_logs_actor_user.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/audit_logs/audit_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="action">
                                        { item.action }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_name">
                                        { item.entity_name }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="entity_key">
                                        { item.entity_key }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="before_data">
                                        { item.before_data }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="after_data">
                                        { item.after_data }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ip_address">
                                        { item.ip_address }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="user_agent">
                                        { item.user_agent }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="logged_at">
                                        { dataFormatter.dateTimeFormatter(item.logged_at) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!users?.audit_logs_actor_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;