File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,7 +64,14 @@ export default function Admin (props: any): JSX.Element {
6464 fetch ( `/api/user?id=${ txt } ` , undefined , 'GET' )
6565 . then ( ( res ) => {
6666 setLoading ( '' )
67- setUsers ( [ res . user ] )
67+ if ( res . user !== undefined ) {
68+ setUsers ( [ res . user ] )
69+ setCount ( 1 )
70+ } else {
71+ setUsers ( [ ] ) // Set to empty array if no user found
72+ setCount ( 0 )
73+ void message . info ( 'No user found' ) // Optionally inform the user
74+ }
6875 } )
6976 . catch ( e => {
7077 setLoading ( '' )
@@ -120,13 +127,7 @@ export default function Admin (props: any): JSX.Element {
120127 }
121128
122129 function onChangeSearch ( txt : string ) : void {
123- setTxt ( oldTxt => {
124- if ( oldTxt !== txt && txt === '' ) {
125- getUsers ( )
126- return txt
127- }
128- return oldTxt
129- } )
130+ setTxt ( txt )
130131 }
131132
132133 const usersProps = {
You can’t perform that action at this time.
0 commit comments