This commit is contained in:
IGNY8 VPS (Salman)
2025-11-11 16:03:58 +00:00
parent 618ed0543d
commit fedf415646
4 changed files with 36 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ import {
fetchContent,
Content as ContentType,
ContentFilters,
autoGenerateImages,
} from '../../services/api';
import { useToast } from '../../components/ui/toast/ToastContainer';
import { FileIcon } from '../../icons';
@@ -145,6 +146,32 @@ export default function Content() {
}));
}, [pageConfig?.headerMetrics, content, totalCount]);
const handleRowAction = useCallback(async (action: string, row: ContentType) => {
if (action === 'generate_images') {
const taskId = row.task_id;
if (!taskId) {
toast.error('No task linked to this content for image generation');
return;
}
try {
const result = await autoGenerateImages([taskId]);
if (result.success) {
if (result.task_id) {
toast.success('Image generation started');
} else {
toast.success(`Image generation complete: ${result.images_created || 0} image${(result.images_created || 0) === 1 ? '' : 's'} generated`);
}
} else {
toast.error(result.error || 'Failed to generate images');
}
} catch (error: any) {
toast.error(`Failed to generate images: ${error.message}`);
}
}
}, [toast]);
return (
<>
<TablePageTemplate
@@ -184,6 +211,7 @@ export default function Content() {
onSelectionChange: setSelectedIds,
}}
headerMetrics={headerMetrics}
onRowAction={handleRowAction}
getItemDisplayName={(row: ContentType) => row.meta_title || row.title || `Content #${row.id}`}
/>
</>