🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
'use client';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { marketplaceAppPath } from '@/features/Marketplace/paths';
import { buildDiscordOpenBotUrl } from '../../constants';
import {
ConfirmCard,
type ExistingLink,
type InfoRow,
type PeekedToken,
type PlatformMeta,
SuccessCard,
} from './shared';
import { isSingleAccountRebindBlocked, shouldShowSingleAccountSuccess } from './singleAccountState';
interface DiscordBodyProps {
existingLink?: ExistingLink | null;
lobeAccount: string;
platformMeta?: PlatformMeta;
randomId: string;
signInUrl: string;
tokenData?: PeekedToken | null;
userAvatar?: string | null;
}
const DiscordBody = memo<DiscordBodyProps>(
({ existingLink, lobeAccount, platformMeta, randomId, signInUrl, tokenData, userAvatar }) => {
const { t } = useTranslation('messenger');
const [done, setDone] = useState(false);
const platformLabel = platformMeta?.name ?? 'Discord';
const appId = platformMeta?.appId;
const rebindBlocked = isSingleAccountRebindBlocked(existingLink, tokenData);
if (shouldShowSingleAccountSuccess(existingLink, tokenData, done)) {
return (
<SuccessCard
openBotUrl={appId ? buildDiscordOpenBotUrl(appId) : null}
platform="discord"
platformLabel={platformLabel}
/>
);
}
if (!tokenData) return null;
const handle = tokenData.platformUsername ?? `ID ${tokenData.platformUserId}`;
const infoRows: InfoRow[] = [
{ label: t('verify.confirm.fields.lobeHubAccount'), value: lobeAccount },
{
label: t('verify.confirm.fields.platformAccount', { platform: platformLabel }),
value: handle,
},
];
if (tokenData.tenantName) {
infoRows.push({ label: t('verify.confirm.fields.workspace'), value: tokenData.tenantName });
}
return (
<ConfirmCard
infoRows={infoRows}
platform="discord"
randomId={randomId}
userAvatar={userAvatar}
blockingNotice={
rebindBlocked
? {
ctaHref: marketplaceAppPath('discord'),
ctaLabel: t('verify.confirm.relink.openApp'),
description: t('verify.confirm.relink.disconnectInMarketplace', {
account:
existingLink?.platformUsername ?? `ID ${existingLink?.platformUserId ?? ''}`,
platform: platformLabel,
}),
title: t('verify.confirm.relink.title', { platform: platformLabel }),
}
: tokenData.linkedToEmail
? {
ctaHref: signInUrl,
ctaLabel: t('verify.confirm.conflict.switchAccount'),
description: t('verify.confirm.conflict.description', {
email: tokenData.linkedToEmail,
platform: platformLabel,
}),
title: t('verify.confirm.conflict.title'),
}
: undefined
}
onSuccess={() => setDone(true)}
/>
);
},
);
DiscordBody.displayName = 'MessengerVerifyDiscordBody';
export default DiscordBody;