|
@@ -807,7 +814,12 @@ const PurchaseOrderStaffApprovalForm = ({
placeholder='Masukkan jumlah'
allowNegative={false}
decimalScale={0}
- bottomLabel={`Previous: ${formatNumber(purchaseItem.quantity)}`}
+ disabled={isQtyDisabled}
+ bottomLabel={
+ isQtyDisabled
+ ? 'Sudah chickin, tidak bisa diubah'
+ : `Previous: ${formatNumber(purchaseItem.quantity)}`
+ }
className={{
wrapper: 'min-w-32',
}}
diff --git a/src/components/pages/purchase/order/PurchaseOrderInvoice.tsx b/src/components/pages/purchase/order/PurchaseOrderInvoice.tsx
index 4ad093e1..aed154d0 100644
--- a/src/components/pages/purchase/order/PurchaseOrderInvoice.tsx
+++ b/src/components/pages/purchase/order/PurchaseOrderInvoice.tsx
@@ -1,6 +1,6 @@
'use client';
-import { useMemo, useState, useEffect, useCallback, useRef } from 'react';
+import { useMemo, useState } from 'react';
import {
Page,
Text,
@@ -235,16 +235,11 @@ const pdfStyles = StyleSheet.create({
interface PurchaseOrderInvoiceProps {
data?: Purchase;
className?: string;
- triggerDownloadOnMount?: boolean;
}
-const PurchaseOrderInvoice = ({
- data,
- triggerDownloadOnMount,
-}: PurchaseOrderInvoiceProps) => {
+const PurchaseOrderInvoice = ({ data }: PurchaseOrderInvoiceProps) => {
const [, setIsGeneratingPDF] = useState(false);
const purchaseData = data;
- const hasDownloadedRef = useRef(false);
const grandTotal = useMemo(() => {
return (
@@ -255,7 +250,7 @@ const PurchaseOrderInvoice = ({
);
}, [purchaseData?.items]);
- const handleDownloadPDF = useCallback(async () => {
+ const handleDownloadPDF = async () => {
if (!purchaseData) {
toast.error('No purchase order data available');
return;
@@ -515,20 +510,7 @@ const PurchaseOrderInvoice = ({
} finally {
setIsGeneratingPDF(false);
}
- }, [purchaseData]);
-
- useEffect(() => {
- if (triggerDownloadOnMount && purchaseData && !hasDownloadedRef.current) {
- hasDownloadedRef.current = true;
- handleDownloadPDF();
- }
- }, [triggerDownloadOnMount, purchaseData]);
-
- useEffect(() => {
- if (!triggerDownloadOnMount) {
- hasDownloadedRef.current = false;
- }
- }, [triggerDownloadOnMount]);
+ };
if (!purchaseData) {
return (
@@ -538,10 +520,6 @@ const PurchaseOrderInvoice = ({
);
}
- if (triggerDownloadOnMount) {
- return null;
- }
-
return purchaseData?.po_number &&
purchaseData.po_number !== 'Belum dibuat' ? (
|