import { Cropper, CropperRef } from 'react-advanced-cropper'; import { Box, Button, Dialog, DialogContent, DialogTitle, useTheme, } from '@mui/material'; import { useRef } from 'react'; import 'react-advanced-cropper/dist/style.css'; export interface ImageCropDialogProps { onCancel: () => void; onCropComplete: (file: File) => void; cropImageUrl: string; } export function ImageCropDialog(props: ImageCropDialogProps) { const cropperRef = useRef(null); const { cropImageUrl, onCancel, onCropComplete } = props; const handleCrop = async () => { const cropper = cropperRef.current; if (!cropper) return; const canvas = cropper.getCanvas(); if (!canvas) return; canvas.toBlob((blob) => { if (!blob) return; const file = new File([blob], `crop-${Date.now()}.jpeg`, { type: 'image/jpeg', lastModified: Date.now(), }); onCropComplete(file); }, 'image/jpeg'); }; const theme = useTheme(); return ( ); }