feat(doctor-avatar): enhance DoctorAvatar component with initials formatting and integrate into ItemAppointment
This commit is contained in:
@@ -3,10 +3,11 @@ import { imageUrl } from "@/helper";
|
||||
|
||||
function getInitials(name) {
|
||||
if (!name) return "";
|
||||
const parts = name.trim().split(/\s+/).filter(Boolean);
|
||||
const cleanName = name.trim().replace(/^دکتر\s+/, "");
|
||||
const parts = cleanName.split(/\s+/).filter(Boolean);
|
||||
if (parts.length === 0) return "";
|
||||
if (parts.length === 1) return parts[0][0];
|
||||
return `${parts[0][0]}${parts[1][0]}`;
|
||||
return `${parts[0][0]} - ${parts[1][0]}`;
|
||||
}
|
||||
|
||||
function DoctorAvatar({ doctor, size = 72, className = "", priority = false }) {
|
||||
@@ -18,7 +19,9 @@ function DoctorAvatar({ doctor, size = 72, className = "", priority = false }) {
|
||||
style={{ width: size, height: size }}
|
||||
className={`flex items-center justify-center rounded-full bg-[#F8F8FF] text-[#3B3B3B] font-bold select-none ${className}`}
|
||||
>
|
||||
<span style={{ fontSize: size * 0.32 }}>{getInitials(doctor?.name)}</span>
|
||||
<span style={{ fontSize: size * 0.22 }} className="whitespace-nowrap">
|
||||
{getInitials(doctor?.name)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user