From a9d4b62f8515eaf8ee71927b18780009b749e5e6 Mon Sep 17 00:00:00 2001 From: Malini Date: Wed, 5 Nov 2025 19:04:23 +0530 Subject: [PATCH] bug fixed in submission history --- .../assets/images/arrow-right-bold 1.svg | 3 + .../components/overview/DetailedOverview.jsx | 101 ++++++++++++++---- .../components/overview/ProductDetails.jsx | 24 ++++- .../src/pages/History/History.jsx | 90 +++++++++------- .../src/pages/Overview/Overview.jsx | 18 ++-- .../services/submissions/submissionService.js | 23 +++- 6 files changed, 185 insertions(+), 74 deletions(-) create mode 100644 ipi-survey-platform/public/assets/images/arrow-right-bold 1.svg diff --git a/ipi-survey-platform/public/assets/images/arrow-right-bold 1.svg b/ipi-survey-platform/public/assets/images/arrow-right-bold 1.svg new file mode 100644 index 0000000..e10d8d7 --- /dev/null +++ b/ipi-survey-platform/public/assets/images/arrow-right-bold 1.svg @@ -0,0 +1,3 @@ + + + diff --git a/ipi-survey-platform/src/components/overview/DetailedOverview.jsx b/ipi-survey-platform/src/components/overview/DetailedOverview.jsx index 6e35e0f..c2949f5 100644 --- a/ipi-survey-platform/src/components/overview/DetailedOverview.jsx +++ b/ipi-survey-platform/src/components/overview/DetailedOverview.jsx @@ -4,6 +4,20 @@ import { fetchSubmissionDetail } from '@/services/submissions/submissionService' import Table from '@/components/common/Table'; import ProductDetails from './ProductDetails'; +// Format date to readable format +const formatDate = (dateString) => { + if (!dateString) return '—'; + const options = { + year: 'numeric', + month: 'short', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + hour12: true + }; + return new Date(dateString).toLocaleString('en-US', options); +}; + const searchIconSrc = '/assets/images/material-symbols_search-rounded.svg'; const caretDownSrc = '/assets/images/CaretDown.svg'; const downloadIconSrc = '/assets/images/DownloadSimple.svg'; @@ -25,6 +39,25 @@ export const DetailedOverview = ({ submission, onBack }) => { pageSizeOptions: [10, 20, 50, 100] }); + const getStatusBadge = (status) => { + const statusMap = { + 'Approved': 'bg-[#F3FAF4] text-[#2F663C]', + 'Submitted': 'bg-[#E7F5FF] text-[#003CFF]', + 'Pending': 'bg-[#F9F7ED] text-[#7C5E24]', + 'Rejected': 'bg-[#FEF2F2] text-[#B52520]' + }; + + const statusClass = statusMap[status] || 'bg-gray-100 text-gray-800'; + + return ( + + {status || 'N/A'} + + ); +}; + + + // Add state for tracking loading and error states const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); @@ -217,24 +250,39 @@ export const DetailedOverview = ({ submission, onBack }) => { unit.uom || 'N/A', product.previous_quantity || '0', `AED ${product.previous_cost || '0'}`, - - {product.is_active ? 'Submitted' : 'Pending'} - {/* {product.is_active ? 'Rejected' : 'Rejected'} */} + // + // {product.is_active ? 'Submitted' : 'Pending'} + // {/* {product.is_active ? 'Rejected' : 'Rejected'} */} + // , + // new Date(product.updated_at || product.created_at).toLocaleString('en-US', { + // year: 'numeric', + // month: 'short', + // day: 'numeric', + // hour: '2-digit', + // minute: '2-digit', + // hour12: true + // }), +
+ + {getStatusBadge(submission.status) || 'Pending'} + +
, + + {formatDate(product.created_at) || '—'} , - new Date(product.updated_at || product.created_at).toLocaleString('en-US', { - year: 'numeric', - month: 'short', - day: 'numeric', - hour: '2-digit', - minute: '2-digit', - hour12: true - }), +