Skip to content

Commit c4f22cb

Browse files
committed
fix: questionnaire index type
1 parent 1e42711 commit c4f22cb

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

apps/backend/src/research/questionnaires/questionnaire.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class QuestionnaireDto {
3535
}
3636
export class QuestionnaireResponseDto extends QuestionnaireDto {}
3737
export class EntryQuestionnaireDto extends OmitType(QuestionnaireDto, ["entries"]) {}
38-
export class QuestionnairesResponseDto extends Array<EntryQuestionnaireDto> {}
38+
export class QuestionnairesResponseDto extends OmitType(QuestionnaireDto, ["entries"]) {}
3939
export class QuestionnaireCreationDto extends OmitType(QuestionnaireDto, ["id", "study", "participant"]) {
4040
study: number;
4141
participant: number;

apps/backend/src/research/questionnaires/questionnaires.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class QuestionnairesController {
2020

2121
@Get()
2222
@ApiOperation({ summary: "Get all questionnairess" })
23-
index(): Promise<QuestionnairesResponseDto> {
23+
index(): Promise<QuestionnairesResponseDto[]> {
2424
return this.questionnairesService.findAll();
2525
}
2626

apps/frontend/src/api.gen.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,37 @@ export interface components {
854854
participant?: components["schemas"]["ParticipantDto"];
855855
entries?: components["schemas"]["QuestionnaireEntryDto"][];
856856
};
857-
QuestionnairesResponseDto: Record<string, never>;
857+
QuestionnairesResponseDto: {
858+
/**
859+
* @description The id of the questionnaire
860+
* @example 1
861+
*/
862+
id: number;
863+
/**
864+
* Format: date-time
865+
* @description The starting date of the questionnaire
866+
* @example 2024-11-01T07:00:00.000Z
867+
*/
868+
startedAt?: string;
869+
/**
870+
* Format: date-time
871+
* @description The ending date of the questionnaire
872+
* @example 2024-11-01T08:00:00.00Z
873+
*/
874+
endedAt?: string;
875+
/**
876+
* @description The title of the questionnaire
877+
* @example First few months
878+
*/
879+
title?: string;
880+
/**
881+
* @description The remark of the questionnaire
882+
* @example We went on holidays for 2 weeks and only spoke Esperanto
883+
*/
884+
remark?: string;
885+
study?: components["schemas"]["StudyDto"];
886+
participant?: components["schemas"]["ParticipantDto"];
887+
};
858888
QuestionnaireMutationDto: {
859889
/**
860890
* Format: date-time
@@ -1756,7 +1786,7 @@ export interface operations {
17561786
[name: string]: unknown;
17571787
};
17581788
content: {
1759-
"application/json": components["schemas"]["QuestionnairesResponseDto"];
1789+
"application/json": components["schemas"]["QuestionnairesResponseDto"][];
17601790
};
17611791
};
17621792
};

apps/frontend/src/routes/_auth/administration/questionnaires/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { createFileRoute, Link } from "@tanstack/react-router";
22
import { $api } from "../../../../stores/api";
33
import { Button, Table } from "@quassel/ui";
4-
import { useSuspenseQuery } from "@tanstack/react-query";
54

65
function AdministrationQuestionnairesIndex() {
7-
const questionnaires = useSuspenseQuery($api.queryOptions("get", "/questionnaires"));
6+
const { data, refetch } = $api.useSuspenseQuery("get", "/questionnaires");
87
const deleteQuestionnaireMutation = $api.useMutation("delete", "/questionnaires/{id}", {
9-
onSuccess: () => questionnaires.refetch(),
8+
onSuccess: () => refetch(),
109
});
1110

1211
return (
@@ -19,7 +18,7 @@ function AdministrationQuestionnairesIndex() {
1918
</Table.Tr>
2019
</Table.Thead>
2120
<Table.Tbody>
22-
{questionnaires.data?.map((q) => (
21+
{data?.map((q) => (
2322
<Table.Tr key={q.id}>
2423
<Table.Td>{q.id}</Table.Td>
2524
<Table.Td>

0 commit comments

Comments
 (0)