/*
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 { Copy as ActionCopy } from '@/components/common/icons/ActionIcons';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Toast, Banner } from '@/components/ui';
import { copy as copyText } from '../../helpers/utils';
/**
* 企业建号一次性凭证展示面板(注册自助建号 / 管理员建号复用)。
* props:
* creds: { status?, org_code, org_name, owner_login_name, initial_password }
* onLogin?: () => void 存在时展示「立即登录」按钮
*/
const OrgCredentialResult = ({ creds, onLogin }) => {
const { t } = useTranslation();
if (!creds) return null;
const isPending = creds.status === 'pending';
const copy = async (val) => {
if (await copyText(val)) {
Toast.success(t('已复制到剪贴板'));
} else {
Toast.error(t('复制失败,请手动复制'));
}
};
// 四项凭证拼成带标签的文本块一次复制,避免逐项复制的遗漏(如只记了密码没记企业代码)
const copyAll = () => {
copy(
[
`${t('企业代码')}: ${creds.org_code}`,
`${t('企业名称')}: ${creds.org_name}`,
`${t('登录名')}: ${creds.owner_login_name}`,
`${t('初始密码')}: ${creds.initial_password}`,
].join('\n'),
);
};
const Row = ({ label, value, mono }) => (