diff --git a/src/components/forms/update-product-form.tsx b/src/components/forms/update-product-form.tsx index 1cfc4f833..3b19b152e 100644 --- a/src/components/forms/update-product-form.tsx +++ b/src/components/forms/update-product-form.tsx @@ -35,6 +35,7 @@ import { import { Textarea } from "@/components/ui/textarea" import { FileDialog } from "@/components/file-dialog" import { Icons } from "@/components/icons" +import { ToastWithButton } from "@/components/toast-with-button" import { checkProductAction, deleteProductAction, @@ -89,7 +90,7 @@ export function UpdateProductForm({ product }: UpdateProductFormProps) { const subcategories = getSubcategories(form.watch("category")) function onSubmit(data: Inputs) { - console.log(data) + // console.log(data) startTransition(async () => { try { @@ -119,7 +120,17 @@ export function UpdateProductForm({ product }: UpdateProductFormProps) { images: images ?? product.images, }) - toast.success("Product updated successfully.") + const handleToastAction = () => { + router.push(`/product/${product.storeId}`) + toast.dismiss(`update-product-success-${product.id}`) + } + + toast( + View, + { + id: `update-product-success-${product.id}`, + } + ) setFiles(null) } catch (error) { error instanceof Error diff --git a/src/components/toast-with-button.tsx b/src/components/toast-with-button.tsx new file mode 100644 index 000000000..6a0a3555d --- /dev/null +++ b/src/components/toast-with-button.tsx @@ -0,0 +1,46 @@ +import type { ButtonHTMLAttributes } from "react" + +import { Button } from "@/components/ui/button" + +export function ToastWithButton({ + children, + ...props +}: ButtonHTMLAttributes) { + return ( +
+
+ + Product updated successfully. +
+ +
+ ) +} + +export const SonnerSuccessIcon = () => { + return ( +
+ + + +
+ ) +}