mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE-208): add edit functionality to Item Pembelian section in PurchaseOrderDetail
This commit is contained in:
@@ -303,7 +303,9 @@ const PurchaseOrderStaffApprovalForm = ({
|
|||||||
>
|
>
|
||||||
<div className='w-full'>
|
<div className='w-full'>
|
||||||
<h2 className='text-lg font-semibold mb-4'>
|
<h2 className='text-lg font-semibold mb-4'>
|
||||||
Konfirmasi Approve Pembelian
|
{type === 'add'
|
||||||
|
? 'Konfirmasi Item Pembelian'
|
||||||
|
: 'Edit Item Pembelian'}
|
||||||
</h2>
|
</h2>
|
||||||
<div className='overflow-x-auto'>
|
<div className='overflow-x-auto'>
|
||||||
<table className='table'>
|
<table className='table'>
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import { Icon } from '@iconify/react';
|
|||||||
import { useModal } from '@/components/Modal';
|
import { useModal } from '@/components/Modal';
|
||||||
import Modal from '@/components/Modal';
|
import Modal from '@/components/Modal';
|
||||||
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
|
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
|
||||||
|
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
|
||||||
|
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
|
||||||
import PurchaseOrderStaffApprovalForm from '@/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm';
|
import PurchaseOrderStaffApprovalForm from '@/components/pages/purchase/form/order/PurchaseOrderStaffApprovalForm';
|
||||||
import PurchaseOrderAcceptApprovalForm from '@/components/pages/purchase/form/order/PurchaseOrderAcceptApprovalForm';
|
import PurchaseOrderAcceptApprovalForm from '@/components/pages/purchase/form/order/PurchaseOrderAcceptApprovalForm';
|
||||||
import PurchaseOrderInvoice from '@/components/pages/purchase/order/PurchaseOrderInvoice';
|
import PurchaseOrderInvoice from '@/components/pages/purchase/order/PurchaseOrderInvoice';
|
||||||
@@ -36,6 +38,22 @@ import { isResponseError } from '@/lib/api-helper';
|
|||||||
import { toast } from 'react-hot-toast';
|
import { toast } from 'react-hot-toast';
|
||||||
import { useSearchParams } from 'next/navigation';
|
import { useSearchParams } from 'next/navigation';
|
||||||
|
|
||||||
|
const ItemPembelianDropdown = ({ onEdit }: { onEdit: () => void }) => {
|
||||||
|
return (
|
||||||
|
<RowOptionsMenuWrapper type='dropdown'>
|
||||||
|
<Button
|
||||||
|
onClick={onEdit}
|
||||||
|
variant='ghost'
|
||||||
|
color='warning'
|
||||||
|
className='justify-start text-sm'
|
||||||
|
>
|
||||||
|
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
|
</RowOptionsMenuWrapper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
interface PurchaseOrderDetailProps {
|
interface PurchaseOrderDetailProps {
|
||||||
type?: 'detail' | 'edit';
|
type?: 'detail' | 'edit';
|
||||||
data?: Purchase;
|
data?: Purchase;
|
||||||
@@ -306,6 +324,7 @@ const PurchaseOrderDetail = ({
|
|||||||
const confirmationModalWithNotes = useModal();
|
const confirmationModalWithNotes = useModal();
|
||||||
const staffApprovalModal = useModal();
|
const staffApprovalModal = useModal();
|
||||||
const acceptApprovalModal = useModal();
|
const acceptApprovalModal = useModal();
|
||||||
|
const editModal = useModal();
|
||||||
|
|
||||||
// ===== STATIC DATA =====
|
// ===== STATIC DATA =====
|
||||||
const purchaseData = data || dummyPurchaseData;
|
const purchaseData = data || dummyPurchaseData;
|
||||||
@@ -707,9 +726,14 @@ const PurchaseOrderDetail = ({
|
|||||||
|
|
||||||
{/* Item Pembelian Section */}
|
{/* Item Pembelian Section */}
|
||||||
<div className='mb-8'>
|
<div className='mb-8'>
|
||||||
<h3 className='text-lg font-semibold text-gray-800 mb-4 pb-2 border-b border-gray-200'>
|
<div className='flex items-center justify-between mb-4 pb-2 border-b border-gray-200'>
|
||||||
|
<h3 className='text-lg font-semibold text-gray-800'>
|
||||||
Item Pembelian
|
Item Pembelian
|
||||||
</h3>
|
</h3>
|
||||||
|
<RowDropdownOptions isLast2Rows>
|
||||||
|
<ItemPembelianDropdown onEdit={editModal.openModal} />
|
||||||
|
</RowDropdownOptions>
|
||||||
|
</div>
|
||||||
<div className='rounded-lg border border-gray-200 overflow-hidden'>
|
<div className='rounded-lg border border-gray-200 overflow-hidden'>
|
||||||
{/* Product Table */}
|
{/* Product Table */}
|
||||||
<div className='overflow-x-auto'>
|
<div className='overflow-x-auto'>
|
||||||
@@ -857,6 +881,21 @@ const PurchaseOrderDetail = ({
|
|||||||
onCancel={acceptApprovalModal.closeModal}
|
onCancel={acceptApprovalModal.closeModal}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
{/* Edit Modal */}
|
||||||
|
<Modal
|
||||||
|
ref={editModal.ref}
|
||||||
|
closeOnBackdrop
|
||||||
|
className={{
|
||||||
|
modalBox: 'w-full max-w-screen-2xl max-h-[90vh] overflow-y-auto',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PurchaseOrderStaffApprovalForm
|
||||||
|
type='edit'
|
||||||
|
initialValues={purchaseData}
|
||||||
|
onCancel={editModal.closeModal}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user