From b13016df2adc218cd87d77264d789eeeac7f1009 Mon Sep 17 00:00:00 2001 From: Senthamilselvi Date: Wed, 5 Nov 2025 17:10:59 +0530 Subject: [PATCH 1/2] view submission products new design completed --- .../src/pages/Admin/ValidationReview.jsx | 229 ++++++++++++------ 1 file changed, 150 insertions(+), 79 deletions(-) diff --git a/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx b/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx index 9a959c3..4d55036 100644 --- a/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx +++ b/ipi-survey-platform/src/pages/Admin/ValidationReview.jsx @@ -374,87 +374,158 @@ const ValidationReview = () => { {productDetails.length > 0 ? ( -
- {productDetails.map((product, idx) => ( -
-
-
- Product: {product.code} - {product.name} -
- -
-
- Submitted By: - {product.submittedBy} -
-
- Unit: - {product.unit} -
-
- Capacity: - {product.capacity} -
-
-
- -
- - - - - {product.quarters.map((quarter) => ( - - ))} - - - - {product.rows.map((row) => ( - - - {row.values.map((value, index) => ( - - ))} - - ))} - -
Description - {quarter.label} -
{row.label} - {value} -
-
- -
-
- Remarks: {product.remarks} -
-
- Admin Remarks - +
+
+ ))} +
+) : ( +
+

No products found for this submission.

+
+)}
From b444718d8b21fc9e0b15959d2c3f620f9c74457f Mon Sep 17 00:00:00 2001 From: Senthamilselvi Date: Wed, 5 Nov 2025 18:17:13 +0530 Subject: [PATCH 2/2] establishment dashboard bug solved --- .../dashboard/SubmissionHistory.jsx | 165 ++++++++++-------- 1 file changed, 91 insertions(+), 74 deletions(-) diff --git a/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx b/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx index a4c3486..cabf24a 100644 --- a/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx +++ b/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx @@ -40,18 +40,32 @@ const getStatusClass = (status) => { return 'inline-flex items-center rounded-md bg-[#F8FAFC] px-2 py-1 text-xs font-medium text-[#374151]'; }; -const downloadCsv = (rows) => { - if (!rows.length) return; +const downloadCsv = (data) => { + if (!data.length) return; + const headers = ['Survey Name', 'Year', 'Quarter', 'Status', 'Submission On', 'Products']; const csvRows = [headers.join(',')]; - rows.forEach((row) => { - csvRows.push( - row - .slice(0, 6) - .map((cell) => `"${String(cell).replace(/"/g, '""')}"`) - .join(',') - ); + + data.forEach((item) => { + const surveyName = item.survey_name || '—'; + const year = item.year || '—'; + const quarter = item.quarter || '—'; + + const normalized = String(item.status || '').toLowerCase(); + let status = '—'; + if (normalized === 'pending') status = 'Under Review'; + else if (normalized === 'rejected') status = 'Returned'; + else if (['submitted', 'approved'].includes(normalized)) status = 'Approved'; + + const submissionOn = item.submission_on || '—'; + + const productCount = Number(item.products) || 0; + const products = `${productCount} ${productCount === 1 ? 'product' : 'products'}`; + + const row = [surveyName, year, quarter, status, submissionOn, products]; + csvRows.push(row.map(cell => `"${String(cell).replace(/"/g, '""')}"`).join(',')); }); + const blob = new Blob([csvRows.join('\n')], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); @@ -131,25 +145,19 @@ export const SubmissionHistory = ({ history = [], loading = false, error = '' }) }); const toolbar = ( -
-
-

- Submission History -

-
- {loading && Loading…} - {error && {error}} -
-
+
+

+ Submission History +

-
-
+
+
setSearchTerm(e.target.value)} placeholder="Search Establishment" - className="w-full h-10 rounded-md border border-[#E5E7EB] pl-10 pr-3 text-sm focus:outline-none" + className="w-full h-10 rounded-md border border-[#E5E7EB] pl-10 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-[#92722A]" />
+ + {rowsData.length === 0 ? ( + + + {loading ? 'Loading...' : error ? error : 'No submissions found'} + + + ) : ( + rowsData.map((row, rowIndex) => ( + + {row.map((cell, cellIndex) => ( + + {cell} + + ))} + + )) + )} + + + +