File size: 1,426 Bytes
17bca00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// src/components/Sidebar/UserInfo.jsx
import React from 'react';

const UserInfo = ({ currentUser }) => {
  // Sử dụng ảnh mặc định nếu currentUser không có hoặc không có avatar
  const avatarUrl = currentUser?.avatar || `https://ui-avatars.com/api/?name=${currentUser?.name || 'User'}&background=ffffff&color=3b82f6`;
  const userName = currentUser?.name || 'Đang tải...';
  const userRole = currentUser?.role || 'Đang tải...';
  const userId = currentUser?.id || ''; // Giả sử currentUser có id

  return (
    <div className="flex items-center px-4 py-3 mb-6 bg-blue-700 bg-opacity-30 rounded-lg">
      <img
        id="user-avatar"
        className="w-10 h-10 rounded-full"
        src={avatarUrl}
        alt="User Avatar"
      />
      <div className="ml-3 flex-shrink-0">
        <p id="user-name" className="text-sm font-medium text-white bold">
          {userName}
        </p>
        <p id="user-role" className="text-xs text-blue-100 break-words">
          {userRole}
        </p>
        {userId && (
          <p
            id="user-id"
            className="text-xs text-blue-100 break-words"
            style={{ wordBreak: 'break-all' }}
          >
            {/* Có thể bạn không muốn hiển thị User ID ở đây, tùy theo thiết kế */}
            {/* ID: {userId} */}
          </p>
        )}
      </div>
    </div>
  );
};

export default UserInfo;