Skip to content

Commit

Permalink
Merge branch 'main' into 38-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-nagaraj authored Aug 17, 2024
2 parents 4428829 + 72fb612 commit 6745d59
Show file tree
Hide file tree
Showing 38 changed files with 1,045 additions and 54 deletions.
77 changes: 77 additions & 0 deletions app/(default)/api/registration/recruitment/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { db } from "@/Firebase";
import { recruitValidate } from "@/lib/utils";
import { addDoc, collection, getDocs } from "firebase/firestore";
import { NextResponse } from "next/server";

// Verify reCAPTCHA Token
async function verifyRecaptcha(token: string) {
const secretKey = process.env.RECAPTCHA_SECRET_KEY;
const response = await fetch(
`https://www.google.com/recaptcha/api/siteverify`,
{
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
secret: secretKey || "",
response: token,
}),
}
);
const data = await response.json();
return data.success;
}

// Add a new registration
export async function POST(request: Request) {
const data = await request.json();
const recaptchaToken = data.recaptchaToken; // Extract the reCAPTCHA token from the request

// Verify the reCAPTCHA token
const isRecaptchaValid = await verifyRecaptcha(recaptchaToken);

if (!isRecaptchaValid) {
return NextResponse.json({
message: "reCAPTCHA verification failed",
error: true,
});
}

// Validate the data
const val = recruitValidate(data);

if (!Array.isArray(data)) {
return NextResponse.json({
message: "Expected an array of JSON objects",
error: true,
});
}

if (val.error) {
return NextResponse.json({ message: "Validation error", error: val.error });
}

try {
// Save to Firebase
const docRef = await addDoc(collection(db, "recruitment2024"), data);
console.log("Document written with ID: ", docRef.id);
} catch (error) {
console.error(error);
return NextResponse.json({ message: "An error occurred", error });
}
// Return a response
return NextResponse.json({ message: "Registration successful", data });
}

// Get all registrations
export async function GET() {
try {
// Get all registrations in recruitment2024 collection
const querySnapshot = await getDocs(collection(db, "recruitment2024"));
// Map the data to get only the data
const data = querySnapshot.docs.map((doc) => doc.data());
return NextResponse.json({ data });
} catch (error) {
console.error(error);
return NextResponse.json({ message: "An error occurred", error });
}
}
26 changes: 26 additions & 0 deletions app/(default)/api/registration/sih/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,35 @@ import { sihValidate } from '@/lib/utils';
import { addDoc, collection, getDocs } from 'firebase/firestore';
import { NextResponse } from 'next/server';


// Verify reCAPTCHA Token
async function verifyRecaptcha(token: string) {
const secretKey = process.env.RECAPTCHA_SECRET_KEY;
const response = await fetch(`https://www.google.com/recaptcha/api/siteverify`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
secret: secretKey || '',
response: token,
}),
});
const data = await response.json();
return data.success;
}


