feat: Tambah fitur edit data perusahaan
parent
2d6918cdbc
commit
9579f140eb
|
@ -19,6 +19,7 @@ import {
|
|||
ChevronRight,
|
||||
ChevronUp,
|
||||
Download,
|
||||
Edit,
|
||||
FileText,
|
||||
Key,
|
||||
LockKeyhole,
|
||||
|
@ -30,6 +31,7 @@ import {
|
|||
|
||||
import Select from "react-select";
|
||||
import { AddPerusahaanModal } from "@/components/modals/add-perusahaan-modal";
|
||||
import { EditPerusahaanModal } from "@/components/modals/edit-perusahaan-modal";
|
||||
import {
|
||||
Perusahaan,
|
||||
JenisDokIL,
|
||||
|
@ -163,12 +165,20 @@ export default function PerusahaanIndex({
|
|||
companyOptions[0]
|
||||
);
|
||||
const [showAddModal, setShowAddModal] = useState(false);
|
||||
const [showEditModal, setShowEditModal] = useState(false);
|
||||
const [selectedPerusahaan, setSelectedPerusahaan] =
|
||||
useState<Perusahaan | null>(null);
|
||||
|
||||
const handleSuccess = () => {
|
||||
// Refresh data
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const handleEditClick = (item: Perusahaan) => {
|
||||
setSelectedPerusahaan(item);
|
||||
setShowEditModal(true);
|
||||
};
|
||||
|
||||
// Color coding helper
|
||||
const getStatusColor = (status: string) => {
|
||||
switch (status) {
|
||||
|
@ -199,9 +209,19 @@ export default function PerusahaanIndex({
|
|||
kecamatan={kecamatan}
|
||||
kelurahan={kelurahan}
|
||||
perusahaan={perusahaan}
|
||||
// existingPerusahaan={perusahaan.map(p => ({...p, PerusahaanId: p.PerusahaanId.toString()}))}
|
||||
// existingInduk={[]}
|
||||
// kawasan={kawasan}
|
||||
/>
|
||||
|
||||
<EditPerusahaanModal
|
||||
open={showEditModal}
|
||||
onClose={() => setShowEditModal(false)}
|
||||
onSuccess={handleSuccess}
|
||||
perusahaan={selectedPerusahaan}
|
||||
jenisKegiatan={jenisKegiatan}
|
||||
jenisDokIL={jenisDokIL}
|
||||
verifikator={verifikator}
|
||||
kabupaten={kabupaten}
|
||||
kecamatan={kecamatan}
|
||||
kelurahan={kelurahan}
|
||||
/>
|
||||
|
||||
{/* Filter Section */}
|
||||
|
@ -471,6 +491,12 @@ export default function PerusahaanIndex({
|
|||
>
|
||||
Status Laporan
|
||||
</TableHead>
|
||||
{/* <TableHead
|
||||
rowSpan={2}
|
||||
className="border-r text-center text-white"
|
||||
>
|
||||
Aksi
|
||||
</TableHead> */}
|
||||
</TableRow>
|
||||
<TableRow className="border-b bg-green-600">
|
||||
<TableHead className="text-center border-r text-white">
|
||||
|
@ -503,7 +529,7 @@ export default function PerusahaanIndex({
|
|||
{perusahaan.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell
|
||||
colSpan={20}
|
||||
colSpan={21}
|
||||
className="text-center py-4"
|
||||
>
|
||||
Tidak ada data perusahaan
|
||||
|
@ -525,8 +551,20 @@ export default function PerusahaanIndex({
|
|||
<TableCell className="text-center border-r border-l">
|
||||
{index + 1}
|
||||
</TableCell>
|
||||
<TableCell className="text-center border-r">
|
||||
{item.NamaPerusahaan || "N/A"}
|
||||
<TableCell className="border-r">
|
||||
<div className="flex justify-center">
|
||||
<Button
|
||||
variant="link"
|
||||
className="px-2 py-1 bg-green-100 h-auto font-normal justify-center text-center flex items-center gap-1"
|
||||
onClick={() =>
|
||||
handleEditClick(item)
|
||||
}
|
||||
>
|
||||
<Edit className="h-3 w-3 text-green-500" />
|
||||
{item.NamaPerusahaan ||
|
||||
"N/A"}
|
||||
</Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="text-center border-r">
|
||||
|
@ -616,6 +654,17 @@ export default function PerusahaanIndex({
|
|||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
{/* <TableCell className="text-center border-r">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() =>
|
||||
handleEditClick(item)
|
||||
}
|
||||
>
|
||||
<Edit className="h-4 w-4" />
|
||||
</Button>
|
||||
</TableCell> */}
|
||||
</TableRow>
|
||||
);
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue