diff --git a/middleware.ts b/middleware.ts deleted file mode 100644 index bb437d8..0000000 --- a/middleware.ts +++ /dev/null @@ -1,30 +0,0 @@ - -import { auth } from '@/app/api/auth/[...nextauth]/route'; -import { NextResponse } from 'next/server'; -import type { NextRequest } from 'next/server'; - -export async function middleware(request: NextRequest) { - const session = await auth(); - const { pathname } = request.nextUrl; - - const isAuthPage = pathname === '/login'; - - if (isAuthPage) { - if (session) { - return NextResponse.redirect(new URL('/admin', request.url)); - } - return null; - } - - if (!session && pathname.startsWith('/admin')) { - const signInUrl = new URL('/login', request.url); - signInUrl.searchParams.set('callbackUrl', pathname); - return NextResponse.redirect(signInUrl); - } - - return NextResponse.next(); -} - -export const config = { - matcher: ['/admin/:path*', '/login'], -}; diff --git a/scripts/seed.ts b/scripts/seed.ts index 39eb0b0..83b452c 100644 --- a/scripts/seed.ts +++ b/scripts/seed.ts @@ -5,16 +5,6 @@ const db = new Database('local.db'); function seed() { console.log('Seeding database...'); - // Create users table if it doesn't exist - db.exec(` - CREATE TABLE IF NOT EXISTS users ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - email TEXT UNIQUE NOT NULL, - password TEXT NOT NULL, - name TEXT NOT NULL - ) - `); - // Create settings table if it doesn't exist db.exec(` CREATE TABLE IF NOT EXISTS settings ( @@ -23,22 +13,6 @@ function seed() { ) `); - // Check if the admin user already exists - const userStmt = db.prepare('SELECT * FROM users WHERE email = ?'); - const adminUser = userStmt.get('admin@example.com'); - - if (!adminUser) { - // Insert the default admin user - // In a real application, you should hash the password! - const insertUser = db.prepare( - "INSERT INTO users (email, password, name) VALUES (?, ?, ?)" - ); - insertUser.run("admin@example.com", "password", "Admin User"); - console.log('Admin user created.'); - } else { - console.log('Admin user already exists.'); - } - // Check if the hourly_rate setting already exists const settingStmt = db.prepare('SELECT * FROM settings WHERE key = ?'); const hourlyRateSetting = settingStmt.get('hourly_rate'); diff --git a/src/app/admin/embed/page.tsx b/src/app/admin/embed/page.tsx deleted file mode 100644 index b9afa76..0000000 --- a/src/app/admin/embed/page.tsx +++ /dev/null @@ -1,85 +0,0 @@ - -'use client'; - -import { useEffect, useState } from 'react'; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, - CardFooter, -} from '@/components/ui/card'; -import { Label } from '@/components/ui/label'; -import { Textarea } from '@/components/ui/textarea'; -import { Button } from '@/components/ui/button'; -import { Clipboard } from 'lucide-react'; -import { useToast } from '@/hooks/use-toast'; - -export default function EmbedPage() { - const [embedCode, setEmbedCode] = useState(''); - const [origin, setOrigin] = useState(''); - const { toast } = useToast(); - - useEffect(() => { - // This ensures window is defined, as it's only available on the client - if (typeof window !== 'undefined') { - const currentOrigin = window.location.origin; - setOrigin(currentOrigin); - setEmbedCode( - `` - ); - } - }, []); - - const handleCopy = () => { - navigator.clipboard.writeText(embedCode).then( - () => { - toast({ - title: 'Copied to Clipboard', - description: 'The embed code has been copied successfully.', - }); - }, - (err) => { - toast({ - title: 'Failed to Copy', - description: 'Could not copy the code. Please try again.', - variant: 'destructive', - }); - console.error('Could not copy text: ', err); - } - ); - }; - - return ( - - - Embed EstimateFlow - - Copy and paste the code below into your website's HTML to embed the - cost estimator flow. - - - -
-
- -