Skip to content

Commit 0a1181a

Browse files
New Chat Connections Fetched and in chat box profile details show with click the chat connection
1 parent 61803ea commit 0a1181a

File tree

6 files changed

+156
-187
lines changed

6 files changed

+156
-187
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socialbook-frontend",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"private": true,
55
"dependencies": {
66
"@testing-library/jest-dom": "^5.16.1",

src/component/common/buttons.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export const AcceptButton = ({ darkMode, onClickOperation, customClassName }) => {
1+
export const AcceptButton = ({
2+
darkMode,
3+
onClickOperation,
4+
customClassName,
5+
}) => {
26
return (
37
<button
48
className={`${
@@ -12,7 +16,11 @@ export const AcceptButton = ({ darkMode, onClickOperation, customClassName }) =>
1216
);
1317
};
1418

15-
export const ConnectButton = ({ darkMode, onClickOperation, customClassName }) => {
19+
export const ConnectButton = ({
20+
darkMode,
21+
onClickOperation,
22+
customClassName,
23+
}) => {
1624
return (
1725
<button
1826
className={`${
@@ -26,7 +34,11 @@ export const ConnectButton = ({ darkMode, onClickOperation, customClassName }) =
2634
);
2735
};
2836

29-
export const CancelButton = ({ darkMode, onClickOperation, customClassName }) => {
37+
export const CancelButton = ({
38+
darkMode,
39+
onClickOperation,
40+
customClassName,
41+
}) => {
3042
return (
3143
<button
3244
className={`${
@@ -40,12 +52,16 @@ export const CancelButton = ({ darkMode, onClickOperation, customClassName }) =>
4052
);
4153
};
4254

43-
export const MessageButton = ({ darkMode, onClickOperation, customClassName }) => {
55+
export const MessageButton = ({
56+
darkMode,
57+
onClickOperation,
58+
customClassName,
59+
}) => {
4460
return (
4561
<button
4662
className={`${
4763
darkMode ? "hover:bg-blue-800" : "hover:bg-blue-400"
48-
} text-lightPrimaryFgColor dark:text-darkPrimaryFgColor px-2 py-1 rounded-3xl border-darkPrimaryFgColor hover:bg-opacity-30 transition-all duration-300 sm:ml-3 w-full hover:shadow-sm hover:shadow-darkPrimaryFgColor ${customClassName}`}
64+
} text-lightPrimaryFgColor dark:text-darkPrimaryFgColor px-2 py-1 rounded-3xl border-darkPrimaryFgColor hover:bg-opacity-30 transition-all duration-300 sm:ml-3 w-full ${customClassName}`}
4965
style={{ borderWidth: "0.2px" }}
5066
onClick={onClickOperation}
5167
>

src/component/connection/connection-common-layout.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const ConnectionCollectionItem = ({
3434
connectionType={connectionType}
3535
partnerUserId={user.id}
3636
setCollectiveIds={setCollectiveIds}
37+
userData = {user}
3738
/>
3839
</div>
3940
</div>
@@ -45,13 +46,15 @@ const ButtonCollectionPrediction = ({
4546
darkMode,
4647
partnerUserId,
4748
setCollectiveIds,
49+
userData
4850
}) => {
4951
if (connectionType === ConnectionType.AlreadyConnected) {
5052
return (
5153
<ConnectedUsersButtonCollection
5254
darkMode={darkMode}
5355
partnerUserId={partnerUserId}
5456
setCollectiveIds={setCollectiveIds}
57+
userData={userData}
5558
/>
5659
);
5760
} else if (connectionType === ConnectionType.RequestReceived) {
@@ -114,12 +117,15 @@ const ConnectedUsersButtonCollection = ({
114117
darkMode,
115118
partnerUserId,
116119
setCollectiveIds,
120+
userData
117121
}) => {
118122
// ** NOTE: Message Button Will be redirect to the specific chat..
119123
// ** We will do it after implement chat feature.
120124

125+
const {name, profilePic, description} = userData;
126+
121127
const onMessageButtonClick = () => {
122-
getChatBoxId(partnerUserId)
128+
getChatBoxId(partnerUserId, name, description, profilePic)
123129
.then((data) => {
124130
console.log("Chat Box Id is: ", data);
125131
})

src/component/messaging-section/helper/api_call.js

+32-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { getDataFromLocalStorage } from "../../common/local-storage-management";
33

44
import { errorMessage } from "../../common/desktop-notification";
55

6-
export const getChatBoxId = async (partnerId) => {
7-
const { user, token } = getDataFromLocalStorage();
6+
export const getChatBoxId = async (
7+
partnerId,
8+
partnerName,
9+
partnerDescription,
10+
partnerProfilePic
11+
) => {
12+
const { user, token, name, description, profilePic } =
13+
getDataFromLocalStorage();
814

915
const res = await fetch(`${API}/messaging/getChatBoxId/${user}`, {
1016
method: "POST",
@@ -14,6 +20,12 @@ export const getChatBoxId = async (partnerId) => {
1420
},
1521
body: JSON.stringify({
1622
partnerId,
23+
partnerName,
24+
partnerDescription,
25+
partnerProfilePic,
26+
currentName: name,
27+
currentDescription: description,
28+
currentProfilePic: profilePic,
1729
}),
1830
});
1931

@@ -27,8 +39,23 @@ export const getChatBoxId = async (partnerId) => {
2739
return data.chatBoxId;
2840
};
2941

30-
31-
// TODO: Do it //
3242
export const getAllChatConnections = async () => {
43+
const { token, user } = getDataFromLocalStorage();
44+
45+
const res = await fetch(`${API}/messaging/getAllChatConnections/${user}`, {
46+
method: "GET",
47+
headers: {
48+
"Content-Type": "application/json",
49+
Authorization: `Bearer ${token}`,
50+
},
51+
});
3352

34-
}
53+
const data = await res.json();
54+
55+
if (data.code !== 200) {
56+
errorMessage(data.message);
57+
return;
58+
}
59+
60+
return data.chatConnections;
61+
};

0 commit comments

Comments
 (0)