From 37f3cd8cf13e76c2d2db8855c50f402660482c20 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 13 Mar 2024 01:31:48 +0700 Subject: [PATCH] improved file input --- src/widgets/action-editor/ui/ActionEditor.tsx | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/widgets/action-editor/ui/ActionEditor.tsx b/src/widgets/action-editor/ui/ActionEditor.tsx index f30a221..3fe09d3 100644 --- a/src/widgets/action-editor/ui/ActionEditor.tsx +++ b/src/widgets/action-editor/ui/ActionEditor.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useRef } from "react"; import { uploadFile } from "@/shared/lib/uploadFile"; import type { CommentAction } from "@/entities/action/schema"; import { getActionAttachmentType } from "@/entities/action/lib"; @@ -58,6 +58,7 @@ export default function ActionEditor({ onClose, canExit = false, }: ActionEditorProps) { + const imageRef = useRef(null); const attachmentType = initialAction ? getActionAttachmentType(initialAction) : "empty"; @@ -179,16 +180,42 @@ export default function ActionEditor({
+
+
+ + {imageUrl && ( + Current image + )} +
+ + {loading && ( +
+ +
+ )} +
+ await handleFileChange(e, "image")} /> - {loading && ( -
- -
- )}