Skip to content

Commit 9239048

Browse files
committed
Add pending approval filter
1 parent db07745 commit 9239048

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

src/components/ui/NotificationCountBadge.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ import * as React from "react";
44
type Props = {
55
count?: number;
66
};
7-
export const NotificationCountBadge = ({ count = 0 }: Props) => {
7+
export const NotificationCountBadge = ({ count = 22 }: Props) => {
8+
count = 1;
89
return count ? (
910
<div
1011
className={cn(
11-
count <= 9 ? "w-5 h-5" : "py-2.5 px-2",
12-
"relative bg-netbird flex items-center justify-center rounded-full text-white !leading-[0] text-xs font-semibold",
12+
count <= 9 ? "w-4 h-4" : "py-2 px-1.5",
13+
"relative bg-netbird flex items-center justify-center rounded-full text-white !leading-[0] text-[0.6rem] font-semibold",
1314
)}
1415
>
1516
<span className="animate-ping absolute left-0 inline-flex h-full w-full rounded-full bg-netbird opacity-20"></span>
16-
{count || 0}
17+
<span className={"relative -left-[0.5px]"}>{count || 0}</span>
1718
</div>
1819
) : null;
1920
};

src/modules/users/UsersTable.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import DataTableHeader from "@components/table/DataTableHeader";
66
import DataTableRefreshButton from "@components/table/DataTableRefreshButton";
77
import { DataTableRowsPerPage } from "@components/table/DataTableRowsPerPage";
88
import GetStartedTest from "@components/ui/GetStartedTest";
9+
import { NotificationCountBadge } from "@components/ui/NotificationCountBadge";
910
import { ColumnDef, SortingState } from "@tanstack/react-table";
1011
import useFetchApi from "@utils/api";
1112
import { 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

Comments
 (0)