import React, { useEffect, useState } from 'react'; import Authenticated from '@/Layouts/Authenticated'; import { Head } from '@inertiajs/inertia-react'; import { useModalState } from '@/Hooks' import Button from '@/Components/Button'; import FormModal from './FormModal'; import { getAll, deleteById } from '@/Services/Jabatan'; import { toast } from 'react-toastify'; import { formatIDR } from '@/Utils'; export default function Jabatan(props) { const formModal = useModalState(false) const [items, setItems] = useState([]) const hanldeDeleteClick = (item) => { const con = confirm("delete item?") if (con) { deleteById(item.id) .then(() => toast.success('berhasil hapus')) .finally(() => fetchData()) } } const handleEditClick = (item) => { formModal.setData(item) formModal.toggle() } const fetchData = () => { getAll() .then(items => setItems(items)) } useEffect(() => { fetchData() }, []) return (
Jabatan
{items.map(item => ( ))}
Nama Gaji Pokok Tunjangan Fee Penjualan Tunjangan Transport Uang Makan Bonus Total
{item.data.nama} Rp. {formatIDR(item.data.gajiPokok)} Rp. {formatIDR(item.data.tunjangan)} Rp. {formatIDR(item.data.feePenjualan)} Rp. {formatIDR(item.data.transport)} Rp. {formatIDR(item.data.uangMakan)} Rp. {formatIDR(item.data.bonus)} Rp. {formatIDR(item.data.total)}
); }