diff --git a/frontend/src/pages/settings/users.tsx b/frontend/src/pages/settings/users.tsx
index 1a1abb5f7..16254f86c 100644
--- a/frontend/src/pages/settings/users.tsx
+++ b/frontend/src/pages/settings/users.tsx
@@ -10,28 +10,35 @@ import {
useUser,
useWrite,
} from "@lib/hooks";
+import { filterBySplit } from "@lib/utils";
import { DataTable } from "@ui/data-table";
import { Input } from "@ui/input";
import { useToast } from "@ui/use-toast";
import { Search, User, Users } from "lucide-react";
-import { useState } from "react";
+import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
export const UsersPage = ({ goToProfile }: { goToProfile: () => void }) => {
useSetTitle("Users");
+ const [search, setSearch] = useState("");
return (
-
-
+
+
);
};
-const UserGroupsSection = () => {
+const UserGroupsSection = ({
+ search,
+ setSearch,
+}: {
+ search: string;
+ setSearch: React.Dispatch>;
+}) => {
const nav = useNavigate();
const groups = useRead("ListUserGroups", {}).data;
- const [search, setSearch] = useState("");
- const searchSplit = search.split(" ");
+ const filtered = filterBySplit(groups, search, (group) => group.name);
return (
}>
@@ -59,11 +66,7 @@ const UserGroupsSection = () => {
- searchSplit.every((term) => group.name.includes(term))
- ) ?? []
- }
+ data={filtered}
columns={[
{ header: "Name", accessorKey: "name" },
{
@@ -84,7 +87,13 @@ const UserGroupsSection = () => {
);
};
-const UsersSection = ({ goToProfile }: { goToProfile: () => void }) => {
+const UsersSection = ({
+ goToProfile,
+ search,
+}: {
+ goToProfile: () => void;
+ search: string;
+}) => {
const user = useUser().data;
const inv = useInvalidate();
const { toast } = useToast();
@@ -95,13 +104,12 @@ const UsersSection = ({ goToProfile }: { goToProfile: () => void }) => {
},
});
const users = useRead("ListUsers", {}).data;
- const [search, setSearch] = useState("");
- const searchSplit = search.split(" ");
+ const filtered = filterBySplit(users, search, (user) => user.username);
return (
}>
-
+ {/*
void }) => {
onChange={(e) => setSearch(e.target.value)}
className="pl-8 w-[200px] lg:w-[300px]"
/>
-
+
*/}
- searchSplit.every((term) => user.username.includes(term))
- ) ?? []
- }
+ users={filtered}
onUserDelete={
user?.admin ? (user_id) => deleteUser({ user: user_id }) : undefined
}