mirror of
https://gitea.gofwd.group/dstrawsb/ballistic-builder.git
synced 2025-12-05 18:26:45 -05:00
Beta tester component
This commit is contained in:
@@ -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 */}
|
||||
|
||||
@@ -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>
|
||||
|
||||
37
src/app/api/auth/signin/route.tsx
Normal file
37
src/app/api/auth/signin/route.tsx
Normal 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 });
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
41
src/components/BetaTester/index.tsx
Normal file
41
src/components/BetaTester/index.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
export default function BetaTester() {
|
||||
return (
|
||||
<div className="bg-gray-900 py-16 sm:py-24 lg:py-32">
|
||||
<div className="mx-auto grid max-w-7xl grid-cols-1 gap-10 px-6 lg:grid-cols-12 lg:gap-8 lg:px-8">
|
||||
<h2 className="max-w-xl text-balance text-3xl font-semibold tracking-tight text-white sm:text-4xl lg:col-span-7">
|
||||
Interested in being a beta tester? Join the beta tester list.
|
||||
</h2>
|
||||
<form className="w-full max-w-md lg:col-span-5 lg:pt-2">
|
||||
<div className="flex gap-x-4">
|
||||
<label htmlFor="email-address" className="sr-only">
|
||||
Email address
|
||||
</label>
|
||||
<input
|
||||
id="email-address"
|
||||
name="email"
|
||||
type="email"
|
||||
required
|
||||
placeholder="Enter your email"
|
||||
autoComplete="email"
|
||||
className="min-w-0 flex-auto rounded-md bg-white/5 px-3.5 py-2 text-base text-white outline outline-1 -outline-offset-1 outline-white/10 placeholder:text-gray-500 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-500 sm:text-sm/6"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="flex-none rounded-md bg-lime-800 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-lime-900 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-lime-900"
|
||||
>
|
||||
Join The List
|
||||
</button>
|
||||
</div>
|
||||
<p className="mt-4 text-sm/6 text-gray-300">
|
||||
We care about your data. Read our{' '}
|
||||
<a href="#" className="font-semibold text-white">
|
||||
privacy policy
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
21
src/hooks/useAuth.ts
Normal file
21
src/hooks/useAuth.ts
Normal file
@@ -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 };
|
||||
}
|
||||
Reference in New Issue
Block a user