300 lines
8.9 KiB
TypeScript
300 lines
8.9 KiB
TypeScript
/**
|
|
* Admin options hub page.
|
|
* Presents navigation cards to user management and application settings.
|
|
*/
|
|
import type { ElementType } from 'react';
|
|
import { Box, Card, CardActionArea, CardContent, Chip, Stack, Typography } from '@mui/material';
|
|
import PeopleOutlineRoundedIcon from '@mui/icons-material/PeopleOutlineRounded';
|
|
import SettingsOutlinedIcon from '@mui/icons-material/SettingsOutlined';
|
|
import CampaignRoundedIcon from '@mui/icons-material/CampaignRounded';
|
|
import InsightsRoundedIcon from '@mui/icons-material/InsightsRounded';
|
|
import AccountBalanceWalletRoundedIcon from '@mui/icons-material/AccountBalanceWalletRounded';
|
|
import GroupAddRoundedIcon from '@mui/icons-material/GroupAddRounded';
|
|
import ScienceRoundedIcon from '@mui/icons-material/ScienceRounded';
|
|
import IosShareRoundedIcon from '@mui/icons-material/IosShareRounded';
|
|
import VolunteerActivismRoundedIcon from '@mui/icons-material/VolunteerActivismRounded';
|
|
import PublicRoundedIcon from '@mui/icons-material/PublicRounded';
|
|
import LanRoundedIcon from '@mui/icons-material/LanRounded';
|
|
import SecurityRoundedIcon from '@mui/icons-material/SecurityRounded';
|
|
import ShieldRoundedIcon from '@mui/icons-material/ShieldRounded';
|
|
import HeadsetMicRoundedIcon from '@mui/icons-material/HeadsetMicRounded';
|
|
import HelpOutlineRoundedIcon from '@mui/icons-material/HelpOutlineRounded';
|
|
import AdminPanelSettingsRoundedIcon from '@mui/icons-material/AdminPanelSettingsRounded';
|
|
import ManageAccountsRoundedIcon from '@mui/icons-material/ManageAccountsRounded';
|
|
import RuleFolderRoundedIcon from '@mui/icons-material/RuleFolderRounded';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useAuth } from '../../shared/auth/AuthContext';
|
|
import { OPTIONS_CARD_PERMISSIONS } from '../../shared/auth/permissions';
|
|
|
|
type OptionCardKey =
|
|
| 'users'
|
|
| 'settings'
|
|
| 'catalog'
|
|
| 'treasury'
|
|
| 'approvalPolicies'
|
|
| 'referral'
|
|
| 'referralFraud'
|
|
| 'testWallet'
|
|
| 'shareCards'
|
|
| 'soloEncouragement'
|
|
| 'marketing'
|
|
| 'security'
|
|
| 'network'
|
|
| 'faq'
|
|
| 'support'
|
|
| 'countries'
|
|
| 'rbac'
|
|
| 'adminUsers';
|
|
|
|
type OptionCardConfig = {
|
|
key: OptionCardKey;
|
|
path: string;
|
|
icon: ElementType;
|
|
badgeKey: string;
|
|
badgeColor?: 'primary' | 'success' | 'info' | 'secondary' | 'error' | 'warning';
|
|
bg: string;
|
|
border: string;
|
|
iconColor?: 'error';
|
|
};
|
|
|
|
const OPTION_CARDS: OptionCardConfig[] = [
|
|
{
|
|
key: 'users',
|
|
path: '/admin/users',
|
|
icon: PeopleOutlineRoundedIcon,
|
|
badgeKey: 'admin',
|
|
badgeColor: 'primary',
|
|
bg: 'rgba(214,178,94,0.16)',
|
|
border: 'rgba(214,178,94,0.22)',
|
|
},
|
|
{
|
|
key: 'settings',
|
|
path: '/admin/settings',
|
|
icon: SettingsOutlinedIcon,
|
|
badgeKey: 'dynamic',
|
|
bg: 'rgba(124,92,255,0.16)',
|
|
border: 'rgba(124,92,255,0.22)',
|
|
},
|
|
{
|
|
key: 'catalog',
|
|
path: '/admin/catalog',
|
|
icon: CampaignRoundedIcon,
|
|
badgeKey: 'catalog',
|
|
badgeColor: 'success',
|
|
bg: 'rgba(76,175,80,0.16)',
|
|
border: 'rgba(76,175,80,0.22)',
|
|
},
|
|
{
|
|
key: 'treasury',
|
|
path: '/admin/treasury',
|
|
icon: AccountBalanceWalletRoundedIcon,
|
|
badgeKey: 'coldHot',
|
|
badgeColor: 'info',
|
|
bg: 'rgba(41,182,246,0.16)',
|
|
border: 'rgba(41,182,246,0.22)',
|
|
},
|
|
{
|
|
key: 'approvalPolicies',
|
|
path: '/admin/approval-policies',
|
|
icon: RuleFolderRoundedIcon,
|
|
badgeKey: 'nOfM',
|
|
badgeColor: 'warning',
|
|
bg: 'rgba(255,152,0,0.14)',
|
|
border: 'rgba(255,152,0,0.28)',
|
|
},
|
|
{
|
|
key: 'referral',
|
|
path: '/admin/referral',
|
|
icon: GroupAddRoundedIcon,
|
|
badgeKey: 'levelsBonus',
|
|
badgeColor: 'secondary',
|
|
bg: 'rgba(124,92,255,0.16)',
|
|
border: 'rgba(124,92,255,0.22)',
|
|
},
|
|
{
|
|
key: 'referralFraud',
|
|
path: '/admin/referral/fraud',
|
|
icon: ShieldRoundedIcon,
|
|
badgeKey: 'sybilReview',
|
|
badgeColor: 'error',
|
|
bg: 'rgba(244,67,54,0.12)',
|
|
border: 'rgba(244,67,54,0.22)',
|
|
iconColor: 'error',
|
|
},
|
|
{
|
|
key: 'testWallet',
|
|
path: '/admin/test-wallet',
|
|
icon: ScienceRoundedIcon,
|
|
badgeKey: 'playMoney',
|
|
badgeColor: 'success',
|
|
bg: 'rgba(76,175,80,0.16)',
|
|
border: 'rgba(76,175,80,0.22)',
|
|
},
|
|
{
|
|
key: 'shareCards',
|
|
path: '/admin/share-cards',
|
|
icon: IosShareRoundedIcon,
|
|
badgeKey: 'dynamic',
|
|
badgeColor: 'secondary',
|
|
bg: 'rgba(41,182,246,0.16)',
|
|
border: 'rgba(41,182,246,0.22)',
|
|
},
|
|
{
|
|
key: 'soloEncouragement',
|
|
path: '/admin/solo-encouragement',
|
|
icon: VolunteerActivismRoundedIcon,
|
|
badgeKey: 'soloBonus',
|
|
badgeColor: 'secondary',
|
|
bg: 'rgba(236,72,153,0.14)',
|
|
border: 'rgba(236,72,153,0.22)',
|
|
},
|
|
{
|
|
key: 'marketing',
|
|
path: '/admin/marketing',
|
|
icon: InsightsRoundedIcon,
|
|
badgeKey: 'catalog',
|
|
badgeColor: 'success',
|
|
bg: 'rgba(255,152,0,0.14)',
|
|
border: 'rgba(255,152,0,0.28)',
|
|
},
|
|
{
|
|
key: 'security',
|
|
path: '/admin/security',
|
|
icon: SecurityRoundedIcon,
|
|
badgeKey: 'alertsLedger',
|
|
badgeColor: 'warning',
|
|
bg: 'rgba(255,152,0,0.16)',
|
|
border: 'rgba(255,152,0,0.22)',
|
|
},
|
|
{
|
|
key: 'network',
|
|
path: '/admin/network',
|
|
icon: LanRoundedIcon,
|
|
badgeKey: 'admin',
|
|
badgeColor: 'primary',
|
|
bg: 'rgba(76,175,80,0.16)',
|
|
border: 'rgba(76,175,80,0.22)',
|
|
},
|
|
{
|
|
key: 'faq',
|
|
path: '/admin/faq',
|
|
icon: HelpOutlineRoundedIcon,
|
|
badgeKey: 'staff',
|
|
badgeColor: 'success',
|
|
bg: 'rgba(255,193,7,0.16)',
|
|
border: 'rgba(255,193,7,0.22)',
|
|
},
|
|
{
|
|
key: 'support',
|
|
path: '/admin/support',
|
|
icon: HeadsetMicRoundedIcon,
|
|
badgeKey: 'staff',
|
|
badgeColor: 'success',
|
|
bg: 'rgba(76,175,80,0.16)',
|
|
border: 'rgba(76,175,80,0.22)',
|
|
},
|
|
{
|
|
key: 'countries',
|
|
path: '/admin/countries',
|
|
icon: PublicRoundedIcon,
|
|
badgeKey: 'registration',
|
|
badgeColor: 'info',
|
|
bg: 'rgba(33,150,243,0.16)',
|
|
border: 'rgba(33,150,243,0.22)',
|
|
},
|
|
{
|
|
key: 'rbac',
|
|
path: '/admin/rbac',
|
|
icon: AdminPanelSettingsRoundedIcon,
|
|
badgeKey: 'accessControl',
|
|
badgeColor: 'secondary',
|
|
bg: 'rgba(124,92,255,0.16)',
|
|
border: 'rgba(124,92,255,0.22)',
|
|
},
|
|
{
|
|
key: 'adminUsers',
|
|
path: '/admin/admin-users',
|
|
icon: ManageAccountsRoundedIcon,
|
|
badgeKey: 'accessControl',
|
|
badgeColor: 'secondary',
|
|
bg: 'rgba(214,178,94,0.16)',
|
|
border: 'rgba(214,178,94,0.22)',
|
|
},
|
|
];
|
|
|
|
/** Landing page for administrative tools and configuration shortcuts. */
|
|
export function OptionsPage() {
|
|
const { t } = useTranslation();
|
|
const nav = useNavigate();
|
|
const { can } = useAuth();
|
|
|
|
const visibleCards = OPTION_CARDS.filter((card) => {
|
|
const perm = OPTIONS_CARD_PERMISSIONS[card.key];
|
|
return !perm || can(perm);
|
|
});
|
|
|
|
return (
|
|
<Box sx={{ minWidth: 0 }}>
|
|
<Stack spacing={0.75}>
|
|
<Typography variant="h4" sx={{ fontWeight: 900, letterSpacing: 0.2, fontSize: { xs: '1.65rem', sm: '2.125rem' } }}>
|
|
{t('admin.options.title')}
|
|
</Typography>
|
|
<Typography sx={{ opacity: 0.7 }}>{t('admin.options.subtitle')}</Typography>
|
|
</Stack>
|
|
|
|
<Box
|
|
sx={{
|
|
mt: 2.5,
|
|
display: 'grid',
|
|
gap: 2,
|
|
gridTemplateColumns: { xs: '1fr', md: 'repeat(12, 1fr)' },
|
|
}}
|
|
>
|
|
{visibleCards.map((card) => {
|
|
const Icon = card.icon;
|
|
return (
|
|
<Card key={card.key} sx={{ gridColumn: { xs: '1 / -1', md: 'span 6' } }}>
|
|
<CardActionArea onClick={() => nav(card.path)} sx={{ height: '100%' }}>
|
|
<CardContent sx={{ p: 2.5 }}>
|
|
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'flex-start' }}>
|
|
<Box
|
|
sx={{
|
|
width: 40,
|
|
height: 40,
|
|
borderRadius: 2,
|
|
display: 'grid',
|
|
placeItems: 'center',
|
|
backgroundColor: card.bg,
|
|
border: `1px solid ${card.border}`,
|
|
}}
|
|
>
|
|
<Icon fontSize="small" color={card.iconColor} />
|
|
</Box>
|
|
<Box sx={{ flex: 1, minWidth: 0 }}>
|
|
<Stack direction="row" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap' }}>
|
|
<Typography variant="h6" sx={{ fontWeight: 900 }}>
|
|
{t(`admin.options.cards.${card.key}.title`)}
|
|
</Typography>
|
|
<Chip
|
|
size="small"
|
|
label={t(`admin.badge.${card.badgeKey}`)}
|
|
color={card.badgeColor}
|
|
variant="outlined"
|
|
/>
|
|
</Stack>
|
|
<Typography sx={{ opacity: 0.75, mt: 0.5 }}>
|
|
{t(`admin.options.cards.${card.key}.description`)}
|
|
</Typography>
|
|
</Box>
|
|
</Stack>
|
|
</CardContent>
|
|
</CardActionArea>
|
|
</Card>
|
|
);
|
|
})}
|
|
</Box>
|
|
</Box>
|
|
);
|
|
}
|