dd move
This commit is contained in:
@@ -102,7 +102,7 @@ export const createContentPageConfig = (
|
||||
render: (value: string, row: Content) => (
|
||||
<div>
|
||||
<div className="font-medium text-gray-900 dark:text-white">
|
||||
{row.meta_title || row.title || row.task_title || `Task #${row.task}`}
|
||||
{row.meta_title || row.title || row.task_title || `Task #${row.task_id}`}
|
||||
</div>
|
||||
{row.meta_description && (
|
||||
<div className="mt-1 text-sm text-gray-500 dark:text-gray-400 line-clamp-2">
|
||||
|
||||
@@ -257,6 +257,12 @@ const tableActionsConfigs: Record<string, TableActionsConfig> = {
|
||||
icon: EditIcon,
|
||||
variant: 'primary',
|
||||
},
|
||||
{
|
||||
key: 'generate_images',
|
||||
label: 'Generate Images',
|
||||
icon: <BoltIcon className="w-5 h-5 text-purple-500" />,
|
||||
variant: 'primary',
|
||||
},
|
||||
],
|
||||
bulkActions: [
|
||||
{
|
||||
@@ -271,12 +277,6 @@ const tableActionsConfigs: Record<string, TableActionsConfig> = {
|
||||
icon: <DownloadIcon className="w-4 h-4 text-blue-light-500" />,
|
||||
variant: 'secondary',
|
||||
},
|
||||
{
|
||||
key: 'generate_images',
|
||||
label: 'Generate Images',
|
||||
icon: <BoltIcon className="w-4 h-4 text-purple-500" />,
|
||||
variant: 'secondary',
|
||||
},
|
||||
{
|
||||
key: 'publish',
|
||||
label: 'Publish Selected',
|
||||
|
||||
@@ -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}`}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1464,7 +1464,7 @@ export interface ContentFilters {
|
||||
|
||||
export interface Content {
|
||||
id: number;
|
||||
task: number;
|
||||
task_id: number;
|
||||
task_title?: string | null;
|
||||
sector_name?: string | null;
|
||||
title?: string | null;
|
||||
|
||||
Reference in New Issue
Block a user