updated otp

This commit is contained in:
Malini 2025-12-31 18:26:24 +05:30
parent 16883875fe
commit 45906a55bc
2 changed files with 6 additions and 33 deletions

View File

@ -68,31 +68,22 @@ const ManufacturingIndex = () => {
useEffect(() => {
const fetchData = async () => {
try {
setIsLoading(true);
console.log('Fetching manufacturing index data...');
setIsLoading(true);
const response = await getManufacturingIndex();
console.log('RAW API RESPONSE:', response);
console.log('Response type:', typeof response);
console.log('Response keys:', Object.keys(response || {}));
// Handle different response structures
let dataArray = [];
// Case 1: Response is already an array
if (Array.isArray(response)) {
console.log('Response is array directly');
dataArray = response;
}
// Case 2: Response has data property which is array
else if (response && response.data && Array.isArray(response.data)) {
console.log('Response.data is array');
dataArray = response.data;
}
// Case 3: Response.data is object with nested data
else if (response && response.data && typeof response.data === 'object') {
console.log('Response.data is object');
// Try to extract array from common structures
if (Array.isArray(response.data.manufacturingIndex) || Array.isArray(response.data.data)) {
dataArray = response.data.manufacturingIndex || response.data.data || [];
@ -103,7 +94,6 @@ useEffect(() => {
}
// Case 4: Response has nested structure
else if (response && response.data && response.data.data && Array.isArray(response.data.data)) {
console.log('Response.data.data is array');
dataArray = response.data.data;
}
else {
@ -122,9 +112,7 @@ useEffect(() => {
};
dataArray = findArray(response);
}
console.log('Final dataArray:', dataArray);
// If no data found
if (!dataArray || dataArray.length === 0) {
console.warn('No data array found, using empty array');
@ -187,8 +175,6 @@ useEffect(() => {
};
});
console.log('Formatted Data:', formattedData);
setFilteredMonths(formattedData);
setPagination(prev => ({
...prev,
@ -217,13 +203,10 @@ useEffect(() => {
// ARROW CLICK function
const handleMonthSelect = async (row) => {
try {
console.log('Selected row for API call:', row);
const yearNumber = row.year;
const monthNumber = row.monthNumber;
console.log('API Parameters:', { year: yearNumber, month: monthNumber });
setSelectedMonth(row);
setActiveTab('manufacturing');
setIsPopupOpen(true);
@ -231,15 +214,11 @@ const handleMonthSelect = async (row) => {
// API CALL
const apiResponse = await getManufacturingMonthlyOverview(yearNumber, monthNumber);
console.log('Full API Response:', apiResponse);
// Extract data from the response structure
// Note: Your API returns {status, message, manufacturing_total, isic_2digit, isic_3digit, isic_4digit}
const responseData = apiResponse.data || apiResponse;
console.log('Response Data:', responseData);
// Transform data based on YOUR API structure
const transformedData = {
manufacturing: responseData?.manufacturing_total || {},
@ -247,9 +226,7 @@ const handleMonthSelect = async (row) => {
isic3: Array.isArray(responseData?.isic_3digit) ? responseData.isic_3digit : [],
isic4: Array.isArray(responseData?.isic_4digit) ? responseData.isic_4digit : []
};
console.log('Transformed Data for Popups:', transformedData);
// 4 popups- data set
setMonthlyOverviewData(transformedData);

View File

@ -5,7 +5,6 @@ const MANUFACTURING_ENDPOINT = '/manufacturing';
export const getManufacturingIndex = async () => {
try {
const response = await getRequest(`${MANUFACTURING_ENDPOINT}/getManufacturingIndex`);
console.log('Manufacturing Index API Response:', response);
return response;
} catch (error) {
console.error('Error fetching manufacturing index:', error);
@ -15,7 +14,6 @@ export const getManufacturingIndex = async () => {
export const getManufacturingMonthlyOverview = async (year, month) => {
try {
console.log('Monthly Overview API Call - Year:', year, 'Month:', month);
const response = await getRequest(
`${MANUFACTURING_ENDPOINT}/getManufacturingMonthlyOverview`,
@ -26,9 +24,7 @@ export const getManufacturingMonthlyOverview = async (year, month) => {
},
}
);
console.log('API Response:', response);
// Return the entire response
return response;