Beta tester component

This commit is contained in:
2024-12-16 11:50:09 -05:00
parent e1a094ff4b
commit 023488a939
7 changed files with 112 additions and 17 deletions

View File

@@ -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,
@@ -17,7 +14,7 @@ export default function RootLayout({
<div className="flex min-h-full flex-col">
<PageHero title="Category" />
<PageHero title={metadata.title} />
<div className="mx-auto flex w-full max-w-7xl items-start gap-x-8 ">
<aside className="sticky top-8 hidden w-44 shrink-0 lg:block pt-4">
{/* Left column area */}

View File

@@ -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 (
<div>
<PageHero title="Magazines" />
<div className="container mx-auto">
<SortTable data={data}></SortTable>
</div>

View File

@@ -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 });
}
}

View File

@@ -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() {
</div>
</div>
<Newsletter />
<BetaTester />
</div>
);
}

View File

@@ -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');