diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 99839304..917e5d75 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -248,6 +248,7 @@
"see_profile": "See profile",
"sending": "Sending",
"friend_request_sent": "Friend request sent",
- "friends": "Friends"
+ "friends": "Friends",
+ "friends_list": "Friends list"
}
}
diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json
index 19906e82..46fdf522 100644
--- a/src/locales/pt/translation.json
+++ b/src/locales/pt/translation.json
@@ -248,6 +248,7 @@
"friend_request_sent": "Pedido de amizade enviado",
"friends": "Amigos",
"add": "Adicionar",
- "sending": "Enviando"
+ "sending": "Enviando",
+ "friends_list": "Lista de amigos"
}
}
diff --git a/src/renderer/src/pages/shared-modals/user-friend-modal.tsx b/src/renderer/src/pages/shared-modals/user-friend-modal.tsx
deleted file mode 100644
index c8f870df..00000000
--- a/src/renderer/src/pages/shared-modals/user-friend-modal.tsx
+++ /dev/null
@@ -1,149 +0,0 @@
-import { Button, Modal, TextField } from "@renderer/components";
-import { SPACING_UNIT } from "@renderer/theme.css";
-import { useState } from "react";
-import { useToast, useUserDetails } from "@renderer/hooks";
-import { useTranslation } from "react-i18next";
-import { useNavigate } from "react-router-dom";
-import { UserFriendRequest } from "./user-friend-request";
-
-export interface UserAddFriendsModalProps {
- visible: boolean;
- onClose: () => void;
-}
-
-export const UserFriendModal = ({
- visible,
- onClose,
-}: UserAddFriendsModalProps) => {
- const { t } = useTranslation("user_profile");
-
- const [friendCode, setFriendCode] = useState("");
- const [isAddingFriend, setIsAddingFriend] = useState(false);
-
- const navigate = useNavigate();
-
- const { sendFriendRequest, updateFriendRequestState, friendRequests } =
- useUserDetails();
-
- const { showErrorToast } = useToast();
-
- const handleClickAddFriend = () => {
- setIsAddingFriend(true);
- sendFriendRequest(friendCode)
- .then(() => {
- setFriendCode("");
- })
- .catch(() => {
- showErrorToast("Não foi possível enviar o pedido de amizade");
- })
- .finally(() => {
- setIsAddingFriend(false);
- });
- };
-
- const handleClickRequest = (userId: string) => {
- resetAndClose();
- navigate(`/user/${userId}`);
- };
-
- const handleClickSeeProfile = () => {
- resetAndClose();
- navigate(`/user/${friendCode}`);
- };
-
- const handleClickCancelFriendRequest = (userId: string) => {
- updateFriendRequestState(userId, "CANCEL").catch(() => {
- showErrorToast("Falha ao cancelar convite");
- });
- };
-
- const handleClickAcceptFriendRequest = (userId: string) => {
- updateFriendRequestState(userId, "ACCEPTED").catch(() => {
- showErrorToast("Falha ao aceitar convite");
- });
- };
-
- const handleClickRefuseFriendRequest = (userId: string) => {
- updateFriendRequestState(userId, "REFUSED").catch(() => {
- showErrorToast("Falha ao recusar convite");
- });
- };
-
- const resetAndClose = () => {
- setFriendCode("");
- onClose();
- };
-
- return (
-
-
-
- setFriendCode(e.target.value)}
- />
-
-
-
-
-
-
Pendentes
- {friendRequests?.map((request) => {
- return (
-
- );
- })}
-
-
-
- );
-};
diff --git a/src/renderer/src/pages/shared-modals/user-friend-modal/index.ts b/src/renderer/src/pages/shared-modals/user-friend-modal/index.ts
new file mode 100644
index 00000000..c7484512
--- /dev/null
+++ b/src/renderer/src/pages/shared-modals/user-friend-modal/index.ts
@@ -0,0 +1 @@
+export * from "./user-friend-modal";
diff --git a/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal-add-friend.tsx b/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal-add-friend.tsx
new file mode 100644
index 00000000..45d3bc57
--- /dev/null
+++ b/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal-add-friend.tsx
@@ -0,0 +1,138 @@
+import { Button, TextField } from "@renderer/components";
+import { useToast, useUserDetails } from "@renderer/hooks";
+import { SPACING_UNIT } from "@renderer/theme.css";
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { useNavigate } from "react-router-dom";
+import { UserFriendRequest } from "./user-friend-request";
+
+export interface UserFriendModalAddFriendProps {
+ closeModal: () => void;
+}
+
+export const UserFriendModalAddFriend = ({
+ closeModal,
+}: UserFriendModalAddFriendProps) => {
+ const { t } = useTranslation("user_profile");
+
+ const [friendCode, setFriendCode] = useState("");
+ const [isAddingFriend, setIsAddingFriend] = useState(false);
+
+ const navigate = useNavigate();
+
+ const { sendFriendRequest, updateFriendRequestState, friendRequests } =
+ useUserDetails();
+
+ const { showErrorToast } = useToast();
+
+ const handleClickAddFriend = () => {
+ setIsAddingFriend(true);
+ sendFriendRequest(friendCode)
+ .then(() => {
+ setFriendCode("");
+ })
+ .catch(() => {
+ showErrorToast("Não foi possível enviar o pedido de amizade");
+ })
+ .finally(() => {
+ setIsAddingFriend(false);
+ });
+ };
+
+ const resetAndClose = () => {
+ setFriendCode("");
+ closeModal();
+ };
+
+ const handleClickRequest = (userId: string) => {
+ resetAndClose();
+ navigate(`/user/${userId}`);
+ };
+
+ const handleClickSeeProfile = () => {
+ resetAndClose();
+ navigate(`/user/${friendCode}`);
+ };
+
+ const handleClickCancelFriendRequest = (userId: string) => {
+ updateFriendRequestState(userId, "CANCEL").catch(() => {
+ showErrorToast("Falha ao cancelar convite");
+ });
+ };
+
+ const handleClickAcceptFriendRequest = (userId: string) => {
+ updateFriendRequestState(userId, "ACCEPTED").catch(() => {
+ showErrorToast("Falha ao aceitar convite");
+ });
+ };
+
+ const handleClickRefuseFriendRequest = (userId: string) => {
+ updateFriendRequestState(userId, "REFUSED").catch(() => {
+ showErrorToast("Falha ao recusar convite");
+ });
+ };
+
+ return (
+ <>
+
+ setFriendCode(e.target.value)}
+ />
+
+
+
+
+
+
Pendentes
+ {friendRequests?.map((request) => {
+ return (
+
+ );
+ })}
+
+ >
+ );
+};
diff --git a/src/renderer/src/pages/shared-modals/user-friend-modal.css.ts b/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal.css.ts
similarity index 97%
rename from src/renderer/src/pages/shared-modals/user-friend-modal.css.ts
rename to src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal.css.ts
index 717bc95f..b5b29963 100644
--- a/src/renderer/src/pages/shared-modals/user-friend-modal.css.ts
+++ b/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal.css.ts
@@ -1,4 +1,4 @@
-import { SPACING_UNIT, vars } from "../../theme.css";
+import { SPACING_UNIT, vars } from "../../../theme.css";
import { style } from "@vanilla-extract/css";
export const profileContentBox = style({
diff --git a/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal.tsx b/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal.tsx
new file mode 100644
index 00000000..0e66bc77
--- /dev/null
+++ b/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal.tsx
@@ -0,0 +1,58 @@
+import { Button, Modal } from "@renderer/components";
+import { SPACING_UNIT } from "@renderer/theme.css";
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { UserFriendModalAddFriend } from "./user-friend-modal-add-friend";
+
+export interface UserAddFriendsModalProps {
+ visible: boolean;
+ onClose: () => void;
+}
+
+export const UserFriendModal = ({
+ visible,
+ onClose,
+}: UserAddFriendsModalProps) => {
+ const { t } = useTranslation("user_profile");
+
+ const tabs = [t("add_friends"), t("friends_list")];
+
+ const [currentTabIndex, setCurrentTabIndex] = useState(0);
+
+ const renderTab = () => {
+ if (currentTabIndex == 0) {
+ return ;
+ }
+
+ return <>>;
+ };
+
+ return (
+
+
+
+ {tabs.map((tab, index) => {
+ return (
+
+ );
+ })}
+
+
{tabs[currentTabIndex]}
+ {renderTab()}
+
+
+ );
+};
diff --git a/src/renderer/src/pages/shared-modals/user-friend-request.tsx b/src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-request.tsx
similarity index 100%
rename from src/renderer/src/pages/shared-modals/user-friend-request.tsx
rename to src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-request.tsx