diff --git a/src/app/Products/layout.tsx b/src/app/Products/layout.tsx index c0e3d17..7474e52 100644 --- a/src/app/Products/layout.tsx +++ b/src/app/Products/layout.tsx @@ -2,11 +2,8 @@ import Footer from "@src/components/footer"; import Navbar from "@src/components/Navbar"; import PopNav from "@src/components/PopNav/page"; import PageHero from "@src/components/PageHero"; +import { metadata } from "../layout"; -export const metadata = { - title: "Ballistic Builder", - description: "Built by Forward Group, LLC", -}; export default function RootLayout({ children, diff --git a/src/app/Products/magazines/page.tsx b/src/app/Products/magazines/page.tsx index f8eba77..768d700 100644 --- a/src/app/Products/magazines/page.tsx +++ b/src/app/Products/magazines/page.tsx @@ -3,12 +3,18 @@ import styles from '../styles.module.css'; import PageHero from "@src/components/PageHero"; import SortTable from "@src/components/SortTable"; +export const metadata = { + title: 'Magazines', +} + + export default async function MagsPage() { const data = await getMags(); + + return (
-
diff --git a/src/app/api/auth/signin/route.tsx b/src/app/api/auth/signin/route.tsx new file mode 100644 index 0000000..e644e32 --- /dev/null +++ b/src/app/api/auth/signin/route.tsx @@ -0,0 +1,37 @@ +import { NextResponse } from 'next/server'; +import { db } from '../../../../db'; +import { users } from '../../../../drizzle/schema'; +import bcrypt from 'bcryptjs'; +import { eq } from 'drizzle-orm'; + +export async function POST(request: Request) { + try { + const { email, password } = await request.json(); + + // Fetch the user from the database + const user = await db.select() + .from(users) + .where(eq(users.email, email)) + .limit(1) + .then(rows => rows[0]); + + if (!user) { + return NextResponse.json({ error: 'Invalid email or password' }, { status: 401 }); + } + + // Compare the provided password with the stored hashed password + const isPasswordValid = await bcrypt.compare(password, user.passwordHash); + + if (!isPasswordValid) { + return NextResponse.json({ error: 'Invalid email or password' }, { status: 401 }); + } + + // If authentication is successful, you can set a session or token here + // For example, using JWT or setting a session cookie + + return NextResponse.json({ message: 'Sign in successful', redirect: '/Armory' }, { status: 200 }); + } catch (error) { + console.error('Sign in error:', error); + return NextResponse.json({ error: 'Failed to sign in' }, { status: 500 }); + } +} \ No newline at end of file diff --git a/src/app/page.tsx b/src/app/page.tsx index 925385e..e154b96 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,4 +1,4 @@ -import Newsletter from "@src/components/newsletter"; +import BetaTester from "@src/components/BetaTester"; export default async function Home() { return ( @@ -53,7 +53,7 @@ export default async function Home() {
- + ); } diff --git a/src/app/signin/page.tsx b/src/app/signin/page.tsx index 5d9c435..39af355 100644 --- a/src/app/signin/page.tsx +++ b/src/app/signin/page.tsx @@ -4,13 +4,11 @@ import { useRouter } from 'next/navigation'; import constants from '@src/lib/constants'; import Link from 'next/link'; -export default function SignupPage() { +export default function SignInPage() { const router = useRouter(); const [formData, setFormData] = useState({ - name: '', email: '', password: '', - confirmPassword: '' }); const [error, setError] = useState(''); @@ -18,24 +16,19 @@ export default function SignupPage() { e.preventDefault(); setError(''); - if (formData.password !== formData.confirmPassword) { - setError('Passwords do not match'); - return; - } try { const response = await fetch('/api/auth/signup', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - name: formData.name, email: formData.email, password: formData.password, }), }); if (response.ok) { - router.push('/login'); + router.push('/'); } else { const data = await response.json(); setError(data.error || 'Something went wrong'); diff --git a/src/components/BetaTester/index.tsx b/src/components/BetaTester/index.tsx new file mode 100644 index 0000000..761fd11 --- /dev/null +++ b/src/components/BetaTester/index.tsx @@ -0,0 +1,41 @@ +export default function BetaTester() { + return ( +
+
+

+ Interested in being a beta tester? Join the beta tester list. +

+
+
+ + + +
+

+ We care about your data. Read our{' '} + + privacy policy + + . +

+
+
+
+ ) + } + \ No newline at end of file diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts new file mode 100644 index 0000000..e5f556a --- /dev/null +++ b/src/hooks/useAuth.ts @@ -0,0 +1,21 @@ +'use client'; + +export function useAuth() { + const isLoggedIn = () => { + if (typeof window === 'undefined') return false; + return !!localStorage.getItem('dev_user'); + }; + + const getUser = () => { + if (typeof window === 'undefined') return null; + const user = localStorage.getItem('dev_user'); + return user ? JSON.parse(user) : null; + }; + + const logout = () => { + localStorage.removeItem('dev_user'); + window.location.href = '/signin'; + }; + + return { isLoggedIn, getUser, logout }; +} \ No newline at end of file