AI Implementation feature(903): Admin Area Challenges: List, Import/Export and Add/Edit Modal 1.03 (#44)
This commit was merged in pull request #44.
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
categoryIconSrc,
|
||||
deriveEmptyState,
|
||||
difficultyClass,
|
||||
importErrorMessage,
|
||||
summarizeImportPreview,
|
||||
summarizeImportResult,
|
||||
} from './challenges.pure';
|
||||
@@ -459,11 +460,11 @@ export class AdminChallengesComponent implements OnInit, OnDestroy {
|
||||
this.importError.set(null);
|
||||
try {
|
||||
const result = await this.admin.confirmChallengeImport(doc);
|
||||
this.importResult.set(result);
|
||||
this.statusMessage.set(summarizeImportResult(result));
|
||||
await this.load();
|
||||
this.closeImport();
|
||||
} catch (e: any) {
|
||||
this.importError.set(e?.error?.message ?? e?.message ?? 'Failed to import challenges');
|
||||
this.importError.set(importErrorMessage(e, 'Failed to import challenges'));
|
||||
} finally {
|
||||
this.importing.set(false);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,16 @@ export function summarizeImportResult(r: ImportResultResponse): string {
|
||||
return lines.join(' ');
|
||||
}
|
||||
|
||||
export function importErrorMessage(err: unknown, fallback: string): string {
|
||||
if (err && typeof err === 'object') {
|
||||
const e = err as { error?: { message?: string }; message?: string };
|
||||
if (e.error?.message) return e.error.message;
|
||||
if (typeof e.message === 'string' && e.message.length > 0) return e.message;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
|
||||
export function difficultyClass(difficulty: 'LOW' | 'MEDIUM' | 'HIGH'): string {
|
||||
return `difficulty-badge difficulty-${difficulty.toLowerCase()}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user