jan/web-app/src/containers/AvatarEmoji.tsx
Faisal Amir 135e75b812
fix: avatar assistants render (#5181)
* fix: avatar assistants render

* fix: delete assistant

* Update web-app/src/containers/dialogs/AddEditAssistant.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-03 20:00:25 +07:00

31 lines
796 B
TypeScript

import React from 'react'
/**
* Checks if an avatar is a custom image (starts with '/images/')
*/
const isCustomImageAvatar = (avatar: React.ReactNode): avatar is string => {
return typeof avatar === 'string' && avatar.startsWith('/images/')
}
/**
* Component for rendering assistant avatars with consistent styling
*/
interface AvatarEmojiProps {
avatar?: React.ReactNode
imageClassName?: string
textClassName?: string
}
export const AvatarEmoji: React.FC<AvatarEmojiProps> = ({
avatar,
imageClassName = 'w-5 h-5 object-contain',
textClassName = 'text-base',
}) => {
if (!avatar) return null
if (isCustomImageAvatar(avatar)) {
return <img src={avatar} alt="Custom avatar" className={imageClassName} />
}
return <span className={textClassName}>{avatar}</span>
}