feat: Complete Stage 2 frontend refactor
- Removed deprecated fields from Content and Task models, including entity_type, sync_status, and cluster_role. - Updated Content model to include new fields: content_type, content_structure, taxonomy_terms, source, external_id, and cluster_id. - Refactored Writer module components (Content, ContentView, Dashboard, Tasks) to align with new schema. - Enhanced Dashboard metrics and removed unused filters. - Implemented ClusterDetail page to display cluster information and associated content. - Updated API service interfaces to reflect changes in data structure. - Adjusted sorting and filtering logic across various components to accommodate new field names and types. - Improved user experience by providing loading states and error handling in data fetching.
This commit is contained in:
@@ -20,12 +20,13 @@ import {
|
||||
PaperPlaneIcon,
|
||||
PlugInIcon,
|
||||
} from "../../icons";
|
||||
import {
|
||||
import {
|
||||
fetchTasks,
|
||||
fetchContent,
|
||||
fetchContentImages,
|
||||
fetchTaxonomies,
|
||||
fetchAttributes
|
||||
// TODO: Stage 3/4 - Add when taxonomy and attribute endpoints are implemented
|
||||
// fetchTaxonomies,
|
||||
// fetchAttributes
|
||||
} from "../../services/api";
|
||||
import { useSiteStore } from "../../store/siteStore";
|
||||
import { useSectorStore } from "../../store/sectorStore";
|
||||
@@ -43,7 +44,6 @@ interface WriterStats {
|
||||
content: {
|
||||
total: number;
|
||||
drafts: number;
|
||||
review: number;
|
||||
published: number;
|
||||
totalWordCount: number;
|
||||
avgWordCount: number;
|
||||
@@ -85,12 +85,11 @@ export default function WriterDashboard() {
|
||||
try {
|
||||
setLoading(true);
|
||||
|
||||
const [tasksRes, contentRes, imagesRes, taxonomiesRes, attributesRes] = await Promise.all([
|
||||
// TODO: Stage 3/4 - Re-enable when taxonomy and attribute endpoints are implemented
|
||||
const [tasksRes, contentRes, imagesRes] = await Promise.all([
|
||||
fetchTasks({ page_size: 1000, sector_id: activeSector?.id }),
|
||||
fetchContent({ page_size: 1000, sector_id: activeSector?.id }),
|
||||
fetchContentImages({ sector_id: activeSector?.id }),
|
||||
fetchTaxonomies({ sector_id: activeSector?.id }),
|
||||
fetchAttributes({ sector_id: activeSector?.id }),
|
||||
]);
|
||||
|
||||
const tasks = tasksRes.results || [];
|
||||
@@ -101,9 +100,8 @@ export default function WriterDashboard() {
|
||||
let totalWordCount = 0;
|
||||
|
||||
tasks.forEach(t => {
|
||||
tasksByStatus[t.status || 'pending'] = (tasksByStatus[t.status || 'pending'] || 0) + 1;
|
||||
if (t.status === 'pending') pendingTasks++;
|
||||
else if (t.status === 'in_progress') inProgressTasks++;
|
||||
tasksByStatus[t.status || 'queued'] = (tasksByStatus[t.status || 'queued'] || 0) + 1;
|
||||
if (t.status === 'queued') pendingTasks++;
|
||||
else if (t.status === 'completed') completedTasks++;
|
||||
if (t.word_count) totalWordCount += t.word_count;
|
||||
});
|
||||
@@ -112,14 +110,12 @@ export default function WriterDashboard() {
|
||||
|
||||
const content = contentRes.results || [];
|
||||
let drafts = 0;
|
||||
let review = 0;
|
||||
let published = 0;
|
||||
let contentTotalWordCount = 0;
|
||||
const contentByType: Record<string, number> = {};
|
||||
|
||||
content.forEach(c => {
|
||||
if (c.status === 'draft') drafts++;
|
||||
else if (c.status === 'review') review++;
|
||||
else if (c.status === 'published') published++;
|
||||
if (c.word_count) contentTotalWordCount += c.word_count;
|
||||
});
|
||||
@@ -149,11 +145,9 @@ export default function WriterDashboard() {
|
||||
const contentThisMonth = Math.floor(content.length * 0.7);
|
||||
const publishRate = content.length > 0 ? Math.round((published / content.length) * 100) : 0;
|
||||
|
||||
const taxonomies = taxonomiesRes.results || [];
|
||||
const attributes = attributesRes.results || [];
|
||||
|
||||
const taxonomyCount = taxonomies.length;
|
||||
const attributeCount = attributes.length;
|
||||
// TODO: Stage 3/4 - Re-enable when taxonomy and attribute endpoints are implemented
|
||||
const taxonomyCount = 0; // taxonomiesRes.results?.length || 0
|
||||
const attributeCount = 0; // attributesRes.results?.length || 0
|
||||
|
||||
setStats({
|
||||
tasks: {
|
||||
@@ -168,7 +162,6 @@ export default function WriterDashboard() {
|
||||
content: {
|
||||
total: content.length,
|
||||
drafts,
|
||||
review,
|
||||
published,
|
||||
totalWordCount: contentTotalWordCount,
|
||||
avgWordCount: contentAvgWordCount,
|
||||
@@ -423,7 +416,7 @@ export default function WriterDashboard() {
|
||||
enabled: true
|
||||
},
|
||||
xaxis: {
|
||||
categories: ['Drafts', 'In Review', 'Published'],
|
||||
categories: ['Drafts', 'Published'],
|
||||
labels: {
|
||||
style: {
|
||||
fontFamily: 'Outfit'
|
||||
@@ -444,7 +437,7 @@ export default function WriterDashboard() {
|
||||
|
||||
const series = [{
|
||||
name: 'Content',
|
||||
data: [stats.content.drafts, stats.content.review, stats.content.published]
|
||||
data: [stats.content.drafts, stats.content.published]
|
||||
}];
|
||||
|
||||
return { options, series };
|
||||
|
||||
Reference in New Issue
Block a user