@@ -6,6 +6,7 @@ import DataTableHeader from "@components/table/DataTableHeader";
66import DataTableRefreshButton from "@components/table/DataTableRefreshButton" ;
77import { DataTableRowsPerPage } from "@components/table/DataTableRowsPerPage" ;
88import GetStartedTest from "@components/ui/GetStartedTest" ;
9+ import { NotificationCountBadge } from "@components/ui/NotificationCountBadge" ;
910import { ColumnDef , SortingState } from "@tanstack/react-table" ;
1011import useFetchApi from "@utils/api" ;
1112import { isLocalDev , isNetBirdHosted } from "@utils/netbird" ;
@@ -88,6 +89,12 @@ export const UsersTableColumns: ColumnDef<User>[] = [
8889 />
8990 ) ,
9091 } ,
92+ {
93+ id : "approval_required" ,
94+ accessorKey : "approval_required" ,
95+ sortingFn : "basic" ,
96+ accessorFn : ( u ) => u ?. pending_approval ,
97+ } ,
9198 {
9299 accessorKey : "id" ,
93100 header : "" ,
@@ -127,6 +134,8 @@ export default function UsersTable({
127134 ) ;
128135
129136 const router = useRouter ( ) ;
137+ const pendingApprovalCount =
138+ users ?. filter ( ( u ) => u . pending_approval ) . length || 0 ;
130139
131140 return (
132141 < DataTable
@@ -139,6 +148,7 @@ export default function UsersTable({
139148 data = { users }
140149 columnVisibility = { {
141150 is_current : false ,
151+ approval_required : false ,
142152 } }
143153 onRowClick = { ( row ) => {
144154 router . push ( `/team/user?id=${ row . original . id } ` ) ;
@@ -187,6 +197,34 @@ export default function UsersTable({
187197 >
188198 { ( table ) => (
189199 < >
200+ { pendingApprovalCount > 0 && (
201+ < Button
202+ disabled = { users ?. length == 0 }
203+ onClick = { ( ) => {
204+ table . setPageIndex ( 0 ) ;
205+ let current =
206+ table . getColumn ( "approval_required" ) ?. getFilterValue ( ) ===
207+ undefined
208+ ? true
209+ : undefined ;
210+
211+ table . setColumnFilters ( [
212+ {
213+ id : "approval_required" ,
214+ value : current ,
215+ } ,
216+ ] ) ;
217+ } }
218+ variant = {
219+ table . getColumn ( "approval_required" ) ?. getFilterValue ( ) === true
220+ ? "tertiary"
221+ : "secondary"
222+ }
223+ >
224+ Pending Approvals
225+ < NotificationCountBadge count = { pendingApprovalCount } />
226+ </ Button >
227+ ) }
190228 < DataTableRowsPerPage table = { table } disabled = { users ?. length == 0 } />
191229 < DataTableRefreshButton
192230 isDisabled = { users ?. length == 0 }
0 commit comments