diff --git a/src/renderer/src/pages/user/user-add-friends-modal.tsx b/src/renderer/src/pages/user/user-add-friends-modal.tsx index b61f293c..d980df43 100644 --- a/src/renderer/src/pages/user/user-add-friends-modal.tsx +++ b/src/renderer/src/pages/user/user-add-friends-modal.tsx @@ -25,13 +25,13 @@ export const UserAddFriendsModal = ({ const { sendFriendRequest, updateFriendRequestState, friendRequests } = useUserDetails(); - const { showSuccessToast, showErrorToast } = useToast(); + const { showErrorToast } = useToast(); const handleClickAddFriend = () => { setIsAddingFriend(true); sendFriendRequest(friendCode) .then(() => { - showSuccessToast(t("friend_request_sent")); + setFriendCode(""); }) .catch(() => { showErrorToast("Não foi possível enviar o pedido de amizade"); @@ -41,133 +41,109 @@ export const UserAddFriendsModal = ({ }); }; - const handleClickFriend = (userId: string) => { - //onClose(); - //navigate(`/user/${userId}`); + const handleClickRequest = (userId: string) => { + resetAndClose(); + navigate(`/user/${userId}`); }; const handleClickSeeProfile = () => { - onClose(); + resetAndClose(); navigate(`/user/${friendCode}`); }; - const handleClickCancelFriendRequest = ( - event: React.MouseEvent, - userId: string - ) => { - updateFriendRequestState(userId, "CANCEL") - .then(() => { - console.log("sucesso"); - }) - .catch(() => { - showErrorToast("Falha ao cancelar convite"); - }); + const handleClickCancelFriendRequest = (userId: string) => { + updateFriendRequestState(userId, "CANCEL").catch(() => { + showErrorToast("Falha ao cancelar convite"); + }); }; - const handleClickAcceptFriendRequest = ( - event: React.MouseEvent, - userId: string - ) => { + const handleClickAcceptFriendRequest = (userId: string) => { updateFriendRequestState(userId, "ACCEPTED").catch(() => { showErrorToast("Falha ao aceitar convite"); }); }; - const handleClickRefuseFriendRequest = ( - event: React.MouseEvent, - userId: string - ) => { - event.preventDefault(); + const handleClickRefuseFriendRequest = (userId: string) => { updateFriendRequestState(userId, "REFUSED").catch(() => { showErrorToast("Falha ao recusar convite"); }); }; - const resetModal = () => { + const resetAndClose = () => { setFriendCode(""); - }; - - const cleanFormAndClose = () => { - resetModal(); onClose(); }; return ( - <> - +
+ setFriendCode(e.target.value)} + /> + + +
+ +
-
- setFriendCode(e.target.value)} - /> - - -
- -
-

Pendentes

- {friendRequests?.map((request) => { - return ( - - ); - })} -
+

Pendentes

+ {friendRequests?.map((request) => { + return ( + + ); + })}
- - +
+
); }; diff --git a/src/renderer/src/pages/user/user-content.tsx b/src/renderer/src/pages/user/user-content.tsx index 2915a82a..d8019159 100644 --- a/src/renderer/src/pages/user/user-content.tsx +++ b/src/renderer/src/pages/user/user-content.tsx @@ -375,7 +375,7 @@ export function UserContent({ - ) : ( - <> - +

{displayName}

+ {isRequestSent ? "Pedido enviado" : "Pedido recebido"} + + + +
+ {isRequestSent ? ( - - )} - + ) : ( + <> + + + + )} +
+ ); }; diff --git a/src/renderer/src/pages/user/user.css.ts b/src/renderer/src/pages/user/user.css.ts index 19da3caf..8a56bd7d 100644 --- a/src/renderer/src/pages/user/user.css.ts +++ b/src/renderer/src/pages/user/user.css.ts @@ -178,21 +178,29 @@ export const gameListItem = style({ }, }); -export const friendListItem = style({ - color: vars.color.body, - display: "flex", - flexDirection: "row", - gap: `${SPACING_UNIT + SPACING_UNIT / 2}px`, +export const friendListContainer = style({ width: "100%", height: "54px", - padding: "0 8px", transition: "all ease 0.2s", - cursor: "pointer", + position: "relative", ":hover": { backgroundColor: "rgba(255, 255, 255, 0.15)", }, }); +export const friendListButton = style({ + display: "flex", + alignItems: "center", + position: "absolute", + cursor: "pointer", + height: "100%", + width: "100%", + flexDirection: "row", + color: vars.color.body, + gap: `${SPACING_UNIT + SPACING_UNIT / 2}px`, + padding: "0 8px", +}); + export const gameInformation = style({ display: "flex", flexDirection: "column",