sd
This commit is contained in:
@@ -111,6 +111,40 @@ export function createPublishedPageConfig(params: {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'wordpress_status',
|
||||||
|
label: 'WP Status',
|
||||||
|
sortable: false,
|
||||||
|
width: '120px',
|
||||||
|
render: (_value: any, row: Content) => {
|
||||||
|
// Check if content has been published to WordPress
|
||||||
|
if (!row.external_id) {
|
||||||
|
return (
|
||||||
|
<Badge color="gray" size="xs" variant="soft">
|
||||||
|
<span className="text-[11px] font-normal">Not Published</span>
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// WordPress status badge - use external_status if available, otherwise show 'Published'
|
||||||
|
const wpStatus = (row as any).wordpress_status || 'publish';
|
||||||
|
const statusConfig: Record<string, { color: 'success' | 'amber' | 'blue' | 'gray' | 'red'; label: string }> = {
|
||||||
|
publish: { color: 'success', label: 'Published' },
|
||||||
|
draft: { color: 'gray', label: 'Draft' },
|
||||||
|
pending: { color: 'amber', label: 'Pending' },
|
||||||
|
future: { color: 'blue', label: 'Scheduled' },
|
||||||
|
private: { color: 'amber', label: 'Private' },
|
||||||
|
trash: { color: 'red', label: 'Trashed' },
|
||||||
|
};
|
||||||
|
const config = statusConfig[wpStatus] || { color: 'success' as const, label: 'Published' };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Badge color={config.color} size="xs" variant="soft">
|
||||||
|
<span className="text-[11px] font-normal">{config.label}</span>
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
key: 'content_type',
|
key: 'content_type',
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
ContentListResponse,
|
ContentListResponse,
|
||||||
ContentFilters,
|
ContentFilters,
|
||||||
fetchAPI,
|
fetchAPI,
|
||||||
|
fetchWordPressStatus,
|
||||||
} from '../../services/api';
|
} from '../../services/api';
|
||||||
import { useNavigate } from 'react-router';
|
import { useNavigate } from 'react-router';
|
||||||
import { useToast } from '../../components/ui/toast/ToastContainer';
|
import { useToast } from '../../components/ui/toast/ToastContainer';
|
||||||
@@ -73,7 +74,26 @@ export default function Published() {
|
|||||||
filteredResults = filteredResults.filter(c => !c.external_id);
|
filteredResults = filteredResults.filter(c => !c.external_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
setContent(filteredResults);
|
// Fetch WordPress status for published content
|
||||||
|
const resultsWithWPStatus = await Promise.all(
|
||||||
|
filteredResults.map(async (content) => {
|
||||||
|
if (content.external_id) {
|
||||||
|
try {
|
||||||
|
const wpStatus = await fetchWordPressStatus(content.id);
|
||||||
|
return {
|
||||||
|
...content,
|
||||||
|
wordpress_status: wpStatus.wordpress_status,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Failed to fetch WP status for content ${content.id}:`, error);
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
setContent(resultsWithWPStatus);
|
||||||
setTotalCount(data.count || 0);
|
setTotalCount(data.count || 0);
|
||||||
setTotalPages(Math.ceil((data.count || 0) / pageSize));
|
setTotalPages(Math.ceil((data.count || 0) / pageSize));
|
||||||
|
|
||||||
|
|||||||
@@ -2033,6 +2033,7 @@ export interface Content {
|
|||||||
// WordPress integration
|
// WordPress integration
|
||||||
external_id?: string | null;
|
external_id?: string | null;
|
||||||
external_url?: string | null;
|
external_url?: string | null;
|
||||||
|
wordpress_status?: 'publish' | 'draft' | 'pending' | 'future' | 'private' | 'trash' | null;
|
||||||
// Timestamps
|
// Timestamps
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
@@ -2095,6 +2096,30 @@ export async function fetchContentById(id: number): Promise<Content> {
|
|||||||
return fetchAPI(`/v1/writer/content/${id}/`);
|
return fetchAPI(`/v1/writer/content/${id}/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch WordPress status for published content
|
||||||
|
export interface WordPressStatusResult {
|
||||||
|
wordpress_status: 'publish' | 'draft' | 'pending' | 'future' | 'private' | 'trash' | null;
|
||||||
|
external_id: string | null;
|
||||||
|
external_url: string | null;
|
||||||
|
post_title?: string;
|
||||||
|
post_modified?: string;
|
||||||
|
last_checked?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchWordPressStatus(contentId: number): Promise<WordPressStatusResult> {
|
||||||
|
try {
|
||||||
|
const response = await fetchAPI(`/v1/writer/content/${contentId}/wordpress_status/`);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Failed to fetch WordPress status for content ${contentId}:`, error);
|
||||||
|
return {
|
||||||
|
wordpress_status: null,
|
||||||
|
external_id: null,
|
||||||
|
external_url: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Content Publishing API
|
// Content Publishing API
|
||||||
export interface PublishContentResult {
|
export interface PublishContentResult {
|
||||||
content_id: number;
|
content_id: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user