feat: Add user icon in messages (#275)

* Update GPT4 model icon

* Add user icon support in messages
This commit is contained in:
David Shin 2023-05-16 00:51:58 +09:00 committed by GitHub
parent 9f36e195bc
commit 3120602d6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,25 +3,28 @@ import React from 'react';
import { twMerge } from 'tailwind-merge';
import GPTIcon from '../components/svg/GPTIcon';
import BingIcon from '../components/svg/BingIcon';
import { useAuthContext } from '~/hooks/AuthContext';
const getIcon = props => {
// { size = 30, isCreatedByUser, model, chatGptLabel, error, ...props }
const { size = 30, isCreatedByUser, button, model } = props;
const { user, logout } = useAuthContext();
if (isCreatedByUser)
return (
<div
title="User"
title={user.name}
style={{
background: 'radial-gradient(circle at 90% 110%, rgb(1 43 128), rgb(17, 139, 161))',
color: 'white',
fontSize: 12,
width: size,
height: size
}}
className={`relative flex items-center justify-center rounded-sm text-white ` + props?.className}
className={`relative flex items-center justify-center` + props?.className}
>
User
<img
className="rounded-sm"
src={user?.avatar || `https://avatars.dicebear.com/api/initials/${user?.name}.svg`}
alt=""
/>
</div>
);
else if (!isCreatedByUser) {