-
-
- Quantity updated -; Cost updated -
-
-
-
-
+const tableRows = auditHistory.map((entry, index) => {
+ const isExpanded = expandedRow === index;
+ const details = entry.details || [];
+
+ // Check if there are quantity or cost changes
+ const hasQuantityChanges = details.some(d => d.column.includes('quantity'));
+ const hasCostChanges = details.some(d => d.column.includes('cost'));
- {isExpanded && (
-
-
-
-
Quantity Updated:
-
-
-
-
-
-
-
Reason for variations:
-
-
-
-
- )}
+ return [
+ formatDateTime(entry.submission_date || entry.created_at),
+ entry.year || '—',
+ entry.quarter || '—',
+ entry.hs_code || '—',
+ entry.product_name || '—',
+
+
+ {formatStatus(entry.status)}
+
+
,
+ entry.actor || '—',
+
+
+
+ {hasQuantityChanges ? 'Quantity updated' : ''}
+ {hasQuantityChanges && hasCostChanges ? '; ' : ''}
+ {hasCostChanges ? 'Cost updated' : ''}
+ {!hasQuantityChanges && !hasCostChanges ? 'No changes' : ''}
+
+
+
- ];
- });
+
+{isExpanded && details.length > 0 && (
+
+
+
+
Quantity Updated:
+
+ {details
+ .filter(d => d.column.includes('quantity'))
+ .reduce((sum, d) => sum + (Number(d.new) - Number(d.old)), 0)
+ .toLocaleString('en-IN')}
+
+
+
+
Cost Updated:
+
+ {details
+ .filter(d => d.column.includes('cost'))
+ .reduce((sum, d) => sum + (Number(d.new) - Number(d.old)), 0)
+ .toLocaleString('en-IN', {
+ style: 'currency',
+ currency: 'AED',
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2
+ })}
+
+
+
+
Reason for variations: -
+
+
+
+
+
+)}
+
+ ];
+});
const toolbar = (
@@ -386,11 +570,16 @@ const History = () => {
@@ -512,35 +701,60 @@ const History = () => {
+ {/* Replace both HS Code and Product dropdowns with this */}
+
+
+
+ {isLoadingHscodes ? (
+
+ ) : (
+
+ )}
+
+
+
-
- {isLoadingHscodes ? (
-
- ) : (
-
- )}
-
-
-
+
@@ -553,7 +767,6 @@ const History = () => {
>
-
@@ -576,7 +789,7 @@ const History = () => {
type="text"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
- placeholder="Search establishment"
+ placeholder="Search Product"
className="w-full h-10 rounded-md border border-[#E2E8F0] pl-10 pr-3 text-sm text-[#232528] focus:outline-none"
/>
![]()
{
{filteredRows.length === 0 && !loading ? (
-
-
No details found
- {/*
Try adjusting your search or filter to find what you're looking for.
*/}
-
+
+
+ {/*
*/}
+
No submissions History found
+ {/*
+ No submission history is available for the current filters
+
*/}
+
+
) : (
{
if (ci === 5) { // Status column
return {formatStatus(filteredRows[ri]?.status)};
}
- if (ci === 6) {
- const submission = filteredRows[ri];
- const disabled = !submission;
- return (
-
- );
- }
+ // if (ci === 6) {
+ // const submission = filteredRows[ri];
+ // const disabled = !submission;
+ // return (
+ //
+ // );
+ // }
return value;
}}
/>
diff --git a/ipi-survey-platform/src/pages/Survey/Survey.jsx b/ipi-survey-platform/src/pages/Survey/Survey.jsx
index fde87a3..aba2fef 100644
--- a/ipi-survey-platform/src/pages/Survey/Survey.jsx
+++ b/ipi-survey-platform/src/pages/Survey/Survey.jsx
@@ -314,6 +314,7 @@ const Survey = () => {
return {
quarter: establishmentData?.quarter ?? '',
year: parseNumber(establishmentData?.year),
+ status: 'Submitted',
emirati_male: parseNumber(info.emiratiMale),
emirati_female: parseNumber(info.emiratiFemale),
non_emirati_male: parseNumber(info.nonEmiratiMale),
diff --git a/ipi-survey-platform/src/services/submissions/submissionService.js b/ipi-survey-platform/src/services/submissions/submissionService.js
index e85b5cd..9d2b8f5 100644
--- a/ipi-survey-platform/src/services/submissions/submissionService.js
+++ b/ipi-survey-platform/src/services/submissions/submissionService.js
@@ -103,6 +103,26 @@ export const getSubmissionHistoryByEstablishment = async (establishmentId, confi
}
};
+export const getSubmissionAuditHistory = async (establishmentId, params = {}) => {
+ try {
+ if (!establishmentId) {
+ throw new Error('Establishment ID is required');
+ }
+
+ const response = await getRequest('/submission-audit-history', {
+ params: {
+ establishment_id: establishmentId,
+ ...params // Spread any additional parameters (year, quarter, product_id)
+ }
+ });
+
+ return response.data || response;
+ } catch (error) {
+ console.error('Error fetching submission audit history:', error);
+ throw error;
+ }
+};
+
export default {
getSubmissions,
submitSurvey,
@@ -110,5 +130,6 @@ export default {
fetchSubmissionDetail,
getQuarterPeriods,
getPreviousForecastData,
- getSubmissionHistoryByEstablishment
+ getSubmissionHistoryByEstablishment,
+ getSubmissionAuditHistory
};
\ No newline at end of file