diff --git a/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx b/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx index d1e0ab5..94624d2 100644 --- a/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx +++ b/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx @@ -29,11 +29,13 @@ const ValidationReview = () => { const { id } = useParams(); const [isRejectOpen, setIsRejectOpen] = React.useState(false); const [rejectReason, setRejectReason] = React.useState(''); + const [showRejectError, setShowRejectError] = React.useState(false); const [loading, setLoading] = React.useState(true); const [actionLoading, setActionLoading] = React.useState(false); const [error, setError] = React.useState(null); const [submissionData, setSubmissionData] = React.useState(null); const [quarterPeriods, setQuarterPeriods] = React.useState(null); + const [isApproveOpen, setIsApproveOpen] = React.useState(false); React.useEffect(() => { const fetchSubmission = async () => { @@ -81,6 +83,7 @@ const ValidationReview = () => { }, [id]); const handleApprove = async () => { + setIsApproveOpen(false); if (actionLoading) return; setActionLoading(true); @@ -116,9 +119,10 @@ const ValidationReview = () => { if (actionLoading) return; if (!rejectReason.trim()) { - alert('Please provide a reason for rejection.'); + setShowRejectError(true); return; } + setShowRejectError(false); setActionLoading(true); try { @@ -316,7 +320,7 @@ const ValidationReview = () => {
@@ -378,226 +382,220 @@ const ValidationReview = () => {
- {productDetails.length > 0 ? ( -
- {productDetails.map((product, idx) => ( +{submissionData?.products?.length > 0 ? ( +
+ {submissionData.products.map((product, idx) => (
+ {/* Header Section */}
- Product: {product.code} - {product.name} + Product:{' '} + + {product?.product?.hs_code} - {product?.product?.product_name} +
- Submitted By: {product.submittedBy} + Submitted By: System - Unit: {product.unit} + Unit: {product?.unit?.uom || 'units'} - Capacity: {product.capacity} + Capacity: {product?.annual_installed_capacity}
+ {/* Table Section */}
- - - - - - - - +
- Metric - - {quarterPeriods?.previous_quarter}-{quarterPeriods?.previous_year} (Previous Quarter) - - {quarterPeriods?.current_quarter}-{quarterPeriods?.current_year} (Current Quarter) - - {quarterPeriods?.forecast_quarter}-{quarterPeriods?.forecast_year} (Next Quarter) -
+ + + + + + + - - - - + + + + - - - + + + - - - - - + + + + + - - {submissionData?.products?.map((product, idx) => ( - - {/* Quantity Row */} - - - {/* Previous Quarter Quantities */} - - - - - {/* Current Quarter Quantities */} - - - - - {/* Forecast Quarter Quantities */} - - - - + + {/* Quantity Row */} + + + + + - {/* Cost Row */} - - - {/* Previous Quarter Costs */} - - - - - {/* Current Quarter Costs */} - - - - - {/* Forecast Quarter Costs */} - - - - - - {/* Remarks Row (if exists) */} - {product.remarks && ( - - - - - )} - - {/* Current Quarter Reason Row */} - - - - - - + + + - {/* Forecast Quarter Reason Row */} - - - - - - - - ))} - -
+ Metric + + {quarterPeriods?.previous_quarter}-{quarterPeriods?.previous_year}{' '} + (Previous Quarter) + + {quarterPeriods?.current_quarter}-{quarterPeriods?.current_year}{' '} + (Current Quarter) + + {quarterPeriods?.forecast_quarter}-{quarterPeriods?.forecast_year}{' '} + (Next Quarter) +
{quarterPeriods?.current_month?.current_period_one}{quarterPeriods?.current_month?.current_period_two}{quarterPeriods?.current_month?.current_period_three}
+ {quarterPeriods?.previous_month?.previous_period_one} + + {quarterPeriods?.previous_month?.previous_period_two} + + {quarterPeriods?.previous_month?.previous_period_three} + {quarterPeriods?.forecast_month?.forecast_period_one}{quarterPeriods?.forecast_month?.forecast_period_two}{quarterPeriods?.forecast_month?.forecast_period_three} + {quarterPeriods?.current_month?.current_period_one} + + {quarterPeriods?.current_month?.current_period_two} + + {quarterPeriods?.current_month?.current_period_three} + {quarterPeriods?.previous_month?.previous_period_one}{quarterPeriods?.previous_month?.previous_period_two}{quarterPeriods?.previous_month?.previous_period_three}
+ {quarterPeriods?.forecast_month?.forecast_period_one} + + {quarterPeriods?.forecast_month?.forecast_period_two} + + {quarterPeriods?.forecast_month?.forecast_period_three} +
- Quantity ({product.unit?.uom || 'units'}) - - {product.previous_quantity_period_one || '0'} - - {product.previous_quantity_period_two || '0'} - - {product.previous_quantity_period_three || '0'} - - {product.current_quantity_period_one || '0'} - - {product.current_quantity_period_two || '0'} - - {product.current_quantity_period_three || '0'} - - {product.forecast_quantity_period_one || '0'} - - {product.forecast_quantity_period_two || '0'} - - {product.forecast_quantity_period_three || '0'} -
+ Quantity ({product?.unit?.uom || 'units'}) + {product.previous_quantity_period_one || '0'}{product.previous_quantity_period_two || '0'}{product.previous_quantity_period_three || '0'}
- Cost (AED) - - {product.previous_cost_period_one || '0'} - - {product.previous_cost_period_two || '0'} - - {product.previous_cost_period_three || '0'} - - {product.current_cost_period_one || '0'} - - {product.current_cost_period_two || '0'} - - {product.current_cost_period_three || '0'} - - {product.forecast_cost_period_one || '0'} - - {product.forecast_cost_period_two || '0'} - - {product.forecast_cost_period_three || '0'} -
- Remarks - - {product.remarks} -
- Reason (Current) - -- - {product.variation_reason?.reason || 'No reason provided'} - {product.other_variation_reason && ( -
Note: {product.other_variation_reason}
- )} -
--
{product.current_quantity_period_one || '0'}{product.current_quantity_period_two || '0'}{product.current_quantity_period_three || '0'}
- Reason (Forecast) - ---- - {product.zero_target_reason?.reason || 'No reason provided'} - {product.other_zero_target_reason && ( -
Note: {product.other_zero_target_reason}
- )} -
- -
- {/*

- Green ▲ indicates upward trend;{' '} - Red ▼ indicates downward trend compared to previous month or quarter -

*/} -

- Remarks: NA -

+ {product.forecast_quantity_period_one || '0'} + {product.forecast_quantity_period_two || '0'} + {product.forecast_quantity_period_three || '0'} + + + {/* Cost Row */} + + + Cost (AED) + + {product.previous_cost_period_one || '0'} + {product.previous_cost_period_two || '0'} + {product.previous_cost_period_three || '0'} + + {product.current_cost_period_one || '0'} + {product.current_cost_period_two || '0'} + {product.current_cost_period_three || '0'} + + {product.forecast_cost_period_one || '0'} + {product.forecast_cost_period_two || '0'} + {product.forecast_cost_period_three || '0'} + + + {/* Reason (Current) */} + + + Reason (Current) + + + -- + + + {product?.variation_reason?.reason || 'No reason provided'} + {product.other_variation_reason && ( +
+ Note: {product.other_variation_reason} +
+ )} + + + -- + + + + {/* Reason (Forecast) */} + + + Reason (Forecast) + + + -- + + + -- + + + {product?.zero_target_reason?.reason || 'No reason provided'} + {product.other_zero_target_reason && ( +
+ Note: {product.other_zero_target_reason} +
+ )} + + + + + +
+ Remarks:{' '} + {product.remarks || 'NA'} +
+ +
+ + +
+
+
+ ))}
- -
- - -
- {/*

- Please refer to the screenshot -

*/} -
-
-
- -))} - ) : (

No products found for this submission.

)} + {actionType !== 'view' && (
@@ -643,23 +641,35 @@ const ValidationReview = () => { ×
-
-