Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
7bf1808
1
Parent(s): 8257090
ui: harden internal message identification with role updates and localStorage fallback
Browse files
frontend/apps/internal/src/components/TicketDetails.tsx
CHANGED
|
@@ -156,7 +156,11 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 156 |
const replyFileInputRef = useRef<HTMLInputElement>(null);
|
| 157 |
const scratchpadFileInputRef = useRef<HTMLInputElement>(null);
|
| 158 |
const userRole = user?.role?.toLowerCase() || "";
|
| 159 |
-
const isStaff = [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
const handleUpdateRCA = async () => {
|
| 162 |
if (!ticket) return;
|
|
@@ -1481,11 +1485,12 @@ export const TicketDetails: React.FC<TicketDetailsProps> = ({ initialTicket, onB
|
|
| 1481 |
{messages
|
| 1482 |
.filter(m => rightSidebarTab === 'notes' ? m.is_internal : !m.is_internal)
|
| 1483 |
.map((msg, i) => {
|
| 1484 |
-
//
|
| 1485 |
-
const
|
|
|
|
| 1486 |
const msgSenderId = String(msg.sender_id || '').toLowerCase();
|
| 1487 |
-
const userFullName = (user?.full_name || '').trim().toLowerCase();
|
| 1488 |
-
const msgSenderName = (msg.sender_name || '').trim().toLowerCase();
|
| 1489 |
|
| 1490 |
const isMe = !!((userId && msgSenderId && userId === msgSenderId) ||
|
| 1491 |
(userFullName && msgSenderName && userFullName === msgSenderName));
|
|
|
|
| 156 |
const replyFileInputRef = useRef<HTMLInputElement>(null);
|
| 157 |
const scratchpadFileInputRef = useRef<HTMLInputElement>(null);
|
| 158 |
const userRole = user?.role?.toLowerCase() || "";
|
| 159 |
+
const isStaff = [
|
| 160 |
+
'3sc_admin', '3sc_lead', '3sc_agent',
|
| 161 |
+
'sc_admin', 'sc_lead', 'sc_agent',
|
| 162 |
+
'superadmin'
|
| 163 |
+
].includes(userRole);
|
| 164 |
|
| 165 |
const handleUpdateRCA = async () => {
|
| 166 |
if (!ticket) return;
|
|
|
|
| 1485 |
{messages
|
| 1486 |
.filter(m => rightSidebarTab === 'notes' ? m.is_internal : !m.is_internal)
|
| 1487 |
.map((msg, i) => {
|
| 1488 |
+
// Ultimate Identification Layer: use context user with a direct localStorage fallback
|
| 1489 |
+
const savedUser = JSON.parse(localStorage.getItem('internal_user') || 'null');
|
| 1490 |
+
const userId = String(user?.id || savedUser?.id || '').toLowerCase();
|
| 1491 |
const msgSenderId = String(msg.sender_id || '').toLowerCase();
|
| 1492 |
+
const userFullName = String(user?.full_name || savedUser?.full_name || '').trim().toLowerCase();
|
| 1493 |
+
const msgSenderName = String(msg.sender_name || '').trim().toLowerCase();
|
| 1494 |
|
| 1495 |
const isMe = !!((userId && msgSenderId && userId === msgSenderId) ||
|
| 1496 |
(userFullName && msgSenderName && userFullName === msgSenderName));
|