mirror of
https://ghproxy.net/https://github.com/abhijitb/helix.git
synced 2025-08-27 20:13:02 +08:00
removed all console statements
This commit is contained in:
parent
310e99b204
commit
76b5131180
5 changed files with 5 additions and 74 deletions
|
@ -42,18 +42,9 @@ document.addEventListener( 'DOMContentLoaded', function () {
|
|||
|
||||
// Posts page
|
||||
const postsRoot = document.getElementById( 'helix-posts-root' );
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Posts root element:', postsRoot );
|
||||
if ( postsRoot ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Creating Posts app root' );
|
||||
const root = createRoot( postsRoot );
|
||||
root.render( <PostsApp /> );
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Posts app rendered' );
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Posts root element not found' );
|
||||
}
|
||||
|
||||
// Users page
|
||||
|
|
|
@ -8,10 +8,6 @@ import './Posts.css';
|
|||
* Phase 1: Foundation & Core List View with Pagination
|
||||
*/
|
||||
export default function Posts() {
|
||||
// Debug: Log when component mounts
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Posts component mounted' );
|
||||
|
||||
const [ posts, setPosts ] = useState( [] );
|
||||
const [ loading, setLoading ] = useState( true );
|
||||
const [ error, setError ] = useState( null );
|
||||
|
@ -35,10 +31,6 @@ export default function Posts() {
|
|||
setLoading( true );
|
||||
setError( null );
|
||||
|
||||
// Debug: Log function start
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'fetchPosts function called' );
|
||||
|
||||
try {
|
||||
const queryParams = new URLSearchParams( {
|
||||
page: pagination.page,
|
||||
|
@ -63,12 +55,6 @@ export default function Posts() {
|
|||
window.location.origin + '/wp-json/wp/v2/'
|
||||
}posts?${ queryParams }`;
|
||||
|
||||
// Debug: Log the API URL and nonce
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'API URL:', apiUrl );
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Nonce:', window.helixData?.nonce );
|
||||
|
||||
// Try different authentication methods
|
||||
const headers = {
|
||||
'X-WP-Nonce': window.helixData?.nonce || '',
|
||||
|
@ -90,18 +76,6 @@ export default function Posts() {
|
|||
}
|
||||
|
||||
const postsData = await response.json();
|
||||
|
||||
// Debug: Log what posts we're getting
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
'Fetched posts:',
|
||||
postsData.map( ( p ) => ( {
|
||||
id: p.id,
|
||||
title: p.title.rendered,
|
||||
status: p.status,
|
||||
} ) )
|
||||
);
|
||||
|
||||
// Store posts for current page
|
||||
setPosts( postsData );
|
||||
|
||||
|
@ -120,25 +94,16 @@ export default function Posts() {
|
|||
} ) );
|
||||
} catch ( err ) {
|
||||
setError( err.message );
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching posts:', err );
|
||||
} finally {
|
||||
setLoading( false );
|
||||
}
|
||||
}, [ pagination.page, pagination.perPage, filters ] );
|
||||
|
||||
// useEffect must come after fetchPosts is defined
|
||||
useEffect( () => {
|
||||
// Debug: Log when useEffect runs
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'useEffect triggered, calling fetchPosts' );
|
||||
fetchPosts();
|
||||
}, [ fetchPosts ] ); // fetchPosts is now stable with useCallback
|
||||
}, [ fetchPosts ] );
|
||||
|
||||
// Trigger fetch when filters change (for server-side filtering)
|
||||
useEffect( () => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Filters changed, triggering new fetch' );
|
||||
fetchPosts();
|
||||
}, [ filters.status, filters.author, filters.search, fetchPosts ] );
|
||||
|
||||
|
@ -147,8 +112,7 @@ export default function Posts() {
|
|||
*/
|
||||
const handleFilterChange = ( newFilters ) => {
|
||||
setFilters( newFilters );
|
||||
setPagination( ( prev ) => ( { ...prev, page: 1 } ) ); // Reset to first page
|
||||
// API call will be triggered by useEffect dependency
|
||||
setPagination( ( prev ) => ( { ...prev, page: 1 } ) );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,10 +34,7 @@ export default function PostFilters( { filters, onFilterChange } ) {
|
|||
const authorsData = await response.json();
|
||||
setAuthors( authorsData );
|
||||
}
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching authors:', error );
|
||||
}
|
||||
} catch ( error ) {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -55,10 +52,7 @@ export default function PostFilters( { filters, onFilterChange } ) {
|
|||
const categoriesData = await response.json();
|
||||
setCategories( categoriesData );
|
||||
}
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching categories:', error );
|
||||
}
|
||||
} catch ( error ) {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,10 +91,8 @@ export default function PostRow( { post, onDelete, onStatusChange } ) {
|
|||
/**
|
||||
* Handle quick edit (placeholder for future implementation)
|
||||
*/
|
||||
const handleQuickEdit = ( postData ) => {
|
||||
const handleQuickEdit = () => {
|
||||
// TODO: Implement quick edit modal
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Quick edit for post:', postData.id );
|
||||
setShowActions( false );
|
||||
};
|
||||
|
||||
|
|
|
@ -42,8 +42,6 @@ export const fetchPosts = async ( params = {} ) => {
|
|||
},
|
||||
};
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching posts:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
@ -61,8 +59,6 @@ export const fetchPost = async ( postId ) => {
|
|||
|
||||
return await response.json();
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching post:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
@ -87,8 +83,6 @@ export const createPost = async ( postData ) => {
|
|||
|
||||
return await response.json();
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error creating post:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
@ -113,8 +107,6 @@ export const updatePost = async ( postId, postData ) => {
|
|||
|
||||
return await response.json();
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error updating post:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
@ -137,8 +129,6 @@ export const deletePost = async ( postId ) => {
|
|||
|
||||
return true;
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error deleting post:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
@ -156,8 +146,6 @@ export const fetchAuthors = async () => {
|
|||
|
||||
return await response.json();
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching authors:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
@ -175,8 +163,6 @@ export const fetchCategories = async () => {
|
|||
|
||||
return await response.json();
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching categories:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
@ -194,8 +180,6 @@ export const fetchTags = async () => {
|
|||
|
||||
return await response.json();
|
||||
} catch ( error ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error( 'Error fetching tags:', error );
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue