Skip to content

Commit f1df1f4

Browse files
committed
Fix errors
1 parent a1fd776 commit f1df1f4

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/client/admin/admin.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff 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 = {

0 commit comments

Comments
 (0)