From 93265fe9751311644794edef3858c2c2972cd93b Mon Sep 17 00:00:00 2001 From: Aayush Jain Date: Mon, 31 Mar 2025 17:14:13 +0530 Subject: [PATCH 1/7] check --- src/app/ac/page.js | 4 +- src/app/startup/page.js | 229 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 src/app/startup/page.js diff --git a/src/app/ac/page.js b/src/app/ac/page.js index b1d62f5..ef4ca8d 100644 --- a/src/app/ac/page.js +++ b/src/app/ac/page.js @@ -13,6 +13,7 @@ const BookingForm = () => { contact: "", email: "", confirmEmail: "", + team:"", }); const handleChange = (e) => { @@ -43,7 +44,7 @@ const BookingForm = () => { const currency = "INR"; const response = await axios.post("https://ecell-orcin.vercel.app/payment/", { - amount: 1800 * 100, + amount: 10 * 100, receipt: "AAyu9414", currency, }); @@ -110,6 +111,7 @@ const BookingForm = () => { { label: "College", id: "college", type: "text" }, { label: "City", id: "city", type: "text" }, { label: "Contact", id: "contact", type: "text" }, + { label: "Team", id: "team", type: "text" }, { label: "Email", id: "email", type: "email" }, { label: "Confirm Email", id: "confirmEmail", type: "email" }, ].map(({ label, id, type }) => ( diff --git a/src/app/startup/page.js b/src/app/startup/page.js new file mode 100644 index 0000000..ca14a82 --- /dev/null +++ b/src/app/startup/page.js @@ -0,0 +1,229 @@ +'use client'; +import { useState } from "react"; +import axios from "axios"; +import Script from "next/script"; +import HyperText from '../../components/magicui/hyper-text' + +const BookingForm = () => { + const [formData, setFormData] = useState({ + name: "", + college: "", + city: "", + gender: "", + contact: "", + email: "", + team:"", + confirmEmail: "", + }); + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData((prevData) => ({ + ...prevData, + [name]: value, + })); + }; + + const handleSubmit = async () => { + if (formData.email !== formData.confirmEmail) { + alert("Emails do not match. Please try again."); + return; + } + try { + const response = await axios.post("http://localhost:4000/startup/", formData); + console.log("Task created:", response.data); + alert("Your registeration is sucessfull"); + } catch (error) { + console.error("Error creating task:", error); + alert("Something went wrong"); + } + }; + + const paymentHandler = async (e) => { + e.preventDefault(); + const currency = "INR"; + + const response = await axios.post("http://localhost:4000/payment/", { + amount: 1800 * 100, + receipt: "AAyu9414", + currency, + }); + + const { id: orderId, amount } = response.data; + + const options = { + key: "rzp_live_Kz0ka8aJYIo4Fc", + amount, + currency, + name: "E-Cell DTU", + description: "Test Transaction", + image: "https://example.com/your_logo", + order_id: orderId, + handler: async function (response) { + const verificationResponse = await axios.post( + "https://ecell-orcin.vercel.app/payment/verification", + { + paymentResponse: response, + } + ); + if (verificationResponse.data.msg === "success") { + alert("Payment Successful"); + await handleSubmit(); + setTimeout(() => { + window.location.href = "/"; + }, 3000); + } else { + alert("Payment Verification Failed"); + } + }, + prefill: { + name: formData.name, + email: formData.email, + contact: formData.contact, + }, + notes: { + address: formData.city, + }, + theme: { + color: "#1f2937", + }, + }; + + const rzp1 = new window.Razorpay(options); + rzp1.on("payment.failed", function (response) { + alert("Payment Failed"); + console.error("Payment Failed:", response.error); + }); + rzp1.open(); + }; + + return ( + <> +
+ +
+
+ {[ + { label: "Name", id: "name", type: "text" }, + { label: "College", id: "college", type: "text" }, + { label: "City", id: "city", type: "text" }, + { label: "Contact", id: "contact", type: "text" }, + { label: "Team Name", id: "team", type: "text" }, + { label: "Email", id: "email", type: "email" }, + { label: "Confirm Email", id: "confirmEmail", type: "email" }, + ].map(({ label, id, type }) => ( +
+ + +
+ ))} +
+
+ + +
+ +
+