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]"
/>