make reported user nullable
All checks were successful
delpoy / build-and-deploy (push) Successful in 44s

This commit is contained in:
2023-11-03 18:10:02 +01:00
parent 72eeb59230
commit 81d97380ca
11 changed files with 107 additions and 65 deletions

18
src/lib/utils.ts Normal file
View File

@@ -0,0 +1,18 @@
import { env } from '$env/dynamic/public';
export async function usernameSuggestions(
username: string
): Promise<{ name: string; value: string }[]> {
const response = await fetch(`${env.PUBLIC_BASE_PATH}/admin/users`, {
method: 'POST',
body: JSON.stringify({
limit: 6,
search: username,
slim: true
})
});
const json: { username: string; uuid: string }[] = await response.json();
return json.map((v) => {
return { name: v.username, value: v.uuid };
});
}