fix: Fix 3d models
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
import { Box, Button } from "@mui/material";
|
||||
import { editSightStore, SelectMediaDialog, UploadMediaDialog } from "@shared";
|
||||
import {
|
||||
editSightStore,
|
||||
SelectMediaDialog,
|
||||
UploadMediaDialog,
|
||||
filterValidFiles,
|
||||
getAllAcceptString,
|
||||
} from "@shared";
|
||||
import { Upload } from "lucide-react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useState, DragEvent, useRef } from "react";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
export const MediaAreaForSight = observer(
|
||||
({
|
||||
@@ -38,11 +45,18 @@ export const MediaAreaForSight = observer(
|
||||
setIsDragging(false);
|
||||
|
||||
const files = Array.from(e.dataTransfer.files);
|
||||
if (files.length && onFilesDrop) {
|
||||
setFileToUpload(files[0]);
|
||||
}
|
||||
if (files.length) {
|
||||
const { validFiles, errors } = filterValidFiles(files);
|
||||
|
||||
setUploadMediaDialogOpen(true);
|
||||
if (errors.length > 0) {
|
||||
errors.forEach((error: string) => toast.error(error));
|
||||
}
|
||||
|
||||
if (validFiles.length > 0 && onFilesDrop) {
|
||||
setFileToUpload(validFiles[0]);
|
||||
setUploadMediaDialogOpen(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleDragOver = (e: DragEvent<HTMLDivElement>) => {
|
||||
@@ -60,10 +74,18 @@ export const MediaAreaForSight = observer(
|
||||
|
||||
const handleFileSelect = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const files = Array.from(event.target.files || []);
|
||||
if (files.length && onFilesDrop) {
|
||||
setFileToUpload(files[0]);
|
||||
onFilesDrop(files);
|
||||
setUploadMediaDialogOpen(true);
|
||||
if (files.length) {
|
||||
const { validFiles, errors } = filterValidFiles(files);
|
||||
|
||||
if (errors.length > 0) {
|
||||
errors.forEach((error: string) => toast.error(error));
|
||||
}
|
||||
|
||||
if (validFiles.length > 0 && onFilesDrop) {
|
||||
setFileToUpload(validFiles[0]);
|
||||
onFilesDrop(validFiles);
|
||||
setUploadMediaDialogOpen(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Сбрасываем значение input, чтобы можно было выбрать тот же файл снова
|
||||
@@ -76,7 +98,7 @@ export const MediaAreaForSight = observer(
|
||||
type="file"
|
||||
ref={fileInputRef}
|
||||
onChange={handleFileSelect}
|
||||
accept="image/*,video/*,.glb,.gltf"
|
||||
accept={getAllAcceptString()}
|
||||
multiple
|
||||
style={{ display: "none" }}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user