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/employees/employeesSlice'
import {saveFile} from "../../helpers/fileSaver";
import dataFormatter from '../../helpers/dataFormatter';
import ImageField from "../../components/ImageField";
import LayoutAuthenticated from "../../layouts/Authenticated";
import {getPageTitle} from "../../config";
import SectionTitleLineWithButton from "../../components/SectionTitleLineWithButton";
import SectionMain from "../../components/SectionMain";
import CardBox from "../../components/CardBox";
import BaseButton from "../../components/BaseButton";
import BaseDivider from "../../components/BaseDivider";
import {mdiChartTimelineVariant} from "@mdi/js";
import {SwitchField} from "../../components/SwitchField";
import FormField from "../../components/FormField";


const EmployeesView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { employees } = useAppSelector((state) => state.employees)
    

    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 employees')}</title>
          </Head>
          <SectionMain>
            <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title={removeLastCharacter('View employees')} main>
                <BaseButton
                  color='info'
                  label='Edit'
                  href={`/employees/employees-edit/?id=${id}`}
                />
            </SectionTitleLineWithButton>
            <CardBox>
            

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>EmployeeCode</p>
                    <p>{employees?.employeeCode}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>FirstName</p>
                    <p>{employees?.firstName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>MiddleName</p>
                    <p>{employees?.middleName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>LastName</p>
                    <p>{employees?.lastName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>NameExtension</p>
                    <p>{employees?.nameExtension}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='DateOfBirth'>
                    {employees.dateOfBirth ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={employees.dateOfBirth ?
                        new Date(
                          dayjs(employees.dateOfBirth).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No DateOfBirth</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PlaceOfBirth</p>
                    <p>{employees?.placeOfBirth}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Sex</p>
                    <p>{employees?.sex ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>CivilStatus</p>
                    <p>{employees?.civilStatus ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Nationality</p>
                    <p>{employees?.nationality}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Religion</p>
                    <p>{employees?.religion}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>BloodType</p>
                    <p>{employees?.bloodType}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ProfilePhoto</p>
                    {employees?.profilePhoto?.length
                      ? (
                        <ImageField
                          name={'profilePhoto'}
                          image={employees?.profilePhoto}
                          className='w-20 h-20'
                        />
                      ) : <p>No ProfilePhoto</p>
                    }
                </div>
              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>HomeStreet</p>
                    <p>{employees?.homeStreet}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>HomeBarangay</p>
                    <p>{employees?.homeBarangay}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>HomeCity</p>
                    <p>{employees?.homeCity}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>HomeProvince</p>
                    <p>{employees?.homeProvince}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>HomeZipCode</p>
                    <p>{employees?.homeZipCode}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='PermanentAddressSame'>
                    <SwitchField
                      field={{name: 'permanentAddressSame', value: employees?.permanentAddressSame}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PermanentStreet</p>
                    <p>{employees?.permanentStreet}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PermanentBarangay</p>
                    <p>{employees?.permanentBarangay}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PermanentCity</p>
                    <p>{employees?.permanentCity}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PermanentProvince</p>
                    <p>{employees?.permanentProvince}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PermanentZipCode</p>
                    <p>{employees?.permanentZipCode}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PersonalEmail</p>
                    <p>{employees?.personalEmail}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PersonalMobile</p>
                    <p>{employees?.personalMobile}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>EmergencyContactName</p>
                    <p>{employees?.emergencyContactName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>EmergencyContactRelationship</p>
                    <p>{employees?.emergencyContactRel}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>EmergencyContactMobile</p>
                    <p>{employees?.emergencyContactMobile}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>SSSNumber</p>
                    <p>{employees?.sssNumber}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PhilHealthNumber</p>
                    <p>{employees?.philhealthNumber}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>PagIbigNumber</p>
                    <p>{employees?.pagibigNumber}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>TINNumber</p>
                    <p>{employees?.tinNumber}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>BankName</p>
                    <p>{employees?.bankName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>BankAccountNumber</p>
                    <p>{employees?.bankAccountNumber}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>BankAccountName</p>
                    <p>{employees?.bankAccountName}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='EmploymentDate'>
                    {employees.employmentDate ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={employees.employmentDate ?
                        new Date(
                          dayjs(employees.employmentDate).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No EmploymentDate</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='RegularizationDate'>
                    {employees.regularizationDate ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={employees.regularizationDate ?
                        new Date(
                          dayjs(employees.regularizationDate).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No RegularizationDate</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>EmploymentStatus</p>
                    <p>{employees?.employmentStatus ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>EmploymentType</p>
                    <p>{employees?.employmentType ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>JobLevel</p>
                    <p>{employees?.jobLevel ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>SalaryType</p>
                    <p>{employees?.salaryType ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>BasicSalary</p>
                  <p>{employees?.basicSalary || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>TaxStatus</p>
                    <p>{employees?.taxStatus ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>WorkLocation</p>
                    <p>{employees?.workLocation}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='SeparationDate'>
                    {employees.separationDate ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={employees.separationDate ?
                        new Date(
                          dayjs(employees.separationDate).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No SeparationDate</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>SeparationType</p>
                    <p>{employees?.separationType ?? 'No data'}</p>
                </div>
              

              

              

              

              

              
              

              

              
                <FormField label='Multi Text' hasTextareaHeight>
                  <textarea className={'w-full'} disabled value={employees?.separationReason} />
                </FormField>
              

              

              

              

              

              

              

              

              

              

              

              
              

              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ClearanceStatus</p>
                    <p>{employees?.clearanceStatus}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>FinalPayAmount</p>
                  <p>{employees?.finalPayAmount || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              
                <FormField label='FinalPayReleasedDate'>
                    {employees.finalPayReleasedDate ? <DatePicker
                      dateFormat="yyyy-MM-dd hh:mm"
                      showTimeSelect
                      selected={employees.finalPayReleasedDate ?
                        new Date(
                          dayjs(employees.finalPayReleasedDate).format('YYYY-MM-DD hh:mm'),
                        ) : null
                      }
                      disabled
                    /> : <p>No FinalPayReleasedDate</p>}
                </FormField>
              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              
                <FormField label='IsActive'>
                    <SwitchField
                      field={{name: 'isActive', value: employees?.isActive}}
                      form={{setFieldValue: () => null}}
                      disabled
                    />
                </FormField>
              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Department</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{employees?.department?.name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Position</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{employees?.position?.title ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>Shift</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{employees?.shift?.name ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

              

              

              

              

              

              

              

              

              

              
              
                <div className={'mb-4'}>
                    <p className={'block font-bold mb-2'}>ReportingTo</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                        <p>{employees?.reportingTo?.employeeCode ?? 'No data'}</p>
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </div>
                 
              

              

              

              
              

                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Employee_documents Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>DocumentType</th>
                                
                                
                                
                                <th>FileName</th>
                                
                                
                                
                                
                                
                                <th>UploadedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.employee_documents_employee && Array.isArray(employees.employee_documents_employee) &&
                              employees.employee_documents_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/employee_documents/employee_documents-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="documentType">
                                        { item.documentType }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="fileName">
                                        { item.fileName }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="uploadedAt">
                                        { dataFormatter.dateTimeFormatter(item.uploadedAt) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.employee_documents_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Time_records Employee</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>ScheduledTimeIn</th>
                                
                                
                                
                                <th>ScheduledTimeOut</th>
                                
                                
                                
                                <th>ActualTimeIn</th>
                                
                                
                                
                                <th>ActualTimeOut</th>
                                
                                
                                
                                <th>TardinessMinutes</th>
                                
                                
                                
                                <th>UndertimeMinutes</th>
                                
                                
                                
                                <th>OvertimeMinutes</th>
                                
                                
                                
                                <th>NightDiffHours</th>
                                
                                
                                
                                <th>WorkType</th>
                                
                                
                                
                                <th>IsAbsent</th>
                                
                                
                                
                                <th>IsHalfDay</th>
                                
                                
                                
                                <th>HalfDayType</th>
                                
                                
                                
                                <th>Source</th>
                                
                                
                                
                                
                                
                                <th>ModificationReason</th>
                                
                                
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.time_records_employee && Array.isArray(employees.time_records_employee) &&
                              employees.time_records_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/time_records/time_records-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="workDate">
                                        { dataFormatter.dateTimeFormatter(item.workDate) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduledTimeIn">
                                        { item.scheduledTimeIn }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="scheduledTimeOut">
                                        { item.scheduledTimeOut }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="actualTimeIn">
                                        { dataFormatter.dateTimeFormatter(item.actualTimeIn) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="actualTimeOut">
                                        { dataFormatter.dateTimeFormatter(item.actualTimeOut) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tardinessMinutes">
                                        { item.tardinessMinutes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="undertimeMinutes">
                                        { item.undertimeMinutes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overtimeMinutes">
                                        { item.overtimeMinutes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nightDiffHours">
                                        { item.nightDiffHours }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="workType">
                                        { item.workType }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="isAbsent">
                                        { dataFormatter.booleanFormatter(item.isAbsent) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="isHalfDay">
                                        { dataFormatter.booleanFormatter(item.isHalfDay) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="halfDayType">
                                        { item.halfDayType }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source">
                                        { item.source }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="modificationReason">
                                        { item.modificationReason }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="approvedAt">
                                        { dataFormatter.dateTimeFormatter(item.approvedAt) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.time_records_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Leave_balances Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Year</th>
                                
                                
                                
                                <th>OpeningBalance</th>
                                
                                
                                
                                <th>EarnedThisYear</th>
                                
                                
                                
                                <th>UsedYTD</th>
                                
                                
                                
                                <th>Forfeited</th>
                                
                                
                                
                                <th>ConvertedToCash</th>
                                
                                
                                
                                <th>CurrentBalance</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.leave_balances_employee && Array.isArray(employees.leave_balances_employee) &&
                              employees.leave_balances_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/leave_balances/leave_balances-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="year">
                                        { item.year }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="openingBalance">
                                        { item.openingBalance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="earnedThisYear">
                                        { item.earnedThisYear }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="usedYtd">
                                        { item.usedYtd }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="forfeited">
                                        { item.forfeited }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="convertedToCash">
                                        { item.convertedToCash }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="currentBalance">
                                        { item.currentBalance }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.leave_balances_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Leave_applications Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>DateFrom</th>
                                
                                
                                
                                <th>DateTo</th>
                                
                                
                                
                                <th>TotalDays</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>ManagerNote</th>
                                
                                
                                
                                <th>HRNote</th>
                                
                                
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.leave_applications_employee && Array.isArray(employees.leave_applications_employee) &&
                              employees.leave_applications_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/leave_applications/leave_applications-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="dateFrom">
                                        { dataFormatter.dateTimeFormatter(item.dateFrom) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="dateTo">
                                        { dataFormatter.dateTimeFormatter(item.dateTo) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="totalDays">
                                        { item.totalDays }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="reason">
                                        { item.reason }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="managerNote">
                                        { item.managerNote }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="hrNote">
                                        { item.hrNote }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="approvedAt">
                                        { dataFormatter.dateTimeFormatter(item.approvedAt) }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.leave_applications_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Employee_loans Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>LoanType</th>
                                
                                
                                
                                <th>LoanSource</th>
                                
                                
                                
                                <th>LoanAmount</th>
                                
                                
                                
                                <th>ApprovalDate</th>
                                
                                
                                
                                <th>FirstDeductionDate</th>
                                
                                
                                
                                <th>MonthlyAmortization</th>
                                
                                
                                
                                <th>RemainingBalance</th>
                                
                                
                                
                                <th>TermsMonths</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>LoanAccountNumber</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.employee_loans_employee && Array.isArray(employees.employee_loans_employee) &&
                              employees.employee_loans_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/employee_loans/employee_loans-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="loanType">
                                        { item.loanType }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="loanSource">
                                        { item.loanSource }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="loanAmount">
                                        { item.loanAmount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="approvalDate">
                                        { dataFormatter.dateTimeFormatter(item.approvalDate) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="firstDeductionDate">
                                        { dataFormatter.dateTimeFormatter(item.firstDeductionDate) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="monthlyAmortization">
                                        { item.monthlyAmortization }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="remainingBalance">
                                        { item.remainingBalance }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="termsMonths">
                                        { item.termsMonths }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="loanAccountNumber">
                                        { item.loanAccountNumber }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.employee_loans_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Payroll_items Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>RegularDaysWorked</th>
                                
                                
                                
                                <th>AbsentDays</th>
                                
                                
                                
                                <th>TardinessMinutes</th>
                                
                                
                                
                                <th>OvertimeHours</th>
                                
                                
                                
                                <th>NightDiffHours</th>
                                
                                
                                
                                <th>HolidayDaysWorked</th>
                                
                                
                                
                                <th>BasicPay</th>
                                
                                
                                
                                <th>OvertimePay</th>
                                
                                
                                
                                <th>NightDifferential</th>
                                
                                
                                
                                <th>HolidayPay</th>
                                
                                
                                
                                <th>Allowances</th>
                                
                                
                                
                                <th>OtherEarnings</th>
                                
                                
                                
                                <th>GrossPay</th>
                                
                                
                                
                                <th>SSSEmployee</th>
                                
                                
                                
                                <th>PhilHealthEmployee</th>
                                
                                
                                
                                <th>PagIbigEmployee</th>
                                
                                
                                
                                <th>WithholdingTax</th>
                                
                                
                                
                                <th>SSSEmployer</th>
                                
                                
                                
                                <th>PhilHealthEmployer</th>
                                
                                
                                
                                <th>PagIbigEmployer</th>
                                
                                
                                
                                <th>SSSLoanDeduction</th>
                                
                                
                                
                                <th>PagIbigLoanDeduction</th>
                                
                                
                                
                                <th>CompanyLoanDeduction</th>
                                
                                
                                
                                <th>OtherDeductions</th>
                                
                                
                                
                                <th>TotalDeductions</th>
                                
                                
                                
                                <th>NetPay</th>
                                
                                
                                
                                <th>YTDGrossPay</th>
                                
                                
                                
                                <th>YTDWithholdingTax</th>
                                
                                
                                
                                <th>YTDSSSEmployee</th>
                                
                                
                                
                                <th>YTDPhilHealthEmployee</th>
                                
                                
                                
                                <th>YTDPagIbigEmployee</th>
                                
                                
                                
                                <th>YTDBasicPay</th>
                                
                                
                                
                                <th>PayslipHash</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.payroll_items_employee && Array.isArray(employees.payroll_items_employee) &&
                              employees.payroll_items_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/payroll_items/payroll_items-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="regularDaysWorked">
                                        { item.regularDaysWorked }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="absentDays">
                                        { item.absentDays }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="tardinessMinutes">
                                        { item.tardinessMinutes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overtimeHours">
                                        { item.overtimeHours }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nightDiffHours">
                                        { item.nightDiffHours }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="holidayDaysWorked">
                                        { item.holidayDaysWorked }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="basicPay">
                                        { item.basicPay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overtimePay">
                                        { item.overtimePay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="nightDifferential">
                                        { item.nightDifferential }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="holidayPay">
                                        { item.holidayPay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="allowances">
                                        { item.allowances }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="otherEarnings">
                                        { item.otherEarnings }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="grossPay">
                                        { item.grossPay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sssEmployee">
                                        { item.sssEmployee }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="philhealthEmployee">
                                        { item.philhealthEmployee }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pagibigEmployee">
                                        { item.pagibigEmployee }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="withholdingTax">
                                        { item.withholdingTax }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sssEmployer">
                                        { item.sssEmployer }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="philhealthEmployer">
                                        { item.philhealthEmployer }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pagibigEmployer">
                                        { item.pagibigEmployer }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sssLoanDeduction">
                                        { item.sssLoanDeduction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="pagibigLoanDeduction">
                                        { item.pagibigLoanDeduction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="companyLoanDeduction">
                                        { item.companyLoanDeduction }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="otherDeductions">
                                        { item.otherDeductions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="totalDeductions">
                                        { item.totalDeductions }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="netPay">
                                        { item.netPay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ytdGrossPay">
                                        { item.ytdGrossPay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ytdWithholdingTax">
                                        { item.ytdWithholdingTax }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ytdSssEmployee">
                                        { item.ytdSssEmployee }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ytdPhilhealthEmployee">
                                        { item.ytdPhilhealthEmployee }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ytdPagibigEmployee">
                                        { item.ytdPagibigEmployee }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="ytdBasicPay">
                                        { item.ytdBasicPay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="payslipHash">
                                        { item.payslipHash }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.payroll_items_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Applicants ConvertedEmployee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ApplicationDate</th>
                                
                                
                                
                                <th>FirstName</th>
                                
                                
                                
                                <th>LastName</th>
                                
                                
                                
                                <th>Email</th>
                                
                                
                                
                                <th>Mobile</th>
                                
                                
                                
                                <th>Source</th>
                                
                                
                                
                                
                                
                                <th>InterviewSchedule</th>
                                
                                
                                
                                <th>InterviewResult</th>
                                
                                
                                
                                <th>PsychTestResult</th>
                                
                                
                                
                                <th>MedicalResult</th>
                                
                                
                                
                                <th>BackgroundCheckResult</th>
                                
                                
                                
                                <th>JobOfferStatus</th>
                                
                                
                                
                                <th>ExpectedStartDate</th>
                                
                                
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.applicants_convertedEmployee && Array.isArray(employees.applicants_convertedEmployee) &&
                              employees.applicants_convertedEmployee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/applicants/applicants-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="applicationDate">
                                        { dataFormatter.dateTimeFormatter(item.applicationDate) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="firstName">
                                        { item.firstName }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="lastName">
                                        { item.lastName }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="email">
                                        { item.email }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="mobile">
                                        { item.mobile }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="source">
                                        { item.source }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="interviewSchedule">
                                        { dataFormatter.dateTimeFormatter(item.interviewSchedule) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="interviewResult">
                                        { item.interviewResult }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="psychTestResult">
                                        { item.psychTestResult }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="medicalResult">
                                        { item.medicalResult }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="backgroundCheck">
                                        { item.backgroundCheck }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="jobOfferStatus">
                                        { item.jobOfferStatus }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="expectedStartDate">
                                        { dataFormatter.dateTimeFormatter(item.expectedStartDate) }
                                    </td>
                                    
                                    
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.applicants_convertedEmployee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                
                
                
                

                <BaseDivider />

                <BaseButton
                    color='info'
                    label='Back'
                    onClick={() => router.push('/employees/employees-list')}
                />
              </CardBox>
          </SectionMain>
      </>
    );
};

EmployeesView.getLayout = function getLayout(page: ReactElement) {
    return (
      <LayoutAuthenticated
        
        permission={'READ_EMPLOYEES'}
        
      >
          {page}
      </LayoutAuthenticated>
    )
}

export default EmployeesView;