refactor-migration again

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-26 15:12:14 +00:00
parent 2ef98b5113
commit f88aae78b1
23 changed files with 942 additions and 211 deletions

View File

@@ -14,6 +14,7 @@ import {
import Badge from '../../components/ui/badge/Badge';
import { formatRelativeDate } from '../../utils/date';
import { Content } from '../../services/api';
import { CONTENT_TYPE_OPTIONS, STRUCTURE_LABELS, TYPE_LABELS } from '../structureMapping';
export interface ColumnConfig {
key: string;
@@ -122,21 +123,11 @@ export const createContentPageConfig = (
sortable: true,
sortField: 'content_type',
width: '120px',
render: (value: string) => {
const typeLabels: Record<string, string> = {
'post': 'Post',
'page': 'Page',
'product': 'Product',
'service': 'Service',
'category': 'Category',
'tag': 'Tag',
};
return (
<Badge color="primary" size="sm" variant="light">
{typeLabels[value] || value || '-'}
</Badge>
);
},
render: (value: string) => (
<Badge color="primary" size="sm" variant="light">
{TYPE_LABELS[value] || value || '-'}
</Badge>
),
},
{
key: 'content_structure',
@@ -144,20 +135,11 @@ export const createContentPageConfig = (
sortable: true,
sortField: 'content_structure',
width: '150px',
render: (value: string) => {
const structureLabels: Record<string, string> = {
'article': 'Article',
'listicle': 'Listicle',
'guide': 'Guide',
'comparison': 'Comparison',
'product_page': 'Product Page',
};
return (
<Badge color="info" size="sm" variant="light">
{structureLabels[value] || value || '-'}
</Badge>
);
},
render: (value: string) => (
<Badge color="info" size="sm" variant="light">
{STRUCTURE_LABELS[value] || value || '-'}
</Badge>
),
},
{
key: 'cluster_name',
@@ -332,12 +314,7 @@ export const createContentPageConfig = (
type: 'select',
options: [
{ value: '', label: 'All Types' },
{ value: 'post', label: 'Post' },
{ value: 'page', label: 'Page' },
{ value: 'product', label: 'Product' },
{ value: 'service', label: 'Service' },
{ value: 'category', label: 'Category' },
{ value: 'tag', label: 'Tag' },
...CONTENT_TYPE_OPTIONS,
],
},
{
@@ -347,10 +324,19 @@ export const createContentPageConfig = (
options: [
{ value: '', label: 'All Structures' },
{ value: 'article', label: 'Article' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'guide', label: 'Guide' },
{ value: 'comparison', label: 'Comparison' },
{ value: 'review', label: 'Review' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'landing_page', label: 'Landing Page' },
{ value: 'business_page', label: 'Business Page' },
{ value: 'service_page', label: 'Service Page' },
{ value: 'general', label: 'General' },
{ value: 'cluster_hub', label: 'Cluster Hub' },
{ value: 'product_page', label: 'Product Page' },
{ value: 'category_archive', label: 'Category Archive' },
{ value: 'tag_archive', label: 'Tag Archive' },
{ value: 'attribute_archive', label: 'Attribute Archive' },
],
},
{

View File

@@ -224,25 +224,36 @@ export const createIdeasPageConfig = (
type: 'select',
options: [
{ value: '', label: 'All Structures' },
// Post
{ value: 'article', label: 'Article' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'guide', label: 'Guide' },
{ value: 'comparison', label: 'Comparison' },
{ value: 'review', label: 'Review' },
{ value: 'listicle', label: 'Listicle' },
// Page
{ value: 'landing_page', label: 'Landing Page' },
{ value: 'business_page', label: 'Business Page' },
{ value: 'service_page', label: 'Service Page' },
{ value: 'general', label: 'General' },
{ value: 'cluster_hub', label: 'Cluster Hub' },
// Product
{ value: 'product_page', label: 'Product Page' },
// Taxonomy
{ value: 'category_archive', label: 'Category Archive' },
{ value: 'tag_archive', label: 'Tag Archive' },
{ value: 'attribute_archive', label: 'Attribute Archive' },
],
},
{
key: 'content_type',
label: 'Content Type',
label: 'Type',
type: 'select',
options: [
{ value: '', label: 'All Types' },
{ value: 'post', label: 'Post' },
{ value: 'page', label: 'Page' },
{ value: 'product', label: 'Product' },
{ value: 'service', label: 'Service' },
{ value: 'category', label: 'Category' },
{ value: 'tag', label: 'Tag' },
{ value: 'taxonomy', label: 'Taxonomy' },
],
},
{
@@ -286,11 +297,24 @@ export const createIdeasPageConfig = (
onChange: (value: any) =>
handlers.setFormData({ ...handlers.formData, content_structure: value }),
options: [
// Post
{ value: 'article', label: 'Article' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'guide', label: 'Guide' },
{ value: 'comparison', label: 'Comparison' },
{ value: 'review', label: 'Review' },
{ value: 'listicle', label: 'Listicle' },
// Page
{ value: 'landing_page', label: 'Landing Page' },
{ value: 'business_page', label: 'Business Page' },
{ value: 'service_page', label: 'Service Page' },
{ value: 'general', label: 'General' },
{ value: 'cluster_hub', label: 'Cluster Hub' },
// Product
{ value: 'product_page', label: 'Product Page' },
// Taxonomy
{ value: 'category_archive', label: 'Category Archive' },
{ value: 'tag_archive', label: 'Tag Archive' },
{ value: 'attribute_archive', label: 'Attribute Archive' },
],
},
{
@@ -304,9 +328,7 @@ export const createIdeasPageConfig = (
{ value: 'post', label: 'Post' },
{ value: 'page', label: 'Page' },
{ value: 'product', label: 'Product' },
{ value: 'service', label: 'Service' },
{ value: 'category', label: 'Category' },
{ value: 'tag', label: 'Tag' },
{ value: 'taxonomy', label: 'Taxonomy' },
],
},
{

View File

@@ -14,6 +14,7 @@ import {
import Badge from '../../components/ui/badge/Badge';
import { formatRelativeDate } from '../../utils/date';
import { Task, Cluster } from '../../services/api';
import { CONTENT_TYPE_OPTIONS, CONTENT_STRUCTURE_BY_TYPE, STRUCTURE_LABELS, TYPE_LABELS } from '../structureMapping';
export interface ColumnConfig {
key: string;
@@ -164,21 +165,11 @@ export const createTasksPageConfig = (
sortable: true,
sortField: 'content_type',
width: '120px',
render: (value: string) => {
const typeLabels: Record<string, string> = {
'post': 'Post',
'page': 'Page',
'product': 'Product',
'service': 'Service',
'category': 'Category',
'tag': 'Tag',
};
return (
<Badge color="primary" size="sm" variant="light">
{typeLabels[value] || value || '-'}
</Badge>
);
},
render: (value: string) => (
<Badge color="primary" size="sm" variant="light">
{TYPE_LABELS[value] || value || '-'}
</Badge>
),
},
{
key: 'content_structure',
@@ -186,20 +177,11 @@ export const createTasksPageConfig = (
sortable: true,
sortField: 'content_structure',
width: '150px',
render: (value: string) => {
const structureLabels: Record<string, string> = {
'article': 'Article',
'listicle': 'Listicle',
'guide': 'Guide',
'comparison': 'Comparison',
'product_page': 'Product Page',
};
return (
<Badge color="info" size="sm" variant="light">
{structureLabels[value] || value || '-'}
</Badge>
);
},
render: (value: string) => (
<Badge color="info" size="sm" variant="light">
{STRUCTURE_LABELS[value] || value || '-'}
</Badge>
),
},
{
...statusColumn,
@@ -335,12 +317,7 @@ export const createTasksPageConfig = (
type: 'select',
options: [
{ value: '', label: 'All Types' },
{ value: 'post', label: 'Post' },
{ value: 'page', label: 'Page' },
{ value: 'product', label: 'Product' },
{ value: 'service', label: 'Service' },
{ value: 'category', label: 'Category' },
{ value: 'tag', label: 'Tag' },
...CONTENT_TYPE_OPTIONS,
],
},
{
@@ -350,10 +327,19 @@ export const createTasksPageConfig = (
options: [
{ value: '', label: 'All Structures' },
{ value: 'article', label: 'Article' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'guide', label: 'Guide' },
{ value: 'comparison', label: 'Comparison' },
{ value: 'review', label: 'Review' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'landing_page', label: 'Landing Page' },
{ value: 'business_page', label: 'Business Page' },
{ value: 'service_page', label: 'Service Page' },
{ value: 'general', label: 'General' },
{ value: 'cluster_hub', label: 'Cluster Hub' },
{ value: 'product_page', label: 'Product Page' },
{ value: 'category_archive', label: 'Category Archive' },
{ value: 'tag_archive', label: 'Tag Archive' },
{ value: 'attribute_archive', label: 'Attribute Archive' },
],
},
{
@@ -422,10 +408,19 @@ export const createTasksPageConfig = (
handlers.setFormData({ ...handlers.formData, content_structure: value }),
options: [
{ value: 'article', label: 'Article' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'guide', label: 'Guide' },
{ value: 'comparison', label: 'Comparison' },
{ value: 'review', label: 'Review' },
{ value: 'listicle', label: 'Listicle' },
{ value: 'landing_page', label: 'Landing Page' },
{ value: 'business_page', label: 'Business Page' },
{ value: 'service_page', label: 'Service Page' },
{ value: 'general', label: 'General' },
{ value: 'cluster_hub', label: 'Cluster Hub' },
{ value: 'product_page', label: 'Product Page' },
{ value: 'category_archive', label: 'Category Archive' },
{ value: 'tag_archive', label: 'Tag Archive' },
{ value: 'attribute_archive', label: 'Attribute Archive' },
],
},
{
@@ -435,14 +430,7 @@ export const createTasksPageConfig = (
value: handlers.formData.content_type || 'post',
onChange: (value: any) =>
handlers.setFormData({ ...handlers.formData, content_type: value }),
options: [
{ value: 'post', label: 'Post' },
{ value: 'page', label: 'Page' },
{ value: 'product', label: 'Product' },
{ value: 'service', label: 'Service' },
{ value: 'category', label: 'Category' },
{ value: 'tag', label: 'Tag' },
],
options: CONTENT_TYPE_OPTIONS,
},
{
key: 'status',

View File

@@ -0,0 +1,70 @@
/**
* Structure mapping configuration
* Maps content types to their valid structures and provides label mappings
*/
export const CONTENT_TYPE_OPTIONS = [
{ value: 'post', label: 'Post' },
{ value: 'page', label: 'Page' },
{ value: 'product', label: 'Product' },
{ value: 'taxonomy', label: 'Taxonomy' },
];
export const CONTENT_STRUCTURE_BY_TYPE: Record<string, Array<{ value: string; label: string }>> = {
post: [
{ value: 'article', label: 'Article' },
{ value: 'guide', label: 'Guide' },
{ value: 'comparison', label: 'Comparison' },
{ value: 'review', label: 'Review' },
{ value: 'listicle', label: 'Listicle' },
],
page: [
{ value: 'landing_page', label: 'Landing Page' },
{ value: 'business_page', label: 'Business Page' },
{ value: 'service_page', label: 'Service Page' },
{ value: 'general', label: 'General' },
{ value: 'cluster_hub', label: 'Cluster Hub' },
],
product: [
{ value: 'product_page', label: 'Product Page' },
],
taxonomy: [
{ value: 'category_archive', label: 'Category Archive' },
{ value: 'tag_archive', label: 'Tag Archive' },
{ value: 'attribute_archive', label: 'Attribute Archive' },
],
};
export const ALL_CONTENT_STRUCTURES = Object.values(CONTENT_STRUCTURE_BY_TYPE).flat();
export const STRUCTURE_LABELS: Record<string, string> = {
// Post
article: 'Article',
guide: 'Guide',
comparison: 'Comparison',
review: 'Review',
listicle: 'Listicle',
// Page
landing_page: 'Landing Page',
business_page: 'Business Page',
service_page: 'Service Page',
general: 'General',
cluster_hub: 'Cluster Hub',
// Product
product_page: 'Product Page',
// Taxonomy
category_archive: 'Category Archive',
tag_archive: 'Tag Archive',
attribute_archive: 'Attribute Archive',
};
export const TYPE_LABELS: Record<string, string> = {
post: 'Post',
page: 'Page',
product: 'Product',
taxonomy: 'Taxonomy',
};
export const getStructureOptions = (contentType: string) => {
return CONTENT_STRUCTURE_BY_TYPE[contentType] || [];
};