Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Reset delete discount code confirmation when the modal closes.

Kiran Keaaecd28697d
diff --git a/apps/web/ui/modals/delete-discount-code-modal.tsx b/apps/web/ui/modals/delete-discount-code-modal.tsx
index 2b452cac97..0c363cdf8a 100644
--- a/apps/web/ui/modals/delete-discount-code-modal.tsx
+++ b/apps/web/ui/modals/delete-discount-code-modal.tsx
@@ -3,7 +3,7 @@ import { useApiMutation } from "@/lib/swr/use-api-mutation";
import { DiscountCodeProps } from "@/lib/types";
import { Button, Modal, useMediaQuery } from "@dub/ui";
import { Tag } from "@dub/ui/icons";
-import { FormEvent, useState } from "react";
+import { FormEvent, useEffect, useState } from "react";
import { toast } from "sonner";
interface DeleteDiscountCodeModalProps {
@@ -23,6 +23,12 @@ export const DeleteDiscountCodeModal = ({
const { makeRequest: deleteDiscountCode, isSubmitting } = useApiMutation();
const [inputValue, setInputValue] = useState("");
+ useEffect(() => {
+ if (!showModal) {
+ setInputValue("");
+ }
+ }, [showModal, discountCode.id]);
+
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();