From b18b5fab627ef329649db009d2e88a4bda8913bb Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Fri, 6 Feb 2026 13:37:19 +0100 Subject: [PATCH] feat: Allow direct icon upload when updating an item in the item form. --- web/src/components/item-form.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/web/src/components/item-form.tsx b/web/src/components/item-form.tsx index 628b1b9..a5fd1c5 100644 --- a/web/src/components/item-form.tsx +++ b/web/src/components/item-form.tsx @@ -32,7 +32,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { ImageUploader } from "@/components/image-uploader"; import { EffectEditor } from "@/components/effect-editor"; -import { useCreateItem, useUpdateItem, type ItemWithUsage, type CreateItemData } from "@/hooks/use-items"; +import { useCreateItem, useUpdateItem, useUploadItemIcon, type ItemWithUsage, type CreateItemData } from "@/hooks/use-items"; import { Loader2, Coins, FileText, Image, Zap } from "lucide-react"; // Form schema @@ -72,6 +72,7 @@ export function ItemForm({ initialData, onSuccess, onCancel }: ItemFormProps) { const isEditMode = !!initialData; const { createItem, loading: createLoading } = useCreateItem(); const { updateItem, loading: updateLoading } = useUpdateItem(); + const { uploadIcon, loading: uploadIconLoading } = useUploadItemIcon(); const [imageFile, setImageFile] = useState(null); const [existingImageUrl, setExistingImageUrl] = useState(null); @@ -123,7 +124,12 @@ export function ItemForm({ initialData, onSuccess, onCancel }: ItemFormProps) { if (isEditMode && initialData) { const result = await updateItem(initialData.id, itemData); + + // If update was successful and we have a new image, upload it if (result) { + if (imageFile) { + await uploadIcon(initialData.id, imageFile); + } onSuccess(); } } else { @@ -134,7 +140,7 @@ export function ItemForm({ initialData, onSuccess, onCancel }: ItemFormProps) { } }; - const isLoading = createLoading || updateLoading; + const isLoading = createLoading || updateLoading || uploadIconLoading; return (
@@ -288,13 +294,7 @@ export function ItemForm({ initialData, onSuccess, onCancel }: ItemFormProps) { - {isEditMode && ( -

- To update the image, use the icon upload in the items table after saving. -

- )}