console removed

This commit is contained in:
Malini 2025-11-13 06:37:36 +05:30
parent 4f083b1f68
commit 24fcea6189
14 changed files with 18 additions and 102 deletions

View File

@ -91,7 +91,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
// Function to save resubmission data to localStorage // Function to save resubmission data to localStorage
const saveResubmissionData = (productData) => { const saveResubmissionData = (productData) => {
try { try {
console.log('Saving resubmission data:', productData); // Debug log
const resubmissionData = { const resubmissionData = {
submissionId: productData.submission_id, submissionId: productData.submission_id,
product: { product: {
@ -148,7 +147,6 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
}; };
localStorage.setItem('resubmissionData', JSON.stringify(resubmissionData)); localStorage.setItem('resubmissionData', JSON.stringify(resubmissionData));
console.log('Resubmission data saved to localStorage');
} catch (error) { } catch (error) {
console.error('Error saving resubmission data to localStorage:', error); console.error('Error saving resubmission data to localStorage:', error);
} }
@ -275,10 +273,7 @@ const ProductDetails = ({ product, onBack, showToast: shouldShowToast, onToastSh
}; };
// Save to localStorage // Save to localStorage
localStorage.setItem('resubmissionData', JSON.stringify(dataToStore)); localStorage.setItem('resubmissionData', JSON.stringify(dataToStore));
console.log('API response saved to localStorage:', dataToStore);
// Navigate to the survey page with the submission data // Navigate to the survey page with the submission data
navigate('/survey', { navigate('/survey', {
state: { state: {

View File

@ -152,9 +152,7 @@ const EstablishmentInfo = ({
}; };
// Store establishment data in localStorage during resubmission // Store establishment data in localStorage during resubmission
React.useEffect(() => { React.useEffect(() => {
console.log('Establishment data:', data);
// Check if this is a resubmission // Check if this is a resubmission
const isResubmit = location.state?.fromResubmit; const isResubmit = location.state?.fromResubmit;
@ -184,7 +182,6 @@ const EstablishmentInfo = ({
// Save back to localStorage // Save back to localStorage
localStorage.setItem('resubmissionData', JSON.stringify(updatedData)); localStorage.setItem('resubmissionData', JSON.stringify(updatedData));
console.log('Updated resubmission data with establishment info:', updatedData);
} catch (error) { } catch (error) {
console.error('Error updating resubmission data with establishment info:', error); console.error('Error updating resubmission data with establishment info:', error);
} }

View File

@ -363,7 +363,6 @@ const ProductData = ({
setReasonsError(''); setReasonsError('');
try { try {
const reasons = await fetchVariationReasons({ signal: variationController.signal }); const reasons = await fetchVariationReasons({ signal: variationController.signal });
console.log('Loaded variation reasons:', reasons);
setVariationReasons(reasons || []); setVariationReasons(reasons || []);
setReasonsError(''); setReasonsError('');
} catch (error) { } catch (error) {
@ -462,9 +461,7 @@ const ProductData = ({
setProductsError(''); setProductsError('');
try { try {
// Get products from getEstablishmentProducts // Get products from getEstablishmentProducts
const apiResponse = await getEstablishmentProducts(establishmentId); const apiResponse = await getEstablishmentProducts(establishmentId);
console.log('Products from API:', apiResponse); // Debug log
// Ensure we're working with an array and handle the response structure // Ensure we're working with an array and handle the response structure
const productsList = Array.isArray(apiResponse) ? apiResponse : (apiResponse?.data || []); const productsList = Array.isArray(apiResponse) ? apiResponse : (apiResponse?.data || []);
@ -485,9 +482,6 @@ const ProductData = ({
unit: unitName unit: unitName
}; };
}); });
console.log('Formatted products:', formattedProducts); // Debug log
setProductOptions(formattedProducts); setProductOptions(formattedProducts);
} catch (error) { } catch (error) {
console.error('Error fetching products:', error); console.error('Error fetching products:', error);
@ -663,7 +657,7 @@ const location = useLocation();
// Return the response data or the response itself if data doesn't exist // Return the response data or the response itself if data doesn't exist
const result = response.data || response; const result = response.data || response;
console.log('Processed forecast data:', result); ('Processed forecast data:', result);
return result; return result;
} catch (error) { } catch (error) {
@ -688,10 +682,7 @@ const location = useLocation();
const isOtherSelected = selectedReason && ( const isOtherSelected = selectedReason && (
(selectedReason.name && selectedReason.name.toLowerCase().includes('other')) || (selectedReason.name && selectedReason.name.toLowerCase().includes('other')) ||
(selectedReason.label && selectedReason.label.toLowerCase().includes('other')) (selectedReason.label && selectedReason.label.toLowerCase().includes('other'))
); );
console.log('Selected reason:', selectedReason, 'Is other:', isOtherSelected);
// Update the showOtherVariationReason state for this product // Update the showOtherVariationReason state for this product
setShowOtherVariationReason(prev => ({ setShowOtherVariationReason(prev => ({
...prev, ...prev,
@ -824,10 +815,7 @@ const location = useLocation();
const isOtherSelected = selectedReason && ( const isOtherSelected = selectedReason && (
(selectedReason.name && selectedReason.name.toLowerCase().includes('other')) || (selectedReason.name && selectedReason.name.toLowerCase().includes('other')) ||
(selectedReason.label && selectedReason.label.toLowerCase().includes('other')) (selectedReason.label && selectedReason.label.toLowerCase().includes('other'))
); );
console.log('Selected zero target reason:', selectedReason, 'Is other:', isOtherSelected);
// Update the showOtherZeroTargetReason state for this product // Update the showOtherZeroTargetReason state for this product
setShowOtherZeroTargetReason(prev => ({ setShowOtherZeroTargetReason(prev => ({
...prev, ...prev,
@ -889,9 +877,7 @@ const handleProductSelect = async (productId, establishmentId, id) => {
} }
// Check if the response has a data property (nested response) or is the data itself // Check if the response has a data property (nested response) or is the data itself
const data = forecastData.data || forecastData; const data = forecastData.data || forecastData;
console.log('Processing forecast data:', data);
const updatedProducts = products.map(product => { const updatedProducts = products.map(product => {
if (product.id === id) { if (product.id === id) {
return { return {
@ -907,8 +893,6 @@ const handleProductSelect = async (productId, establishmentId, id) => {
} }
return product; return product;
}); });
console.log('Updating products with new data');
onProductsChange(updatedProducts); onProductsChange(updatedProducts);
} catch (error) { } catch (error) {
console.error('Error in handleProductSelect:', { console.error('Error in handleProductSelect:', {
@ -1087,9 +1071,7 @@ const handleProductSelect = async (productId, establishmentId, id) => {
options={productOptions} options={productOptions}
value={p.productId?.toString() || p.product?.toString() || ''} value={p.productId?.toString() || p.product?.toString() || ''}
onChange={async (e) => { onChange={async (e) => {
const selectedValue = e.target.value; const selectedValue = e.target.value;
console.log('Selected product value:', selectedValue); // Debug log
// Clear error when user selects a product // Clear error when user selects a product
if (formErrors[`product_${idx}`]) { if (formErrors[`product_${idx}`]) {
const newErrors = { ...formErrors }; const newErrors = { ...formErrors };
@ -1099,7 +1081,6 @@ const handleProductSelect = async (productId, establishmentId, id) => {
// Find the selected product from options // Find the selected product from options
const selectedProduct = productOptions.find(opt => opt.value === selectedValue); const selectedProduct = productOptions.find(opt => opt.value === selectedValue);
console.log('Selected product:', selectedProduct); // Debug log
// Get unit information from the selected product // Get unit information from the selected product
const unitId = selectedProduct?.originalData?.['product.unit.id']; const unitId = selectedProduct?.originalData?.['product.unit.id'];
const unitName = selectedProduct?.originalData?.['product.unit.uom'] || const unitName = selectedProduct?.originalData?.['product.unit.uom'] ||
@ -1126,10 +1107,7 @@ const handleProductSelect = async (productId, establishmentId, id) => {
// Update the products array with the updated product // Update the products array with the updated product
const updatedProducts = products.map((prod, i) => const updatedProducts = products.map((prod, i) =>
i === idx ? updatedProduct : prod i === idx ? updatedProduct : prod
); );
console.log('Updated products:', updatedProducts); // Debug log
// Update the parent component's state // Update the parent component's state
onProductsChange(updatedProducts); onProductsChange(updatedProducts);

View File

@ -143,8 +143,6 @@ const findDisplayName = (options, value) => {
}; };
const buildProductRows = (products = [], options = {}) => { const buildProductRows = (products = [], options = {}) => {
console.log('Raw products data:', products); // Debug log
console.log('Available options:', options); // Debug log
if (!Array.isArray(products)) { if (!Array.isArray(products)) {
console.warn('buildProductRows: Expected an array but got', typeof products); console.warn('buildProductRows: Expected an array but got', typeof products);
@ -181,14 +179,11 @@ const buildProductRows = (products = [], options = {}) => {
// Format the display name as "HS Code - Product Name" if HS code exists // Format the display name as "HS Code - Product Name" if HS code exists
const displayName = hsCode ? `${hsCode} - ${productName}` : productName; const displayName = hsCode ? `${hsCode} - ${productName}` : productName;
const productCode = hsCode || product.id || `CODE-${index + 1}`; const productCode = hsCode || product.id || `CODE-${index + 1}`;
console.log("productCode",productCode)
// Use stored unitName if available, otherwise try to find it in unitOptions // Use stored unitName if available, otherwise try to find it in unitOptions
let unitName = product.unitName; let unitName = product.unitName;
if (!unitName && product.unit) { if (!unitName && product.unit) {
unitName = findDisplayName(unitOptions, product.unit); unitName = findDisplayName(unitOptions, product.unit);
} }
console.log("unitName", unitName)
// Use stored reason names if available, otherwise try to find them in the options // Use stored reason names if available, otherwise try to find them in the options
const variationReasonName = product.variationReasonName || findDisplayName(variationReasons, product.variationReason); const variationReasonName = product.variationReasonName || findDisplayName(variationReasons, product.variationReason);
const zeroTargetReasonName = product.zeroTargetReasonName || findDisplayName(zeroTargetReasons, product.zeroTargetReason); const zeroTargetReasonName = product.zeroTargetReasonName || findDisplayName(zeroTargetReasons, product.zeroTargetReason);
@ -267,18 +262,12 @@ const formatSubmissionData = (establishment, products, remarks = '') => {
const totalEmployees = totalEmirati + nonEmiratiMale + nonEmiratiFemale; const totalEmployees = totalEmirati + nonEmiratiMale + nonEmiratiFemale;
// Format products data // Format products data
console.log('Original products data:', JSON.stringify(products, null, 2));
const formattedProducts = products.map(product => { const formattedProducts = products.map(product => {
// Get the actual product_id from the originalData if available // Get the actual product_id from the originalData if available
const originalData = product.originalData || {}; const originalData = product.originalData || {};
console.log('Original data for product:', JSON.stringify(originalData, null, 2));
// Get the product_id directly from the originalData object // Get the product_id directly from the originalData object
// originalData has both id (establishment product ID) and product_id (actual product ID) // originalData has both id (establishment product ID) and product_id (actual product ID)
const productId = originalData.product_id || originalData.id; // Use product_id (56) with fallback to id const productId = originalData.product_id || originalData.id; // Use product_id (56) with fallback to id
console.log('Selected product ID:', productId);
return { return {
product_id: parseInt(productId) || 0, product_id: parseInt(productId) || 0,
unit_id: parseInt(product.unit) || 0, unit_id: parseInt(product.unit) || 0,
@ -367,7 +356,6 @@ const ReviewSubmit = ({
products, products,
remarks remarks
); );
console.log('Submitting data:', submissionData);
onSubmit(submissionData); onSubmit(submissionData);
setConfirm(false); setConfirm(false);
} catch (error) { } catch (error) {

View File

@ -60,10 +60,7 @@ const AdminDashboard = () => {
if (!isMounted.current) return; if (!isMounted.current) return;
const data = response?.data?.summary || {}; const data = response?.data?.summary || {};
const quarterlyWindowsData = response?.data?.quarterly_windows || {}; const quarterlyWindowsData = response?.data?.quarterly_windows || {};
console.log("Fetching data for:", { quarter, year });
setSummary({ setSummary({
total_establishments: data.total_establishments || 0, total_establishments: data.total_establishments || 0,
submitted: data.submitted || 0, submitted: data.submitted || 0,

View File

@ -373,7 +373,6 @@ React.useEffect(() => {
}, [submissions]); }, [submissions]);
const filtered = React.useMemo(() => { const filtered = React.useMemo(() => {
console.log('Current submissions:', submissions);
const term = search.trim().toLowerCase(); const term = search.trim().toLowerCase();
const filteredItems = submissions.filter((item) => { const filteredItems = submissions.filter((item) => {

View File

@ -1812,16 +1812,10 @@ const loadProfiles = async () => {
}; };
}); });
console.log("Formatted Products:", formattedProducts);
setSelectedProducts(formattedProducts); setSelectedProducts(formattedProducts);
} else { } else {
setSelectedProducts([]); setSelectedProducts([]);
} }
// Debug log
console.log('Setting form with products:', mapped.establishment_products);
console.log('Setting selectedProducts:', selectedProducts);
initialSnapshotRef.current = { ...mapped, ...computeEmploymentTotals(mapped) }; initialSnapshotRef.current = { ...mapped, ...computeEmploymentTotals(mapped) };
corporateBackupRef.current = captureCorporateValues(mapped); corporateBackupRef.current = captureCorporateValues(mapped);
} else { } else {
@ -2411,7 +2405,6 @@ const requiredFields = [
setIsUpdating(true); setIsUpdating(true);
const apiResponse = await updateEstablishment(targetId, updatePayload); const apiResponse = await updateEstablishment(targetId, updatePayload);
console.log("apiResponse", apiResponse);
const successMessage = apiResponse?.message || 'Establishment updated successfully.'; const successMessage = apiResponse?.message || 'Establishment updated successfully.';
showToast('success', successMessage); showToast('success', successMessage);

View File

@ -132,8 +132,6 @@ const captureCorporateValues = (data) => {
const EditCompanyProfile = ({ onClose: propOnClose }) => { const EditCompanyProfile = ({ onClose: propOnClose }) => {
const navigate = useNavigate(); const navigate = useNavigate();
const { id: establishmentId } = useParams(); const { id: establishmentId } = useParams();
console.log('EditCompanyProfile mounted, establishmentId from params:', establishmentId);
const onClose = propOnClose || (() => navigate('/survey')); const onClose = propOnClose || (() => navigate('/survey'));
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [form, setForm] = useState(createEmptyProfile()); const [form, setForm] = useState(createEmptyProfile());
@ -295,21 +293,14 @@ const EditCompanyProfile = ({ onClose: propOnClose }) => {
}, []); }, []);
useEffect(() => { useEffect(() => {
console.log('useEffect triggered, establishmentId:', establishmentId);
const fetchData = async () => { const fetchData = async () => {
if (!establishmentId) { if (!establishmentId) {
console.log('No establishmentId found, skipping fetch');
return; return;
} }
try { try {
setLoading(true); setLoading(true);
console.log('Starting API call to fetch establishment details for ID:', establishmentId);
const response = await fetchEstablishmentDetail(establishmentId); const response = await fetchEstablishmentDetail(establishmentId);
console.log('API Response received:', response);
if (!response) { if (!response) {
console.error('Empty response received'); console.error('Empty response received');
@ -317,7 +308,6 @@ useEffect(() => {
} }
const mappedProfile = mapApiEstablishmentToProfile(response); const mappedProfile = mapApiEstablishmentToProfile(response);
console.log('Mapped Profile:', mappedProfile);
const formData = { const formData = {
...createEmptyProfile(), ...createEmptyProfile(),
@ -326,8 +316,6 @@ useEffect(() => {
corporateSameAs: Boolean(mappedProfile.corporateSameAs) corporateSameAs: Boolean(mappedProfile.corporateSameAs)
}; };
console.log('Form Data before corporate same as:', formData);
if (formData.corporateSameAs) { if (formData.corporateSameAs) {
Object.entries(contactToCorporateMap).forEach(([source, target]) => { Object.entries(contactToCorporateMap).forEach(([source, target]) => {
formData[target] = formData[source]; formData[target] = formData[source];
@ -336,9 +324,7 @@ useEffect(() => {
const totals = computeEmploymentTotals(formData); const totals = computeEmploymentTotals(formData);
Object.assign(formData, totals); Object.assign(formData, totals);
console.log('Final Form Data:', formData);
setForm(formData); setForm(formData);
initialSnapshotRef.current = formData; initialSnapshotRef.current = formData;
corporateBackupRef.current = captureCorporateValues(formData); corporateBackupRef.current = captureCorporateValues(formData);
@ -460,7 +446,6 @@ useEffect(() => {
}, [form]); }, [form]);
const handleSave = async () => { const handleSave = async () => {
console.log("Submitted data:", form);
try { try {
setLoading(true); setLoading(true);
@ -512,12 +497,9 @@ useEffect(() => {
updated_by: 1, updated_by: 1,
}; };
console.log("Payload sent:", establishmentData);
if (establishmentId) { if (establishmentId) {
console.log("Updating establishment with ID:", establishmentId);
await updateEstablishment(establishmentId, establishmentData); await updateEstablishment(establishmentId, establishmentData);
console.log("Profile updated successfully!");
onClose(); onClose();
} else { } else {
console.error("No establishment ID provided for update"); console.error("No establishment ID provided for update");

View File

@ -35,7 +35,6 @@ const EmailTemplates = () => {
const handleSave = () => { const handleSave = () => {
// Replace with API call // Replace with API call
console.log('Saving template', selectedTemplate, form);
}; };
return ( return (

View File

@ -372,20 +372,15 @@ const IsicHsCodes = () => {
// Fetch units on mount // Fetch units on mount
useEffect(() => { useEffect(() => {
const fetchUnits = async () => { const fetchUnits = async () => {
console.log('Starting to fetch units...');
setIsLoading(true); setIsLoading(true);
try { try {
console.log('Calling masterService.fetchUnits()...');
const units = await masterService.fetchUnits(); const units = await masterService.fetchUnits();
console.log('Fetched units:', units);
if (units && units.length > 0) { if (units && units.length > 0) {
const formattedUnits = units.map(unit => ({ const formattedUnits = units.map(unit => ({
label: unit.label || 'N/A', label: unit.label || 'N/A',
value: unit.value || 'N/A' value: unit.value || 'N/A'
})); }));
console.log('Formatted units:', formattedUnits);
setUnitOptions(formattedUnits); setUnitOptions(formattedUnits);
setError(null); setError(null);
} else { } else {
@ -412,11 +407,8 @@ const IsicHsCodes = () => {
useEffect(() => { useEffect(() => {
const fetchProducts = async () => { const fetchProducts = async () => {
try { try {
console.log('Fetching products...');
setIsLoading(true); setIsLoading(true);
const response = await productService.getProducts(); const response = await productService.getProducts();
console.log('Complete API Response:', JSON.stringify(response, null, 2));
if (response && response.data) { if (response && response.data) {
const products = Array.isArray(response.data) const products = Array.isArray(response.data)
? response.data ? response.data

View File

@ -295,7 +295,6 @@ const UnitMaster = () => {
is_active: form.status === 'Active', is_active: form.status === 'Active',
productsMapped: selectedProducts.length, productsMapped: selectedProducts.length,
}; };
console.log("unitData",unitData)
try { try {
setLoading(true); setLoading(true);

View File

@ -745,7 +745,6 @@ const tableRows = auditHistory.map((entry, index) => {
<select <select
value={hscodeFilter} value={hscodeFilter}
onChange={(e) => { onChange={(e) => {
console.log("HS filter selected:", e.target.value);
setHscodeFilter(e.target.value); setHscodeFilter(e.target.value);
}} }}
className="h-10 w-48 rounded-md border border-[#E2E8F0] bg-white pl-3 pr-8 text-sm text-[#232528] focus:outline-none cursor-pointer appearance-none" className="h-10 w-48 rounded-md border border-[#E2E8F0] bg-white pl-3 pr-8 text-sm text-[#232528] focus:outline-none cursor-pointer appearance-none"

View File

@ -53,7 +53,6 @@ const Overview = () => {
setLoading(true); setLoading(true);
// Use getSubmissionHistoryByEstablishment instead of getSubmissions // Use getSubmissionHistoryByEstablishment instead of getSubmissions
const response = await getSubmissionHistoryByEstablishment(establishmentId); const response = await getSubmissionHistoryByEstablishment(establishmentId);
console.log("response",response)
setSubmissions(response.data || []); setSubmissions(response.data || []);
} catch (err) { } catch (err) {
setError('Failed to load submission history'); setError('Failed to load submission history');

View File

@ -673,7 +673,6 @@ const Survey = () => {
try { try {
const payload = buildSubmissionPayload(); const payload = buildSubmissionPayload();
console.log('Submission Payload:', JSON.stringify(payload, null, 2));
await submitSurvey(payload); await submitSurvey(payload);
setShowSuccessPopup(true); setShowSuccessPopup(true);
setHasSubmitted(true); setHasSubmitted(true);