Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.5 KB
Raw Blame
'use client';

import { Flexbox, Tag } from '@lobehub/ui';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';

import { ModelTag, ProviderIcon } from '@/components/LobeIcons';
import { OFFICIAL_URL } from '@/const/url';

import ShareButton from '../../../../features/ShareButton';
import { useDetailContext } from '../../DetailProvider';
import ProviderConfig from './ProviderConfig';

const ActionButton = memo(() => {
  const { description, models = [], identifier, name } = useDetailContext();
  const { t } = useTranslation('providers');
  return (
    <Flexbox horizontal align={'center'} gap={8} width={'100%'}>
      <ProviderConfig />
      <ShareButton
        meta={{
          avatar: <ProviderIcon provider={identifier} size={64} type={'avatar'} />,
          desc: description
            ? t(`${identifier}.description`, { defaultValue: description })
            : undefined,
          tags: (
            <Flexbox horizontal align={'center'} gap={4} justify={'center'} wrap={'wrap'}>
              {models
                .slice(0, 4)
                .filter(Boolean)
                .map((item) => (
                  <ModelTag key={item.id} model={item.id} style={{ margin: 0 }} />
                ))}
              {models.length > 3 && <Tag>+{models.length - 3}</Tag>}
            </Flexbox>
          ),
          title: name,
          url: urlJoin(OFFICIAL_URL, '/community/provider', identifier as string),
        }}
      />
    </Flexbox>
  );
});

export default ActionButton;