mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
refactor(FE): Disable invoice download feature
This commit is contained in:
@@ -17,7 +17,7 @@ import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
|||||||
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
|
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
|
||||||
import RequirePermission from '@/components/helper/RequirePermission';
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
import StatusBadge from '@/components/helper/StatusBadge';
|
import StatusBadge from '@/components/helper/StatusBadge';
|
||||||
import PurchaseOrderInvoice from '@/components/pages/purchase/order/PurchaseOrderInvoice';
|
// import PurchaseOrderInvoice from '@/components/pages/purchase/order/PurchaseOrderInvoice';
|
||||||
|
|
||||||
import { cn, formatDate } from '@/lib/helper';
|
import { cn, formatDate } from '@/lib/helper';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
@@ -159,26 +159,26 @@ const PurchaseTable = () => {
|
|||||||
PurchaseApi.getAllFetcher
|
PurchaseApi.getAllFetcher
|
||||||
);
|
);
|
||||||
|
|
||||||
const [isDownloadingInvoice, setIsDownloadingInvoice] = useState(false);
|
// const [isDownloadingInvoice, setIsDownloadingInvoice] = useState(false);
|
||||||
const [invoicePurchaseData, setInvoicePurchaseData] =
|
// const [invoicePurchaseData, setInvoicePurchaseData] =
|
||||||
useState<Purchase | null>(null);
|
// useState<Purchase | null>(null);
|
||||||
|
|
||||||
const handleDownloadInvoice = async (purchaseId: number) => {
|
// const handleDownloadInvoice = async (purchaseId: number) => {
|
||||||
setIsDownloadingInvoice(true);
|
// setIsDownloadingInvoice(true);
|
||||||
try {
|
// try {
|
||||||
const response = await PurchaseApi.getSingle(purchaseId);
|
// const response = await PurchaseApi.getSingle(purchaseId);
|
||||||
if (isResponseSuccess(response) && response.data) {
|
// if (isResponseSuccess(response) && response.data) {
|
||||||
setInvoicePurchaseData(response.data);
|
// setInvoicePurchaseData(response.data);
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
setInvoicePurchaseData(null);
|
// setInvoicePurchaseData(null);
|
||||||
}, 1000);
|
// }, 1000);
|
||||||
}
|
// }
|
||||||
} catch {
|
// } catch {
|
||||||
toast.error('Gagal mengambil data purchase order.');
|
// toast.error('Gagal mengambil data purchase order.');
|
||||||
} finally {
|
// } finally {
|
||||||
setIsDownloadingInvoice(false);
|
// setIsDownloadingInvoice(false);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
// ===== TABLE COLUMNS DEFINITION =====
|
// ===== TABLE COLUMNS DEFINITION =====
|
||||||
const purchaseColumns: ColumnDef<Purchase>[] = [
|
const purchaseColumns: ColumnDef<Purchase>[] = [
|
||||||
@@ -192,33 +192,7 @@ const PurchaseTable = () => {
|
|||||||
{
|
{
|
||||||
accessorKey: 'po_expedition',
|
accessorKey: 'po_expedition',
|
||||||
header: 'PO Ekspedisi',
|
header: 'PO Ekspedisi',
|
||||||
cell: (props) => {
|
cell: (props) => props.row.original.po_expedition || '-',
|
||||||
const purchase = props.row.original;
|
|
||||||
|
|
||||||
if (!purchase.po_number || purchase.po_number === 'Belum dibuat') {
|
|
||||||
return <span>-</span>;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Button
|
|
||||||
color='primary'
|
|
||||||
className='w-fit min-w-32 flex items-center justify-start gap-1 px-2 py-1 text-sm font-mono'
|
|
||||||
onClick={() => handleDownloadInvoice(purchase.id)}
|
|
||||||
disabled={isDownloadingInvoice}
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
icon={
|
|
||||||
isDownloadingInvoice
|
|
||||||
? 'eos-icons:loading'
|
|
||||||
: 'material-symbols:file-open-outline'
|
|
||||||
}
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
/>
|
|
||||||
{purchase.po_number}
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'supplier.name',
|
accessorKey: 'supplier.name',
|
||||||
@@ -506,14 +480,14 @@ const PurchaseTable = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{invoicePurchaseData && (
|
{/*{invoicePurchaseData && (
|
||||||
<div className='hidden'>
|
<div className='hidden'>
|
||||||
<PurchaseOrderInvoice
|
<PurchaseOrderInvoice
|
||||||
data={invoicePurchaseData}
|
data={invoicePurchaseData}
|
||||||
triggerDownloadOnMount={true}
|
triggerDownloadOnMount={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}*/}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user