mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-11 08:05:56 +08:00
check user is known on addFriend modal
This commit is contained in:
parent
5dd4e57bd1
commit
d08db79036
1 changed files with 21 additions and 1 deletions
|
@ -65,7 +65,27 @@ export async function addFriend(friendName: string): Promise<true | string> {
|
|||
const addFriendModal = new SimpleModal({
|
||||
id: "addFriend",
|
||||
title: "Add a friend",
|
||||
inputs: [{ placeholder: "user name", type: "text", initVal: "" }],
|
||||
inputs: [
|
||||
{
|
||||
placeholder: "user name",
|
||||
type: "text",
|
||||
initVal: "",
|
||||
validation: {
|
||||
isValid: async (name: string) => {
|
||||
const checkNameResponse = await Ape.users.getNameAvailability({
|
||||
params: { name: name },
|
||||
});
|
||||
|
||||
return (
|
||||
(checkNameResponse.status === 200 &&
|
||||
!checkNameResponse.body.data.available) ||
|
||||
"Unknown user"
|
||||
);
|
||||
},
|
||||
debounceDelay: 1000,
|
||||
},
|
||||
},
|
||||
],
|
||||
buttonText: "request",
|
||||
onlineOnly: true,
|
||||
execFn: async (_thisPopup, friendName) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue