Squash merge feat/expo-app: app-expo, .cursor, workflows, package.json, .husky; remove app-android, app-ios, react-app

This commit is contained in:
Kevin
2026-03-19 01:12:17 +08:00
parent 9e4f301ab9
commit b4f4369b7d
544 changed files with 23707 additions and 67151 deletions

View File

@@ -0,0 +1,31 @@
import type { Chapter, ChapterViewModel, ImageAsset } from './types';
function countByStatus(images: ImageAsset[], status: string): number {
return images.filter((img) => img.status === status).length;
}
export function toChapterViewModel(chapter: Chapter): ChapterViewModel {
const images = chapter.images ?? [];
const completedCount = countByStatus(images, 'completed');
return {
id: chapter.id,
title: chapter.title,
category: chapter.category,
orderIndex: chapter.order_index,
isEmpty: chapter.status === 'empty' || !chapter.content,
isNew: chapter.is_new,
hasImages: images.length > 0,
allImagesReady: images.length > 0 && completedCount === images.length,
pendingImageCount:
countByStatus(images, 'pending') + countByStatus(images, 'processing'),
failedImageCount: countByStatus(images, 'failed'),
sections: chapter.sections ?? [],
coverImageUrl: chapter.cover_image?.url ?? null,
updatedAt: chapter.updated_at,
};
}
export function toChapterViewModels(chapters: Chapter[]): ChapterViewModel[] {
return chapters.map(toChapterViewModel);
}