dd move
This commit is contained in:
@@ -102,7 +102,7 @@ export const createContentPageConfig = (
|
|||||||
render: (value: string, row: Content) => (
|
render: (value: string, row: Content) => (
|
||||||
<div>
|
<div>
|
||||||
<div className="font-medium text-gray-900 dark:text-white">
|
<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>
|
</div>
|
||||||
{row.meta_description && (
|
{row.meta_description && (
|
||||||
<div className="mt-1 text-sm text-gray-500 dark:text-gray-400 line-clamp-2">
|
<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,
|
icon: EditIcon,
|
||||||
variant: 'primary',
|
variant: 'primary',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'generate_images',
|
||||||
|
label: 'Generate Images',
|
||||||
|
icon: <BoltIcon className="w-5 h-5 text-purple-500" />,
|
||||||
|
variant: 'primary',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
bulkActions: [
|
bulkActions: [
|
||||||
{
|
{
|
||||||
@@ -271,12 +277,6 @@ const tableActionsConfigs: Record<string, TableActionsConfig> = {
|
|||||||
icon: <DownloadIcon className="w-4 h-4 text-blue-light-500" />,
|
icon: <DownloadIcon className="w-4 h-4 text-blue-light-500" />,
|
||||||
variant: 'secondary',
|
variant: 'secondary',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'generate_images',
|
|
||||||
label: 'Generate Images',
|
|
||||||
icon: <BoltIcon className="w-4 h-4 text-purple-500" />,
|
|
||||||
variant: 'secondary',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'publish',
|
key: 'publish',
|
||||||
label: 'Publish Selected',
|
label: 'Publish Selected',
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
fetchContent,
|
fetchContent,
|
||||||
Content as ContentType,
|
Content as ContentType,
|
||||||
ContentFilters,
|
ContentFilters,
|
||||||
|
autoGenerateImages,
|
||||||
} from '../../services/api';
|
} from '../../services/api';
|
||||||
import { useToast } from '../../components/ui/toast/ToastContainer';
|
import { useToast } from '../../components/ui/toast/ToastContainer';
|
||||||
import { FileIcon } from '../../icons';
|
import { FileIcon } from '../../icons';
|
||||||
@@ -145,6 +146,32 @@ export default function Content() {
|
|||||||
}));
|
}));
|
||||||
}, [pageConfig?.headerMetrics, content, totalCount]);
|
}, [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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<TablePageTemplate
|
<TablePageTemplate
|
||||||
@@ -184,6 +211,7 @@ export default function Content() {
|
|||||||
onSelectionChange: setSelectedIds,
|
onSelectionChange: setSelectedIds,
|
||||||
}}
|
}}
|
||||||
headerMetrics={headerMetrics}
|
headerMetrics={headerMetrics}
|
||||||
|
onRowAction={handleRowAction}
|
||||||
getItemDisplayName={(row: ContentType) => row.meta_title || row.title || `Content #${row.id}`}
|
getItemDisplayName={(row: ContentType) => row.meta_title || row.title || `Content #${row.id}`}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1464,7 +1464,7 @@ export interface ContentFilters {
|
|||||||
|
|
||||||
export interface Content {
|
export interface Content {
|
||||||
id: number;
|
id: number;
|
||||||
task: number;
|
task_id: number;
|
||||||
task_title?: string | null;
|
task_title?: string | null;
|
||||||
sector_name?: string | null;
|
sector_name?: string | null;
|
||||||
title?: string | null;
|
title?: string | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user