-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from kamini08/main
- Loading branch information
Showing
7 changed files
with
154 additions
and
71 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,64 @@ | ||
import { db } from "@/Firebase"; | ||
|
||
import { recruitValidate } from "@/lib/server/utils"; | ||
|
||
import { | ||
addDoc, | ||
collection, | ||
getDocs, | ||
limit, | ||
query, | ||
where, | ||
} from "firebase/firestore"; | ||
import { NextResponse } from "next/server"; | ||
|
||
// Add a new registration | ||
export async function POST(request: Request) { | ||
const formData = await request.json(); | ||
const { recaptcha_token } = formData; | ||
|
||
|
||
const recaptchaToken = recaptcha_token; | ||
|
||
const details = { | ||
event: { | ||
token: recaptchaToken, | ||
siteKey: process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY, | ||
}, | ||
}; | ||
|
||
|
||
if (!recaptchaToken) { | ||
return NextResponse.json( | ||
{ | ||
message: "reCAPTCHA token not found! Try again", | ||
error: "reCAPTCHA token not found!", | ||
}, | ||
{ | ||
status: 500, | ||
} | ||
); | ||
} | ||
|
||
// Verify the reCATPTCHA token | ||
|
||
const recaptchaResponse = await fetch( | ||
`https://recaptchaenterprise.googleapis.com/v1/projects/${process.env.RECAPTCHA_PROJECT}/assessments?key=${process.env.RECAPTCHA_API_KEY}`, | ||
{ | ||
method: "POST", | ||
body: JSON.stringify(details), | ||
} | ||
); | ||
|
||
const recaptchaResult = await recaptchaResponse.json(); | ||
console.log(recaptchaResult.riskAnalysis.score); | ||
if (recaptchaResult.riskAnalysis.score < 0.7) { | ||
return NextResponse.json({ | ||
message: "reCAPTCHA validation failed", | ||
error: recaptchaResult["error-codes"], | ||
}); | ||
} | ||
|
||
// Return a response | ||
return NextResponse.json({ message: "Recaptcha validated!" }); | ||
} |
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
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,66 +1,50 @@ | ||
|
||
|
||
export default function Success(props: any) { | ||
return ( | ||
<div className="w-full mx-auto"> | ||
<div className="flex flex-col p-5 rounded-lg shadow"> | ||
|
||
return( | ||
|
||
<div className="w-full max-w-md mx-auto px-4 sm:px-6 lg:px-8"> | ||
<div className="flex flex-col p-6 sm:p-8 rounded-lg shadow-lg bg-black bg-opacity-30 backdrop-blur-lg border border-green-500"> | ||
<div className="flex flex-col items-center text-center"> | ||
<div className="inline-block p-4 bg-green-300 rounded-full"> | ||
<div className="inline-block p-4 bg-green-500 rounded-full animate-bounce"> | ||
<svg | ||
className="w-8 h-8 text-white" | ||
fill="none" | ||
stroke="currentColor" | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
x="0px" | ||
y="0px" | ||
width="100" | ||
height="100" | ||
viewBox="0 0 64 64" | ||
> | ||
<circle cx="32" cy="32" r="23" fill="#98c900"></circle> | ||
<path | ||
fill="#fff" | ||
d="M31.921,13.966c2.577,0,4.674-1.957,4.946-4.461c-1.594-0.349-3.247-0.539-4.946-0.539 c-12.703,0-23,10.297-23,23c0,1.699,0.19,3.352,0.539,4.946c2.505-0.272,4.461-2.369,4.461-4.946 C13.921,22.041,21.997,13.966,31.921,13.966z" | ||
opacity=".3" | ||
></path> | ||
<path | ||
d="M54.382,27.021c-2.505,0.272-4.461,2.369-4.461,4.946c0,9.925-8.075,18-18,18 c-2.577,0-4.674,1.957-4.946,4.461c1.594,0.349,3.247,0.539,4.946,0.539c12.703,0,23-10.297,23-23 C54.921,30.268,54.732,28.614,54.382,27.021z" | ||
opacity=".15" | ||
></path> | ||
<path | ||
fill="none" | ||
stroke="#fff" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-miterlimit="10" | ||
stroke-width="3" | ||
d="M14.968,23.393c1.878-3.699,4.932-6.705,8.666-8.522" | ||
></path> | ||
<ellipse cx="32" cy="61" opacity=".3" rx="19" ry="3"></ellipse> | ||
<g> | ||
<path | ||
fill="#edff9c" | ||
d="M29,42c-0.512,0-1.023-0.195-1.414-0.586l-7-7c-0.781-0.781-0.781-2.047,0-2.828 c0.781-0.781,2.047-0.781,2.828,0L29,37.171l12.586-12.585c0.781-0.781,2.047-0.781,2.828,0c0.781,0.781,0.781,2.047,0,2.828 l-14,14C30.023,41.805,29.512,42,29,42z" | ||
></path> | ||
</g> | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth={2} | ||
d="M5 13l4 4L19 7" | ||
/> | ||
</svg> | ||
</div> | ||
<h2 className="mt-2 font-semibold text-gray-100"> | ||
Registration Successfull! | ||
<h2 className="mt-4 text-2xl sm:text-3xl font-bold text-green-500"> | ||
Registration Successful! | ||
</h2> | ||
<p className="mt-2 text-sm text-gray-500 leading-relaxed"> | ||
{props.message} | ||
<p className="mt-4 text-lg text-gray-300 leading-relaxed"> | ||
{props.message} | ||
</p> | ||
<p className="mt-2 text-sm text-gray-400 leading-relaxed"> | ||
Join the Whatsapp Group for further updates immediately. | ||
<p className="mt-2 text-md text-gray-400 leading-relaxed"> | ||
Join the WhatsApp Group for further updates immediately. | ||
</p> | ||
</div> | ||
|
||
<div className="flex mx-auto items-center mt-3"> | ||
<a href={props.joinLink}> | ||
<button className="flex-1 px-4 py-2 mx-auto bg-green-500 hover:bg-green-600 text-white text-sm rounded-md"> | ||
Join the Whatsapp Group! | ||
<div className="flex mx-auto items-center mt-6"> | ||
<a | ||
href={props.joinLink} | ||
className="w-full" | ||
> | ||
<button className="w-full px-6 py-3 bg-green-500 hover:bg-green-600 text-white text-lg font-semibold rounded-full transition duration-300 transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-green-400 focus:ring-opacity-50"> | ||
Join WhatsApp Group! | ||
</button> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
); | ||
|
||
} |