import React from 'react'; import { Stack, Text, Button, Group } from '@mantine/core'; import HistoryIcon from '@mui/icons-material/History'; import UploadIcon from '@mui/icons-material/Upload'; import CloudIcon from '@mui/icons-material/Cloud'; import { useTranslation } from 'react-i18next'; import { useFileManagerContext } from '../../contexts/FileManagerContext'; import { useGoogleDrivePicker } from '../../hooks/useGoogleDrivePicker'; interface FileSourceButtonsProps { horizontal?: boolean; } const FileSourceButtons: React.FC = ({ horizontal = false }) => { const { activeSource, onSourceChange, onLocalFileClick, onGoogleDriveSelect } = useFileManagerContext(); const { t } = useTranslation(); const { isEnabled: isGoogleDriveEnabled, openPicker: openGoogleDrivePicker } = useGoogleDrivePicker(); const handleGoogleDriveClick = async () => { try { const files = await openGoogleDrivePicker({ multiple: true }); if (files.length > 0) { onGoogleDriveSelect(files); } } catch (error) { console.error('Failed to pick files from Google Drive:', error); } }; const buttonProps = { variant: (source: string) => activeSource === source ? 'filled' : 'subtle', getColor: (source: string) => activeSource === source ? 'var(--mantine-color-gray-2)' : undefined, getStyles: (source: string) => ({ root: { backgroundColor: activeSource === source ? undefined : 'transparent', color: activeSource === source ? 'var(--mantine-color-gray-9)' : 'var(--mantine-color-gray-6)', border: 'none', '&:hover': { backgroundColor: activeSource === source ? undefined : 'var(--mantine-color-gray-0)' } } }) }; const buttons = ( <> ); if (horizontal) { return ( {buttons} ); } return ( {t('fileManager.myFiles', 'My Files')} {buttons} ); }; export default FileSourceButtons;