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 = () => {
| - 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) - | -||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| + 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} + | + + - - {submissionData?.products?.map((product, idx) => ( -
| - Quantity ({product.unit?.uom || 'units'}) - | - {/* Previous Quarter Quantities */} -- {product.previous_quantity_period_one || '0'} - | -- {product.previous_quantity_period_two || '0'} - | -- {product.previous_quantity_period_three || '0'} - | - - {/* Current Quarter Quantities */} -- {product.current_quantity_period_one || '0'} - | -- {product.current_quantity_period_two || '0'} - | -- {product.current_quantity_period_three || '0'} - | - - {/* Forecast Quarter Quantities */} -- {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 Row */} -||||||||
| - Cost (AED) - | - {/* Previous Quarter Costs */} -- {product.previous_cost_period_one || '0'} - | -- {product.previous_cost_period_two || '0'} - | -- {product.previous_cost_period_three || '0'} - | - - {/* Current Quarter Costs */} -- {product.current_cost_period_one || '0'} - | -- {product.current_cost_period_two || '0'} - | -- {product.current_cost_period_three || '0'} - | - - {/* Forecast Quarter Costs */} -- {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'} | - {/* Forecast Quarter Reason Row */} -|||||
| - 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 -
+- Please refer to the screenshot -
*/} -No products found for this submission.