@@ -2328,7 +2355,7 @@ const requiredFields = [
window.scrollTo({ top: 0, behavior: 'smooth' });
},
pageSize,
- totalItems: filteredProfiles.length, // Use filtered count for pagination
+ totalItems: totalItems, // Use the total count from API response
pageSizeOptions: [10, 20, 50, 100],
onPageSizeChange: (size) => {
setPageSize(size);
diff --git a/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx b/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx
index d9cf9c3..fe953ff 100644
--- a/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx
+++ b/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx
@@ -446,14 +446,13 @@ const IsicHsCodes = () => {
}, []);
const headers = [
- 'Code',
+ 'HS Code',
'Product Name',
'Unit',
- 'Mapped Establishments',
- 'Created by',
+ 'Estimated Mapped',
+ 'Created By',
'Last Updated',
- 'Status',
- 'Actions',
+ 'Action',
];
// Filter data based on search term
@@ -495,7 +494,6 @@ const IsicHsCodes = () => {
item.estimatedMapped,
displayName,
item.updated || item.createdOn || '-',
- item.status,
'actions',
];
});
@@ -508,7 +506,6 @@ const IsicHsCodes = () => {
setIsLoading(true);
const productId = selected.id;
console.log(`Fetching product details for ID: ${productId}`);
-
const response = await productService.getProductById(productId);
console.log('Product details response:', response);
@@ -769,8 +766,6 @@ const IsicHsCodes = () => {
};
const handleSaveForm = async () => {
- console.log('handleSaveForm called with mode:', modalMode);
-
if (!form.code || !form.product) {
const errorMsg = 'Please fill in all required fields';
console.error(errorMsg);
@@ -790,24 +785,16 @@ const IsicHsCodes = () => {
created_by: userProfile?.id || null,
...(form.description && { hs_description: form.description })
};
-
- console.log('Saving product data:', JSON.stringify(productData, null, 2));
-
+
if (modalMode === 'edit' && editingRow !== null) {
const productId = rowsData[editingRow]?.id;
if (!productId) {
throw new Error('Product ID not found for editing');
}
-
- console.log(`Updating product with ID: ${productId}`);
-
+
try {
- const response = await productService.updateProduct(productId, productData);
- console.log('Update response:', response);
-
- const selectedUnit = unitOptions.find(u => u.value === form.unit);
- console.log('Selected unit for update:', selectedUnit);
-
+ const response = await productService.updateProduct(productId, productData);
+ const selectedUnit = unitOptions.find(u => u.value === form.unit);
const updatedProduct = {
...rowsData[editingRow],
code: form.code,
@@ -929,10 +916,25 @@ const IsicHsCodes = () => {
{/* Header */}
-
-
HS Codes
-
-
+
+ {/* Mobile Header */}
+
+
+
+ HS Codes ({rowsData.length})
+
+
+
+
+ {/* Search - Mobile */}
+
@@ -944,114 +946,224 @@ const IsicHsCodes = () => {
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]"
/>
-
-
-
+
+ {/* Action Buttons - Mobile */}
+
+
+
+
+
+
+ {/* Desktop Header */}
+
+
+ HS Codes ({rowsData.length})
+
+
+
+
+

+
+
setSearchTerm(e.target.value)}
+ placeholder="Search by code or name"
+ 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]"
+ />
+
+
+
+
+
+
+
- {/* Table */}
-
{
- if (colIndex === 6) {
- return (
-
- );
- }
+ {/* Table - Desktop */}
+
+
{
+ if (colIndex === 6) {
+ return (
+
+
+
+
+
+ );
+ }
+ return value;
+ }}
+ pagination={{
+ currentPage,
+ onPageChange: setCurrentPage,
+ pageSize,
+ totalItems: filteredData.length,
+ }}
+ />
+
- if (colIndex === 7) {
- return (
-
-
-
-
+ {/* Mobile List View */}
+
+ {rows.length === 0 ? (
+
No HS Codes found
+ ) : (
+
+ {rows.map((row, rowIndex) => (
+
+
+
+
{row[1]}
+
{row[0]}
+
+ Unit:
+ {row[2]}
+
+
+ Mapped:
+ {row[3]}
+
+
+
+
+
+
+
- );
- }
-
- return value;
- }}
- pagination={{
- currentPage,
- onPageChange: setCurrentPage,
- pageSize,
- totalItems: filteredData.length,
- }}
- />
+ ))}
+
+ )}
+
+ {/* Mobile Pagination */}
+ {rows.length > 0 && (
+
+
+
+
+ Page {currentPage} of {Math.ceil(filteredData.length / pageSize)}
+
+
+
+
+ )}
+
{/* Add/Edit/View Modal */}
{modalMode && (
-
+
{/* Header */}
@@ -1162,9 +1274,9 @@ const IsicHsCodes = () => {
-
+
{
if (colIndex === headers.length - 1) {
return (
@@ -475,9 +513,18 @@ const QuarterlyWindows = () => {
}}
pagination={{
currentPage,
- onPageChange: setCurrentPage,
+ onPageChange: (page) => {
+ setCurrentPage(page);
+ // Scroll to top when changing pages
+ window.scrollTo({ top: 0, behavior: 'smooth' });
+ },
pageSize,
totalItems: filteredRows.length,
+ pageSizeOptions: [10, 20, 50, 100],
+ onPageSizeChange: (size) => {
+ setPageSize(size);
+ setCurrentPage(1); // Reset to first page when changing page size
+ }
}}
/>
diff --git a/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx b/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx
index cc1e10e..f549ed4 100644
--- a/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx
+++ b/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx
@@ -15,6 +15,7 @@ const caretDownIconSrc = '/assets/images/caretdown-active.svg';
const rectangleIconSrc = '/assets/images/Rectangle.svg';
const checkboxIconSrc = '/assets/images/checkbox.svg';
+
// Custom Toast Component
const CustomToast = ({ message, type, onClose }) => {
useEffect(() => {
@@ -85,6 +86,8 @@ const UnitMaster = () => {
const pageSize = 10;
const [currentUser, setCurrentUser] = useState(null);
const [toastData, setToastData] = useState(null);
+ const [searchTerm, setSearchTerm] = React.useState('');
+
// Fetch units on component mount
useEffect(() => {
@@ -110,6 +113,15 @@ const UnitMaster = () => {
}
};
+ const filteredUnits = React.useMemo(() => {
+ if (!searchTerm) return units;
+ const term = searchTerm.toLowerCase();
+ return units.filter(unit =>
+ (unit.uom && unit.uom.toLowerCase().includes(term)) ||
+ (unit.uom_short_name && unit.uom_short_name.toLowerCase().includes(term)) ||
+ (unit.description && unit.description.toLowerCase().includes(term))
+ );
+}, [units, searchTerm]);
useEffect(() => {
const userProfile = sessionStorage.getItem('user_profile');
if (userProfile) {
@@ -124,7 +136,6 @@ const UnitMaster = () => {
'Created By',
'Created On',
'Last Updated',
- 'Status',
'Actions',
];
@@ -148,14 +159,10 @@ const UnitMaster = () => {
item.created_by_name || currentUserName || '-',
createdDate,
updatedDate,
- ,
'actions',
];
});
- }, [units, currentUser]);
+ }, [units, currentUser,filteredUnits]);
const statusOptions = React.useMemo(
() => [
@@ -165,21 +172,21 @@ const UnitMaster = () => {
[]
);
- const productOptions = React.useMemo(
- () => [
- { label: 'Wheat', value: 'Wheat' },
- { label: 'Barley', value: 'Barley' },
- { label: 'Oats', value: 'Oats' },
- { label: 'Rice', value: 'Rice' },
- { label: 'Corn', value: 'Corn' },
- { label: 'Soybeans', value: 'Soybeans' },
- { label: 'Sorghum', value: 'Sorghum' },
- { label: 'Millet', value: 'Millet' },
- { label: 'Quinoa', value: 'Quinoa' },
- { label: 'Buckwheat', value: 'Buckwheat' },
- ],
- []
- );
+ // const productOptions = React.useMemo(
+ // () => [
+ // { label: 'Wheat', value: 'Wheat' },
+ // { label: 'Barley', value: 'Barley' },
+ // { label: 'Oats', value: 'Oats' },
+ // { label: 'Rice', value: 'Rice' },
+ // { label: 'Corn', value: 'Corn' },
+ // { label: 'Soybeans', value: 'Soybeans' },
+ // { label: 'Sorghum', value: 'Sorghum' },
+ // { label: 'Millet', value: 'Millet' },
+ // { label: 'Quinoa', value: 'Quinoa' },
+ // { label: 'Buckwheat', value: 'Buckwheat' },
+ // ],
+ // []
+ // );
const filteredRows = units;
@@ -266,13 +273,7 @@ const UnitMaster = () => {
});
return;
}
- if (!form.status) {
- setToastData({
- message: 'Please select Status.',
- type: 'error'
- });
- return;
- }
+ // Status validation removed as per request
// ✅ Check for duplicate unit name
const nameExists = units.some(
@@ -314,7 +315,7 @@ const UnitMaster = () => {
type: 'success'
});
} else {
- // ✅ Create new record
+ //Create new record
await createUnit({
...unitData,
created_at: new Date().toISOString(),
@@ -322,7 +323,7 @@ const UnitMaster = () => {
created_by_name: currentUser?.name || '',
});
- // ✅ Show success message for add
+ // Show success message for add
setToastData({
message: 'New unit added successfully!',
type: 'success'
@@ -378,11 +379,26 @@ const UnitMaster = () => {
return (
-
Unit Master (
-
- {units.length} {units.length === 1 ? 'unit': ''}
-
- )
+
+ Unit Master ({units.length}{units.length === 1 ? ' unit' : ''})
+
+ {/*
+
+
+

+
+
setSearchTerm(e.target.value)}
+ placeholder="Search by code or name"
+ 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]"
+ />
+
+
*/}
+
+
+ {/*
*/}
{
placeholder="Enter Description"
width="100%"
/>
-
+ {/*
{
)}
-
+ */}
-
Status *
@@ -606,7 +622,7 @@ const UnitMaster = () => {
onChange={handleFormChange('status')}
options={statusOptions}
placeholder="Select Status"
- />
+ /> */}