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