feat: better handle friend code input

This commit is contained in:
Zamitto
2025-05-30 08:40:55 -03:00
parent 6757ebe13c
commit 5305e5ca18
4 changed files with 14 additions and 9 deletions

View File

@@ -500,7 +500,8 @@
"achievements_unlocked": "Achievements Unlocked",
"earned_points": "Earned points",
"show_achievements_on_profile": "Show your achievements on your profile",
"show_points_on_profile": "Show your earned points on your profile"
"show_points_on_profile": "Show your earned points on your profile",
"error_adding_friend": "Could not send friend request. Please check friend code"
},
"achievement": {
"achievement_unlocked": "Achievement unlocked",

View File

@@ -493,7 +493,8 @@
"achievements_unlocked": "Conquistas desbloqueadas",
"earned_points": "Pontos ganhos",
"show_achievements_on_profile": "Exiba suas conquistas no perfil",
"show_points_on_profile": "Exiba seus pontos ganhos no perfil"
"show_points_on_profile": "Exiba seus pontos ganhos no perfil",
"error_adding_friend": "Não foi possível enviar o pedido de amizade. Verifique o código de amizade inserido"
},
"achievement": {
"achievement_unlocked": "Conquista desbloqueada",

View File

@@ -4,7 +4,8 @@ import { SystemPath } from "./services/system-path";
export const defaultDownloadsPath = SystemPath.getPath("downloads");
export const isStaging = import.meta.env.MAIN_VITE_API_URL.includes("staging");
export const isStaging =
true || import.meta.env.MAIN_VITE_API_URL.includes("staging");
export const windowsStartMenuPath = path.join(
SystemPath.getPath("appData"),

View File

@@ -29,11 +29,10 @@ export const UserFriendModalAddFriend = ({
setIsAddingFriend(true);
sendFriendRequest(friendCode)
.then(() => {
// TODO: add validation for this input?
setFriendCode("");
})
.catch(() => {
showErrorToast("Não foi possível enviar o pedido de amizade");
showErrorToast(t("error_adding_friend"));
})
.finally(() => {
setIsAddingFriend(false);
@@ -46,8 +45,8 @@ export const UserFriendModalAddFriend = ({
};
const handleClickSeeProfile = () => {
closeModal();
if (friendCode.length === 8) {
closeModal();
navigate(`/profile/${friendCode}`);
}
};
@@ -74,16 +73,19 @@ export const UserFriendModalAddFriend = ({
});
};
const handleChangeFriendCode = (e: React.ChangeEvent<HTMLInputElement>) => {
const friendCode = e.target.value.trim().slice(0, 8);
setFriendCode(friendCode);
};
return (
<>
<div className="user-friend-modal-add-friend__actions">
<TextField
label={t("friend_code")}
value={friendCode}
minLength={8}
maxLength={8}
containerProps={{ style: { width: "100%" } }}
onChange={(e) => setFriendCode(e.target.value)}
onChange={handleChangeFriendCode}
/>
<Button
disabled={isAddingFriend}