feat: Admin Area Challenges: List, Import/Export and Add/Edit Modal 1.00
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user