AI Implementation feature(900): Admin Area Challenges: List, Import/Export and Add/Edit Modal 1.00 (#41)

This commit was merged in pull request #41.
This commit is contained in:
2026-07-22 20:50:07 +00:00
parent 8dcbd48045
commit 3d93693fc6
4 changed files with 87 additions and 92 deletions
@@ -15,8 +15,10 @@ import {
AdminService,
AdminCategory,
AdminChallengeListItem,
CreateChallengeBody,
ImportPreviewResponse,
ImportResultResponse,
UpdateChallengeBody,
} from '../../../core/services/admin.service';
import {
buildExportFilename,
@@ -334,17 +336,18 @@ export class AdminChallengesComponent implements OnInit, OnDestroy {
this.fieldErrors.set(null);
}
async onFormSubmit(payload: any): Promise<void> {
async onFormSubmit(payload: { body: CreateChallengeBody | UpdateChallengeBody }): Promise<void> {
this.saving.set(true);
this.formError.set(null);
this.fieldErrors.set(null);
const body = payload.body;
try {
if (this.formMode() === 'create') {
await this.admin.createChallenge(payload);
await this.admin.createChallenge(body as CreateChallengeBody);
} else {
const detail = this.formDetail();
if (!detail) throw new Error('Missing challenge detail');
await this.admin.updateChallenge(detail.id, payload);
await this.admin.updateChallenge(detail.id, body as UpdateChallengeBody);
}
this.closeForm();
await this.load();