From 8fadbdac0ab013e053317117c3a89098885f5af2 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Fri, 8 Nov 2024 13:36:41 +0100 Subject: [PATCH] fix: saving options for the question (#225) --- .../src/lessons/adminLessonItems.service.ts | 1 - .../adminLessonItems.repository.ts | 3 +- apps/api/src/swagger/api-schema.json | 91 +++++++++++++++++++ apps/web/app/api/generated-api.ts | 32 +++++++ 4 files changed, 124 insertions(+), 3 deletions(-) diff --git a/apps/api/src/lessons/adminLessonItems.service.ts b/apps/api/src/lessons/adminLessonItems.service.ts index 58c2024b..e81cde6c 100644 --- a/apps/api/src/lessons/adminLessonItems.service.ts +++ b/apps/api/src/lessons/adminLessonItems.service.ts @@ -329,7 +329,6 @@ export class AdminLessonItemsService { for (const option of options) { if ( - option.id === undefined || option.optionText === undefined || option.isCorrect === undefined || option.position === undefined diff --git a/apps/api/src/lessons/repositories/adminLessonItems.repository.ts b/apps/api/src/lessons/repositories/adminLessonItems.repository.ts index c25da71c..8cbc916c 100644 --- a/apps/api/src/lessons/repositories/adminLessonItems.repository.ts +++ b/apps/api/src/lessons/repositories/adminLessonItems.repository.ts @@ -229,7 +229,7 @@ export class AdminLessonItemsRepository { async upsertQuestionAnswerOptions( questionId: UUIDType, option: { - id: string; + id?: string; optionText: string; isCorrect: boolean; position: number; @@ -237,7 +237,6 @@ export class AdminLessonItemsRepository { trx?: PostgresJsDatabase, ) { const dbInstance = trx ?? this.db; - return await dbInstance .insert(questionAnswerOptions) .values({ diff --git a/apps/api/src/swagger/api-schema.json b/apps/api/src/swagger/api-schema.json index de7618b2..27da5734 100644 --- a/apps/api/src/swagger/api-schema.json +++ b/apps/api/src/swagger/api-schema.json @@ -513,6 +513,33 @@ } } }, + "/api/users/user-details": { + "get": { + "operationId": "UsersController_getUserDetails", + "parameters": [ + { + "name": "userId", + "required": false, + "in": "query", + "schema": { + "format": "uuid", + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetUserDetailsResponse" + } + } + } + } + } + } + }, "/api/users/admin/{id}": { "patch": { "operationId": "UsersController_adminUpdateUser", @@ -2914,6 +2941,70 @@ "data" ] }, + "GetUserDetailsResponse": { + "type": "object", + "properties": { + "data": { + "type": "object", + "properties": { + "id": { + "format": "uuid", + "type": "string" + }, + "description": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "contactEmail": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "contactPhone": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "jobTitle": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "id", + "description", + "contactEmail", + "contactPhone", + "jobTitle" + ] + } + }, + "required": [ + "data" + ] + }, "AdminUpdateUserBody": { "type": "object", "properties": { diff --git a/apps/web/app/api/generated-api.ts b/apps/web/app/api/generated-api.ts index fb9f4d0a..f192ba05 100644 --- a/apps/web/app/api/generated-api.ts +++ b/apps/web/app/api/generated-api.ts @@ -164,6 +164,17 @@ export interface UpdateUserResponse { }; } +export interface GetUserDetailsResponse { + data: { + /** @format uuid */ + id: string; + description: string | null; + contactEmail: string | null; + contactPhone: string | null; + jobTitle: string | null; + }; +} + export interface AdminUpdateUserBody { firstName?: string; lastName?: string; @@ -1472,6 +1483,27 @@ export class API extends HttpClient + this.request({ + path: `/api/users/user-details`, + method: "GET", + query: query, + format: "json", + ...params, + }), + /** * No description *