Skip to content

Commit 751ca5c

Browse files
committed
chore: fix typing
1 parent 7f04161 commit 751ca5c

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

apps/backend/src/defaults/carers/carer.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ export class CarerResponseDto extends CarerDto {}
2222
export class CarerCreationDto extends OmitType(CarerDto, ["id", "entries", "participant"]) {
2323
participant?: number;
2424
}
25-
export class CarerMutationDto extends PartialType(OmitType(CarerDto, ["entries"])) {}
25+
export class CarerMutationDto extends PartialType(CarerCreationDto) {}

apps/frontend/src/api.gen.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,17 +555,12 @@ export interface components {
555555
entries: number[];
556556
};
557557
CarerMutationDto: {
558-
/**
559-
* @description The id of the carer
560-
* @example 1
561-
*/
562-
id?: number;
563558
/**
564559
* @description The name of the carer
565560
* @example Grandmother
566561
*/
567562
name?: string;
568-
participant?: components["schemas"]["ParticipantDto"];
563+
participant?: number;
569564
};
570565
LanguageCreationDto: {
571566
/**

apps/frontend/src/routes/_auth/administration/carers/edit.$id.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createFileRoute, useNavigate } from "@tanstack/react-router";
22
import { components } from "../../../../api.gen";
33
import { $api } from "../../../../stores/api";
4-
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
4+
import { useQueryClient } from "@tanstack/react-query";
55
import { Button, TextInput, useForm } from "@quassel/ui";
66
import { useEffect } from "react";
77

@@ -10,7 +10,7 @@ type FormValues = components["schemas"]["CarerMutationDto"];
1010
function AdministrationCarersEdit() {
1111
const p = Route.useParams();
1212
const q = useQueryClient();
13-
const carer = useSuspenseQuery($api.queryOptions("get", "/carers/{id}", { params: { path: { id: p.id } } }));
13+
const { data, isSuccess } = $api.useSuspenseQuery("get", "/carers/{id}", { params: { path: { id: p.id } } });
1414
const n = useNavigate();
1515
const editCarerMutation = $api.useMutation("patch", "/carers/{id}", {
1616
onSuccess: () => {
@@ -35,9 +35,9 @@ function AdministrationCarersEdit() {
3535
};
3636

3737
useEffect(() => {
38-
f.setValues(carer.data ?? {});
38+
f.setValues({ ...data, participant: data.participant?.id });
3939
f.resetDirty();
40-
}, [carer.isSuccess, carer.data]);
40+
}, [isSuccess, data]);
4141

4242
return (
4343
<>

apps/frontend/src/routes/_auth/administration/languages/edit.$id.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createFileRoute, useNavigate } from "@tanstack/react-router";
22
import { components } from "../../../../api.gen";
33
import { $api } from "../../../../stores/api";
4-
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
4+
import { useQueryClient } from "@tanstack/react-query";
55
import { Button, TextInput, useForm } from "@quassel/ui";
66
import { useEffect } from "react";
77

@@ -10,11 +10,10 @@ type FormValues = components["schemas"]["LanguageMutationDto"];
1010
function AdministrationLanguagesEdit() {
1111
const p = Route.useParams();
1212
const q = useQueryClient();
13-
const carer = useSuspenseQuery(
14-
$api.queryOptions("get", "/languages/{id}", {
15-
params: { path: { id: p.id } },
16-
})
17-
);
13+
const { data, isSuccess } = $api.useSuspenseQuery("get", "/languages/{id}", {
14+
params: { path: { id: p.id } },
15+
});
16+
1817
const n = useNavigate();
1918
const editCarerMutation = $api.useMutation("patch", "/languages/{id}", {
2019
onSuccess: () => {
@@ -40,9 +39,9 @@ function AdministrationLanguagesEdit() {
4039
};
4140

4241
useEffect(() => {
43-
f.setValues(carer.data ?? {});
42+
f.setValues({ ...data, participant: data.participant?.id });
4443
f.resetDirty();
45-
}, [carer.isSuccess, carer.data]);
44+
}, [isSuccess, data]);
4645

4746
return (
4847
<>
@@ -60,10 +59,6 @@ function AdministrationLanguagesEdit() {
6059

6160
export const Route = createFileRoute("/_auth/administration/languages/edit/$id")({
6261
loader: ({ params, context: { queryClient } }) =>
63-
queryClient.ensureQueryData(
64-
$api.queryOptions("get", "/languages/{id}", {
65-
params: { path: { id: params.id } },
66-
})
67-
),
62+
queryClient.ensureQueryData($api.queryOptions("get", "/languages/{id}", { params: { path: params } })),
6863
component: AdministrationLanguagesEdit,
6964
});

0 commit comments

Comments
 (0)