🤯 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 { createStaticStyles, Flexbox } from '@lobehub/ui';
import { Form } from '@lobehub/ui/form';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { FormInput, FormPassword } from '@/components/FormInput';
import QrCodeAuth from './QrCodeAuth';
const styles = createStaticStyles(({ css }) => ({
header: css`
display: flex;
align-items: center;
margin-block-end: 16px;
`,
}));
const ReadOnlyField = memo<{
divider?: boolean;
label: string;
password?: boolean;
value?: string;
}>(({ divider, label, password, value }) => {
const InputComponent = password ? FormPassword : FormInput;
return (
<Form.Field divider={divider} label={label} layout="vertical">
<InputComponent readOnly value={value || ''} />
</Form.Field>
);
});
interface WechatConnectedInfoProps {
currentConfig: {
applicationId: string;
credentials: Record<string, string>;
};
disabled?: boolean;
onQrAuthenticated?: (credentials: { botId: string; botToken: string; userId: string }) => void;
}
const WechatConnectedInfo = memo<WechatConnectedInfoProps>(
({ currentConfig, disabled, onQrAuthenticated }) => {
const { t: _t } = useTranslation('agent');
const t = _t as (key: string) => string;
const shouldShowApplicationId =
!!currentConfig.applicationId &&
currentConfig.applicationId !== currentConfig.credentials.botId;
return (
<>
<div className={styles.header}>
<Flexbox gap={4}>
<div style={{ fontSize: 16, fontWeight: 600 }}>{t('channel.wechatConnectedInfo')}</div>
<div style={{ color: 'var(--lobe-color-text-secondary)', fontSize: 13 }}>
{t('channel.wechatManagedCredentials')}
</div>
</Flexbox>
</div>
{onQrAuthenticated && (
<QrCodeAuth
buttonType="default"
disabled={disabled}
showTips={false}
onAuthenticated={onQrAuthenticated}
/>
)}
{shouldShowApplicationId && (
<ReadOnlyField label={t('channel.applicationId')} value={currentConfig.applicationId} />
)}
{__DEV__ && (
<>
<ReadOnlyField
divider={shouldShowApplicationId}
label={t('channel.wechatBotId')}
value={currentConfig.credentials.botId}
/>
<ReadOnlyField
divider
password
label={t('channel.botToken')}
value={currentConfig.credentials.botToken}
/>
<ReadOnlyField
divider
label={t('channel.wechatUserId')}
value={currentConfig.credentials.userId}
/>
</>
)}
</>
);
},
);
export default WechatConnectedInfo;