Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New admin #93

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/app/api/verify-order/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ export async function POST(request: NextRequest) {
if (!session) {
return NextResponse.json({ message: "No session", isOk: false }, { status: 400 });
}
const { orderId, razorpayPaymentId, razorpaySignature, amount } = await request.json();
const { email, orderId, razorpayPaymentId, razorpaySignature, amount } = await request.json();
if (!email || !orderId || !razorpayPaymentId || !razorpaySignature || !amount) {
return NextResponse.json({ message: "Invalid data", isOk: false }, { status : 400 });
}
const userEmail = session.user?.role === "ADMIN" || session.user?.email !== email
? email
: session.user?.email!;


const signature = generatedSignature(orderId, razorpayPaymentId);
if (signature !== razorpaySignature) {
Expand All @@ -18,13 +25,13 @@ export async function POST(request: NextRequest) {
if (signature === razorpaySignature) {
const user = await prisma.user.findUnique({
where: {
email: session.user?.email!,
email: userEmail,
},
});

try {
await sendRegistrationEmail({
email: session.user?.email!,
email: userEmail,
name: session.user?.name!,
registrationLink: `${process.env.NEXT_PUBLIC_SITE_URL}/admin/verify/${razorpayPaymentId}`,
});
Expand Down
9 changes: 3 additions & 6 deletions src/components/common/cta-section-2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function FullScreenCTA() {
<div className="space-y-4 block ml-4 lg:hidden">
<div className="flex items-center space-x-3 text-lg">
<Calendar className="h-6 w-6 text-red-500" />
<span>December 14, 2024 | 9:00 AM - 4:00 PM</span>
<span>December 14, 2024 | 9:00 AM - 5:30 PM</span>
</div>
<div className="flex items-center space-x-3 text-lg">
<MapPin className="h-6 w-6 text-red-500" />
Expand All @@ -90,11 +90,8 @@ export default function FullScreenCTA() {
<div className="text-center space-y-6">
<p className="text-xl text-gray-300">
Limited spots available! <br />
Register by{" "}
<span className="font-semibold text-gray-100">
December 10, 2024
</span>{" "}
to secure your spot. <br />
<span className="text-gray-300 font-semibold text-xl">Register now
to secure your spot. <br /></span>
</p>

<Link href={"/register"}>
Expand Down
13 changes: 7 additions & 6 deletions src/components/common/registration-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default function RegistrationForm() {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
email: form.getValues("email"),
orderId: response.razorpay_order_id,
razorpayPaymentId: response.razorpay_payment_id,
razorpaySignature: response.razorpay_signature,
Expand Down Expand Up @@ -218,7 +219,7 @@ export default function RegistrationForm() {
},
notes: {
name: form.getValues("name"),
email: session?.user?.email,
email: form.getValues("email"),
contact: form.getValues("phone"),
designation: form.getValues("designation"),
foodPreference: form.getValues("foodPreference"),
Expand All @@ -233,7 +234,7 @@ export default function RegistrationForm() {
},
prefill: {
name: form.getValues("name"),
email: session?.user?.email,
email: form.getValues("email"),
contact: form.getValues("phone"),
},
theme: {
Expand Down Expand Up @@ -299,7 +300,7 @@ export default function RegistrationForm() {
const handleNext = async () => {
let isValid = false;
if (step === 1) {
isValid = await form.trigger(["designation", "foodPreference", "name"]);
isValid = await form.trigger(["designation", "foodPreference", "name", "email"]);
} else if (step === 2) {
const designation = form.getValues("designation");
if (designation === "student") {
Expand Down Expand Up @@ -380,10 +381,10 @@ export default function RegistrationForm() {
<div className="flex items-center space-x-2">
<FormControl>
<Input
placeholder="[email protected]"
placeholder=""
{...field}
disabled
value={session?.user.email!}
disabled={!(session?.user.role === "ADMIN")}
className="cursor-not-allowed"
/>
</FormControl>
<Button
Expand Down
Loading