import type { DebugPublishMeta } from '../../utils/debugPublish'; import { inferGradeFromAge } from '../../utils/debugPublish'; import { WORD_TEST_WORKSHEET_DEFINITIONS } from '../../config/worksheets/wordTest'; type WordTestWorksheetRow = (typeof WORD_TEST_WORKSHEET_DEFINITIONS)[number]; const WORKSHEET_BY_ID = Object.fromEntries( WORD_TEST_WORKSHEET_DEFINITIONS.map((m) => [m.id, m]), ) as Record; export const WORD_TEST_WORKSHEET_ID = WORD_TEST_WORKSHEET_DEFINITIONS[0].id; export function getModeInfo(id: string) { const m = WORKSHEET_BY_ID[id]; return m ? { title: m.title, desc: m.subtitle } : undefined; } export function isValidMode(id: string): boolean { return id in WORKSHEET_BY_ID; } export function getPublishMetaByMode(id: string): DebugPublishMeta | null { const m = WORKSHEET_BY_ID[id]; if (!m) return null; return { id: m.id, title: m.title, subtitle: m.subtitle, category: 'chinese', subcategory: 'word-test', path: `/chinesePages/wordTestSheet/wordTestSheet?id=${m.id}`, ageMin: m.ageMin, ageMax: m.ageMax, grade: inferGradeFromAge(m.ageMin, m.ageMax), difficulty: m.difficulty, previewImg: '', tags: [...m.tags], isNew: true, isHot: false, sortOrder: m.sortOrder, status: 'draft', }; }