diff --git a/ipi-survey-platform/src/components/layout/HeaderBar.jsx b/ipi-survey-platform/src/components/layout/HeaderBar.jsx index a3c9f3a..b58a62d 100644 --- a/ipi-survey-platform/src/components/layout/HeaderBar.jsx +++ b/ipi-survey-platform/src/components/layout/HeaderBar.jsx @@ -13,11 +13,26 @@ const overviewIconInactiveSrc = '/assets/images/mdi_file-find-outline-active.svg const HeaderBar = () => { const [open, setOpen] = React.useState(false); - const [userOpen, setUserOpen] = React.useState(false); const [userName, setUserName] = React.useState('User'); const [userEmail, setUserEmail] = React.useState(''); + const [userOpen, setUserOpen] = React.useState(false); + const profileRef = React.useRef(null); const navigate = useNavigate(); + // Close dropdown when clicking outside + React.useEffect(() => { + const handleClickOutside = (event) => { + if (profileRef.current && !profileRef.current.contains(event.target)) { + setUserOpen(false); + } + }; + + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, []); + React.useEffect(() => { let parsed; try { @@ -127,32 +142,38 @@ const HeaderBar = () => { )} */} -
+
{userOpen && ( -
-
-

{userName}

- {userEmail &&

{userEmail}

} +
+
+

+ {userName?.replace(/([a-z])([A-Z])/g, '$1 $2')} +

+ {userEmail &&

{userEmail}

}
diff --git a/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx b/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx index fc4c689..c8490b1 100644 --- a/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx +++ b/ipi-survey-platform/src/components/survey/EstablishmentInfo/EstablishmentInfo.jsx @@ -187,8 +187,6 @@ const EstablishmentInfo = ({ e.preventDefault(); const establishmentId = sessionStorage.getItem('establishment_id'); - console.log('Edit Profile clicked, establishment_id:', establishmentId); - if (!establishmentId) { alert('No establishment ID found in session'); return; diff --git a/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx b/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx index c6f51d8..61bff1b 100644 --- a/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx +++ b/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx @@ -644,7 +644,6 @@ const location = useLocation(); product_id: productId }; - console.log('Calling getPreviousForecastData with params:', params); const response = await getPreviousForecastData( establishmentId, diff --git a/ipi-survey-platform/src/pages/Admin/Validations.jsx b/ipi-survey-platform/src/pages/Admin/Validations.jsx index 8f8b3c4..761658b 100644 --- a/ipi-survey-platform/src/pages/Admin/Validations.jsx +++ b/ipi-survey-platform/src/pages/Admin/Validations.jsx @@ -64,10 +64,10 @@ const ManageSubmissions = () => { const [error, setError] = React.useState(null); const [search, setSearch] = React.useState(''); const [year, setYear] = React.useState(''); - const [quarter, setQuarter] = React.useState(''); - const [emirate, setEmirate] = React.useState(''); + const [quarter, setQuarter] = React.useState('All'); + const [emirate, setEmirate] = React.useState('All'); const [status, setStatus] = React.useState('All'); - const [selectedQuarter, setSelectedQuarter] = React.useState('Q1'); + const [selectedQuarter, setSelectedQuarter] = React.useState('All'); const [selectedYear, setSelectedYear] = React.useState(new Date().getFullYear().toString()); const [currentPage, setCurrentPage] = React.useState(1); const [toast, setToast] = React.useState(null); @@ -181,7 +181,7 @@ const ManageSubmissions = () => { // Validate the rejection reason if (!rejectReason.trim()) { setShowRejectError(true); - showToast('error', 'Please provide a reason for rejection'); + // showToast('error', 'Please provide a reason for rejection'); return; } @@ -308,9 +308,10 @@ React.useEffect(() => { // First, get the current quarter and year const response = await apiClient.get('/admin_dashboard'); - const currentQuarter = response?.data?.selected_quarter || 'Q1'; - const currentYear = response?.data?.selected_year || new Date().getFullYear().toString(); - + // const currentQuarter = response?.data?.selected_quarter || 'Q1'; + const currentQuarter = 'All'; + // const currentYear = response?.data?.selected_year || new Date().getFullYear().toString(); + const currentYear = 'All'; // Set the filter states setSelectedQuarter(currentQuarter); setSelectedYear(currentYear); @@ -462,8 +463,9 @@ React.useEffect(() => { { - setSelectedQuarter(e.target.value); - setQuarter(e.target.value); + const value = e.target.value || 'All'; + setSelectedQuarter(value); + setQuarter(value); }} options={quarterOptions.map((v) => ({ label: v, value: v }))} placeholder="Quarter" @@ -826,29 +828,19 @@ React.useEffect(() => { {showRejectError && !rejectReason.trim() && (

Reason for rejection is required

)} -

- Please refer to the screenshot -

+
-
) : ( diff --git a/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx b/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx index bf2720a..765a634 100644 --- a/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx +++ b/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx @@ -46,9 +46,7 @@ const createEmptyProfile = () => ({ employmentNonEmiratiFemale: 0, }); -const mapApiEstablishmentToProfile = (apiData) => { - console.log('API Data to map:', apiData); - +const mapApiEstablishmentToProfile = (apiData) => { const data = apiData.data || apiData; return { diff --git a/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx b/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx index fe953ff..64f8639 100644 --- a/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx +++ b/ipi-survey-platform/src/pages/Admin/configuration/IsicHsCodes.jsx @@ -505,10 +505,7 @@ const IsicHsCodes = () => { try { 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); - + const response = await productService.getProductById(productId); if (response && response.data) { const product = response.data; setForm({ @@ -540,12 +537,8 @@ const IsicHsCodes = () => { try { setIsLoading(true); - const productId = selected.id; - console.log(`Fetching product details for editing ID: ${productId}`); - - const response = await productService.getProductById(productId); - console.log('Product details for edit:', response); - + const productId = selected.id; + const response = await productService.getProductById(productId); if (response && response.data) { const product = response.data; setForm({ @@ -572,9 +565,7 @@ const IsicHsCodes = () => { const [deletingRowIndex, setDeletingRowIndex] = React.useState(null); const handleDelete = async (paginationIndex) => { - const dataIndex = (currentPage - 1) * pageSize + paginationIndex; - console.log('Delete button clicked, paginationIndex:', paginationIndex, 'dataIndex:', dataIndex); - + const dataIndex = (currentPage - 1) * pageSize + paginationIndex; if (dataIndex < 0 || dataIndex >= rowsData.length) { console.error('Invalid row index for deletion'); return; @@ -589,12 +580,8 @@ const IsicHsCodes = () => { setDeletingRowIndex(dataIndex); try { - setIsLoading(true); - console.log('Fetching product details before deletion, ID:', productId); - - const response = await productService.getProductById(productId); - console.log('Product details from API:', response); - + setIsLoading(true); + const response = await productService.getProductById(productId); if (!response || !response.data) { throw new Error('Invalid product data received'); } @@ -628,7 +615,6 @@ const IsicHsCodes = () => { }; const handleDeleteConfirm = async () => { - console.log('Delete confirmed, deletingRowIndex:', deletingRowIndex); if (deletingRowIndex === null || deletingRowIndex < 0 || deletingRowIndex >= rowsData.length) { const errorMsg = 'Invalid row selected for deletion'; @@ -648,9 +634,7 @@ const IsicHsCodes = () => { if (!productId) { throw new Error('No product ID found for deletion'); } - - console.log('Deleting product:', { productId, product }); - + try { await productService.deleteProduct(productId); @@ -716,9 +700,7 @@ const IsicHsCodes = () => { const handleImportCSV = async (file) => { try { - // Simulate CSV processing - replace with actual API call - console.log('Importing file:', file); - + // Simulate CSV processing - replace with actual API call // Simulate successful import await new Promise(resolve => setTimeout(resolve, 1500)); @@ -835,11 +817,8 @@ const IsicHsCodes = () => { } } - console.log('Creating new product...'); try { - const response = await productService.createProduct(productData); - console.log('Create response:', response); - + const response = await productService.createProduct(productData); const selectedUnit = unitOptions.find(u => u.value === form.unit); const newProduct = { @@ -858,7 +837,6 @@ const IsicHsCodes = () => { setRowsData(prev => [newProduct, ...prev]); setFilteredData(prev => [newProduct, ...prev]); - console.log('Product created successfully'); showToast('Product created successfully!', 'success'); closeModal(); } catch (createError) { diff --git a/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx b/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx index 80edb2a..eb76f69 100644 --- a/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx +++ b/ipi-survey-platform/src/pages/Admin/configuration/UnitMaster.jsx @@ -274,9 +274,8 @@ const UnitMaster = () => { } const selectedProducts = Array.isArray(form.productsMapped) ? form.productsMapped : []; - console.log(selectedProducts,"selectedProducts"); - // โœ… Check for duplicate unit name + // Check for duplicate unit name const nameExists = units.some( unit => unit.uom?.toLowerCase().trim() === form.unitName.toLowerCase().trim() ); diff --git a/ipi-survey-platform/src/pages/History/History.jsx b/ipi-survey-platform/src/pages/History/History.jsx index a7fdafd..3fcd7fd 100644 --- a/ipi-survey-platform/src/pages/History/History.jsx +++ b/ipi-survey-platform/src/pages/History/History.jsx @@ -140,7 +140,7 @@ useEffect(() => { ? hscodeFilter.split(" - ")[1].trim() : hscodeFilter.trim(); - console.log("๐Ÿ“ฆ Loading audit history with:", { + console.log("Loading audit history with:", { yearFilter, quarterFilter, productName, @@ -170,7 +170,6 @@ useEffect(() => { currentPage: 1, })); - console.log("โœ… Loaded audit history rows:", data.length); } catch (error) { console.error(" Error loading audit history:", error); setAuditHistory([]); @@ -616,7 +615,6 @@ const tableRows = auditHistory.map((entry, index) => { onChange={(e) => { const value = e.target.value; setSearchTerm(value); - console.log("๐Ÿ” Searching for:", value); }} className="w-64 h-10 border border-gray-300 rounded-md px-3 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500" /> diff --git a/ipi-survey-platform/src/pages/SubmissionDetails/SubmissionDetails.jsx b/ipi-survey-platform/src/pages/SubmissionDetails/SubmissionDetails.jsx index 1bdbe79..fbac62d 100644 --- a/ipi-survey-platform/src/pages/SubmissionDetails/SubmissionDetails.jsx +++ b/ipi-survey-platform/src/pages/SubmissionDetails/SubmissionDetails.jsx @@ -15,7 +15,6 @@ const SubmissionDetails = () => { try { const response = await fetchSubmissionDetail(submissionId); const data = response.data; - console.log("data",data) setSubmission({ id: submissionId, survey_name: 'Industrial Production Survey', diff --git a/ipi-survey-platform/src/services/admin/submission.js b/ipi-survey-platform/src/services/admin/submission.js index beb21cc..166f8dc 100644 --- a/ipi-survey-platform/src/services/admin/submission.js +++ b/ipi-survey-platform/src/services/admin/submission.js @@ -41,14 +41,11 @@ export const getSubmissions = async (params = {}) => { }); const url = `/submissions?${queryParams.toString()}`; - console.log('Making API request to:', url); const response = await apiClient.get(url); - console.log('API response received:', response); // Check if response.data is an array or has a data property const responseData = Array.isArray(response.data) ? response.data : response.data?.data; - console.log('Processed response data:', responseData); return responseData || []; } catch (error) { diff --git a/ipi-survey-platform/src/services/configuration/adminService.js b/ipi-survey-platform/src/services/configuration/adminService.js index f435071..cb3e937 100644 --- a/ipi-survey-platform/src/services/configuration/adminService.js +++ b/ipi-survey-platform/src/services/configuration/adminService.js @@ -45,8 +45,7 @@ export const changeAdminUserPassword = async (id, passwordData) => { try { if (!id) throw new Error("Invalid user ID"); - console.log('๐Ÿ” Debug: Changing password for admin user:', id); - console.log('๐Ÿ” Debug: Password data received:', { + console.log('Debug: Password data received:', { hasOldPassword: !!passwordData.old_password, hasNewPassword: !!passwordData.new_password, hasConfirmPassword: !!passwordData.confirm_password @@ -59,17 +58,15 @@ export const changeAdminUserPassword = async (id, passwordData) => { confirm_password: passwordData.confirm_password }; - console.log('๐Ÿ” Debug: Final request data being sent:', requestData); // Use the correct endpoint for admin users // const response = await putRequest(`/admin_users/${id}/change-password`, requestData); const response = await putRequest(`admin_users/${id}/change-password`, requestData); - console.log('๐Ÿ” Debug: Admin password change successful:', response.data); return response.data; } catch (error) { - console.error("โŒ Error changing admin user password:", error); + console.error("Error changing admin user password:", error); if (error.response) { console.error("๐Ÿ” Debug: API error response:", {