diff --git a/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx b/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx index b6b55b6..648c7f1 100644 --- a/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx +++ b/ipi-survey-platform/src/components/dashboard/SubmissionHistory.jsx @@ -36,11 +36,11 @@ const getStatusBadge = (status) => { Submitted ); - } else if (normalized === 'resubmitted') { + } else if (normalized === 'resubmitted') { return ( Resubmitted - + ); } else if (['pending', 'under review', 'in-progress'].includes(normalized)) { return ( @@ -102,7 +102,6 @@ const downloadCsv = (data) => { URL.revokeObjectURL(url); }; - export const SubmissionHistory = ({ history = [], loading = false, error = '' }) => { const [searchTerm, setSearchTerm] = React.useState(''); const [selectedSubmission, setSelectedSubmission] = React.useState(null); @@ -110,6 +109,10 @@ export const SubmissionHistory = ({ history = [], loading = false, error = '' }) const pageSize = 10; const navigate = useNavigate(); + const handleViewDetails = (submission) => { + navigate('/overview', { state: { selectedSubmission: submission } }); + }; + const normalizedHistory = React.useMemo(() => { if (!Array.isArray(history)) return []; return history.map((entry, index) => ({ @@ -126,11 +129,11 @@ export const SubmissionHistory = ({ history = [], loading = false, error = '' }) const filtered = normalizedHistory.filter((entry) => { const term = searchTerm.trim().toLowerCase().replace(/\s+/g, ''); if (!term) return true; - + return Object.values(entry).some((val) => String(val).toLowerCase().replace(/\s+/g, '').includes(term) ); - }); + }); const tableHeaders = [ 'Survey Name', @@ -152,7 +155,7 @@ export const SubmissionHistory = ({ history = [], loading = false, error = '' }) {item.submission_on}, productsLabel, + setSelectedSubmission(null)} /> + + + ); + } + if (loading) { return (