// Add a new registration
export async function POST(request: Request) {
const data = await request.json();
const recaptchaToken = data.recaptchaToken; // Extract the reCAPTCHA token from the request

// Verify the reCAPTCHA token
const isRecaptchaValid = await verifyRecaptcha(recaptchaToken);

if (!isRecaptchaValid) {
return NextResponse.json({ message: 'reCAPTCHA verification failed', error: true });
}

// Validate the data
const val = sihValidate(data);

Expand Down
6 changes: 5 additions & 1 deletion app/(default)/leads/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import Leads from "@/components/leads"


export const metadata = {
title: 'Leads',
description: 'Leads page',
}

export default function Leads() {
export default function leads() {

return (
<>
<Leads/>
</>
)
}
11 changes: 11 additions & 0 deletions app/(default)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import Link from "next/link";
import SparklesText from "@/components/magicui/sparkles-text";
import EventComponent from "@/components/eventcards";
import Leads from "@/components/leads";
import Achievements from '@/components/achievements';
import Founder from "@/components/founder";


export default function Home() {
return (
Expand All @@ -33,9 +36,17 @@ export default function Home() {
Register for SIH
</button>
</Link>
{/* Add a download button */}
<a href="/Shortlisted.pdf" download>
<button className="btn-sm px-5 py-3 text-xl font-bold text-white bg-green-600 mx-3 rounded-xl mt-10">
Download Shortlisted Problem Statements
</button>
</a>
</div>
<Domains />
<Activities />
<Founder />
<Achievements/>
<EventComponent />
<Leads />
</>
Expand Down
43 changes: 43 additions & 0 deletions app/(default)/recruitment/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use client'
import RecruitmentForm from "@/components/forms/recruitmentForm";
import DotPattern from "@/components/magicui/dot-pattern";
import "../../css/additional-styles/form.css";
import { cn } from "@/lib/utils";
import { onAuthStateChanged } from "firebase/auth";
import { auth } from "@/Firebase";
import { useEffect } from "react";
import { useRouter } from "next/navigation";

const RegisterPage = () => {
const router = useRouter();

useEffect(() => {
onAuthStateChanged(auth, (user) => {
if (!user) {
router.push("/login");
}
});
});
return (

<div className="w-50 mt-16 mx-auto flex flex-col items-center justify-center">

<div className="form-container my-2">
<RecruitmentForm />
</div>
<DotPattern
width={20}
height={20}
cx={1}
cy={1}
cr={1}
className={cn(
"[mask-image:linear-gradient(to_bottom_right,white,transparent,transparent)] "
)}
/>
</div>

);
};

export default RegisterPage;
13 changes: 12 additions & 1 deletion app/(default)/sihregistration/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
// pages/register.tsx
'use client'
import SIHRegistrationForm from "@/components/forms/sihForm";
import { FormProvider } from "@/components/forms/formContext";
import DotPattern from "@/components/magicui/dot-pattern";
import "../../css/additional-styles/form.css";
import { cn } from "@/lib/utils";
import { onAuthStateChanged } from "firebase/auth";
import { auth } from "@/Firebase";
import { useRouter } from "next/navigation";
const RegisterPage = () => {
const router = useRouter();

onAuthStateChanged(auth, (user) => {
if (!user) {
router.push("/login");
}
});

return (
<FormProvider>
<div className="mt-16 mx-auto flex flex-col items-center justify-center">
Expand Down
3 changes: 2 additions & 1 deletion app/css/additional-styles/landing.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.div-class {
background-image: url("../../../public/images/pbimage3.jpeg");
background-image: url("../../../public/images/google_logo.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
Expand All @@ -8,6 +8,7 @@
}
};


h1{
width: 100%;
height: 100vh;
Expand Down
14 changes: 12 additions & 2 deletions app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
"use client";
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import Login from '../../components/Login';
import Signup from '../../components/Signup';

import { onAuthStateChanged } from 'firebase/auth';
import { auth } from '@/Firebase';
import { useRouter } from 'next/navigation';
export default function Home() {
const [isLogin, setIsLogin] = useState(true);
const router = useRouter();

useEffect(() => {
onAuthStateChanged(auth, (user) => {
if (user) {
router.push('/');
}
});
});
return (
<div className="flex flex-col items-center justify-center min-h-screen pt-20">
<div className="flex space-x-4 mb-6">
Expand Down
4 changes: 3 additions & 1 deletion components/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ const Signup = () => {
id="secret-code"
placeholder=" "
value={secretCode}
onChange={(e) => setSecretCode(e.target.value)}
onChange={(e) => {
console.log(e.target.value);
setSecretCode(e.target.value)}}
className="peer w-full bg-transparent border-0 border-b-2 border-green-500 text-white placeholder-transparent focus:border-green-400 focus:outline-none focus:ring-0 autofill:shadow-[inset_0_0_0px_1000px_rgba(0,0,0,0.8)] autofill:text-white pt-2 m-1"
required
/>
Expand Down
23 changes: 23 additions & 0 deletions components/achievements.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";

import Carousel from "./carousel.component";
import imageOne from "../public/images/pbach1.jpg";
import imageTwo from "../public/images/pbach2.jpg";
import imageThree from "../public/images/pbach3.jpg";

function Achievements() {
let slides = [imageOne, imageTwo, imageThree];

return (
<>
<div className="container place-items-center font-bold pt-20 pb-5">
<h2 className="text-5xl text-white-800 text-center">Achievements</h2>
</div>
<div className="w-[40%] m-auto pt-11">
<Carousel slides={slides} />
</div>
</>
);
}

export default Achievements;
10 changes: 5 additions & 5 deletions components/activities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ export default function Activities() {
return (
<>
<div className="flex flex-col place-items-center font-bold pt-20 pb-10">
<h2 className="text-5xl text-white-800 text-center mb-5">Activities</h2>
<h2 className="text-5xl text-white-800 text-center mb-0">Activities</h2>
</div>

{/* CP Post */}
<div className="flex flex-col md:flex-row w-full h-full" data-aos="zoom-y-out" data-aos-delay="150">
<div className="highlight flex-1 flex items-center justify-center bg-black-800 p-8">
<div className="p-8 md:p-16">
<HyperText className="text-3xl font-bold mb-4 text-green-500" text="Competetive Programming" />
<h2 className="text-2xl font-bold mb-4">PB Hustle</h2>
<p className="text-lg text-justify">
<HyperText className="text-3xl font-bold mb-4 text-green-500 " text="Competitive Programming" />
<h2 className="text-2xl font-bold mb-4 px-10">PB Hustle</h2>
<p className="text-lg text-justify px-16">
Point Blank has organized over 40+ editions of its PB Hustle
coding contest, where participants solve 5-7 increasingly
difficult problems in their preferred programming language. The
Expand Down Expand Up @@ -56,7 +56,7 @@ export default function Activities() {
<div className="highlight flex-1 flex items-center justify-center p-8 bg-black-800">
<div className="p-8 md:p-16 text-justify">
<HyperText className="text-3xl font-bold mb-4 text-green-500" text="Development" />
<h2 className="text-2xl font-bold mb-4">PB Chronicals</h2>
<h2 className="text-2xl font-bold mb-4">PB Chronicles</h2>
<p className="text-lg text-justify">
Point Blank has hosted over 100+ workshops, covering a wide range
of topics including open source, DevOps, machine learning,
Expand Down
61 changes: 61 additions & 0 deletions components/carousel.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

import Image from "next/image";
import { useState } from "react";

import {
BsFillArrowRightCircleFill,
BsFillArrowLeftCircleFill,
} from "react-icons/bs";
export default function Carousel({ slides }) {
let [current, setCurrent] = useState(0);

let previousSlide = () => {
if (current === 0) setCurrent(slides.length - 1);
else setCurrent(current - 1);
};

let nextSlide = () => {
if (current === slides.length - 1) setCurrent(0);
else setCurrent(current + 1);
};

return (
<div className="overflow-hidden relative">
<div
className={`flex transition ease-out duration-1000`}
style={{
transform: `translateX(-${current * 100}%)`,
}}
>
{slides.map((s) => {
return <Image src={s} alt="" className="items-center"/>;
})}
</div>

<div className="absolute top-0 h-full w-full justify-between items-center flex text-white px-10 text-3xl">
<button onClick={previousSlide}>
<BsFillArrowLeftCircleFill />
</button>
<button onClick={nextSlide}>
<BsFillArrowRightCircleFill />
</button>
</div>

<div className="absolute bottom-0 py-4 flex justify-center gap-3 w-full">
{slides.map((s, i) => {
return (
<div
onClick={() => {
setCurrent(i);
}}
key={"circle" + i}
className={`rounded-full w-5 h-5 cursor-pointer ${
i == current ? "bg-white" : "bg-gray-500"
}`}
></div>
);
})}
</div>
</div>
);
}
Loading

0 comments on commit 6745d59

Please sign in to comment.