gallery:
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
hamid zarghami
2026-05-25 09:35:57 +03:30
parent cbdc7edbf5
commit 83b2fd809c
19 changed files with 413 additions and 163 deletions
@@ -1,7 +1,6 @@
import { useEditorStore, type ToolType } from "@/pages/editor/store/editorStore";
import { useSingleUpload } from "@/pages/uploader/hooks/useUploaderData";
import { type ToolType } from "@/pages/editor/store/editorStore";
import {
ImageUpload,
ImageGallery,
VideoInput,
LinkInput,
SelectInstruction,
@@ -18,39 +17,8 @@ type ToolInstructionsProps = {
};
const ToolInstructions = ({ tool }: ToolInstructionsProps) => {
const { addObject, setSelectedObjectId, setTool } = useEditorStore();
const { mutateAsync: uploadFile } = useSingleUpload();
const handleImageUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (!file) return;
try {
const result = await uploadFile(file);
const imageUrl = result?.data?.url;
if (!imageUrl) return;
const img = new Image();
img.onload = () => {
const newImage = {
id: `image-${Date.now()}`,
type: "image" as ToolType,
x: 100,
y: 100,
width: img.width,
height: img.height,
imageUrl,
};
addObject(newImage);
setSelectedObjectId(newImage.id);
setTool("select");
};
img.src = imageUrl;
} catch {
// TODO: show error toast
}
};
if (tool === "image") {
return <ImageUpload onImageUpload={handleImageUpload} />;
return <ImageGallery />;
}
if (tool === "video") {