/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useState } from 'react';
import { Button, Popover, Typography, Modal } from '@douyinfe/semi-ui';
import { IconMail, IconShield, IconGithubLogo } from '@douyinfe/semi-icons';
import { Link2, ExternalLink, Check, X } from 'lucide-react';
import {
TelegramBrandIcon,
WechatBrandIcon,
LinuxBrandIcon,
DiscordBrandIcon,
} from '../../../common/icons/BrandIcons';
import TelegramLoginButton from 'react-telegram-login';
import {
onGitHubOAuthClicked,
onOIDCClicked,
onLinuxDOOAuthClicked,
onDiscordOAuthClicked,
} from '../../../../helpers';
// 绑定卡片配置
const BINDING_CARDS = [
{
key: 'email',
icon: IconMail,
gradient: 'from-blue-500 to-cyan-500',
panelClass:
'bg-gradient-to-br from-blue-50/78 to-cyan-50/70 dark:from-blue-500/[0.09] dark:to-cyan-400/[0.07]',
},
{
key: 'wechat',
icon: WechatBrandIcon,
gradient: 'from-green-500 to-emerald-500',
panelClass:
'bg-gradient-to-br from-green-50/78 to-emerald-50/70 dark:from-green-500/[0.09] dark:to-emerald-400/[0.07]',
isBrandIcon: true,
},
{
key: 'github',
icon: IconGithubLogo,
gradient: 'from-gray-700 to-gray-900',
panelClass:
'bg-gradient-to-br from-gray-50/88 to-slate-50/75 dark:from-slate-500/[0.10] dark:to-slate-700/[0.10]',
},
{
key: 'discord',
icon: DiscordBrandIcon,
gradient: 'from-brand-from to-brand-to',
panelClass:
'bg-gradient-to-br from-brand-from/10 to-brand-to/10 dark:from-brand-from/[0.14] dark:to-brand-to/[0.12]',
isBrandIcon: true,
},
{
key: 'oidc',
icon: IconShield,
gradient: 'from-orange-500 to-red-500',
panelClass:
'bg-gradient-to-br from-orange-50/78 to-red-50/70 dark:from-orange-500/[0.10] dark:to-red-500/[0.08]',
},
{
key: 'telegram',
icon: TelegramBrandIcon,
gradient: 'from-sky-500 to-blue-500',
panelClass:
'bg-gradient-to-br from-sky-50/78 to-blue-50/70 dark:from-sky-500/[0.10] dark:to-blue-500/[0.08]',
isBrandIcon: true,
},
{
key: 'linuxdo',
icon: LinuxBrandIcon,
gradient: 'from-yellow-500 to-orange-500',
panelClass:
'bg-gradient-to-br from-yellow-50/78 to-orange-50/70 dark:from-yellow-500/[0.10] dark:to-orange-500/[0.08]',
isBrandIcon: true,
},
];
const AccountBindingSection = ({
t,
userState,
status,
setShowEmailBindModal,
setShowWeChatBindModal,
}) => {
const [showTelegramBindModal, setShowTelegramBindModal] = useState(false);
const isBound = (accountId) => Boolean(accountId);
const renderAccountInfo = (accountId, label) => {
if (!accountId || accountId === '') {
return {t('未绑定')};
}
const popContent = (