l-min-components 1.6.1240 → 1.6.1245
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -62,7 +62,7 @@ const ChatHeader = ({
|
|
|
62
62
|
{chatRecipient?.is_online && <span className="online-dot"></span>}
|
|
63
63
|
</div>
|
|
64
64
|
<div className="user-details">
|
|
65
|
-
<h5>{chatRecipient?.course
|
|
65
|
+
<h5>{courseName || chatRecipient?.course}</h5>
|
|
66
66
|
<div className="friend_cont">
|
|
67
67
|
{/* <div className="friend-tag">
|
|
68
68
|
<HiUser /> {userType}
|
|
@@ -32,7 +32,8 @@ const SideMenu = ({
|
|
|
32
32
|
// const [isOpen, setIsOpen] = useState(false);
|
|
33
33
|
const [gracePeriod, setGracePeriod] = useState(true);
|
|
34
34
|
|
|
35
|
-
const { setGeneralData, generalData } = useContext(OutletContext);
|
|
35
|
+
const { setGeneralData, generalData, messageKit } = useContext(OutletContext);
|
|
36
|
+
const { state } = messageKit;
|
|
36
37
|
const onToggle = () => {
|
|
37
38
|
setIsOpen(!isOpen);
|
|
38
39
|
window.localStorage.setItem("isOpen", !isOpen);
|
|
@@ -88,8 +89,11 @@ const SideMenu = ({
|
|
|
88
89
|
const InstructorRight = <InstructorRightBar />;
|
|
89
90
|
|
|
90
91
|
const renderNavigationItem = (route, index) => {
|
|
92
|
+
console.log(route, "route");
|
|
93
|
+
let notificationCount;
|
|
91
94
|
const { icon, iconActive, text, notifications, path, affiliates, newTab } =
|
|
92
95
|
route;
|
|
96
|
+
|
|
93
97
|
const handlePathCheck = () => {
|
|
94
98
|
let statusText;
|
|
95
99
|
//console.log(window.location.pathname, "pathname");
|
|
@@ -268,6 +272,11 @@ const SideMenu = ({
|
|
|
268
272
|
}
|
|
269
273
|
};
|
|
270
274
|
const active = handlePathCheck();
|
|
275
|
+
if (notifications && String(text).toLowerCase().includes("message")) {
|
|
276
|
+
notificationCount = state.roomsByCourses.reduce((acc, group) => {
|
|
277
|
+
return acc + group.total_unread_count;
|
|
278
|
+
}, 0);
|
|
279
|
+
}
|
|
271
280
|
|
|
272
281
|
return (
|
|
273
282
|
<NavigationItemContainer
|
|
@@ -280,16 +289,15 @@ const SideMenu = ({
|
|
|
280
289
|
}}
|
|
281
290
|
key={index}
|
|
282
291
|
className={cx(`${route.text} ${active && "active"}`)}
|
|
283
|
-
minimal={isOpen}
|
|
284
|
-
>
|
|
292
|
+
minimal={isOpen}>
|
|
285
293
|
<IconContainer active={active}>
|
|
286
294
|
{active ? iconActive : icon}
|
|
287
295
|
</IconContainer>
|
|
288
296
|
<TextContainer minimal={isOpen}>{findText(text)}</TextContainer>
|
|
289
297
|
|
|
290
|
-
{notifications && (
|
|
298
|
+
{!!notifications && (
|
|
291
299
|
<NotificationCount minimal={isOpen}>
|
|
292
|
-
<div className="text">{
|
|
300
|
+
<div className="text">{notificationCount}</div>
|
|
293
301
|
</NotificationCount>
|
|
294
302
|
)}
|
|
295
303
|
</NavigationItemContainer>
|
|
@@ -304,8 +312,7 @@ const SideMenu = ({
|
|
|
304
312
|
generalData?.selectedAccount?.type?.toLowerCase() === "enterprise"
|
|
305
313
|
? "grace_period disabled"
|
|
306
314
|
: ""
|
|
307
|
-
}
|
|
308
|
-
>
|
|
315
|
+
}>
|
|
309
316
|
<UserCard user={user} isOpen={isOpen} findText={findText} />
|
|
310
317
|
|
|
311
318
|
{!isPendingDelete && (
|
|
@@ -20,7 +20,6 @@ export const SideMenuContainer = styled.div`
|
|
|
20
20
|
|
|
21
21
|
&.disabled {
|
|
22
22
|
pointer-events: none;
|
|
23
|
-
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
.toggle {
|
|
@@ -99,10 +98,9 @@ export const NavigationItemContainer = styled.p`
|
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
background: var(--Neutral-40, #ADB2B2);
|
|
101
|
+
/* GRACE PERIOD AND DEACTIVATED */
|
|
102
|
+
&.grace_period {
|
|
103
|
+
background: var(--Neutral-40, #adb2b2);
|
|
106
104
|
margin: 2px 0px;
|
|
107
105
|
}
|
|
108
106
|
|
|
@@ -142,7 +140,7 @@ export const TextContainer = styled.div`
|
|
|
142
140
|
`;
|
|
143
141
|
|
|
144
142
|
export const NotificationCount = styled.div`
|
|
145
|
-
background-color:
|
|
143
|
+
background-color: rgba(254, 191, 16, 0.7);
|
|
146
144
|
color: #fff;
|
|
147
145
|
font-size: 12px;
|
|
148
146
|
font-weight: 500;
|
|
@@ -658,6 +658,69 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
658
658
|
|
|
659
659
|
// --- 2. Update State ---
|
|
660
660
|
setState((prevState) => {
|
|
661
|
+
// --- Check if room exists before updating state ---
|
|
662
|
+
let roomExistsInState = false;
|
|
663
|
+
for (const courseGroup of prevState.roomsByCourses) {
|
|
664
|
+
if (courseGroup.rooms.some((room) => room.id === roomId)) {
|
|
665
|
+
roomExistsInState = true;
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// If room doesn't exist, fetch rooms and skip this state update
|
|
671
|
+
if (!roomExistsInState) {
|
|
672
|
+
console.log(
|
|
673
|
+
`Room ${roomId} not found in state after sending message, refetching room list.`
|
|
674
|
+
);
|
|
675
|
+
getMessageRoomsByCourses(null, true); // Fetch room list
|
|
676
|
+
|
|
677
|
+
// --- Update chats state even if room metadata isn't found yet ---
|
|
678
|
+
const chatHistoryForMissingRoom = prevState.chats[roomId] || [];
|
|
679
|
+
let updatedChatHistoryForMissingRoom = [...chatHistoryForMissingRoom];
|
|
680
|
+
const todayDateStringForMissing = "today"; // Assume API uses "today"
|
|
681
|
+
|
|
682
|
+
const todayGroupIndexForMissing =
|
|
683
|
+
updatedChatHistoryForMissingRoom.findIndex(
|
|
684
|
+
(group) => group.date === todayDateStringForMissing
|
|
685
|
+
);
|
|
686
|
+
|
|
687
|
+
if (todayGroupIndexForMissing !== -1) {
|
|
688
|
+
const todayGroup =
|
|
689
|
+
updatedChatHistoryForMissingRoom[todayGroupIndexForMissing];
|
|
690
|
+
if (
|
|
691
|
+
!todayGroup.messages.some((msg) => msg.id === newChatMessage.id)
|
|
692
|
+
) {
|
|
693
|
+
const updatedTodayGroup = {
|
|
694
|
+
...todayGroup,
|
|
695
|
+
messages: [...todayGroup.messages, newChatMessage],
|
|
696
|
+
};
|
|
697
|
+
updatedChatHistoryForMissingRoom.splice(
|
|
698
|
+
todayGroupIndexForMissing,
|
|
699
|
+
1,
|
|
700
|
+
updatedTodayGroup
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
} else {
|
|
704
|
+
const newTodayGroup = {
|
|
705
|
+
date: todayDateStringForMissing,
|
|
706
|
+
messages: [newChatMessage],
|
|
707
|
+
};
|
|
708
|
+
updatedChatHistoryForMissingRoom = [
|
|
709
|
+
newTodayGroup,
|
|
710
|
+
...updatedChatHistoryForMissingRoom,
|
|
711
|
+
];
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const updatedChatsOnly = {
|
|
715
|
+
...prevState.chats,
|
|
716
|
+
[roomId]: updatedChatHistoryForMissingRoom,
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
// Return state with only chats updated, roomsByCourses will update after fetch
|
|
720
|
+
return { ...prevState, chats: updatedChatsOnly };
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// --- Room exists, proceed with updates for both chats and roomsByCourses ---
|
|
661
724
|
// --- 2a. Update chats state ---
|
|
662
725
|
const currentChatHistory = prevState.chats[roomId] || [];
|
|
663
726
|
let updatedChatHistory = [...currentChatHistory];
|
|
@@ -863,6 +926,39 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
863
926
|
setState(previousState);
|
|
864
927
|
}
|
|
865
928
|
};
|
|
929
|
+
const reportChat = async ({
|
|
930
|
+
reasons,
|
|
931
|
+
accountId,
|
|
932
|
+
messageIds,
|
|
933
|
+
others, // optional
|
|
934
|
+
}) => {
|
|
935
|
+
let response;
|
|
936
|
+
const data = {
|
|
937
|
+
reasons,
|
|
938
|
+
account_id: accountId,
|
|
939
|
+
message_ids: messageIds,
|
|
940
|
+
others,
|
|
941
|
+
};
|
|
942
|
+
if (selectedAccount.type.toLowerCase() === "enterprise") {
|
|
943
|
+
console.log("Reporting chat in enterprise", data);
|
|
944
|
+
response = await request({
|
|
945
|
+
url: `/notify/v1/enterprise/chats/reports/`,
|
|
946
|
+
method: "post",
|
|
947
|
+
data,
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
if (
|
|
951
|
+
selectedAccount.type.toLowerCase() === "instructor" &&
|
|
952
|
+
affiliateAccount
|
|
953
|
+
) {
|
|
954
|
+
response = await request({
|
|
955
|
+
url: `/notify/v1/instructor/${affiliateAccount}/chats/reports/`,
|
|
956
|
+
method: "post",
|
|
957
|
+
data,
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
return response;
|
|
961
|
+
};
|
|
866
962
|
// Initial data fetch effect
|
|
867
963
|
useEffect(() => {
|
|
868
964
|
(async () => {
|
|
@@ -1089,6 +1185,7 @@ const useMessageKit = (/*affiliatesActive*/) => {
|
|
|
1089
1185
|
removeAutoReadRooms, // Expose new function
|
|
1090
1186
|
pinRoom,
|
|
1091
1187
|
deleteRoom,
|
|
1188
|
+
reportChat,
|
|
1092
1189
|
};
|
|
1093
1190
|
};
|
|
1094
1191
|
|