21 lines
1002 B
TypeScript
21 lines
1002 B
TypeScript
export interface PublicationCheckInput {
|
|
exists: boolean;
|
|
overview: string;
|
|
coverReady: boolean;
|
|
catalogVersion: string | null;
|
|
renderableSectionCount: number;
|
|
version: number;
|
|
expectedVersion: number;
|
|
}
|
|
|
|
export function publicationIssues(input: PublicationCheckInput): string[] {
|
|
if (!input.exists) return ["ไม่พบ Guide"];
|
|
const issues: string[] = [];
|
|
if (!input.overview.trim()) issues.push("กรุณากรอก Overview");
|
|
if (!input.coverReady) issues.push("รูปปกยังไม่พร้อมใช้งาน");
|
|
if (!input.catalogVersion) issues.push("กรุณา Sync Catalog ก่อนเผยแพร่");
|
|
if (input.renderableSectionCount === 0) issues.push("กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section");
|
|
if (input.version !== input.expectedVersion) issues.push("Guide ถูกแก้ไขแล้ว กรุณาลองใหม่");
|
|
return issues;
|
|
}
|