2
0

feat(bot): ️ Make multiple avatar possible

This commit is contained in:
Baptiste Arnaud
2022-06-25 18:26:14 +02:00
parent bd2b906bd3
commit d7b9bda5d5

View File

@@ -1,10 +1,12 @@
import React from 'react' import React, { useState } from 'react'
import { isDefined } from 'utils' import { isDefined } from 'utils'
import { DefaultAvatar } from './DefaultAvatar' import { DefaultAvatar } from './DefaultAvatar'
export const Avatar = ({ avatarSrc }: { avatarSrc?: string }): JSX.Element => { export const Avatar = ({ avatarSrc }: { avatarSrc?: string }): JSX.Element => {
if (avatarSrc === '') return <></> const [currentAvatarSrc] = useState(avatarSrc)
if (isDefined(avatarSrc))
if (currentAvatarSrc === '') return <></>
if (isDefined(currentAvatarSrc))
return ( return (
<figure <figure
className={ className={
@@ -12,7 +14,7 @@ export const Avatar = ({ avatarSrc }: { avatarSrc?: string }): JSX.Element => {
} }
> >
<img <img
src={avatarSrc} src={currentAvatarSrc}
alt="Bot avatar" alt="Bot avatar"
className="rounded-full object-cover w-full h-full" className="rounded-full object-cover w-full h-full"
/> />