All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 2m39s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 37s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
Desktop changes: - Replace ImportButton component with MUI Button matching Export style - Use hidden file input with validation - Dark red/maroon button with consistent styling Mobile changes: - Update both Import and Export buttons to use primary-500 style - Consistent dark primary button appearance - Maintains 44px touch target requirement Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
/**
|
|
* @ai-summary Import button component
|
|
* @ai-context Opens file selector and triggers import dialog
|
|
*/
|
|
|
|
import React, { useRef } from 'react';
|
|
import toast from 'react-hot-toast';
|
|
|
|
interface ImportButtonProps {
|
|
onFileSelected: (file: File) => void;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
export const ImportButton: React.FC<ImportButtonProps> = ({
|
|
onFileSelected,
|
|
disabled = false,
|
|
}) => {
|
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
|
|
const handleButtonClick = () => {
|
|
fileInputRef.current?.click();
|
|
};
|
|
|
|
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
const file = event.target.files?.[0];
|
|
if (!file) return;
|
|
|
|
// Validate file extension
|
|
if (!file.name.endsWith('.tar.gz')) {
|
|
toast.error('Please select a .tar.gz file');
|
|
return;
|
|
}
|
|
|
|
// Validate file size (max 500MB)
|
|
const maxSize = 500 * 1024 * 1024;
|
|
if (file.size > maxSize) {
|
|
toast.error('File size exceeds 500MB limit');
|
|
return;
|
|
}
|
|
|
|
onFileSelected(file);
|
|
|
|
// Reset input so same file can be selected again
|
|
event.target.value = '';
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<input
|
|
ref={fileInputRef}
|
|
type="file"
|
|
accept=".tar.gz"
|
|
onChange={handleFileChange}
|
|
style={{ display: 'none' }}
|
|
aria-label="Select import file"
|
|
/>
|
|
<button
|
|
onClick={handleButtonClick}
|
|
disabled={disabled}
|
|
className="w-full text-left p-3 bg-primary-500 text-white rounded-lg font-medium hover:bg-primary-600 transition-colors disabled:opacity-50 dark:bg-primary-600 dark:hover:bg-primary-700"
|
|
style={{ minHeight: '44px' }}
|
|
>
|
|
Import My Data
|
|
</button>
|
|
</>
|
|
);
|
|
};
|