From 599ce12424bf63c3772c08011fa4977081159090 Mon Sep 17 00:00:00 2001 From: camw0 Date: Fri, 25 Oct 2024 01:04:18 +0100 Subject: [PATCH] (ui): add search functionality to users list --- resources/js/Pages/Users/Index.tsx | 112 ++++++++++++++++++----------- 1 file changed, 69 insertions(+), 43 deletions(-) diff --git a/resources/js/Pages/Users/Index.tsx b/resources/js/Pages/Users/Index.tsx index f69e248..9fec1c4 100644 --- a/resources/js/Pages/Users/Index.tsx +++ b/resources/js/Pages/Users/Index.tsx @@ -2,62 +2,88 @@ import PrimaryButton from '@/Components/PrimaryButton'; import { Body, Head } from '@/Components/Table'; import Authenticated from '@/Layouts/AuthenticatedLayout'; import { PageProps, User } from '@/types'; +import { MagnifyingGlassIcon } from '@heroicons/react/24/outline'; import { Link } from '@inertiajs/react'; import Avatar from 'boring-avatars'; +import { useState } from 'react'; export default function Index({ users }: PageProps<{ users: User[] }>) { + const [filter, setFilter] = useState(''); + return ( -
- - New User - +
+
+
+ +
+ { + if (e.currentTarget.value.length > 2) { + setFilter(e.currentTarget.value); + } else { + setFilter(''); + } + }} + required + /> +
+
+ + New User + +
- {users.map((user) => ( - - - -
-
- {user.name} +
+ + - - - - ))} + + + + ))}
x.email.startsWith(filter)) + .map((user) => ( +
+ +
+
+ {user.name} +
+
+ {user.email} +
-
- {user.email} +
+ {user.superuser ? 'Superuser' : 'Standard'} + +
+
{' '} + Online
- - -
- {user.superuser ? 'Superuser' : 'Standard'} - -
-
{' '} - Online -
-
- - Edit - -
+ + Edit + +