diff --git a/ipi-survey-platform/package-lock.json b/ipi-survey-platform/package-lock.json index 48d243e..57f0983 100644 --- a/ipi-survey-platform/package-lock.json +++ b/ipi-survey-platform/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "dependencies": { "axios": "^1.12.2", + "lucide-react": "^0.548.0", "react": "^19.1.1", "react-dom": "^19.1.1", "react-google-recaptcha": "^3.1.0", @@ -3190,6 +3191,15 @@ "yallist": "^3.0.2" } }, + "node_modules/lucide-react": { + "version": "0.548.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.548.0.tgz", + "integrity": "sha512-63b16z63jM9yc1MwxajHeuu0FRZFsDtljtDjYm26Kd86UQ5HQzu9ksEtoUUw4RBuewodw/tGFmvipePvRsKeDA==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/magic-string": { "version": "0.30.19", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.19.tgz", diff --git a/ipi-survey-platform/package.json b/ipi-survey-platform/package.json index e03f330..60e9044 100644 --- a/ipi-survey-platform/package.json +++ b/ipi-survey-platform/package.json @@ -11,6 +11,7 @@ }, "dependencies": { "axios": "^1.12.2", + "lucide-react": "^0.548.0", "react": "^19.1.1", "react-dom": "^19.1.1", "react-google-recaptcha": "^3.1.0", diff --git a/ipi-survey-platform/src/components/admin/StatCard.jsx b/ipi-survey-platform/src/components/admin/StatCard.jsx index 2e79009..5fbfe3b 100644 --- a/ipi-survey-platform/src/components/admin/StatCard.jsx +++ b/ipi-survey-platform/src/components/admin/StatCard.jsx @@ -5,14 +5,21 @@ const StatCard = ({ icon = null, label, value, width = 200.4 }) => { return (
- {icon} - {label} - {value} +
+ {icon &&
{icon}
} + + {label} + +
+ + + {value} +
); }; -export default StatCard; +export default StatCard; \ No newline at end of file diff --git a/ipi-survey-platform/src/components/admin/SubmissionTable.jsx b/ipi-survey-platform/src/components/admin/SubmissionTable.jsx index f923574..b695ac4 100644 --- a/ipi-survey-platform/src/components/admin/SubmissionTable.jsx +++ b/ipi-survey-platform/src/components/admin/SubmissionTable.jsx @@ -1,6 +1,6 @@ import React from 'react'; -import Table from '@/components/common/Table'; -import SearchIcon from '@/assets/images/material-symbols_search-rounded.svg'; +import Table from '../common/Table'; +import SearchIcon from '../../assets/images/material-symbols_search-rounded.svg'; const submissions = [ { @@ -98,62 +98,107 @@ const submissions = [ const SubmissionTable = () => { const [search, setSearch] = React.useState(''); - const filtered = React.useMemo(() => { - if (!search.trim()) return submissions; + const filtered = useMemo(() => { + if (!search.trim()) return filteredByQuarterYear; const normalized = search.trim().toLowerCase(); - return submissions.filter((item) => - [ - item.establishment, - item.emirate, - item.productCount, - item.year, - item.quarter, - item.lastSubmission, - item.deadline, - ] - .join(' ') - .toLowerCase() - .includes(normalized) + return filteredByQuarterYear.filter((item) => + Object.values(item).join(' ').toLowerCase().includes(normalized) ); - }, [search]); + }, [search, filteredByQuarterYear]); + + const headers = [ + 'Establishment', + 'Emirates', + 'Year', + 'Quarter', + 'Product Count', + 'Submitted By', + 'Submission Date & Time', + 'Status', + 'Reviewer', + 'Reviewer On', + 'Actions', + ]; + + const renderStatusBadge = (status) => { + const normalized = status?.toLowerCase(); + if (normalized === 'approved') { + return ( + + Approved + + ); + } else if (normalized === 'rejected') { + return ( + + Rejected + + ); + } else if (normalized === 'pending') { + return ( + + Pending + + ); + } else { + return ( + + {status || '-'} + + ); + } + }; - const headers = ['Establishment', 'Emirates', 'Product Count', 'Year', 'Quarter', 'Last Submission', 'Deadline']; const tableRows = filtered.map((item) => [ item.establishment, item.emirate, - item.productCount, item.year, item.quarter, - item.lastSubmission, - item.deadline, + item.productCount, + item.submittedBy, + item.submissionDateTime, + renderStatusBadge(item.status), + item.reviewer, + item.reviewedOn, +
+ + + +
, ]); - const columnWidths = React.useMemo( - () => [ - 317, - 161, - 140, - 119, - 98, - 158, - 150, - ], - [] - ); + const columnWidths = [240, 120, 100, 100, 130, 150, 180, 150, 150, 180, 120]; + + const titleText = useMemo(() => { + const count = filtered.length; + if (selectedQuarter !== 'None' && selectedYear !== 'None') { + return `Recent 10 Submissions for Selected Quarter ${selectedQuarter} ${selectedYear} (${count})`; + } else if (selectedQuarter !== 'None') { + return `Recent 10 Submissions for Selected Quarter ${selectedQuarter} (${count})`; + } else if (selectedYear !== 'None') { + return `Recent 10 Submissions for Selected Year ${selectedYear} (${count})`; + } else { + return `Recent 10 Submissions (${count})`; + } + }, [selectedQuarter, selectedYear, filtered]); const toolbar = (

- Recent Submissions ({submissions.length}) + {titleText}

- Search + Search setSearch(event.target.value)} - placeholder="Search Establishment" + placeholder="Search Establishment or Status" className="h-10 w-full rounded-md border border-[#C3C6CB] pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-[#92722A]" />
@@ -162,18 +207,29 @@ const SubmissionTable = () => { ); return ( -
-
+
+
{toolbar} - + {loading ? ( +
+ Loading submissions... +
+ ) : ( +
+
+ + )} +