diff --git a/src/components/common/Avatar.jsx b/src/components/common/Avatar.jsx index 537af159..81e16e9c 100644 --- a/src/components/common/Avatar.jsx +++ b/src/components/common/Avatar.jsx @@ -1,22 +1,21 @@ import React, { useState, useEffect } from "react"; -// A simple hash function to generate a deterministic value from the name -function hashString(str) { - let hash = 0; - for (let i = 0; i < str.length; i++) { - const char = str.charCodeAt(i); - hash = (hash << 5) - hash + char; - } - return hash; -} - -const Avatar = ({ firstName, lastName, size='sm' }) => { +const Avatar = ({ firstName, lastName }) => { // Combine firstName and lastName to create a unique string for hashing const fullName = `${firstName} ${lastName}`; const [bgClass, setBgClass] = useState(""); - // Function to generate the avatar text + // A simple hash function to generate a deterministic value from the name + function hashString(str) { + let hash = 0; + for (let i = 0; i < str.length; i++) { + const char = str.charCodeAt(i); + hash = (hash << 5) - hash + char; + } + return hash; + } + function generateAvatarText(firstName, lastName) { if (!firstName) return ""; if (!lastName || lastName.trim() === "") { @@ -50,15 +49,15 @@ const Avatar = ({ firstName, lastName, size='sm' }) => { }, [fullName]); // Re-run if the fullName changes return ( -