import React, { useRef, useState } from 'react'; import Authenticated from '@/Layouts/Authenticated'; import { Head, useForm } from '@inertiajs/inertia-react'; import { useModalState } from '@/Hooks' import Button from '@/Components/Button'; import FormModal from './FormModal'; import { useReactToPrint } from 'react-to-print'; import { getByPeriode } from '@/Services/Absensi'; import { toast } from 'react-toastify'; const ComponentToPrint = React.forwardRef(({ absensi, month, year }, ref) => { const date = new Date() return (

Koro Koro Family Karaoke

Periode Absen Bulan {month} Tahun {year}

{absensi.data?.users?.map(item => ( ))}
NIK Nama Jenis Kelamin Jabatan Hadir Sakit Alfa
{item.nik} {item.name} {item.jenisKelamin} {item.jabatan} {item.hadir} {item.sakit} {item.alfa}

Pekanbaru, {date.getDate()}-{date.getMonth()}-{date.getFullYear()}

Finance

) }) export default function Karyawan(props) { const formModal = useModalState(false) const componentRef = useRef(); const handlePrint = useReactToPrint({ content: () => componentRef.current, }); const month = (new Date()).getMonth() const year = (new Date()).getFullYear() const months = [1,2,3,4,5,6,7,8,9,10,11,12] const years = [+year-2, +year-1, year, +year+1, +year+2] const {data, setData} = useForm({ month: month, year: year }) const onHandleChange = (event) => { setData( event.target.name, event.target.type === 'checkbox' ? event.target.checked : event.target.value ) } const [absensi, setAbsensi] = useState({}) const onClickShow = () => { setAbsensi({}) getByPeriode(`${data.month}_${data.year}`) .then(items => { if(items.length <= 0) { toast.error("No data found") return } setAbsensi(items[0]) }) } return (
Absensi

Periode Data :

{absensi.data?.users?.map(item => ( ))}
NIK Nama Jenis Kelamin Jabatan Hadir Sakit Alfa
{item.nik} {item.name} {item.jenisKelamin} {item.jabatan} {item.hadir} {item.sakit} {item.alfa}
{absensi.data?.users?.length > 0 && (
)}
); }