-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 38-integration
- Loading branch information
Showing
38 changed files
with
1,045 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
Oops, something went wrong.