@@ -15,7 +15,7 @@ import {
15
15
import { enqueueSnackbar } from 'notistack'
16
16
import { useTranslation } from 'react-i18next'
17
17
18
- import { ChatInstanceUsage , ChatInstance } from '../../../types'
18
+ import { ChatInstanceUsage , ChatInstance , User } from '../../../types'
19
19
import useChatInstanceUsage from '../../../hooks/useChatInstanceUsage'
20
20
import useUsers from '../../../hooks/useUsers'
21
21
import { useDeleteChatInstanceUsageMutation } from '../../../hooks/useChatInstanceUsageMutation'
@@ -28,6 +28,11 @@ type Usage = Omit<ChatInstanceUsage, 'chatInstance'> & {
28
28
const sortUsage = ( a : Usage , b : Usage ) =>
29
29
a . user . username . localeCompare ( b . user . username )
30
30
31
+ const handleLoginAs = ( user : User ) => ( ) => {
32
+ localStorage . setItem ( 'adminLoggedInAs' , user . id )
33
+ window . location . reload ( )
34
+ }
35
+
31
36
const UserTable = ( ) => {
32
37
const { usage : chatInstanceUsage , isLoading } = useChatInstanceUsage ( )
33
38
const { users, isLoading : usersLoading } = useUsers ( )
@@ -136,6 +141,11 @@ const UserTable = () => {
136
141
{ t ( 'admin:reset' ) }
137
142
</ Button >
138
143
</ TableCell >
144
+ < TableCell >
145
+ < Button variant = "outlined" onClick = { handleLoginAs ( user ) } >
146
+ Kirjaudu käyttäjällä
147
+ </ Button >
148
+ </ TableCell >
139
149
</ TableRow >
140
150
)
141
151
) }
0 commit comments