From 34d2b3abf9d3dff44383f95238c50071294be86c Mon Sep 17 00:00:00 2001
From: alorig <220087330+alorig@users.noreply.github.com>
Date: Mon, 1 Dec 2025 04:31:13 +0500
Subject: [PATCH] sd
---
.../src/config/pages/published.config.tsx | 34 +++++++++++++++++++
frontend/src/pages/Writer/Published.tsx | 22 +++++++++++-
frontend/src/services/api.ts | 25 ++++++++++++++
3 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/frontend/src/config/pages/published.config.tsx b/frontend/src/config/pages/published.config.tsx
index e1768578..fd16eed8 100644
--- a/frontend/src/config/pages/published.config.tsx
+++ b/frontend/src/config/pages/published.config.tsx
@@ -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 (
+
+ Not Published
+
+ );
+ }
+
+ // WordPress status badge - use external_status if available, otherwise show 'Published'
+ const wpStatus = (row as any).wordpress_status || 'publish';
+ const statusConfig: Record = {
+ 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 (
+
+ {config.label}
+
+ );
+ },
+ },
{
key: 'content_type',
diff --git a/frontend/src/pages/Writer/Published.tsx b/frontend/src/pages/Writer/Published.tsx
index 4c610f45..e8c0bb7e 100644
--- a/frontend/src/pages/Writer/Published.tsx
+++ b/frontend/src/pages/Writer/Published.tsx
@@ -11,6 +11,7 @@ import {
ContentListResponse,
ContentFilters,
fetchAPI,
+ fetchWordPressStatus,
} from '../../services/api';
import { useNavigate } from 'react-router';
import { useToast } from '../../components/ui/toast/ToastContainer';
@@ -73,7 +74,26 @@ export default function Published() {
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);
setTotalPages(Math.ceil((data.count || 0) / pageSize));
diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts
index 252318de..3c100514 100644
--- a/frontend/src/services/api.ts
+++ b/frontend/src/services/api.ts
@@ -2033,6 +2033,7 @@ export interface Content {
// WordPress integration
external_id?: string | null;
external_url?: string | null;
+ wordpress_status?: 'publish' | 'draft' | 'pending' | 'future' | 'private' | 'trash' | null;
// Timestamps
created_at: string;
updated_at: string;
@@ -2095,6 +2096,30 @@ export async function fetchContentById(id: number): Promise {
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 {
+ 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
export interface PublishContentResult {
content_id: number;