publish to wp
This commit is contained in:
@@ -10,8 +10,6 @@ import {
|
||||
Content as ContentType,
|
||||
ContentFilters,
|
||||
generateImagePrompts,
|
||||
publishContent,
|
||||
unpublishContent,
|
||||
} from '../../services/api';
|
||||
import { optimizerApi } from '../../api/optimizer.api';
|
||||
import { useNavigate } from 'react-router';
|
||||
@@ -164,40 +162,12 @@ export default function Content() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleRowAction = useCallback(async (action: string, row: ContentType) => {
|
||||
if (action === 'publish') {
|
||||
try {
|
||||
// Check if already published
|
||||
if (row.external_id) {
|
||||
toast.warning('Content is already published to WordPress');
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await publishContent(row.id);
|
||||
toast.success(`Content published successfully! View at: ${result.external_url}`);
|
||||
loadContent(); // Reload to show updated external_id
|
||||
} catch (error: any) {
|
||||
toast.error(`Failed to publish content: ${error.message}`);
|
||||
}
|
||||
} else if (action === 'view_on_wordpress') {
|
||||
if (action === 'view_on_wordpress') {
|
||||
if (row.external_url) {
|
||||
window.open(row.external_url, '_blank');
|
||||
} else {
|
||||
toast.warning('WordPress URL not available');
|
||||
}
|
||||
} else if (action === 'unpublish') {
|
||||
try {
|
||||
// Check if not published
|
||||
if (!row.external_id) {
|
||||
toast.warning('Content is not currently published');
|
||||
return;
|
||||
}
|
||||
|
||||
await unpublishContent(row.id);
|
||||
toast.success('Content unpublished successfully');
|
||||
loadContent(); // Reload to show cleared external_id
|
||||
} catch (error: any) {
|
||||
toast.error(`Failed to unpublish content: ${error.message}`);
|
||||
}
|
||||
} else if (action === 'generate_image_prompts') {
|
||||
try {
|
||||
const result = await generateImagePrompts([row.id]);
|
||||
|
||||
Reference in New Issue
Block a user