Files
buzz-sheet/lib/guides/publication.ts
T

19 lines
861 B
TypeScript

export interface PublicationCheckInput {
exists: boolean;
overview: string;
coverReady: boolean;
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.renderableSectionCount === 0) issues.push("กรุณาเพิ่มเนื้อหาอย่างน้อยหนึ่ง Section");
if (input.version !== input.expectedVersion) issues.push("Guide ถูกแก้ไขแล้ว กรุณาลองใหม่");
return issues;
}