From a196b91cb9a744b6bac644611de51ea60a7328b4 Mon Sep 17 00:00:00 2001
From: Zamitto <167933696+zamitto@users.noreply.github.com>
Date: Tue, 23 Jul 2024 20:27:38 -0300
Subject: [PATCH] feat: pass userId to modal
---
src/preload/index.ts | 3 +-
src/renderer/src/app.tsx | 16 +++++---
.../components/sidebar/sidebar-profile.tsx | 4 +-
src/renderer/src/declaration.d.ts | 6 ++-
.../src/features/user-details-slice.ts | 7 +++-
src/renderer/src/hooks/use-user-details.ts | 6 ++-
.../user-friend-modal-list.tsx | 40 ++++++++++++++++++
.../user-friend-modal/user-friend-modal.tsx | 41 +++++++++++--------
src/renderer/src/pages/user/user-content.tsx | 12 +++++-
9 files changed, 104 insertions(+), 31 deletions(-)
create mode 100644 src/renderer/src/pages/shared-modals/user-friend-modal/user-friend-modal-list.tsx
diff --git a/src/preload/index.ts b/src/preload/index.ts
index e6dafe0f..cd3b9686 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -145,7 +145,8 @@ contextBridge.exposeInMainWorld("electron", {
/* User */
getUser: (userId: string) => ipcRenderer.invoke("getUser", userId),
- getUserFriends: (userId: string) => ipcRenderer.invoke("getUserFriends", userId),
+ getUserFriends: (userId: string, take: number, skip: number) =>
+ ipcRenderer.invoke("getUserFriends", userId, take, skip),
/* Auth */
signOut: () => ipcRenderer.invoke("signOut"),
diff --git a/src/renderer/src/app.tsx b/src/renderer/src/app.tsx
index 689a338e..8c6f7604 100644
--- a/src/renderer/src/app.tsx
+++ b/src/renderer/src/app.tsx
@@ -42,11 +42,12 @@ export function App() {
const {
isFriendsModalVisible,
friendRequetsModalTab,
+ friendModalUserId,
fetchFriendRequests,
hideFriendsModal,
} = useUserDetails();
- const { fetchUserDetails, updateUserDetails, clearUserDetails } =
+ const { userDetails, fetchUserDetails, updateUserDetails, clearUserDetails } =
useUserDetails();
const dispatch = useAppDispatch();
@@ -218,11 +219,14 @@ export function App() {
onClose={handleToastClose}
/>
-
+ {userDetails && (
+
+ )}
diff --git a/src/renderer/src/components/sidebar/sidebar-profile.tsx b/src/renderer/src/components/sidebar/sidebar-profile.tsx
index 66c4d82d..3ff598f7 100644
--- a/src/renderer/src/components/sidebar/sidebar-profile.tsx
+++ b/src/renderer/src/components/sidebar/sidebar-profile.tsx
@@ -84,7 +84,9 @@ export function SidebarProfile() {