1- import { ChevronsUpDown , CircleUser , Cog , MessageCircle , RefreshCw } from "lucide-react" ;
1+ import {
2+ ChevronsUpDown ,
3+ CircleUser ,
4+ Cog ,
5+ MessageCircle ,
6+ RefreshCw ,
7+ } from "lucide-react" ;
28import { useMemo , useState } from "react" ;
39import { useTranslation } from "react-i18next" ;
410import { Link } from "react-router-dom" ;
@@ -8,9 +14,25 @@ import { InstanceStatus } from "@/components/instance-status";
814import { InstanceToken } from "@/components/instance-token" ;
915import { Avatar , AvatarImage } from "@/components/ui/avatar" ;
1016import { Button } from "@/components/ui/button" ;
11- import { Card , CardContent , CardFooter , CardHeader } from "@/components/ui/card" ;
12- import { Dialog , DialogClose , DialogContent , DialogFooter , DialogHeader } from "@/components/ui/dialog" ;
13- import { DropdownMenu , DropdownMenuContent , DropdownMenuCheckboxItem , DropdownMenuTrigger } from "@/components/ui/dropdown-menu" ;
17+ import {
18+ Card ,
19+ CardContent ,
20+ CardFooter ,
21+ CardHeader ,
22+ } from "@/components/ui/card" ;
23+ import {
24+ Dialog ,
25+ DialogClose ,
26+ DialogContent ,
27+ DialogFooter ,
28+ DialogHeader ,
29+ } from "@/components/ui/dialog" ;
30+ import {
31+ DropdownMenu ,
32+ DropdownMenuContent ,
33+ DropdownMenuCheckboxItem ,
34+ DropdownMenuTrigger ,
35+ } from "@/components/ui/dropdown-menu" ;
1436import { Input } from "@/components/ui/input" ;
1537
1638import { useFetchInstances } from "@/lib/queries/instance/fetchInstances" ;
@@ -23,7 +45,9 @@ import { NewInstance } from "./NewInstance";
2345function Dashboard ( ) {
2446 const { t } = useTranslation ( ) ;
2547
26- const [ deleteConfirmation , setDeleteConfirmation ] = useState < string | null > ( null ) ;
48+ const [ deleteConfirmation , setDeleteConfirmation ] = useState < string | null > (
49+ null ,
50+ ) ;
2751 const { deleteInstance, logout } = useManageInstance ( ) ;
2852 const { data : instances , refetch } = useFetchInstances ( ) ;
2953 const [ deleting , setDeleting ] = useState < string [ ] > ( [ ] ) ;
@@ -58,11 +82,15 @@ function Dashboard() {
5882 const filteredInstances = useMemo ( ( ) => {
5983 let instancesList = instances ? [ ...instances ] : [ ] ;
6084 if ( searchStatus !== "all" ) {
61- instancesList = instancesList . filter ( ( instance ) => instance . connectionStatus === searchStatus ) ;
85+ instancesList = instancesList . filter (
86+ ( instance ) => instance . connectionStatus === searchStatus ,
87+ ) ;
6288 }
6389
6490 if ( nameSearch !== "" ) {
65- instancesList = instancesList . filter ( ( instance ) => instance . name . toLowerCase ( ) . includes ( nameSearch . toLowerCase ( ) ) ) ;
91+ instancesList = instancesList . filter ( ( instance ) =>
92+ instance . name . toLowerCase ( ) . includes ( nameSearch . toLowerCase ( ) ) ,
93+ ) ;
6694 }
6795
6896 return instancesList ;
@@ -88,7 +116,11 @@ function Dashboard() {
88116 </ div >
89117 < div className = "my-4 flex items-center justify-between gap-3 px-4" >
90118 < div className = "flex-1" >
91- < Input placeholder = { t ( "dashboard.search" ) } value = { nameSearch } onChange = { ( e ) => setNameSearch ( e . target . value ) } />
119+ < Input
120+ placeholder = { t ( "dashboard.search" ) }
121+ value = { nameSearch }
122+ onChange = { ( e ) => setNameSearch ( e . target . value ) }
123+ />
92124 </ div >
93125 < DropdownMenu >
94126 < DropdownMenuTrigger asChild >
@@ -105,7 +137,8 @@ function Dashboard() {
105137 if ( checked ) {
106138 setSearchStatus ( status . value ) ;
107139 }
108- } } >
140+ } }
141+ >
109142 { status . label }
110143 </ DropdownMenuCheckboxItem >
111144 ) ) }
@@ -114,11 +147,14 @@ function Dashboard() {
114147 </ div >
115148 < main className = "grid gap-6 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4" >
116149 { filteredInstances . length > 0 &&
117- Array . isArray ( instances ) &&
118- instances . map ( ( instance : Instance ) => (
150+ Array . isArray ( filteredInstances ) &&
151+ filteredInstances . map ( ( instance : Instance ) => (
119152 < Card key = { instance . id } >
120153 < CardHeader >
121- < Link to = { `/manager/instance/${ instance . id } /dashboard` } className = "flex w-full flex-row items-center justify-between gap-4" >
154+ < Link
155+ to = { `/manager/instance/${ instance . id } /dashboard` }
156+ className = "flex w-full flex-row items-center justify-between gap-4"
157+ >
122158 < h3 className = "text-wrap font-semibold" > { instance . name } </ h3 >
123159 < Button variant = "ghost" size = "icon" >
124160 < Cog className = "card-icon" size = "20" />
@@ -136,7 +172,10 @@ function Dashboard() {
136172 </ Avatar >
137173 < div className = "space-y-1" >
138174 < strong > { instance . profileName } </ strong >
139- < p className = "text-sm text-muted-foreground" > { instance . ownerJid && instance . ownerJid . split ( "@" ) [ 0 ] } </ p >
175+ < p className = "text-sm text-muted-foreground" >
176+ { instance . ownerJid &&
177+ instance . ownerJid . split ( "@" ) [ 0 ] }
178+ </ p >
140179 </ div >
141180 </ >
142181 ) }
@@ -145,19 +184,39 @@ function Dashboard() {
145184 < div className = "flex items-center justify-end gap-4 text-sm" >
146185 < div className = "flex flex-col items-center justify-center gap-1" >
147186 < CircleUser className = "text-muted-foreground" size = "20" />
148- < span > { new Intl . NumberFormat ( "pt-BR" ) . format ( instance ?. _count ?. Contact || 0 ) } </ span >
187+ < span >
188+ { new Intl . NumberFormat ( "pt-BR" ) . format (
189+ instance ?. _count ?. Contact || 0 ,
190+ ) }
191+ </ span >
149192 </ div >
150193 < div className = "flex flex-col items-center justify-center gap-1" >
151- < MessageCircle className = "text-muted-foreground" size = "20" />
152- < span > { new Intl . NumberFormat ( "pt-BR" ) . format ( instance ?. _count ?. Message || 0 ) } </ span >
194+ < MessageCircle
195+ className = "text-muted-foreground"
196+ size = "20"
197+ />
198+ < span >
199+ { new Intl . NumberFormat ( "pt-BR" ) . format (
200+ instance ?. _count ?. Message || 0 ,
201+ ) }
202+ </ span >
153203 </ div >
154204 </ div >
155205 </ div >
156206 </ CardContent >
157207 < CardFooter className = "justify-between" >
158208 < InstanceStatus status = { instance . connectionStatus } />
159- < Button variant = "destructive" size = "sm" onClick = { ( ) => setDeleteConfirmation ( instance . name ) } disabled = { deleting . includes ( instance . name ) } >
160- { deleting . includes ( instance . name ) ? < span > { t ( "button.deleting" ) } </ span > : < span > { t ( "button.delete" ) } </ span > }
209+ < Button
210+ variant = "destructive"
211+ size = "sm"
212+ onClick = { ( ) => setDeleteConfirmation ( instance . name ) }
213+ disabled = { deleting . includes ( instance . name ) }
214+ >
215+ { deleting . includes ( instance . name ) ? (
216+ < span > { t ( "button.deleting" ) } </ span >
217+ ) : (
218+ < span > { t ( "button.delete" ) } </ span >
219+ ) }
161220 </ Button >
162221 </ CardFooter >
163222 </ Card >
@@ -169,13 +228,22 @@ function Dashboard() {
169228 < DialogContent >
170229 < DialogClose />
171230 < DialogHeader > { t ( "modal.delete.title" ) } </ DialogHeader >
172- < p > { t ( "modal.delete.message" , { instanceName : deleteConfirmation } ) } </ p >
231+ < p >
232+ { t ( "modal.delete.message" , { instanceName : deleteConfirmation } ) }
233+ </ p >
173234 < DialogFooter >
174235 < div className = "flex items-center gap-4" >
175- < Button onClick = { ( ) => setDeleteConfirmation ( null ) } size = "sm" variant = "outline" >
236+ < Button
237+ onClick = { ( ) => setDeleteConfirmation ( null ) }
238+ size = "sm"
239+ variant = "outline"
240+ >
176241 { t ( "button.cancel" ) }
177242 </ Button >
178- < Button onClick = { ( ) => handleDelete ( deleteConfirmation ) } variant = "destructive" >
243+ < Button
244+ onClick = { ( ) => handleDelete ( deleteConfirmation ) }
245+ variant = "destructive"
246+ >
179247 { t ( "button.delete" ) }
180248 </ Button >
181249 </ div >
0 commit comments