import { Box, Heading, VStack, Text, Button, OrderedList, ListItem, useDisclosure, Modal, ModalOverlay, ModalContent, ModalHeader, ModalBody, ModalFooter, useToast, IconButton, Flex, Tabs, TabList, TabPanels, Tab, TabPanel, Icon, HStack, } from "@chakra-ui/react"; import { ChevronLeftIcon } from "@chakra-ui/icons"; import { FiDatabase, FiSettings, FiUpload, FiLink, FiRefreshCw, FiTrash2 } from 'react-icons/fi'; import { useNavigate } from "react-router-dom"; import { useXmlParser } from "../hooks/useXmlParser"; import { StyledFileInput } from "../components/StyledFileInput"; import { S3Configuration } from "./S3Configuration"; import { MusicUpload } from "../components/MusicUpload"; import { SongMatching } from "../components/SongMatching"; import { api } from "../services/api"; import { DuplicatesViewer } from "../components/DuplicatesViewer.tsx"; import { useState, useMemo } from "react"; interface MusicFile { _id: string; originalName: string; title?: string; artist?: string; album?: string; duration?: number; size: number; format?: string; uploadedAt: string; songId?: any; // Reference to linked song } export function Configuration() { const { resetLibrary } = useXmlParser(); const { isOpen, onOpen, onClose } = useDisclosure(); const toast = useToast(); const navigate = useNavigate(); // Music storage state removed from Config; see Sync & Matching section // Tabs: remember active tab across refreshes const initialTabIndex = useMemo(() => { const stored = localStorage.getItem('configTabIndex'); return stored ? parseInt(stored, 10) : 0; }, []); const [tabIndex, setTabIndex] = useState(initialTabIndex); // No explicit tab index enum needed // S3 config fetch removed; Sync buttons remain available in the panel // Removed Music Library sync handlers from Config (moved to Sync & Matching panel) const handleUploadComplete = (files: MusicFile[]) => { toast({ title: 'Upload Complete', description: `${files.length} file${files.length !== 1 ? 's' : ''} uploaded successfully`, status: 'success', duration: 3000, isClosable: true, }); }; // Deletion handler not needed in Config anymore // Utilities for file list removed with Music Library tab const handleResetDatabase = async () => { try { await api.resetDatabase(); await resetLibrary(); onClose(); toast({ title: "Database reset successful", description: "Your library has been cleared.", status: "success", duration: 5000, isClosable: true, }); // Navigate to homepage to show welcome modal and start fresh navigate('/'); } catch (error) { toast({ title: "Failed to reset database", description: "An error occurred while resetting the database.", status: "error", duration: 5000, isClosable: true, }); } }; return ( } aria-label="Go back" variant="ghost" onClick={() => navigate('/')} color="gray.300" _hover={{ color: "white", bg: "whiteAlpha.200" }} /> Configuration { setTabIndex(index); localStorage.setItem('configTabIndex', String(index)); }} > Library Management Upload Music {/* Hide heavy Music Library tab from config to reduce load; may move to separate page later */} Song Matching Duplicates S3 Configuration {/* Library Management Tab */} To get started with Rekordbox Reader, you'll need to export your library from Rekordbox and import it here. Open Rekordbox and go to File → Export Collection in xml format Choose a location to save your XML file Click the button below to import your Rekordbox XML file Import Library Reset Database Clear all songs and playlists from the database. This action cannot be undone. {/* Upload Music Tab */} Upload Music Files Drag and drop your music files here or click to select. Files will be uploaded to S3 storage and metadata will be automatically extracted. {/* Music Library tab removed from Config (heavy). Consider separate page if needed. */} {/* Song Matching Tab */} Sync and Matching {/* Duplicates Tab */} {/* S3 Configuration Tab */} {/* Reset Database Confirmation Modal */} Confirm Database Reset Are you sure you want to reset the database? This will: Delete all imported songs Remove all playlists Clear all custom configurations This action cannot be undone. ); }