From 60d6586f7789353b299979945c6f968916920c30 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Sun, 23 Aug 2026 18:01:00 +0530 Subject: [PATCH] feat: add image preview and upload animation to AddProductTab --- .../dashboard/tabs/AddProductTab.tsx | 76 +++++++++++++++---- 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/src/components/dashboard/tabs/AddProductTab.tsx b/src/components/dashboard/tabs/AddProductTab.tsx index 36c7c9f..ca785a9 100644 --- a/src/components/dashboard/tabs/AddProductTab.tsx +++ b/src/components/dashboard/tabs/AddProductTab.tsx @@ -1,8 +1,32 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useSeller } from '../../../context/SellerContext'; export default function AddProductTab() { const { setDashTab } = useSeller(); + + const [imagePreview, setImagePreview] = useState(null); + const [isSubmitting, setIsSubmitting] = useState(false); + + const handleImageChange = (e: React.ChangeEvent) => { + const file = e.target.files?.[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setImagePreview(reader.result as string); + }; + reader.readAsDataURL(file); + } + }; + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + setIsSubmitting(true); + // Simulate API call and progress + setTimeout(() => { + setIsSubmitting(false); + setDashTab('products'); + }, 1500); // 1.5 seconds animation + }; return (
@@ -18,7 +42,7 @@ export default function AddProductTab() {
-
{ e.preventDefault(); setDashTab('products'); }}> +
{/* Left Column: Basic Info */} @@ -69,18 +93,32 @@ export default function AddProductTab() {
-
+ {imagePreview && ( +

+ setImagePreview(null)} className="has-text-danger">Remove image +

+ )}
@@ -103,8 +141,20 @@ export default function AddProductTab() {
- - + +