File tree Expand file tree Collapse file tree 8 files changed +91
-58
lines changed
routes/_auth/administration Expand file tree Collapse file tree 8 files changed +91
-58
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @quassel/frontend " : patch
3
+ ---
4
+
5
+ Disable delete for assistants
Original file line number Diff line number Diff line change 1
1
import { createFileRoute , Link } from "@tanstack/react-router" ;
2
2
import { $api } from "../../../../stores/api" ;
3
3
import { Button , Table } from "@quassel/ui" ;
4
+ import { $session } from "../../../../stores/session" ;
5
+ import { useStore } from "@nanostores/react" ;
4
6
5
7
function AdministrationCarersIndex ( ) {
8
+ const sessionStore = useStore ( $session ) ;
6
9
const carers = $api . useSuspenseQuery ( "get" , "/carers" ) ;
7
10
const deleteCarerMutation = $api . useMutation ( "delete" , "/carers/{id}" , {
8
11
onSuccess : ( ) => carers . refetch ( ) ,
@@ -29,16 +32,18 @@ function AdministrationCarersIndex() {
29
32
< Button variant = "default" renderRoot = { ( props ) => < Link to = { `/administration/carers/edit/${ c . id } ` } { ...props } /> } >
30
33
Edit
31
34
</ Button >
32
- < Button
33
- variant = "default"
34
- onClick = { ( ) =>
35
- deleteCarerMutation . mutate ( {
36
- params : { path : { id : c . id . toString ( ) } } ,
37
- } )
38
- }
39
- >
40
- Delete
41
- </ Button >
35
+ { sessionStore . role === "ADMIN" && (
36
+ < Button
37
+ variant = "default"
38
+ onClick = { ( ) =>
39
+ deleteCarerMutation . mutate ( {
40
+ params : { path : { id : c . id . toString ( ) } } ,
41
+ } )
42
+ }
43
+ >
44
+ Delete
45
+ </ Button >
46
+ ) }
42
47
</ Table . Td >
43
48
</ Table . Tr >
44
49
) ) }
Original file line number Diff line number Diff line change @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
2
2
import { $api } from "../../../../stores/api" ;
3
3
import { Button , Table } from "@quassel/ui" ;
4
4
import { useSuspenseQuery } from "@tanstack/react-query" ;
5
+ import { $session } from "../../../../stores/session" ;
6
+ import { useStore } from "@nanostores/react" ;
5
7
6
8
function AdministrationLanguageIndex ( ) {
9
+ const sessionStore = useStore ( $session ) ;
7
10
const languages = useSuspenseQuery ( $api . queryOptions ( "get" , "/languages" ) ) ;
8
11
const deleteLanguageMutation = $api . useMutation ( "delete" , "/languages/{id}" , {
9
12
onSuccess : ( ) => languages . refetch ( ) ,
@@ -32,16 +35,18 @@ function AdministrationLanguageIndex() {
32
35
< Button variant = "default" renderRoot = { ( props ) => < Link to = { `/administration/languages/edit/${ l . id } ` } { ...props } /> } >
33
36
Edit
34
37
</ Button >
35
- < Button
36
- variant = "default"
37
- onClick = { ( ) =>
38
- deleteLanguageMutation . mutate ( {
39
- params : { path : { id : l . id . toString ( ) } } ,
40
- } )
41
- }
42
- >
43
- Delete
44
- </ Button >
38
+ { sessionStore . role === "ADMIN" && (
39
+ < Button
40
+ variant = "default"
41
+ onClick = { ( ) =>
42
+ deleteLanguageMutation . mutate ( {
43
+ params : { path : { id : l . id . toString ( ) } } ,
44
+ } )
45
+ }
46
+ >
47
+ Delete
48
+ </ Button >
49
+ ) }
45
50
</ Table . Td >
46
51
</ Table . Tr >
47
52
) ) }
Original file line number Diff line number Diff line change @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
2
2
import { $api } from "../../../../stores/api" ;
3
3
import { Button , Table } from "@quassel/ui" ;
4
4
import { useSuspenseQuery } from "@tanstack/react-query" ;
5
+ import { $session } from "../../../../stores/session" ;
6
+ import { useStore } from "@nanostores/react" ;
5
7
6
8
function AdministrationParticipantsIndex ( ) {
9
+ const sessionStore = useStore ( $session ) ;
7
10
const participants = useSuspenseQuery ( $api . queryOptions ( "get" , "/participants" ) ) ;
8
11
const deleteParticipantMutation = $api . useMutation ( "delete" , "/participants/{id}" , {
9
12
onSuccess : ( ) => participants . refetch ( ) ,
@@ -34,16 +37,18 @@ function AdministrationParticipantsIndex() {
34
37
< Button variant = "default" renderRoot = { ( props ) => < Link to = { `/administration/participants/edit/${ p . id } ` } { ...props } /> } >
35
38
Edit
36
39
</ Button >
37
- < Button
38
- variant = "default"
39
- onClick = { ( ) =>
40
- deleteParticipantMutation . mutate ( {
41
- params : { path : { id : p . id . toString ( ) } } ,
42
- } )
43
- }
44
- >
45
- Delete
46
- </ Button >
40
+ { sessionStore . role === "ADMIN" && (
41
+ < Button
42
+ variant = "default"
43
+ onClick = { ( ) =>
44
+ deleteParticipantMutation . mutate ( {
45
+ params : { path : { id : p . id . toString ( ) } } ,
46
+ } )
47
+ }
48
+ >
49
+ Delete
50
+ </ Button >
51
+ ) }
47
52
</ Table . Td >
48
53
</ Table . Tr >
49
54
) ) }
Original file line number Diff line number Diff line change 1
1
import { createFileRoute , Link } from "@tanstack/react-router" ;
2
2
import { $api } from "../../../../stores/api" ;
3
3
import { Button , Table } from "@quassel/ui" ;
4
+ import { $session } from "../../../../stores/session" ;
5
+ import { useStore } from "@nanostores/react" ;
4
6
5
7
function AdministrationQuestionnairesIndex ( ) {
8
+ const sessionStore = useStore ( $session ) ;
6
9
const { data, refetch } = $api . useSuspenseQuery ( "get" , "/questionnaires" ) ;
7
10
const deleteQuestionnaireMutation = $api . useMutation ( "delete" , "/questionnaires/{id}" , {
8
11
onSuccess : ( ) => refetch ( ) ,
@@ -25,16 +28,18 @@ function AdministrationQuestionnairesIndex() {
25
28
< Button variant = "default" renderRoot = { ( props ) => < Link to = { `/administration/questionnaires/edit/${ q . id } ` } { ...props } /> } >
26
29
Edit
27
30
</ Button >
28
- < Button
29
- variant = "default"
30
- onClick = { ( ) =>
31
- deleteQuestionnaireMutation . mutate ( {
32
- params : { path : { id : q . id . toString ( ) } } ,
33
- } )
34
- }
35
- >
36
- Delete
37
- </ Button >
31
+ { sessionStore . role === "ADMIN" && (
32
+ < Button
33
+ variant = "default"
34
+ onClick = { ( ) =>
35
+ deleteQuestionnaireMutation . mutate ( {
36
+ params : { path : { id : q . id . toString ( ) } } ,
37
+ } )
38
+ }
39
+ >
40
+ Delete
41
+ </ Button >
42
+ ) }
38
43
</ Table . Td >
39
44
</ Table . Tr >
40
45
) ) }
Original file line number Diff line number Diff line change @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
2
2
import { $api } from "../../../../stores/api" ;
3
3
import { Button , Table } from "@quassel/ui" ;
4
4
import { useSuspenseQuery } from "@tanstack/react-query" ;
5
+ import { $session } from "../../../../stores/session" ;
6
+ import { useStore } from "@nanostores/react" ;
5
7
6
8
function AdministrationStudiesIndex ( ) {
9
+ const sessionStore = useStore ( $session ) ;
7
10
const studies = useSuspenseQuery ( $api . queryOptions ( "get" , "/studies" ) ) ;
8
11
const deleteStudyMutation = $api . useMutation ( "delete" , "/studies/{id}" , {
9
12
onSuccess : ( ) => studies . refetch ( ) ,
@@ -30,16 +33,18 @@ function AdministrationStudiesIndex() {
30
33
< Button variant = "default" renderRoot = { ( props ) => < Link to = { `/administration/studies/edit/${ s . id } ` } { ...props } /> } >
31
34
Edit
32
35
</ Button >
33
- < Button
34
- variant = "default"
35
- onClick = { ( ) =>
36
- deleteStudyMutation . mutate ( {
37
- params : { path : { id : s . id . toString ( ) } } ,
38
- } )
39
- }
40
- >
41
- Delete
42
- </ Button >
36
+ { sessionStore . role === "ADMIN" && (
37
+ < Button
38
+ variant = "default"
39
+ onClick = { ( ) =>
40
+ deleteStudyMutation . mutate ( {
41
+ params : { path : { id : s . id . toString ( ) } } ,
42
+ } )
43
+ }
44
+ >
45
+ Delete
46
+ </ Button >
47
+ ) }
43
48
</ Table . Td >
44
49
</ Table . Tr >
45
50
) ) }
Original file line number Diff line number Diff line change @@ -2,8 +2,11 @@ import { createFileRoute, Link } from "@tanstack/react-router";
2
2
import { $api } from "../../../../stores/api" ;
3
3
import { Button , Table } from "@quassel/ui" ;
4
4
import { useSuspenseQuery } from "@tanstack/react-query" ;
5
+ import { useStore } from "@nanostores/react" ;
6
+ import { $session } from "../../../../stores/session" ;
5
7
6
8
function AdministrationUsersIndex ( ) {
9
+ const sessionStore = useStore ( $session ) ;
7
10
const users = useSuspenseQuery ( $api . queryOptions ( "get" , "/users" ) ) ;
8
11
const deleteUserMutation = $api . useMutation ( "delete" , "/users/{id}" , { onSuccess : ( ) => users . refetch ( ) } ) ;
9
12
@@ -31,9 +34,11 @@ function AdministrationUsersIndex() {
31
34
< Button variant = "default" renderRoot = { ( props ) => < Link to = { `/administration/users/edit/${ u . id } ` } { ...props } /> } >
32
35
Edit
33
36
</ Button >
34
- < Button variant = "default" onClick = { ( ) => deleteUserMutation . mutate ( { params : { path : { id : u . id . toString ( ) } } } ) } >
35
- Delete
36
- </ Button >
37
+ { sessionStore . role === "ADMIN" && (
38
+ < Button variant = "default" onClick = { ( ) => deleteUserMutation . mutate ( { params : { path : { id : u . id . toString ( ) } } } ) } >
39
+ Delete
40
+ </ Button >
41
+ ) }
37
42
</ Table . Td >
38
43
</ Table . Tr >
39
44
) ) }
Original file line number Diff line number Diff line change 1
1
import { persistentMap } from "@nanostores/persistent" ;
2
+ import { components } from "../api.gen" ;
2
3
3
- type Session = {
4
- email ?: string ;
5
- role ?: string ;
6
- } ;
4
+ type Session = Partial < Omit < components [ "schemas" ] [ "SessionResponseDto" ] , "id" > > ;
7
5
8
- export const $session = persistentMap < Session > ( "session: " , { } ) ;
6
+ export const $session = persistentMap < Session > ( "session" , { } ) ;
You can’t perform that action at this time.
0 commit comments