@@ -43,12 +43,11 @@ import {
4343} from "@/components/ui/form"
4444import { Button } from "@/components/ui/button" ;
4545import { Input } from "@/components/ui/input" ;
46- import { Trash2 , Eye , EyeOff } from "lucide-react"
46+ import { Eye , EyeOff } from "lucide-react"
4747
4848export default function Devices ( ) {
4949 const { t } = useTranslation ( ) ;
5050 const [ showPassword , setShowPassword ] = useState ( false ) ;
51- const [ logoutDevice , setLogoutDevice ] = useState ( null ) ;
5251
5352 const usernameForm = createForm ( {
5453 new_username : { schema : "username" }
@@ -60,7 +59,7 @@ export default function Devices() {
6059 } ) ( ) ;
6160
6261 const { data : usernameData , isLoading : usernameLoading , mutate : mutateUsername } = useData ( API . USERNAME , t ( "toast.failed.fetch_config" ) ) ;
63- const { data : deviceData , isLoading : deviceLoading , mutate : mutateDevice } = useData ( API . DEVICE , t ( "toast.failed.fetch_config" ) ) ;
62+ const { data : deviceData , isLoading : deviceLoading } = useData ( API . DEVICE , t ( "toast.failed.fetch_config" ) ) ;
6463
6564 // Set page title
6665 useEffect ( ( ) => {
@@ -91,13 +90,6 @@ export default function Devices() {
9190 }
9291 } ;
9392
94- const handleDelete = async ( id ) => {
95- const result = await handleRequest ( "DELETE" , `${ API . DEVICE } /${ id } ` , null , t ( "toast.failed.delete" ) ) ;
96- if ( result ) {
97- mutateDevice ( ) ;
98- }
99- } ;
100-
10193 if ( usernameLoading || deviceLoading ) {
10294 return < > </ > ;
10395 }
@@ -178,49 +170,29 @@ export default function Devices() {
178170 < TableHead className = "px-2 py-4" > { t ( "st.user.devices.os" ) } </ TableHead >
179171 < TableHead className = "px-2 py-4" > { t ( "st.user.devices.browser" ) } </ TableHead >
180172 < TableHead className = "px-2 py-4" > { t ( "st.user.devices.ip" ) } </ TableHead >
181- < TableHead className = "px-2 py-4" > { t ( "st.user.devices.last " ) } </ TableHead >
182- < TableHead className = "px-3 py-4 w-4" > </ TableHead >
173+ < TableHead className = "px-2 py-4" > { t ( "st.user.devices.created " ) } </ TableHead >
174+ < TableHead className = "px-2 py-4" > { t ( "st.user.devices.expired" ) } </ TableHead >
183175 </ TableRow >
184176 </ TableHeader >
185177 < TableBody >
186178 { deviceData ?. devices . map ( ( device ) => (
187179 < TableRow key = { device . id } className = "hover:bg-transparent" >
188180 < TableCell className = "px-2 py-4" > { device . os } </ TableCell >
189- < TableCell className = "px-2 py-4" > { device . browser } </ TableCell >
190- < TableCell className = "px-2 py-4" > { device . ip } </ TableCell >
191181 < TableCell className = "px-2 py-4" >
192- { deviceData . currentDevice === device . id ? (
193- t ( "st.user.devices.current" )
194- ) : (
195- new Date ( device . lastActiveAt ) . toLocaleString ( )
196- ) }
197- </ TableCell >
198- < TableCell className = "px-3 py-4 w-4" >
199- < Button variant = "ghost" size = "icon" disabled = { deviceData . currentDevice === device . id } onClick = { ( ) => setLogoutDevice ( device ) } >
200- < Trash2 className = "text-muted-foreground" />
201- </ Button >
182+ < div className = "flex items-center gap-2" >
183+ { device . browser }
184+ { deviceData . currentDevice === device . id && (
185+ < div className = "w-2 h-2 rounded-full bg-green-500" > </ div >
186+ ) }
187+ </ div >
202188 </ TableCell >
189+ < TableCell className = "px-2 py-4" > { device . ip } </ TableCell >
190+ < TableCell className = "px-2 py-4" > { new Date ( device . createdAt ) . toLocaleString ( ) } </ TableCell >
191+ < TableCell className = "px-2 py-4" > { new Date ( device . expiredAt ) . toLocaleString ( ) } </ TableCell >
203192 </ TableRow >
204193 ) ) }
205194 </ TableBody >
206195 </ Table >
207-
208- < AlertDialog open = { logoutDevice !== null } onOpenChange = { ( open ) => ! open && setLogoutDevice ( null ) } >
209- < AlertDialogContent >
210- < AlertDialogHeader >
211- < AlertDialogTitle > { t ( "glb.confirm_logout" ) } </ AlertDialogTitle >
212- < AlertDialogDescription > { t ( "st.user.devices.alert" ) } </ AlertDialogDescription >
213- </ AlertDialogHeader >
214- < AlertDialogFooter >
215- < AlertDialogCancel >
216- { t ( "glb.cancel" ) }
217- </ AlertDialogCancel >
218- < AlertDialogAction onClick = { ( ) => { handleDelete ( logoutDevice . id ) ; setLogoutDevice ( null ) ; } } >
219- { t ( "glb.logout" ) }
220- </ AlertDialogAction >
221- </ AlertDialogFooter >
222- </ AlertDialogContent >
223- </ AlertDialog >
224196 </ CardContent >
225197 </ Card >
226198 </ >
0 commit comments