import { Stack, Text, Group, Button, Menu, Select, Badge } from '@mantine/core'; import { Save, Settings2, File } from 'lucide-react'; import { forwardRef, type ComponentPropsWithoutRef } from 'react'; import type { ConfigFile } from '@/types'; interface ConfigurationManagerProps { configFiles: ConfigFile[]; selectedFile: string | null; onFileSelection: (fileName: string) => void; onSaveAsNew: () => void; onUpdateCurrent: () => void; } interface SelectItemProps extends ComponentPropsWithoutRef<'div'> { label: string; extension: string; } const getBadgeColor = (extension: string) => { switch (extension.toLowerCase()) { case '.kcpps': return 'blue'; case '.kcppt': return 'green'; default: return 'gray'; } }; const SelectItem = forwardRef( ({ label, extension, ...others }, ref) => (
{label} {extension}
) ); SelectItem.displayName = 'SelectItem'; export const ConfigurationManager = ({ configFiles, selectedFile, onFileSelection, onSaveAsNew, onUpdateCurrent, }: ConfigurationManagerProps) => ( Configuration File } onClick={onSaveAsNew}> Save as new configuration } disabled={!selectedFile} onClick={onUpdateCurrent} > Update current configuration {configFiles.length === 0 ? ( No configuration files found in the installation directory.
Please ensure your .kcpps or .kcppt files are in the correct location.
) : ( (() => { const selectData = configFiles.map((file) => { const extension = file.name.split('.').pop() || ''; const nameWithoutExtension = file.name.replace(`.${extension}`, ''); return { value: file.name, label: nameWithoutExtension, extension: `.${extension}`, }; }); return (