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

View File

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

View File

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

View File

@ -143,8 +143,6 @@ const findDisplayName = (options, value) => {
};
const buildProductRows = (products = [], options = {}) => {
console.log('Raw products data:', products); // Debug log
console.log('Available options:', options); // Debug log
if (!Array.isArray(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
const displayName = hsCode ? `${hsCode} - ${productName}` : productName;
const productCode = hsCode || product.id || `CODE-${index + 1}`;
console.log("productCode",productCode)
// Use stored unitName if available, otherwise try to find it in unitOptions
let unitName = product.unitName;
if (!unitName && 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
const variationReasonName = product.variationReasonName || findDisplayName(variationReasons, product.variationReason);
const zeroTargetReasonName = product.zeroTargetReasonName || findDisplayName(zeroTargetReasons, product.zeroTargetReason);
@ -267,18 +262,12 @@ const formatSubmissionData = (establishment, products, remarks = '') => {
const totalEmployees = totalEmirati + nonEmiratiMale + nonEmiratiFemale;
// Format products data
console.log('Original products data:', JSON.stringify(products, null, 2));
const formattedProducts = products.map(product => {
// Get the actual product_id from the originalData if available
const originalData = product.originalData || {};
console.log('Original data for product:', JSON.stringify(originalData, null, 2));
const originalData = product.originalData || {};
// Get the product_id directly from the originalData object
// 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
console.log('Selected product ID:', productId);
const productId = originalData.product_id || originalData.id; // Use product_id (56) with fallback to id
return {
product_id: parseInt(productId) || 0,
unit_id: parseInt(product.unit) || 0,
@ -367,7 +356,6 @@ const ReviewSubmit = ({
products,
remarks
);
console.log('Submitting data:', submissionData);
onSubmit(submissionData);
setConfirm(false);
} catch (error) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -745,7 +745,6 @@ const tableRows = auditHistory.map((entry, index) => {
<select
value={hscodeFilter}
onChange={(e) => {
console.log("HS filter selected:", 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"

View File

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

View File

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