dd move
This commit is contained in:
@@ -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}`}
|
||||
/>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user