Skip to content

Commit df57fc8

Browse files
committed
feat: replace ActionIcon with Button for participant deletion and restrict access to ADMIN role
1 parent 9506b55 commit df57fc8

File tree

1 file changed

+12
-4
lines changed
  • apps/frontend/src/routes/_auth/administration/studies

1 file changed

+12
-4
lines changed

apps/frontend/src/routes/_auth/administration/studies/$id.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { createFileRoute } from "@tanstack/react-router";
22
import { $api } from "../../../../stores/api";
33
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
4-
import { ActionIcon, Stack, Table, Title, IconTrash } from "@quassel/ui";
4+
import { Stack, Table, Title, Button } from "@quassel/ui";
5+
import { useStore } from "@nanostores/react";
6+
import { $session } from "../../../../stores/session";
57

68
function AdministrationStudiesEdit() {
9+
const sessionStore = useStore($session);
710
const p = Route.useParams();
811
const q = useQueryClient();
912
const study = useSuspenseQuery(
@@ -45,9 +48,14 @@ function AdministrationStudiesEdit() {
4548
<Table.Td>{p.id}</Table.Td>
4649
<Table.Td>{p.birthday}</Table.Td>
4750
<Table.Td>
48-
<ActionIcon onClick={() => removeParticipantMutation.mutate({ body: { participantId: p.id, studyId: study.data.id } })}>
49-
<IconTrash />
50-
</ActionIcon>
51+
{sessionStore.role === "ADMIN" && (
52+
<Button
53+
variant="default"
54+
onClick={() => removeParticipantMutation.mutate({ body: { participantId: p.id, studyId: study.data.id } })}
55+
>
56+
Delete
57+
</Button>
58+
)}
5159
</Table.Td>
5260
</Table.Tr>
5361
))}

0 commit comments

Comments
 (0)