Skip to content

Commit

Permalink
subscription form with fixed form
Browse files Browse the repository at this point in the history
  • Loading branch information
eonurk committed Aug 3, 2024
1 parent b90af6a commit 7d08fb1
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/components/Subscription.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import React from "react";

import { Button } from "@/components/ui/button";
import { useToast } from "@/components/ui/use-toast";
import { useState } from "react";
import { ReloadIcon } from "@radix-ui/react-icons";
import { FormDescription } from "@/components/ui/form";

function SubscribeForm() {
const { toast } = useToast();
const [buttonDisable, setButtonDisable] = useState(false);

const handleSubmit = async (event: {
preventDefault: () => void;
target: HTMLFormElement | undefined;
}) => {
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault(); // Prevent default form submission

setButtonDisable(true);

const formData = new FormData(event.target); // Collect form data
const formDataEntries = Object.fromEntries(formData.entries());
const formData = new FormData(event.currentTarget); // Collect form data
const formDataEntries: Record<string, string> = {};
formData.forEach((value, key) => {
formDataEntries[key] = value.toString();
});
try {
const params = new URLSearchParams(formDataEntries).toString();
const response = await fetch(
Expand Down

0 comments on commit 7d08fb1

Please sign in to comment.