Commit 269feb45 by Arjun Jhukal

updated teh checkout props to fix build

parent 15bfac34
......@@ -9,8 +9,7 @@ interface Props {
searchParams: { amount?: string; bonus?: string };
params: { slug: string };
}
export default async function CheckoutPage(props: Promise<Props>) {
const { searchParams, params } = await props;
export default async function CheckoutPage({ searchParams, params }: Props) {
const amount = searchParams.amount ? Number(searchParams.amount) : 0;
const bonus = searchParams.bonus ? Number(searchParams.bonus) : 0;
const slug = params.slug;
......
"use client";
import { getCookie, setCookie } from '@/utils/ageChecker';
import { useEffect } from 'react';
interface AgeCheckerProps {
apiKey: string;
onVerified?: () => void;
onSkipped?: () => void;
}
// Types for AgeChecker integration
interface AgeCheckerConfig {
mode?: string;
key: string;
path?: string;
onready?: () => void;
onclosed?: () => void;
[key: string]: unknown;
}
interface AgeCheckerAPI {
show: () => void;
[key: string]: unknown;
}
// Extend Window interface to include AgeChecker globals
declare global {
interface Window {
AgeCheckerConfig?: AgeCheckerConfig;
AgeCheckerAPI?: AgeCheckerAPI;
}
}
export const AgeChecker: React.FC<AgeCheckerProps> = ({
apiKey,
onVerified,
onSkipped
}) => {
useEffect(() => {
// Check if user is already verified
if (getCookie("ac_custom_verified")) {
onSkipped?.();
return;
}
// AgeChecker configuration
const config: AgeCheckerConfig = {
mode: "manual",
key: apiKey,
onready: () => {
if (window.AgeCheckerAPI) {
window.AgeCheckerAPI.show();
}
},
onclosed: () => {
setCookie("ac_custom_verified", "true", 30);
onVerified?.();
}
};
// Set global config
window.AgeCheckerConfig = config;
// Check if path condition should prevent loading (from original script)
// Only check if path is defined in config
if (config.path && (window.location.pathname + window.location.search).indexOf(config.path)) {
return;
}
// Load AgeChecker script
const head = document.getElementsByTagName("head")[0];
const script = document.createElement("script");
script.src = "https://cdn.agechecker.net/static/popup/v1/popup.js";
script.crossOrigin = "anonymous";
script.onerror = () => {
window.location.href = "https://agechecker.net/loaderror";
};
head.insertBefore(script, head.firstChild);
// Cleanup function
return () => {
// Remove script if component unmounts
const existingScript = document.querySelector('script[src="https://cdn.agechecker.net/static/popup/v1/popup.js"]');
if (existingScript) {
existingScript.remove();
}
};
}, [apiKey, onVerified, onSkipped]);
return (
<>
{/* NoScript fallback */}
<noscript>
<meta httpEquiv="refresh" content="0;url=https://agechecker.net/noscript" />
</noscript>
</>
);
};
......@@ -3,6 +3,7 @@ import { ThemeContextProvider } from '@/context/ThemeContext'
import { ClientProvider } from '@/hooks/ReduxProvider'
import ThemeCustomization from '@/theme'
import React from 'react'
import { AgeChecker } from './AgeChecker'
export default function ProviderWrapper({ children }: { children: React.ReactNode }) {
return (
......@@ -11,6 +12,11 @@ export default function ProviderWrapper({ children }: { children: React.ReactNod
<ThemeCustomization>
{children}
<Toast />
{/* <AgeChecker
apiKey="lwU8lOYysWXrIZaijSG3Hfcxmzc4DlS9"
onVerified={() => { }}
onSkipped={() => { }}
/> */}
</ThemeCustomization>
</ClientProvider>
</ThemeContextProvider>
......
......@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import ProviderWrapper from "./ProviderWrapper";
import { AgeChecker } from "./AgeChecker";
export const metadata: Metadata = {
title: "Sweepstake",
......@@ -25,6 +26,7 @@ export default function RootLayout({
{/* className="dark" */}
<body className={`${inter.className} scroll-smooth dark`}>
<ProviderWrapper>
{children}
</ProviderWrapper>
</body>
......
// Cookie utilities for age verification
export const getCookie = (name: string): string | null => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) {
return parts.pop()?.split(';').shift() || null;
}
return null;
};
export const setCookie = (name: string, value: string | boolean, days = 30): void => {
const expires = new Date();
expires.setTime(expires.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=/`;
};
export const deleteCookie = (name: string): void => {
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;`;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment