import React, { useEffect, 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 { getByPeriode } from '@/Services/Absensi'; import { toast } from 'react-toastify'; export default function Karyawan(props) { const formModal = useModalState(false) 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}
); }