Skip to content

Commit

Permalink
chore: fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
stampaaaron committed Dec 17, 2024
1 parent 7f04161 commit 751ca5c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion apps/backend/src/defaults/carers/carer.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export class CarerResponseDto extends CarerDto {}
export class CarerCreationDto extends OmitType(CarerDto, ["id", "entries", "participant"]) {
participant?: number;
}
export class CarerMutationDto extends PartialType(OmitType(CarerDto, ["entries"])) {}
export class CarerMutationDto extends PartialType(CarerCreationDto) {}
7 changes: 1 addition & 6 deletions apps/frontend/src/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,17 +555,12 @@ export interface components {
entries: number[];
};
CarerMutationDto: {
/**
* @description The id of the carer
* @example 1
*/
id?: number;
/**
* @description The name of the carer
* @example Grandmother
*/
name?: string;
participant?: components["schemas"]["ParticipantDto"];
participant?: number;
};
LanguageCreationDto: {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { components } from "../../../../api.gen";
import { $api } from "../../../../stores/api";
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
import { useQueryClient } from "@tanstack/react-query";
import { Button, TextInput, useForm } from "@quassel/ui";
import { useEffect } from "react";

Expand All @@ -10,7 +10,7 @@ type FormValues = components["schemas"]["CarerMutationDto"];
function AdministrationCarersEdit() {
const p = Route.useParams();
const q = useQueryClient();
const carer = useSuspenseQuery($api.queryOptions("get", "/carers/{id}", { params: { path: { id: p.id } } }));
const { data, isSuccess } = $api.useSuspenseQuery("get", "/carers/{id}", { params: { path: { id: p.id } } });

Check warning on line 13 in apps/frontend/src/routes/_auth/administration/carers/edit.$id.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L13 was not covered by tests
const n = useNavigate();
const editCarerMutation = $api.useMutation("patch", "/carers/{id}", {
onSuccess: () => {
Expand All @@ -35,9 +35,9 @@ function AdministrationCarersEdit() {
};

useEffect(() => {
f.setValues(carer.data ?? {});
f.setValues({ ...data, participant: data.participant?.id });

Check warning on line 38 in apps/frontend/src/routes/_auth/administration/carers/edit.$id.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L38 was not covered by tests
f.resetDirty();
}, [carer.isSuccess, carer.data]);
}, [isSuccess, data]);

Check warning on line 40 in apps/frontend/src/routes/_auth/administration/carers/edit.$id.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L40 was not covered by tests

return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { components } from "../../../../api.gen";
import { $api } from "../../../../stores/api";
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
import { useQueryClient } from "@tanstack/react-query";
import { Button, TextInput, useForm } from "@quassel/ui";
import { useEffect } from "react";

Expand All @@ -10,11 +10,10 @@ type FormValues = components["schemas"]["LanguageMutationDto"];
function AdministrationLanguagesEdit() {
const p = Route.useParams();
const q = useQueryClient();
const carer = useSuspenseQuery(
$api.queryOptions("get", "/languages/{id}", {
params: { path: { id: p.id } },
})
);
const { data, isSuccess } = $api.useSuspenseQuery("get", "/languages/{id}", {
params: { path: { id: p.id } },
});

Check warning on line 15 in apps/frontend/src/routes/_auth/administration/languages/edit.$id.tsx

View check run for this annotation

Codecov / codecov/patch

apps/frontend/src/routes/_auth/administration/languages/edit.$id.tsx#L13-L15

Added lines #L13 - L15 were not covered by tests

const n = useNavigate();
const editCarerMutation = $api.useMutation("patch", "/languages/{id}", {
onSuccess: () => {
Expand All @@ -40,9 +39,9 @@ function AdministrationLanguagesEdit() {
};

useEffect(() => {
f.setValues(carer.data ?? {});
f.setValues({ ...data, participant: data.participant?.id });

Check warning on line 42 in apps/frontend/src/routes/_auth/administration/languages/edit.$id.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L42 was not covered by tests
f.resetDirty();
}, [carer.isSuccess, carer.data]);
}, [isSuccess, data]);

Check warning on line 44 in apps/frontend/src/routes/_auth/administration/languages/edit.$id.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L44 was not covered by tests

return (
<>
Expand All @@ -60,10 +59,6 @@ function AdministrationLanguagesEdit() {

export const Route = createFileRoute("/_auth/administration/languages/edit/$id")({
loader: ({ params, context: { queryClient } }) =>
queryClient.ensureQueryData(
$api.queryOptions("get", "/languages/{id}", {
params: { path: { id: params.id } },
})
),
queryClient.ensureQueryData($api.queryOptions("get", "/languages/{id}", { params: { path: params } })),

Check warning on line 62 in apps/frontend/src/routes/_auth/administration/languages/edit.$id.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L62 was not covered by tests
component: AdministrationLanguagesEdit,
});

0 comments on commit 751ca5c

Please sign in to comment.