mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-09-13 16:23:08 +00:00
- Replace flat sidebar with collapsible tree groups (7 groups, 52 sub-items) - Map all 61 backend category keys to sidebar navigation - Add QuickToggles panel for boolean settings - Replace card-style SettingRow with compact SettingsTableRow - Add breadcrumb navigation for tree sub-items - Add source badges (modified/DB/ENV) on settings - Implement two-level mobile navigation with group chips - Add i18n translations for all new keys (en, ru, zh, fa)
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import { useTranslation } from 'react-i18next';
|
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { SettingDefinition, adminSettingsApi } from '../../api/adminSettings';
|
|
import { StarIcon } from './icons';
|
|
import { SettingsTableRow } from './SettingsTableRow';
|
|
|
|
interface FavoritesTabProps {
|
|
settings: SettingDefinition[];
|
|
isFavorite: (key: string) => boolean;
|
|
toggleFavorite: (key: string) => void;
|
|
}
|
|
|
|
export function FavoritesTab({ settings, isFavorite, toggleFavorite }: FavoritesTabProps) {
|
|
const { t } = useTranslation();
|
|
const queryClient = useQueryClient();
|
|
|
|
const updateSettingMutation = useMutation({
|
|
mutationFn: ({ key, value }: { key: string; value: string }) =>
|
|
adminSettingsApi.updateSetting(key, value),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['admin-settings'] });
|
|
},
|
|
});
|
|
|
|
const resetSettingMutation = useMutation({
|
|
mutationFn: (key: string) => adminSettingsApi.resetSetting(key),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['admin-settings'] });
|
|
},
|
|
});
|
|
|
|
if (settings.length === 0) {
|
|
return (
|
|
<div className="rounded-2xl border border-dark-700/30 bg-dark-800/30 p-12 text-center">
|
|
<div className="mb-4 flex justify-center text-dark-500">
|
|
<StarIcon filled={false} />
|
|
</div>
|
|
<p className="text-dark-400">{t('admin.settings.favoritesEmpty')}</p>
|
|
<p className="mt-1 text-sm text-dark-500">{t('admin.settings.favoritesHint')}</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="overflow-hidden rounded-xl border border-dark-700/40">
|
|
{settings.map((setting, idx) => (
|
|
<SettingsTableRow
|
|
key={setting.key}
|
|
setting={setting}
|
|
isFavorite={isFavorite(setting.key)}
|
|
onToggleFavorite={() => toggleFavorite(setting.key)}
|
|
onUpdate={(value) => updateSettingMutation.mutate({ key: setting.key, value })}
|
|
onReset={() => resetSettingMutation.mutate(setting.key)}
|
|
isUpdating={updateSettingMutation.isPending}
|
|
isResetting={resetSettingMutation.isPending}
|
|
isLast={idx === settings.length - 1}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|