Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 198-improve-calendar-…
Browse files Browse the repository at this point in the history
…entries-display
  • Loading branch information
stampaaaron committed Dec 17, 2024
2 parents f29044f + f85465f commit 92c30ca
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-dolphins-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@quassel/frontend": patch
---

Disable delete for assistants
2 changes: 1 addition & 1 deletion .changeset/sixty-wolves-sell.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"@quassel/ui": patch
---

Introduce entering custom values for carers and languages
Allow custom carers and languages per participant
25 changes: 15 additions & 10 deletions apps/frontend/src/routes/_auth/administration/carers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { createFileRoute, Link } from "@tanstack/react-router";
import { $api } from "../../../../stores/api";
import { Button, ColorSwatch, Table } from "@quassel/ui";
import { $session } from "../../../../stores/session";
import { useStore } from "@nanostores/react";

function AdministrationCarersIndex() {
const sessionStore = useStore($session);
const carers = $api.useSuspenseQuery("get", "/carers");
const deleteCarerMutation = $api.useMutation("delete", "/carers/{id}", {
onSuccess: () => carers.refetch(),
Expand Down Expand Up @@ -31,16 +34,18 @@ function AdministrationCarersIndex() {
<Button variant="default" renderRoot={(props) => <Link to={`/administration/carers/edit/${c.id}`} {...props} />}>
Edit
</Button>
<Button
variant="default"
onClick={() =>
deleteCarerMutation.mutate({
params: { path: { id: c.id.toString() } },
})
}
>
Delete
</Button>
{sessionStore.role === "ADMIN" && (
<Button
variant="default"
onClick={() =>
deleteCarerMutation.mutate({
params: { path: { id: c.id.toString() } },
})
}
>
Delete
</Button>
)}
</Table.Td>
</Table.Tr>
))}
Expand Down
25 changes: 15 additions & 10 deletions apps/frontend/src/routes/_auth/administration/languages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
import { $api } from "../../../../stores/api";
import { Button, Table } from "@quassel/ui";
import { useSuspenseQuery } from "@tanstack/react-query";
import { $session } from "../../../../stores/session";
import { useStore } from "@nanostores/react";

function AdministrationLanguageIndex() {
const sessionStore = useStore($session);
const languages = useSuspenseQuery($api.queryOptions("get", "/languages"));
const deleteLanguageMutation = $api.useMutation("delete", "/languages/{id}", {
onSuccess: () => languages.refetch(),
Expand Down Expand Up @@ -32,16 +35,18 @@ function AdministrationLanguageIndex() {
<Button variant="default" renderRoot={(props) => <Link to={`/administration/languages/edit/${l.id}`} {...props} />}>
Edit
</Button>
<Button
variant="default"
onClick={() =>
deleteLanguageMutation.mutate({
params: { path: { id: l.id.toString() } },
})
}
>
Delete
</Button>
{sessionStore.role === "ADMIN" && (
<Button
variant="default"
onClick={() =>
deleteLanguageMutation.mutate({
params: { path: { id: l.id.toString() } },
})
}
>
Delete
</Button>
)}
</Table.Td>
</Table.Tr>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
import { $api } from "../../../../stores/api";
import { Button, Table } from "@quassel/ui";
import { useSuspenseQuery } from "@tanstack/react-query";
import { $session } from "../../../../stores/session";
import { useStore } from "@nanostores/react";

function AdministrationParticipantsIndex() {
const sessionStore = useStore($session);
const participants = useSuspenseQuery($api.queryOptions("get", "/participants"));
const deleteParticipantMutation = $api.useMutation("delete", "/participants/{id}", {
onSuccess: () => participants.refetch(),
Expand Down Expand Up @@ -34,16 +37,18 @@ function AdministrationParticipantsIndex() {
<Button variant="default" renderRoot={(props) => <Link to={`/administration/participants/edit/${p.id}`} {...props} />}>
Edit
</Button>
<Button
variant="default"
onClick={() =>
deleteParticipantMutation.mutate({
params: { path: { id: p.id.toString() } },
})
}
>
Delete
</Button>
{sessionStore.role === "ADMIN" && (
<Button
variant="default"
onClick={() =>
deleteParticipantMutation.mutate({
params: { path: { id: p.id.toString() } },
})
}
>
Delete
</Button>
)}
</Table.Td>
</Table.Tr>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { createFileRoute, Link } from "@tanstack/react-router";
import { $api } from "../../../../stores/api";
import { Button, Table } from "@quassel/ui";
import { $session } from "../../../../stores/session";
import { useStore } from "@nanostores/react";

function AdministrationQuestionnairesIndex() {
const sessionStore = useStore($session);
const { data, refetch } = $api.useSuspenseQuery("get", "/questionnaires");
const deleteQuestionnaireMutation = $api.useMutation("delete", "/questionnaires/{id}", {
onSuccess: () => refetch(),
Expand All @@ -25,16 +28,18 @@ function AdministrationQuestionnairesIndex() {
<Button variant="default" renderRoot={(props) => <Link to={`/administration/questionnaires/edit/${q.id}`} {...props} />}>
Edit
</Button>
<Button
variant="default"
onClick={() =>
deleteQuestionnaireMutation.mutate({
params: { path: { id: q.id.toString() } },
})
}
>
Delete
</Button>
{sessionStore.role === "ADMIN" && (
<Button
variant="default"
onClick={() =>
deleteQuestionnaireMutation.mutate({
params: { path: { id: q.id.toString() } },
})
}
>
Delete
</Button>
)}
</Table.Td>
</Table.Tr>
))}
Expand Down
25 changes: 15 additions & 10 deletions apps/frontend/src/routes/_auth/administration/studies/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
import { $api } from "../../../../stores/api";
import { Button, Table } from "@quassel/ui";
import { useSuspenseQuery } from "@tanstack/react-query";
import { $session } from "../../../../stores/session";
import { useStore } from "@nanostores/react";

function AdministrationStudiesIndex() {
const sessionStore = useStore($session);
const studies = useSuspenseQuery($api.queryOptions("get", "/studies"));
const deleteStudyMutation = $api.useMutation("delete", "/studies/{id}", {
onSuccess: () => studies.refetch(),
Expand All @@ -30,16 +33,18 @@ function AdministrationStudiesIndex() {
<Button variant="default" renderRoot={(props) => <Link to={`/administration/studies/edit/${s.id}`} {...props} />}>
Edit
</Button>
<Button
variant="default"
onClick={() =>
deleteStudyMutation.mutate({
params: { path: { id: s.id.toString() } },
})
}
>
Delete
</Button>
{sessionStore.role === "ADMIN" && (
<Button
variant="default"
onClick={() =>
deleteStudyMutation.mutate({
params: { path: { id: s.id.toString() } },
})
}
>
Delete
</Button>
)}
</Table.Td>
</Table.Tr>
))}
Expand Down
11 changes: 8 additions & 3 deletions apps/frontend/src/routes/_auth/administration/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
import { $api } from "../../../../stores/api";
import { Button, Table } from "@quassel/ui";
import { useSuspenseQuery } from "@tanstack/react-query";
import { useStore } from "@nanostores/react";
import { $session } from "../../../../stores/session";

function AdministrationUsersIndex() {
const sessionStore = useStore($session);
const users = useSuspenseQuery($api.queryOptions("get", "/users"));
const deleteUserMutation = $api.useMutation("delete", "/users/{id}", { onSuccess: () => users.refetch() });

Expand Down Expand Up @@ -31,9 +34,11 @@ function AdministrationUsersIndex() {
<Button variant="default" renderRoot={(props) => <Link to={`/administration/users/edit/${u.id}`} {...props} />}>
Edit
</Button>
<Button variant="default" onClick={() => deleteUserMutation.mutate({ params: { path: { id: u.id.toString() } } })}>
Delete
</Button>
{sessionStore.role === "ADMIN" && (
<Button variant="default" onClick={() => deleteUserMutation.mutate({ params: { path: { id: u.id.toString() } } })}>
Delete
</Button>
)}
</Table.Td>
</Table.Tr>
))}
Expand Down
8 changes: 3 additions & 5 deletions apps/frontend/src/stores/session.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { persistentMap } from "@nanostores/persistent";
import { components } from "../api.gen";

type Session = {
email?: string;
role?: string;
};
type Session = Partial<Omit<components["schemas"]["SessionResponseDto"], "id">>;

export const $session = persistentMap<Session>("session:", {});
export const $session = persistentMap<Session>("session", {});
9 changes: 9 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage:
status:
project:
default:
threshold: 2%
patch:
default:
target: 5%
threshold: 10%
4 changes: 1 addition & 3 deletions libs/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,5 @@ export {
IconRepeat,
} from "@tabler/icons-react";

export { DSVImport } from "react-dsv-import";
export type { ColumnType } from "react-dsv-import";

export { uzhColors } from "./theme/uzh";
export { DSVImport, type ColumnType } from "react-dsv-import";

0 comments on commit 92c30ca

Please sign in to comment.