2aa9d73325
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
95 lines
3.1 KiB
React
95 lines
3.1 KiB
React
import React, { useEffect, useId, useState } from 'react';
|
|
import { Link, useLocation } from 'react-router-dom';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { Wallet } from 'lucide-react';
|
|
import { ChevronDown as ActionChevronDown } from '@/components/common/icons/ActionIcons';
|
|
import {
|
|
PARTNER_NAVIGATION,
|
|
partnerView,
|
|
} from '../CommissionV2/partnerNavigation';
|
|
|
|
export default function OrgCommissionNavigation({
|
|
collapsed,
|
|
expandSidebar,
|
|
query,
|
|
renderText,
|
|
onNavigate,
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const location = useLocation();
|
|
const active = location.pathname === '/org/commission';
|
|
const view = partnerView(location.search);
|
|
const [open, setOpen] = useState(active);
|
|
const submenuId = useId();
|
|
useEffect(() => {
|
|
if (active) setOpen(true);
|
|
}, [active, location.key]);
|
|
const expanded = !collapsed && (open || !!query);
|
|
const parentMatches = t('企业分佣').toLowerCase().includes(query);
|
|
const children = PARTNER_NAVIGATION.filter(
|
|
(item) =>
|
|
!query || parentMatches || t(item.label).toLowerCase().includes(query),
|
|
);
|
|
|
|
// 样式与控制台二级菜单一致(center-layout.css 的 .ui-console-submenu-*):父项 16px 图标 + 展开箭头,
|
|
// 子项无图标、与父项文字左对齐并带层级引导线;收起态点击先展开侧栏。
|
|
return (
|
|
<div className='ui-console-submenu org-commission-navigation'>
|
|
<button
|
|
type='button'
|
|
className='ui-center-menu-item ui-console-submenu-toggle'
|
|
data-child-active={active || undefined}
|
|
aria-label={t('企业分佣')}
|
|
title={collapsed ? t('企业分佣') : undefined}
|
|
aria-expanded={expanded}
|
|
aria-controls={submenuId}
|
|
onClick={() => {
|
|
if (collapsed) {
|
|
expandSidebar();
|
|
setOpen(true);
|
|
} else setOpen((value) => !value);
|
|
}}
|
|
>
|
|
<Wallet size={16} strokeWidth={1.5} aria-hidden='true' />
|
|
{!collapsed && (
|
|
<>
|
|
<span className='ui-center-menu-label'>
|
|
{renderText(t('企业分佣'))}
|
|
</span>
|
|
<ActionChevronDown
|
|
size={14}
|
|
className='ui-console-submenu-arrow'
|
|
aria-hidden
|
|
/>
|
|
</>
|
|
)}
|
|
</button>
|
|
<div
|
|
id={submenuId}
|
|
role='group'
|
|
aria-label={t('企业分佣')}
|
|
className='ui-org-group-items ui-console-submenu-items'
|
|
hidden={!expanded}
|
|
>
|
|
{children.map((item) => {
|
|
const selected = active && view === item.key;
|
|
return (
|
|
<Link
|
|
key={item.key}
|
|
to={`/org/commission?view=${item.key}`}
|
|
onClick={() => onNavigate?.()}
|
|
aria-current={selected ? 'page' : undefined}
|
|
data-active={selected || undefined}
|
|
className='ui-center-menu-item ui-console-submenu-item'
|
|
>
|
|
<span className='ui-center-menu-label'>
|
|
{renderText(t(item.label))}
|
|
</span>
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|