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

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


const EmployeesView = () => {
    const router = useRouter()
    const dispatch = useAppDispatch()
    const { employees } = useAppSelector((state) => state.employees)
    
    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 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?.employee_code}</p>
                </div>
              

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

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

              

              

              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

              

              

              

              

              

              

              

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

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              

              

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

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>BaseSalary(Monthly)</p>
                  <p>{employees?.base_salary_monthly || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>PositionAllowance(Fixed)</p>
                  <p>{employees?.position_allowance_fixed || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>MealAllowance(Daily)</p>
                  <p>{employees?.meal_allowance_daily || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              
                <div className={'mb-4'}>
                  <p className={'block font-bold mb-2'}>TransportAllowance(Daily)</p>
                  <p>{employees?.transport_allowance_daily || 'No data'}</p>
                </div>
              

              

              

              

              

              

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

              

              

              

              

              

              

              

              

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

              

              

              

              
              

              

              

              

              

              

              

              

              

              

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

              

              

              
              

                
                
                
                
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Employee_contracts Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                <th>ContractType</th>
                                
                                
                                
                                <th>StartDate</th>
                                
                                
                                
                                <th>EndDate</th>
                                
                                
                                
                                
                                
                                <th>Notes</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.employee_contracts_employee && Array.isArray(employees.employee_contracts_employee) &&
                              employees.employee_contracts_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/employee_contracts/employee_contracts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    <td data-label="contract_type">
                                        { item.contract_type }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_date">
                                        { dataFormatter.dateTimeFormatter(item.start_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_date">
                                        { dataFormatter.dateTimeFormatter(item.end_date) }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.employee_contracts_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Attendance_logs 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>CheckInTime</th>
                                
                                
                                
                                <th>CheckOutTime</th>
                                
                                
                                
                                <th>CheckInLatitude</th>
                                
                                
                                
                                <th>CheckInLongitude</th>
                                
                                
                                
                                <th>CheckOutLatitude</th>
                                
                                
                                
                                <th>CheckOutLongitude</th>
                                
                                
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>LateMinutes</th>
                                
                                
                                
                                <th>GPSValid</th>
                                
                                
                                
                                <th>Remarks</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.attendance_logs_employee && Array.isArray(employees.attendance_logs_employee) &&
                              employees.attendance_logs_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/attendance_logs/attendance_logs-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="work_date">
                                        { dataFormatter.dateTimeFormatter(item.work_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_in_at">
                                        { dataFormatter.dateTimeFormatter(item.check_in_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_out_at">
                                        { dataFormatter.dateTimeFormatter(item.check_out_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_in_lat">
                                        { item.check_in_lat }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_in_lng">
                                        { item.check_in_lng }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_out_lat">
                                        { item.check_out_lat }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="check_out_lng">
                                        { item.check_out_lng }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="late_minutes">
                                        { item.late_minutes }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="gps_valid">
                                        { dataFormatter.booleanFormatter(item.gps_valid) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="remarks">
                                        { item.remarks }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.attendance_logs_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Attendance_requests Employee</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>
                            {employees.attendance_requests_employee && Array.isArray(employees.attendance_requests_employee) &&
                              employees.attendance_requests_employee.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>
                        {!employees?.attendance_requests_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Overtime_logs 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>OvertimeHours</th>
                                
                                
                                
                                <th>Reason</th>
                                
                                
                                
                                <th>ApprovalStatus</th>
                                
                                
                                
                                
                                
                                <th>ApprovedAt</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.overtime_logs_employee && Array.isArray(employees.overtime_logs_employee) &&
                              employees.overtime_logs_employee.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>
                        {!employees?.overtime_logs_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                <>
                    <p className={'block font-bold mb-2'}>Disciplinary_actions Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>Level</th>
                                
                                
                                
                                <th>IssuedAt</th>
                                
                                
                                
                                <th>ValidUntil</th>
                                
                                
                                
                                <th>Description</th>
                                
                                
                                
                                
                                
                                <th>Status</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.disciplinary_actions_employee && Array.isArray(employees.disciplinary_actions_employee) &&
                              employees.disciplinary_actions_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/disciplinary_actions/disciplinary_actions-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="level">
                                        { item.level }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="issued_at">
                                        { dataFormatter.dateTimeFormatter(item.issued_at) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="valid_until">
                                        { dataFormatter.dateTimeFormatter(item.valid_until) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="description">
                                        { item.description }
                                    </td>
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.disciplinary_actions_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Kpi_scores Employee</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>
                            {employees.kpi_scores_employee && Array.isArray(employees.kpi_scores_employee) &&
                              employees.kpi_scores_employee.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>
                        {!employees?.kpi_scores_employee?.length && <div className={'text-center py-4'}>No data</div>}
                    </CardBox>
                </>
                
                
                
                
                <>
                    <p className={'block font-bold mb-2'}>Loan_accounts Employee</p>
                    <CardBox
                      className='mb-6 border border-gray-300 rounded overflow-hidden'
                      hasTable
                    >
                        <div className='overflow-x-auto'>
                            <table>
                            <thead>
                            <tr>
                                
                                
                                
                                
                                
                                
                                <th>PrincipalAmount</th>
                                
                                
                                
                                <th>InstallmentAmount</th>
                                
                                
                                
                                <th>RemainingAmount</th>
                                
                                
                                
                                <th>StartDate</th>
                                
                                
                                
                                <th>EndDate</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>Notes</th>
                                
                                
                            </tr>
                            </thead>
                            <tbody>
                            {employees.loan_accounts_employee && Array.isArray(employees.loan_accounts_employee) &&
                              employees.loan_accounts_employee.map((item: any) => (
                                <tr key={item.id} onClick={() => router.push(`/loan_accounts/loan_accounts-view/?id=${item.id}`)}>
                                    
                                    
                                    
                                    
                                    
                                    
                                    <td data-label="principal_amount">
                                        { item.principal_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="installment_amount">
                                        { item.installment_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="remaining_amount">
                                        { item.remaining_amount }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="start_date">
                                        { dataFormatter.dateTimeFormatter(item.start_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="end_date">
                                        { dataFormatter.dateTimeFormatter(item.end_date) }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="notes">
                                        { item.notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.loan_accounts_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>Workdays</th>
                                
                                
                                
                                <th>SickDays</th>
                                
                                
                                
                                <th>LeaveDays</th>
                                
                                
                                
                                <th>AbsentDays</th>
                                
                                
                                
                                <th>LateCount</th>
                                
                                
                                
                                <th>LateMinutesTotal</th>
                                
                                
                                
                                <th>BaseSalary(Monthly)</th>
                                
                                
                                
                                <th>DailyRate</th>
                                
                                
                                
                                <th>BaseSalaryTotal</th>
                                
                                
                                
                                <th>Meal+TransportTotal</th>
                                
                                
                                
                                <th>PositionAllowanceTotal</th>
                                
                                
                                
                                <th>KPIScore</th>
                                
                                
                                
                                <th>KPIAllowanceTotal</th>
                                
                                
                                
                                <th>OvertimeHoursTotal</th>
                                
                                
                                
                                <th>OvertimeRate</th>
                                
                                
                                
                                <th>OvertimeTotal</th>
                                
                                
                                
                                <th>RevenueBonusTotal</th>
                                
                                
                                
                                <th>ServiceChargeTotal</th>
                                
                                
                                
                                <th>DeductionTotal</th>
                                
                                
                                
                                <th>TakeHomePay</th>
                                
                                
                                
                                <th>Status</th>
                                
                                
                                
                                <th>AdjustmentNotes</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="workdays">
                                        { item.workdays }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="sick_days">
                                        { item.sick_days }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="leave_days">
                                        { item.leave_days }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="absent_days">
                                        { item.absent_days }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="late_count">
                                        { item.late_count }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="late_minutes_total">
                                        { item.late_minutes_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_salary_monthly">
                                        { item.base_salary_monthly }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="daily_rate">
                                        { item.daily_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="base_salary_total">
                                        { item.base_salary_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="meal_transport_total">
                                        { item.meal_transport_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="position_allowance_total">
                                        { item.position_allowance_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="kpi_score">
                                        { item.kpi_score }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="kpi_allowance_total">
                                        { item.kpi_allowance_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overtime_hours_total">
                                        { item.overtime_hours_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overtime_rate">
                                        { item.overtime_rate }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="overtime_total">
                                        { item.overtime_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="revenue_bonus_total">
                                        { item.revenue_bonus_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="service_charge_total">
                                        { item.service_charge_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="deduction_total">
                                        { item.deduction_total }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="take_home_pay">
                                        { item.take_home_pay }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="status">
                                        { item.status }
                                    </td>
                                    
                                    
                                    
                                    <td data-label="adjustment_notes">
                                        { item.adjustment_notes }
                                    </td>
                                    
                                    
                                </tr>
                              ))}
                            </tbody>
                        </table>
                        </div>
                        {!employees?.payroll_items_employee?.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;