Skip to content

Commit

Permalink
fix: saving options for the question (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
typeWolffo authored Nov 8, 2024
1 parent 56d50d6 commit 8fadbda
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 3 deletions.
1 change: 0 additions & 1 deletion apps/api/src/lessons/adminLessonItems.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,14 @@ export class AdminLessonItemsRepository {
async upsertQuestionAnswerOptions(
questionId: UUIDType,
option: {
id: string;
id?: string;
optionText: string;
isCorrect: boolean;
position: number;
},
trx?: PostgresJsDatabase<typeof schema>,
) {
const dbInstance = trx ?? this.db;

return await dbInstance
.insert(questionAnswerOptions)
.values({
Expand Down
91 changes: 91 additions & 0 deletions apps/api/src/swagger/api-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
32 changes: 32 additions & 0 deletions apps/web/app/api/generated-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1472,6 +1483,27 @@ export class API<SecurityDataType extends unknown> extends HttpClient<SecurityDa
...params,
}),

/**
* No description
*
* @name UsersControllerGetUserDetails
* @request GET:/api/users/user-details
*/
usersControllerGetUserDetails: (
query?: {
/** @format uuid */
userId?: string;
},
params: RequestParams = {},
) =>
this.request<GetUserDetailsResponse, any>({
path: `/api/users/user-details`,
method: "GET",
query: query,
format: "json",
...params,
}),

/**
* No description
*
Expand Down

0 comments on commit 8fadbda

Please sign in to comment.