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 } from '@/Services/SettingPotonganGaji'; import { toast } from 'react-toastify'; import { formatIDR } from '@/Utils'; export default function Karyawan(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 => { console.log(items) setItems(items) }) } useEffect(() => { fetchData() }, []) return (
Setting Potongan Gaji
{items.map(item => ( ))}
Jenis Potongan Jumlah Potongan
{item.data.jenis} Rp. {formatIDR(item.data.potongan)}
); }