diff --git a/omniparse-hf-space (1)/.dockerignore b/omniparse-hf-space (1)/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..7a25b3381552a979e5ee235e47b88307a3e08a19 --- /dev/null +++ b/omniparse-hf-space (1)/.dockerignore @@ -0,0 +1,29 @@ +node_modules +.next +.git +.gitignore +db/ +*.db +*.log +dev.log +server.log +tool-results/ +download/ +hf-deploy/ +examples/ +agent-ctx/ +vercel/ +--output +.env +*.png +*.jpg +*.jpeg +claude* +.z-ai-config +.claude +Caddyfile +hf_*.py +hf_*.json +bun.lock +README.md +worklog.md \ No newline at end of file diff --git a/omniparse-hf-space (1)/Dockerfile b/omniparse-hf-space (1)/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a2b48b238472affc0b896058818a47159fd8ba15 --- /dev/null +++ b/omniparse-hf-space (1)/Dockerfile @@ -0,0 +1,51 @@ +# ── Stage 1: Install dependencies ───────────────────────────────────── +FROM node:20-alpine AS deps +WORKDIR /app + +# Copy package.json AND prisma schema (postinstall needs schema) +COPY package.json ./ +COPY prisma ./prisma/ + +# Install deps without scripts (prisma generate runs in builder stage) +RUN npm install --ignore-scripts 2>/dev/null + +# ── Stage 2: Build the Next.js app ──────────────────────────────────── +FROM node:20-alpine AS builder +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Generate Prisma client then build +RUN npx prisma generate +RUN npm run build + +# ── Stage 3: Production ─────────────────────────────────────────────── +FROM node:20-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=7860 +ENV HOSTNAME="0.0.0.0" + +# Create db directory for SQLite +RUN mkdir -p /app/db + +# Copy standalone output +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/public ./public + +# Copy Prisma schema + engine for db push on startup +COPY --from=builder /app/prisma ./prisma +COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma +COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma +COPY --from=builder /app/node_modules/prisma ./node_modules/prisma + +EXPOSE 7860 + +# Entrypoint: init DB then start server +RUN printf '#!/bin/sh\nnpx prisma db push --skip-generate 2>&1 || true\nexec node /app/server.js\n' > /app/entrypoint.sh \ + && chmod +x /app/entrypoint.sh + +CMD ["/app/entrypoint.sh"] \ No newline at end of file diff --git a/omniparse-hf-space (1)/README.md b/omniparse-hf-space (1)/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2c0fabf7cb9e739c21e0e50620314e507c7ae316 --- /dev/null +++ b/omniparse-hf-space (1)/README.md @@ -0,0 +1,42 @@ +--- +title: OmniParse AI +emoji: "\U0001F4CB" +colorFrom: yellow +colorTo: zinc +sdk: docker +app_port: 7860 +pinned: false +license: mit +--- + +# OmniParse AI — Invoice Processing in Seconds + +AI-powered invoice processing SaaS. Upload PDFs or images and extract vendor, dates, amounts, and line items as structured data. + +## Features + +- **Secure Auth** — Signup/login with bcrypt-hashed passwords, session tokens, rate limiting +- **Upload Invoices** — PDF, JPEG, PNG, TIFF support (up to 20 MB) +- **Dashboard** — View, filter, and manage extracted invoices +- **AI Chat** — Ask questions about your invoices (Pro plan) +- **Export** — CSV, JSON, Excel (XLSX) downloads +- **Demo Mode** — Login with `demo@omniparse.ai` / `demo1234` to see 20 sample invoices +- **Dark Theme** — Full dark/light mode support + +## Quick Start + +1. The Space builds automatically on push +2. Wait for the Docker build to complete (~2-3 minutes) +3. Sign up for a new account or use the demo credentials: + - **Email:** `demo@omniparse.ai` + - **Password:** `demo1234` +4. Visit `/api/seed` once to populate demo data (auto-seeded on first request) + +## Tech Stack + +- **Next.js 16** (App Router, standalone output) +- **TypeScript 5** +- **Tailwind CSS 4** + shadcn/ui +- **Prisma ORM** (SQLite) +- **Zod** for validation +- **bcryptjs** for password hashing \ No newline at end of file diff --git a/omniparse-hf-space (1)/components.json b/omniparse-hf-space (1)/components.json new file mode 100644 index 0000000000000000000000000000000000000000..ffe928f5b6dfe484f57a5fd47d0487f21e164fa3 --- /dev/null +++ b/omniparse-hf-space (1)/components.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "new-york", + "rsc": true, + "tsx": true, + "tailwind": { + "config": "", + "css": "src/app/globals.css", + "baseColor": "neutral", + "cssVariables": true, + "prefix": "" + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils", + "ui": "@/components/ui", + "lib": "@/lib", + "hooks": "@/hooks" + }, + "iconLibrary": "lucide" +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/eslint.config.mjs b/omniparse-hf-space (1)/eslint.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..84578b30a5400c49ff17f1a8872824427ed5ff71 --- /dev/null +++ b/omniparse-hf-space (1)/eslint.config.mjs @@ -0,0 +1,50 @@ +import nextCoreWebVitals from "eslint-config-next/core-web-vitals"; +import nextTypescript from "eslint-config-next/typescript"; +import { dirname } from "path"; +import { fileURLToPath } from "url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +const eslintConfig = [...nextCoreWebVitals, ...nextTypescript, { + rules: { + // TypeScript rules + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/prefer-as-const": "off", + "@typescript-eslint/no-unused-disable-directive": "off", + + // React rules + "react-hooks/exhaustive-deps": "off", + "react-hooks/purity": "off", + "react/no-unescaped-entities": "off", + "react/display-name": "off", + "react/prop-types": "off", + "react-compiler/react-compiler": "off", + + // Next.js rules + "@next/next/no-img-element": "off", + "@next/next/no-html-link-for-pages": "off", + + // General JavaScript rules + "prefer-const": "off", + "no-unused-vars": "off", + "no-console": "off", + "no-debugger": "off", + "no-empty": "off", + "no-irregular-whitespace": "off", + "no-case-declarations": "off", + "no-fallthrough": "off", + "no-mixed-spaces-and-tabs": "off", + "no-redeclare": "off", + "no-undef": "off", + "no-unreachable": "off", + "no-useless-escape": "off", + }, +}, { + ignores: ["node_modules/**", ".next/**", "out/**", "build/**", "next-env.d.ts", "examples/**", "skills"] +}]; + +export default eslintConfig; diff --git a/omniparse-hf-space (1)/next.config.ts b/omniparse-hf-space (1)/next.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..0bd2f1124a09380d96f5128412059e51f4af8106 --- /dev/null +++ b/omniparse-hf-space (1)/next.config.ts @@ -0,0 +1,12 @@ +import type { NextConfig } from "next"; + +const nextConfig: NextConfig = { + output: "standalone", + /* config options here */ + typescript: { + ignoreBuildErrors: true, + }, + reactStrictMode: false, +}; + +export default nextConfig; diff --git a/omniparse-hf-space (1)/package.json b/omniparse-hf-space (1)/package.json new file mode 100644 index 0000000000000000000000000000000000000000..564d410e2bdce05101a7879a4867085131f76320 --- /dev/null +++ b/omniparse-hf-space (1)/package.json @@ -0,0 +1,100 @@ +{ + "name": "nextjs_tailwind_shadcn_ts", + "version": "0.2.0", + "private": true, + "scripts": { + "dev": "next dev -p 3000 2>&1 | tee dev.log", + "build": "next build && cp -r .next/static .next/standalone/.next/ && cp -r public .next/standalone/", + "start": "NODE_ENV=production node .next/standalone/server.js", + "start:bun": "NODE_ENV=production bun .next/standalone/server.js", + "lint": "eslint .", + "db:push": "prisma db push", + "db:generate": "prisma generate", + "db:migrate": "prisma migrate dev", + "db:reset": "prisma migrate reset", + "postinstall": "prisma generate", + "koyeb:build": "prisma generate && next build && cp -r .next/static .next/standalone/.next/ && cp -r public .next/standalone/", + "koyeb:start": "npx prisma db push --skip-generate 2>/dev/null; NODE_ENV=production node .next/standalone/server.js" + }, + "dependencies": { + "@dnd-kit/core": "^6.3.1", + "@dnd-kit/sortable": "^10.0.0", + "@dnd-kit/utilities": "^3.2.2", + "@hookform/resolvers": "^5.1.1", + "@mdxeditor/editor": "^3.39.1", + "@prisma/client": "^6.11.1", + "@radix-ui/react-accordion": "^1.2.11", + "@radix-ui/react-alert-dialog": "^1.1.14", + "@radix-ui/react-aspect-ratio": "^1.1.7", + "@radix-ui/react-avatar": "^1.1.10", + "@radix-ui/react-checkbox": "^1.3.2", + "@radix-ui/react-collapsible": "^1.1.11", + "@radix-ui/react-context-menu": "^2.2.15", + "@radix-ui/react-dialog": "^1.1.14", + "@radix-ui/react-dropdown-menu": "^2.1.15", + "@radix-ui/react-hover-card": "^1.1.14", + "@radix-ui/react-label": "^2.1.7", + "@radix-ui/react-menubar": "^1.1.15", + "@radix-ui/react-navigation-menu": "^1.2.13", + "@radix-ui/react-popover": "^1.1.14", + "@radix-ui/react-progress": "^1.1.7", + "@radix-ui/react-radio-group": "^1.3.7", + "@radix-ui/react-scroll-area": "^1.2.9", + "@radix-ui/react-select": "^2.2.5", + "@radix-ui/react-separator": "^1.1.7", + "@radix-ui/react-slider": "^1.3.5", + "@radix-ui/react-slot": "^1.2.3", + "@radix-ui/react-switch": "^1.2.5", + "@radix-ui/react-tabs": "^1.1.12", + "@radix-ui/react-toast": "^1.2.14", + "@radix-ui/react-toggle": "^1.1.9", + "@radix-ui/react-toggle-group": "^1.1.10", + "@radix-ui/react-tooltip": "^1.2.7", + "@reactuses/core": "^6.0.5", + "@tanstack/react-query": "^5.82.0", + "@tanstack/react-table": "^8.21.3", + "bcryptjs": "^3.0.3", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "cmdk": "^1.1.1", + "date-fns": "^4.1.0", + "embla-carousel-react": "^8.6.0", + "exceljs": "^4.4.0", + "framer-motion": "^12.23.2", + "input-otp": "^1.4.2", + "lucide-react": "^0.525.0", + "next": "^16.1.1", + "next-auth": "^4.24.11", + "next-intl": "^4.3.4", + "next-themes": "^0.4.6", + "prisma": "^6.11.1", + "react": "^19.0.0", + "react-day-picker": "^9.8.0", + "react-dom": "^19.0.0", + "react-hook-form": "^7.60.0", + "react-markdown": "^10.1.0", + "react-resizable-panels": "^3.0.3", + "react-syntax-highlighter": "^15.6.1", + "recharts": "^2.15.4", + "sharp": "^0.34.3", + "sonner": "^2.0.6", + "tailwind-merge": "^3.3.1", + "tailwindcss-animate": "^1.0.7", + "uuid": "^11.1.0", + "vaul": "^1.1.2", + "zod": "^4.4.3", + "zustand": "^5.0.6" + }, + "devDependencies": { + "@tailwindcss/postcss": "^4", + "@types/bcryptjs": "^3.0.0", + "@types/react": "^19", + "@types/react-dom": "^19", + "@types/uuid": "^11.0.0", + "eslint": "^9", + "eslint-config-next": "^16.1.1", + "tailwindcss": "^4", + "tw-animate-css": "^1.3.5", + "typescript": "^5" + } +} diff --git a/omniparse-hf-space (1)/postcss.config.mjs b/omniparse-hf-space (1)/postcss.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c7bcb4b1ee14cd5e25078c2c934529afdd2a7df9 --- /dev/null +++ b/omniparse-hf-space (1)/postcss.config.mjs @@ -0,0 +1,5 @@ +const config = { + plugins: ["@tailwindcss/postcss"], +}; + +export default config; diff --git a/omniparse-hf-space (1)/prisma/schema.prisma b/omniparse-hf-space (1)/prisma/schema.prisma new file mode 100644 index 0000000000000000000000000000000000000000..4a124f9c93733a1a6923e000afbcc03c247eff34 --- /dev/null +++ b/omniparse-hf-space (1)/prisma/schema.prisma @@ -0,0 +1,80 @@ +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "sqlite" + url = "file:../db/custom.db" +} + +model User { + id String @id @default(cuid()) + email String @unique + name String + password String + plan String @default("free") + stripeCid String? + apiKey String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + sessions Session[] + invoices Invoice[] + activityLogs ActivityLog[] +} + +model Session { + id String @id @default(cuid()) + token String @unique + userId String + expiresAt DateTime + createdAt DateTime @default(now()) + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) +} + +model Invoice { + id String @id @default(cuid()) + userId String + filename String? + vendor String? + invNumber String? + invDate String? + dueDate String? + amount Float? + vatAmount Float? + total Float? + currency String @default("USD") + status String @default("done") + isDuplicate Boolean @default(false) + confidence Float? + rawJson String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) +} + +model RateLimit { + id String @id @default(cuid()) + key String @unique + count Int @default(0) + resetAt DateTime + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model ActivityLog { + id String @id @default(cuid()) + userId String + type String + title String + description String + metadata String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@index([userId]) +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/public/logo.svg b/omniparse-hf-space (1)/public/logo.svg new file mode 100644 index 0000000000000000000000000000000000000000..d93ac8f66e41897acac0185396d5b91c32856c9a --- /dev/null +++ b/omniparse-hf-space (1)/public/logo.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + diff --git a/omniparse-hf-space (1)/public/robots.txt b/omniparse-hf-space (1)/public/robots.txt new file mode 100644 index 0000000000000000000000000000000000000000..6018e701fc7dd0317cda9eceea390524322e8a05 --- /dev/null +++ b/omniparse-hf-space (1)/public/robots.txt @@ -0,0 +1,14 @@ +User-agent: Googlebot +Allow: / + +User-agent: Bingbot +Allow: / + +User-agent: Twitterbot +Allow: / + +User-agent: facebookexternalhit +Allow: / + +User-agent: * +Allow: / diff --git a/omniparse-hf-space (1)/src/app/api/activity/route.ts b/omniparse-hf-space (1)/src/app/api/activity/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..2461ddd1605b68a120b9cc3f5c567995e024a63e --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/activity/route.ts @@ -0,0 +1,24 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { getCookieToken, getSessionUser } from '@/lib/auth'; + +export async function GET(req: NextRequest) { + try { + const token = getCookieToken(req); + if (!token) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + const user = await getSessionUser(token); + if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + const logs = await db.activityLog.findMany({ + where: { userId: user.id }, + orderBy: { createdAt: 'desc' }, + take: 50, + }); + + return NextResponse.json({ activities: logs }); + } catch (error) { + console.error('Activity fetch error:', error); + return NextResponse.json({ error: 'Internal error' }, { status: 500 }); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/auth/login/route.ts b/omniparse-hf-space (1)/src/app/api/auth/login/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..64ca57e94a83d326af461e2dc605b295833491da --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/auth/login/route.ts @@ -0,0 +1,89 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { loginSchema, getClientIp } from '@/lib/validation'; +import { + verifyPassword, + createSession, + SESSION_COOKIE_NAME, +} from '@/lib/auth'; +import { authRateLimit } from '@/lib/rate-limit'; +import { logActivity } from '@/lib/activity'; + +export async function POST(request: NextRequest) { + try { + // ── Rate Limit ──────────────────────────────────────────────────── + const ip = getClientIp(request); + const { allowed, retryAfterMs } = await authRateLimit(`auth:${ip}`); + if (!allowed) { + return NextResponse.json( + { error: 'Too many login attempts. Please try again later.' }, + { + status: 429, + headers: { 'Retry-After': String(Math.ceil(retryAfterMs / 1000)) }, + } + ); + } + + // ── Parse & Validate Body ───────────────────────────────────────── + const body = await request.json(); + const parsed = loginSchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json( + { error: parsed.error.issues[0].message }, + { status: 400 } + ); + } + + const { email, password } = parsed.data; + + // ── Find User ───────────────────────────────────────────────────── + const user = await db.user.findUnique({ where: { email } }); + if (!user) { + return NextResponse.json( + { error: 'Invalid email or password' }, + { status: 401 } + ); + } + + // ── Verify Password ─────────────────────────────────────────────── + const valid = await verifyPassword(password, user.password); + if (!valid) { + return NextResponse.json( + { error: 'Invalid email or password' }, + { status: 401 } + ); + } + + // ── Create Session ──────────────────────────────────────────────── + const token = await createSession(user.id); + + // ── Set Cookie & Respond ────────────────────────────────────────── + const response = NextResponse.json({ + user: { + id: user.id, + email: user.email, + name: user.name, + plan: user.plan, + createdAt: user.createdAt, + }, + }); + + response.cookies.set(SESSION_COOKIE_NAME, token, { + httpOnly: true, + secure: true, + sameSite: 'lax', + path: '/', + maxAge: 7 * 24 * 60 * 60, // 7 days + }); + + logActivity(user.id, 'login', 'Logged in', 'Signed in successfully'); + + return response; + } catch (error) { + console.error('[LOGIN_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/auth/logout/route.ts b/omniparse-hf-space (1)/src/app/api/auth/logout/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..f31bd2d09d984b42298b730a5aa0e5be95f619b0 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/auth/logout/route.ts @@ -0,0 +1,30 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { getCookieToken, deleteSession, SESSION_COOKIE_NAME } from '@/lib/auth'; + +export async function POST(request: NextRequest) { + try { + const token = getCookieToken(request); + + if (token) { + await deleteSession(token); + } + + const response = NextResponse.json({ success: true }); + + response.cookies.set(SESSION_COOKIE_NAME, '', { + httpOnly: true, + secure: true, + sameSite: 'lax', + path: '/', + maxAge: 0, + }); + + return response; + } catch (error) { + console.error('[LOGOUT_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/auth/me/route.ts b/omniparse-hf-space (1)/src/app/api/auth/me/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..d058e9eca2449d3369b6e73bcfa84e527538c1d5 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/auth/me/route.ts @@ -0,0 +1,33 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { getCookieToken, getSessionUser } from '@/lib/auth'; + +export async function GET(request: NextRequest) { + try { + const token = getCookieToken(request); + if (!token) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + const user = await getSessionUser(token); + if (!user) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + return NextResponse.json({ + user: { + id: user.id, + email: user.email, + name: user.name, + plan: user.plan, + apiKey: user.apiKey, + createdAt: user.createdAt, + }, + }); + } catch (error) { + console.error('[ME_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/auth/password/route.ts b/omniparse-hf-space (1)/src/app/api/auth/password/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..f93efae13d6c03ae35c391f03de43859eca96c72 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/auth/password/route.ts @@ -0,0 +1,81 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { changePasswordSchema, getClientIp } from '@/lib/validation'; +import { getSessionUser, verifyPassword, hashPassword, getCookieToken } from '@/lib/auth'; +import { rateLimit } from '@/lib/rate-limit'; +import { logActivity } from '@/lib/activity'; + +export async function POST(request: NextRequest) { + try { + // ── Rate Limit ──────────────────────────────────────────────────── + const ip = getClientIp(request); + const { allowed, retryAfterMs } = await rateLimit(`password:${ip}`, 3, 60_000); + if (!allowed) { + return NextResponse.json( + { error: 'Too many password change attempts. Please try again later.' }, + { + status: 429, + headers: { 'Retry-After': String(Math.ceil(retryAfterMs / 1000)) }, + } + ); + } + + // ── Authenticate User ───────────────────────────────────────────── + const token = getCookieToken(request); + const user = await getSessionUser(token || ''); + if (!user) { + return NextResponse.json( + { error: 'Authentication required' }, + { status: 401 } + ); + } + + // ── Parse & Validate Body ───────────────────────────────────────── + const body = await request.json(); + const parsed = changePasswordSchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json( + { error: parsed.error.issues[0].message }, + { status: 400 } + ); + } + + const { currentPassword, newPassword } = parsed.data; + + // ── Verify Current Password ─────────────────────────────────────── + const valid = await verifyPassword(currentPassword, user.password); + if (!valid) { + return NextResponse.json( + { error: 'Invalid credentials' }, + { status: 401 } + ); + } + + // ── Hash New Password ───────────────────────────────────────────── + const hashedPassword = await hashPassword(newPassword); + + // ── Update User Password ────────────────────────────────────────── + await db.user.update({ + where: { id: user.id }, + data: { password: hashedPassword }, + }); + + // ── Invalidate All Sessions (force re-login) ────────────────────── + await db.session.deleteMany({ + where: { userId: user.id }, + }); + + logActivity(user.id, 'password_change', 'Password changed', 'Account password was updated'); + + return NextResponse.json({ + success: true, + message: 'Password updated successfully', + }); + } catch (error) { + console.error('[PASSWORD_CHANGE_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/auth/signup/route.ts b/omniparse-hf-space (1)/src/app/api/auth/signup/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..9517c672b7f568f388cc93a54feecb5172ccf671 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/auth/signup/route.ts @@ -0,0 +1,98 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { signupSchema, getClientIp } from '@/lib/validation'; +import { + hashPassword, + createSession, + generateApiKey, + SESSION_COOKIE_NAME, +} from '@/lib/auth'; +import { authRateLimit } from '@/lib/rate-limit'; +import { logActivity } from '@/lib/activity'; + +export async function POST(request: NextRequest) { + try { + // ── Rate Limit ──────────────────────────────────────────────────── + const ip = getClientIp(request); + const { allowed, retryAfterMs } = await authRateLimit(`auth:${ip}`); + if (!allowed) { + return NextResponse.json( + { error: 'Too many signup attempts. Please try again later.' }, + { + status: 429, + headers: { 'Retry-After': String(Math.ceil(retryAfterMs / 1000)) }, + } + ); + } + + // ── Parse & Validate Body ───────────────────────────────────────── + const body = await request.json(); + const parsed = signupSchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json( + { error: parsed.error.issues[0].message }, + { status: 400 } + ); + } + + const { name, email, password } = parsed.data; + + // ── Check if Email Exists ───────────────────────────────────────── + const existing = await db.user.findUnique({ where: { email } }); + if (existing) { + return NextResponse.json( + { error: 'An account with this email already exists' }, + { status: 409 } + ); + } + + // ── Hash Password & Generate API Key ────────────────────────────── + const [hashedPassword, apiKey] = await Promise.all([ + hashPassword(password), + generateApiKey(), + ]); + + // ── Create User ─────────────────────────────────────────────────── + const user = await db.user.create({ + data: { + name, + email, + password: hashedPassword, + apiKey, + plan: 'free', + }, + }); + + // ── Create Session ──────────────────────────────────────────────── + const token = await createSession(user.id); + + // ── Set Cookie & Respond ────────────────────────────────────────── + const response = NextResponse.json({ + user: { + id: user.id, + email: user.email, + name: user.name, + plan: user.plan, + createdAt: user.createdAt, + }, + }); + + response.cookies.set(SESSION_COOKIE_NAME, token, { + httpOnly: true, + secure: true, + sameSite: 'lax', + path: '/', + maxAge: 7 * 24 * 60 * 60, // 7 days + }); + + logActivity(user.id, 'signup', 'Account created', user.email); + + return response; + } catch (error) { + console.error('[SIGNUP_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/chat/route.ts b/omniparse-hf-space (1)/src/app/api/chat/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..bee8cc8f6f2fe8a111f6088df43a8b84a26924fa --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/chat/route.ts @@ -0,0 +1,215 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { getCookieToken, getSessionUser } from '@/lib/auth'; +import { chatSchema } from '@/lib/validation'; +import { chatRateLimit } from '@/lib/rate-limit'; + +function buildInvoiceContext(userId: string): string { + // Intentionally synchronous placeholder — actual query runs async + return ''; +} + +export async function POST(request: NextRequest) { + try { + // ── Auth ────────────────────────────────────────────────────────── + const token = getCookieToken(request); + if (!token) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + const user = await getSessionUser(token); + if (!user) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + // ── Plan Check (Pro / Enterprise only) ─────────────────────────── + if (user.plan !== 'pro' && user.plan !== 'enterprise') { + return NextResponse.json( + { error: 'AI Chat is available on Pro and Enterprise plans. Please upgrade your plan.' }, + { status: 403 } + ); + } + + // ── Rate Limit ──────────────────────────────────────────────────── + const { allowed, retryAfterMs } = await chatRateLimit(`chat:${user.id}`); + if (!allowed) { + return NextResponse.json( + { error: 'Chat rate limit exceeded. Please try again later.' }, + { + status: 429, + headers: { 'Retry-After': String(Math.ceil(retryAfterMs / 1000)) }, + } + ); + } + + // ── Validate Body ───────────────────────────────────────────────── + const body = await request.json(); + const parsed = chatSchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json( + { error: parsed.error.issues[0].message }, + { status: 400 } + ); + } + + const { message, history = [] } = parsed.data; + + // ── Fetch User's Invoices for Context ───────────────────────────── + const recentInvoices = await db.invoice.findMany({ + where: { userId: user.id }, + orderBy: { createdAt: 'desc' }, + take: 20, + }); + + const invoiceSummary = recentInvoices.length > 0 + ? recentInvoices + .map( + (inv) => + `- Invoice ${inv.invNumber || 'N/A'} from ${inv.vendor || 'Unknown'}: ${inv.currency} ${inv.total ?? 0} (${inv.status}, ${inv.isDuplicate ? 'duplicate' : 'unique'}, confidence: ${inv.confidence ? (inv.confidence * 100).toFixed(0) + '%' : 'N/A'})` + ) + .join('\n') + : 'No invoices found.'; + + const totalAmount = recentInvoices.reduce((sum, inv) => sum + (inv.total ?? 0), 0); + const duplicateCount = recentInvoices.filter((inv) => inv.isDuplicate).length; + + const systemPrompt = `You are OmniParse AI, an intelligent invoice processing assistant. You help users understand, analyze, and manage their invoices. Be concise, helpful, and professional. + +Here is the user's recent invoice data: +Total invoices (recent 20): ${recentInvoices.length} +Total amount: USD ${totalAmount.toFixed(2)} +Duplicates found: ${duplicateCount} + +${invoiceSummary} + +The user is on the "${user.plan}" plan. Answer questions about their invoices, provide spending insights, flag potential duplicates, and help with invoice management. Keep responses concise and actionable.`; + + // ── Try AI SDK, Fall Back to Demo Response ──────────────────────── + let aiResponse: string; + + try { + // Attempt to use z-ai-web-dev-sdk for real AI responses + const { default: ZAI } = await import('z-ai-web-dev-sdk'); + const zai = await ZAI.create(); + + const messages: Array<{ role: string; content: string }> = [ + { role: 'system', content: systemPrompt }, + ...history.map((h) => ({ role: h.role, content: h.content })), + { role: 'user', content: message }, + ]; + + const result = await zai.chat.completions.create({ + model: 'default', + messages: messages as never, + }); + + const completion = result as Record; + const choices = completion.choices as Array<{ message: { content: string } }>; + aiResponse = choices?.[0]?.message?.content ?? 'I was unable to generate a response. Please try again.'; + } catch { + // Fallback: Generate a helpful context-aware demo response + aiResponse = generateDemoResponse(message, recentInvoices, totalAmount, duplicateCount, user.plan); + } + + return NextResponse.json({ reply: aiResponse }); + } catch (error) { + console.error('[CHAT_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} + +// ─── Demo Response Generator (fallback when AI SDK unavailable) ──────────────── + +function generateDemoResponse( + message: string, + invoices: Array<{ + vendor: string | null; + invNumber: string | null; + total: number | null; + currency: string; + status: string; + isDuplicate: boolean; + confidence: number | null; + invDate: string | null; + dueDate: string | null; + }>, + totalAmount: number, + duplicateCount: number, + plan: string +): string { + const msgLower = message.toLowerCase(); + + // Summary / overview queries + if (msgLower.includes('summary') || msgLower.includes('overview') || msgLower.includes('how many')) { + if (invoices.length === 0) { + return "You don't have any invoices yet. Upload some invoices to get started, and I'll help you analyze them!"; + } + const vendors = [...new Set(invoices.map((i) => i.vendor).filter(Boolean))]; + const avgAmount = totalAmount / invoices.length; + return `Here's a quick overview of your invoices:\n\n` + + `📊 **Total invoices:** ${invoices.length}\n` + + `💰 **Total amount:** $${totalAmount.toFixed(2)}\n` + + `📈 **Average invoice:** $${avgAmount.toFixed(2)}\n` + + `🏢 **Unique vendors:** ${vendors.length} (${vendors.slice(0, 5).join(', ')}${vendors.length > 5 ? '...' : ''})\n` + + `🔄 **Duplicates:** ${duplicateCount}\n\n` + + `Would you like me to break this down by vendor or time period?`; + } + + // Duplicate queries + if (msgLower.includes('duplicate') || msgLower.includes('repeat')) { + if (duplicateCount === 0) { + return "Great news! No duplicates were detected in your invoices. The system automatically flags potential duplicates during upload based on vendor and amount matching."; + } + const dups = invoices.filter((i) => i.isDuplicate); + const dupSummary = dups + .map((i) => `• ${i.invNumber || 'N/A'} from ${i.vendor || 'Unknown'} — $${i.total ?? 0}`) + .join('\n'); + return `⚠️ **${duplicateCount} potential duplicate(s) found:**\n\n${dupSummary}\n\n` + + `These were flagged because they share the same vendor and a similar amount with another invoice. You can review them in the "Duplicates" tab or delete any that are truly repeated.`; + } + + // Vendor queries + if (msgLower.includes('vendor') || msgLower.includes('supplier') || msgLower.includes('company')) { + const vendorMap = new Map(); + for (const inv of invoices) { + const v = inv.vendor || 'Unknown'; + const existing = vendorMap.get(v) ?? { count: 0, total: 0 }; + vendorMap.set(v, { + count: existing.count + 1, + total: existing.total + (inv.total ?? 0), + }); + } + const lines = [...vendorMap.entries()] + .sort((a, b) => b[1].total - a[1].total) + .map(([v, data]) => `• **${v}**: ${data.count} invoice(s), totaling $${data.total.toFixed(2)}`) + .join('\n'); + return `Here's a breakdown by vendor:\n\n${lines || 'No vendor data available.'}`; + } + + // Spending / amount queries + if (msgLower.includes('spend') || msgLower.includes('cost') || msgLower.includes('total') || msgLower.includes('amount')) { + if (invoices.length === 0) return "No invoices to analyze yet."; + const avgAmount = totalAmount / invoices.length; + const maxInv = invoices.reduce((a, b) => (b.total ?? 0) > (a.total ?? 0) ? b : a); + const minInv = invoices.reduce((a, b) => (b.total ?? 0) < (a.total ?? 0) ? b : a); + return `💰 **Spending Analysis:**\n\n` + + `• Total: $${totalAmount.toFixed(2)} across ${invoices.length} invoices\n` + + `• Average: $${avgAmount.toFixed(2)} per invoice\n` + + `• Largest: $${maxInv.total ?? 0} from ${maxInv.vendor || 'Unknown'} (${maxInv.invNumber || 'N/A'})\n` + + `• Smallest: $${minInv.total ?? 0} from ${minInv.vendor || 'Unknown'} (${minInv.invNumber || 'N/A'})\n\n` + + `Want me to analyze spending trends or identify cost-saving opportunities?`; + } + + // Default helpful response + return `I can help you with your invoices! Here are some things you can ask me:\n\n` + + `• **"Give me a summary"** — Overview of all your invoices\n` + + `• **"Show duplicates"** — Find potential duplicate invoices\n` + + `• **"Breakdown by vendor"** — Spending per vendor\n` + + `• **"Spending analysis"** — Cost insights and trends\n\n` + + `You currently have **${invoices.length} invoice(s)** totaling **$${totalAmount.toFixed(2)}** on the **${plan}** plan. How can I help?`; +} + +// Suppress unused import warning +void buildInvoiceContext; \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/invoices/export/csv/route.ts b/omniparse-hf-space (1)/src/app/api/invoices/export/csv/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..a5b5e78c8d001018be26b3198a3c9f9334d7fae2 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/invoices/export/csv/route.ts @@ -0,0 +1,89 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { getCookieToken, getSessionUser } from '@/lib/auth'; +import { logActivity } from '@/lib/activity'; + +function escapeCsvField(value: unknown): string { + const str = value === null || value === undefined ? '' : String(value); + if (str.includes(',') || str.includes('"') || str.includes('\n')) { + return `"${str.replace(/"/g, '""')}"`; + } + return str; +} + +export async function GET(request: NextRequest) { + try { + const token = getCookieToken(request); + if (!token) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + const user = await getSessionUser(token); + if (!user) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + const invoices = await db.invoice.findMany({ + where: { userId: user.id }, + orderBy: { createdAt: 'desc' }, + }); + + const headers = [ + 'ID', + 'Filename', + 'Vendor', + 'Invoice Number', + 'Invoice Date', + 'Due Date', + 'Subtotal', + 'VAT Amount', + 'Total', + 'Currency', + 'Status', + 'Duplicate', + 'Confidence', + 'Created At', + ]; + + const rows = invoices.map((inv) => + [ + inv.id, + inv.filename ?? '', + inv.vendor ?? '', + inv.invNumber ?? '', + inv.invDate ?? '', + inv.dueDate ?? '', + inv.amount ?? '', + inv.vatAmount ?? '', + inv.total ?? '', + inv.currency, + inv.status, + inv.isDuplicate ? 'Yes' : 'No', + inv.confidence !== null ? (inv.confidence * 100).toFixed(1) + '%' : '', + inv.createdAt.toISOString(), + ].map(escapeCsvField).join(',') + ); + + const csvContent = [ + headers.map(escapeCsvField).join(','), + ...rows, + ].join('\n'); + + const timestamp = new Date().toISOString().split('T')[0]; + + logActivity(user.id, 'export', 'CSV exported', 'Exported all invoices as CSV'); + + return new NextResponse(csvContent, { + status: 200, + headers: { + 'Content-Type': 'text/csv; charset=utf-8', + 'Content-Disposition': `attachment; filename="invoices-${timestamp}.csv"`, + }, + }); + } catch (error) { + console.error('[EXPORT_CSV_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/invoices/export/json/route.ts b/omniparse-hf-space (1)/src/app/api/invoices/export/json/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb7ba8bf4c6a4a96c38280aa056a8ed258c94833 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/invoices/export/json/route.ts @@ -0,0 +1,63 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { getCookieToken, getSessionUser } from '@/lib/auth'; + +export async function GET(request: NextRequest) { + try { + const token = getCookieToken(request); + if (!token) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + const user = await getSessionUser(token); + if (!user) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + // Free plan users cannot export JSON + if (user.plan === 'free') { + return NextResponse.json( + { error: 'JSON export is available on Basic, Pro, and Enterprise plans. Please upgrade your plan.' }, + { status: 403 } + ); + } + + const invoices = await db.invoice.findMany({ + where: { userId: user.id }, + orderBy: { createdAt: 'desc' }, + }); + + const jsonData = invoices.map((inv) => ({ + id: inv.id, + filename: inv.filename, + vendor: inv.vendor, + invoiceNumber: inv.invNumber, + invoiceDate: inv.invDate, + dueDate: inv.dueDate, + subtotal: inv.amount, + vatAmount: inv.vatAmount, + total: inv.total, + currency: inv.currency, + status: inv.status, + isDuplicate: inv.isDuplicate, + confidence: inv.confidence, + rawJson: inv.rawJson ? JSON.parse(inv.rawJson) : null, + createdAt: inv.createdAt, + updatedAt: inv.updatedAt, + })); + + const timestamp = new Date().toISOString().split('T')[0]; + return new NextResponse(JSON.stringify(jsonData, null, 2), { + status: 200, + headers: { + 'Content-Type': 'application/json; charset=utf-8', + 'Content-Disposition': `attachment; filename="invoices-${timestamp}.json"`, + }, + }); + } catch (error) { + console.error('[EXPORT_JSON_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/invoices/export/xlsx/route.ts b/omniparse-hf-space (1)/src/app/api/invoices/export/xlsx/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..fae590c5c2e511d1ff7ff300bebc9de5fed6f614 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/invoices/export/xlsx/route.ts @@ -0,0 +1,144 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { getCookieToken, getSessionUser } from '@/lib/auth'; + +export async function GET(request: NextRequest) { + try { + const token = getCookieToken(request); + if (!token) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + const user = await getSessionUser(token); + if (!user) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + const invoices = await db.invoice.findMany({ + where: { userId: user.id }, + orderBy: { createdAt: 'desc' }, + }); + + // Dynamic import to avoid bundling issues + const ExcelJS = await import('exceljs'); + const workbook = new ExcelJS.Workbook(); + const worksheet = workbook.addWorksheet('Invoices'); + + // Style definitions + const headerFill = { + type: 'pattern' as const, + pattern: 'solid' as const, + fgColor: { argb: 'FFF59E0B' }, + }; + const headerFont = { bold: true, color: { argb: 'FF09090B' }, size: 11 }; + const borderStyle = { + bottom: { style: 'thin' as const, color: { argb: 'FFD4D4D8' } }, + }; + + // Title row + worksheet.mergeCells('A1:K1'); + const titleCell = worksheet.getCell('A1'); + titleCell.value = 'OmniParse AI \u2014 Invoice Export'; + titleCell.font = { bold: true, size: 14, color: { argb: 'FF18181B' } }; + titleCell.alignment = { horizontal: 'center' }; + + // Date row + worksheet.mergeCells('A2:K2'); + const dateCell = worksheet.getCell('A2'); + dateCell.value = `Exported: ${new Date().toLocaleString('en-US')}`; + dateCell.font = { italic: true, size: 10, color: { argb: 'FF71717A' } }; + dateCell.alignment = { horizontal: 'center' }; + + // Headers (row 4) + const headers = ['Vendor', 'Invoice #', 'Invoice Date', 'Due Date', 'Amount', 'VAT', 'Total', 'Currency', 'Status', 'Duplicate', 'Confidence', 'Filename']; + headers.forEach((h, i) => { + const cell = worksheet.getCell(4, i + 1); + cell.value = h; + cell.fill = headerFill; + cell.font = headerFont; + cell.alignment = { horizontal: 'center' }; + cell.border = borderStyle; + }); + + // Data rows + invoices.forEach((inv, idx) => { + const row = idx + 5; + worksheet.getCell(row, 1).value = inv.vendor || ''; + worksheet.getCell(row, 2).value = inv.invNumber || ''; + worksheet.getCell(row, 3).value = inv.invDate || ''; + worksheet.getCell(row, 4).value = inv.dueDate || ''; + worksheet.getCell(row, 5).value = inv.amount ?? 0; + worksheet.getCell(row, 6).value = inv.vatAmount ?? 0; + worksheet.getCell(row, 7).value = inv.total ?? 0; + worksheet.getCell(row, 8).value = inv.currency; + worksheet.getCell(row, 9).value = inv.isDuplicate ? 'Yes' : 'No'; + worksheet.getCell(row, 10).value = inv.confidence ? `${(inv.confidence * 100).toFixed(1)}%` : ''; + worksheet.getCell(row, 11).value = inv.filename || ''; + + // Format currency columns + [5, 6, 7].forEach(col => { + worksheet.getCell(row, col).numFmt = '$#,##0.00'; + }); + + // Alternate row shading + if (idx % 2 === 0) { + for (let col = 1; col <= 12; col++) { + worksheet.getCell(row, col).fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFF4F4F5' } }; + } + } + + // Color status + const statusCell = worksheet.getCell(row, 9); + if (inv.isDuplicate) { + statusCell.font = { color: { argb: 'FFEF4444' } }; + } else if (inv.status === 'review') { + statusCell.font = { color: { argb: 'FFEAB308' } }; + } else { + statusCell.font = { color: { argb: 'FF22C55E' } }; + } + + // Bottom border + for (let col = 1; col <= 12; col++) { + worksheet.getCell(row, col).border = borderStyle; + } + }); + + // Summary row + const summaryRow = invoices.length + 5; + worksheet.getCell(summaryRow, 6).value = 'TOTAL'; + worksheet.getCell(summaryRow, 6).font = { bold: true }; + const totalAmount = invoices.reduce((s, i) => s + (i.total ?? 0), 0); + worksheet.getCell(summaryRow, 7).value = totalAmount; + worksheet.getCell(summaryRow, 7).numFmt = '$#,##0.00'; + worksheet.getCell(summaryRow, 7).font = { bold: true, size: 12 }; + for (let col = 1; col <= 12; col++) { + worksheet.getCell(summaryRow, col).border = { top: { style: 'double', color: { argb: 'FF18181B' } } }; + } + + // Auto-fit column widths + worksheet.columns.forEach((column, i) => { + const maxLength = Math.max( + headers[i]?.length || 5, + ...invoices.slice(0, 20).map(inv => { + const vals = [inv.vendor, inv.invNumber, inv.invDate, inv.dueDate, inv.currency, inv.filename]; + return (vals[i] || '').toString().length; + }) + ); + column.width = Math.min(maxLength + 4, 30); + }); + + const buffer = await workbook.xlsx.writeBuffer(); + return new NextResponse(buffer, { + status: 200, + headers: { + 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'Content-Disposition': `attachment; filename="omniparse-invoices-${new Date().toISOString().split('T')[0]}.xlsx"`, + }, + }); + } catch (error) { + console.error('[EXPORT_XLSX_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/invoices/route.ts b/omniparse-hf-space (1)/src/app/api/invoices/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..a481fe9f3e7167d5d64c56b77ac7cc9cf22b0a0e --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/invoices/route.ts @@ -0,0 +1,103 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { getCookieToken, getSessionUser } from '@/lib/auth'; +import { invoiceIdSchema } from '@/lib/validation'; +import { logActivity } from '@/lib/activity'; + +type FilterValue = 'all' | 'done' | 'review' | 'duplicates'; + +// ─── GET: List Invoices ─────────────────────────────────────────────────────── + +export async function GET(request: NextRequest) { + try { + const token = getCookieToken(request); + if (!token) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + const user = await getSessionUser(token); + if (!user) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + const { searchParams } = new URL(request.url); + const filter = (searchParams.get('filter') || 'all') as FilterValue; + + // Build the where clause + const where: Record = { userId: user.id }; + + switch (filter) { + case 'done': + where.status = 'done'; + where.isDuplicate = false; + break; + case 'review': + where.status = 'review'; + break; + case 'duplicates': + where.isDuplicate = true; + break; + // 'all' uses the base where (userId only) + } + + const invoices = await db.invoice.findMany({ + where, + orderBy: { createdAt: 'desc' }, + }); + + return NextResponse.json({ invoices }); + } catch (error) { + console.error('[INVOICES_GET_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} + +// ─── DELETE: Remove Invoice ──────────────────────────────────────────────────── + +export async function DELETE(request: NextRequest) { + try { + const token = getCookieToken(request); + if (!token) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + const user = await getSessionUser(token); + if (!user) { + return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); + } + + const body = await request.json(); + const parsed = invoiceIdSchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json( + { error: parsed.error.issues[0].message }, + { status: 400 } + ); + } + + // Verify ownership + const invoice = await db.invoice.findUnique({ + where: { id: parsed.data.id }, + }); + + if (!invoice || invoice.userId !== user.id) { + return NextResponse.json( + { error: 'Invoice not found' }, + { status: 404 } + ); + } + + await db.invoice.delete({ where: { id: parsed.data.id } }); + + logActivity(user.id, 'delete', 'Invoice deleted', `Removed invoice ${parsed.data.id}`); + + return NextResponse.json({ success: true }); + } catch (error) { + console.error('[INVOICES_DELETE_ERROR]', error); + return NextResponse.json( + { error: 'Internal server error' }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/invoices/update/route.ts b/omniparse-hf-space (1)/src/app/api/invoices/update/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..c19a0b7935ee83692e21edb2492fae30b4cffe6e --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/invoices/update/route.ts @@ -0,0 +1,45 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { db } from '@/lib/db'; +import { getSessionUser } from '@/lib/auth'; +import { z } from 'zod'; +import { logActivity } from '@/lib/activity'; + +const updateSchema = z.object({ + id: z.string().min(1), + vendor: z.string().optional(), + invNumber: z.string().optional(), + invDate: z.string().optional(), + dueDate: z.string().optional(), + amount: z.string().transform(Number).optional(), + vatAmount: z.string().transform(Number).optional(), + total: z.string().transform(Number).optional(), + currency: z.string().optional(), + status: z.enum(['done', 'review']).optional(), +}); + +export async function POST(req: NextRequest) { + try { + const user = await getSessionUser(req); + if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + const body = await req.json(); + const parsed = updateSchema.safeParse(body); + if (!parsed.success) return NextResponse.json({ error: 'Invalid input' }, { status: 400 }); + + const { id, ...data } = parsed.data; + const invoice = await db.invoice.findFirst({ where: { id, userId: user.id } }); + if (!invoice) return NextResponse.json({ error: 'Not found' }, { status: 404 }); + + const updated = await db.invoice.update({ + where: { id }, + data, + }); + + logActivity(user.id, 'edit', 'Invoice updated', 'Updated invoice fields'); + + return NextResponse.json({ invoice: updated }); + } catch (error) { + console.error('Invoice update error:', error); + return NextResponse.json({ error: 'Internal error' }, { status: 500 }); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/route.ts b/omniparse-hf-space (1)/src/app/api/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..0277710b3e8ce8861be944e9d69f62481dc57471 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/route.ts @@ -0,0 +1,5 @@ +import { NextResponse } from "next/server"; + +export async function GET() { + return NextResponse.json({ message: "Hello, world!" }); +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/api/seed/route.ts b/omniparse-hf-space (1)/src/app/api/seed/route.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b94a7be539feb7ff43ccae6d33fd25532a2f2f8 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/api/seed/route.ts @@ -0,0 +1,364 @@ +import { db } from '@/lib/db'; +import { hashPassword, generateApiKey } from '@/lib/auth'; +import { NextResponse } from 'next/server'; + +export async function GET() { + try { + // Upsert demo user + const hashedPw = await hashPassword('demo1234'); + const apiKey = generateApiKey(); + + const user = await db.user.upsert({ + where: { email: 'demo@omniparse.ai' }, + update: {}, + create: { + email: 'demo@omniparse.ai', + name: 'Demo User', + password: hashedPw, + plan: 'pro', + apiKey, + }, + }); + + // Delete any existing invoices for this user + await db.invoice.deleteMany({ + where: { userId: user.id }, + }); + + // Define 20 diverse invoices + const invoiceData = [ + // ── January 2025 (5 invoices) ── + { + vendor: 'Acme Corp', + invNumber: 'INV-2024-001', + invDate: '2025-01-05', + dueDate: '2025-02-04', + amount: 1200, + vatPct: 0.20, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.95, + filename: 'invoice_acme_jan.pdf', + createdAt: new Date('2025-01-06T09:15:00Z'), + }, + { + vendor: 'TechVision Inc', + invNumber: 'INV-2024-002', + invDate: '2025-01-12', + dueDate: '2025-02-11', + amount: 3450, + vatPct: 0.21, + currency: 'EUR', + status: 'done' as const, + isDuplicate: false, + confidence: 0.97, + filename: 'invoice_techvision_jan.pdf', + createdAt: new Date('2025-01-13T14:30:00Z'), + }, + { + vendor: 'Global Supplies Ltd', + invNumber: 'INV-2024-003', + invDate: '2025-01-18', + dueDate: '2025-02-17', + amount: 890, + vatPct: 0.15, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.92, + filename: 'receipt_global_jan.png', + createdAt: new Date('2025-01-19T11:00:00Z'), + }, + { + vendor: 'CloudNine Services', + invNumber: 'INV-2024-004', + invDate: '2025-01-22', + dueDate: '2025-02-21', + amount: 5200, + vatPct: 0.20, + currency: 'USD', + status: 'review' as const, + isDuplicate: false, + confidence: 0.88, + filename: 'invoice_cloudnine_jan.pdf', + createdAt: new Date('2025-01-23T08:45:00Z'), + }, + { + vendor: 'DataFlow Systems', + invNumber: 'INV-2024-005', + invDate: '2025-01-28', + dueDate: '2025-02-27', + amount: 750, + vatPct: 0.10, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.96, + filename: 'receipt_dataflow_jan.pdf', + createdAt: new Date('2025-01-29T16:20:00Z'), + }, + + // ── February 2025 (5 invoices) ── + { + vendor: 'Pinnacle Solutions', + invNumber: 'INV-2024-006', + invDate: '2025-02-03', + dueDate: '2025-03-05', + amount: 1250, + vatPct: 0.18, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.94, + filename: 'invoice_pinnacle_feb.pdf', + createdAt: new Date('2025-02-04T10:00:00Z'), + }, + { + vendor: 'TechVision Inc', + invNumber: 'INV-2024-007', + invDate: '2025-02-08', + dueDate: '2025-03-10', + amount: 2100, + vatPct: 0.20, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.98, + filename: 'invoice_techvision_feb.pdf', + createdAt: new Date('2025-02-09T13:15:00Z'), + }, + { + vendor: 'Acme Corp', + invNumber: 'INV-2024-008', + invDate: '2025-02-14', + dueDate: '2025-03-16', + amount: 8750, + vatPct: 0.20, + currency: 'GBP', + status: 'review' as const, + isDuplicate: false, + confidence: 0.87, + filename: 'invoice_acme_feb.pdf', + createdAt: new Date('2025-02-15T09:30:00Z'), + }, + { + vendor: 'Meridian Group', + invNumber: 'INV-2024-009', + invDate: '2025-02-20', + dueDate: '2025-03-22', + amount: 430, + vatPct: 0.12, + currency: 'USD', + status: 'pending' as const, + isDuplicate: false, + confidence: 0.99, + filename: 'receipt_meridian_feb.png', + createdAt: new Date('2025-02-21T15:45:00Z'), + }, + { + vendor: 'Nexus Technologies', + invNumber: 'INV-2024-010', + invDate: '2025-02-26', + dueDate: '2025-03-28', + amount: 6300, + vatPct: 0.25, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.91, + filename: 'invoice_nexus_feb.pdf', + createdAt: new Date('2025-02-27T11:10:00Z'), + }, + + // ── March 2025 (5 invoices) ── + { + vendor: 'CloudNine Services', + invNumber: 'INV-2024-011', + invDate: '2025-03-04', + dueDate: '2025-04-03', + amount: 4800, + vatPct: 0.20, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.93, + filename: 'invoice_cloudnine_mar.pdf', + createdAt: new Date('2025-03-05T08:00:00Z'), + }, + { + vendor: 'Pinnacle Solutions', + invNumber: 'INV-2024-012', + invDate: '2025-03-10', + dueDate: '2025-04-09', + amount: 15000, + vatPct: 0.22, + currency: 'USD', + status: 'review' as const, + isDuplicate: false, + confidence: 0.86, + filename: 'invoice_pinnacle_mar.pdf', + createdAt: new Date('2025-03-11T14:25:00Z'), + }, + { + vendor: 'Global Supplies Ltd', + invNumber: 'INV-2024-013', + invDate: '2025-03-15', + dueDate: '2025-04-14', + amount: 2350, + vatPct: 0.19, + currency: 'EUR', + status: 'done' as const, + isDuplicate: false, + confidence: 0.95, + filename: 'invoice_global_mar.pdf', + createdAt: new Date('2025-03-16T10:40:00Z'), + }, + { + vendor: 'DataFlow Systems', + invNumber: 'INV-2024-014', + invDate: '2025-03-19', + dueDate: '2025-04-18', + amount: 1100, + vatPct: 0.15, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.97, + filename: 'receipt_dataflow_mar.png', + createdAt: new Date('2025-03-20T09:55:00Z'), + }, + { + vendor: 'Acme Corp', + invNumber: 'INV-2024-015', + invDate: '2025-03-25', + dueDate: '2025-04-24', + amount: 9200, + vatPct: 0.20, + currency: 'USD', + status: 'done' as const, + isDuplicate: false, + confidence: 0.89, + filename: 'invoice_acme_mar.pdf', + createdAt: new Date('2025-03-26T16:30:00Z'), + }, + + // ── April 2025 (5 invoices) ── + { + vendor: 'Nexus Technologies', + invNumber: 'INV-2024-016', + invDate: '2025-04-02', + dueDate: '2025-05-02', + amount: 6280, + vatPct: 0.23, + currency: 'USD', + status: 'done' as const, + isDuplicate: true, // Duplicate of INV-2024-010 (same vendor, $6300) + confidence: 0.88, + filename: 'invoice_nexus_apr.pdf', + createdAt: new Date('2025-04-03T11:20:00Z'), + }, + { + vendor: 'Meridian Group', + invNumber: 'INV-2024-017', + invDate: '2025-04-08', + dueDate: '2025-05-08', + amount: 780, + vatPct: 0.14, + currency: 'EUR', + status: 'pending' as const, + isDuplicate: false, + confidence: 0.96, + filename: 'receipt_meridian_apr.png', + createdAt: new Date('2025-04-09T08:10:00Z'), + }, + { + vendor: 'CloudNine Services', + invNumber: 'INV-2024-018', + invDate: '2025-04-14', + dueDate: '2025-05-14', + amount: 5150, + vatPct: 0.20, + currency: 'USD', + status: 'done' as const, + isDuplicate: true, // Duplicate of INV-2024-004 (same vendor, $5200) + confidence: 0.92, + filename: 'invoice_cloudnine_apr.pdf', + createdAt: new Date('2025-04-15T13:50:00Z'), + }, + { + vendor: 'Pinnacle Solutions', + invNumber: 'INV-2024-019', + invDate: '2025-04-20', + dueDate: '2025-05-20', + amount: 3200, + vatPct: 0.20, + currency: 'GBP', + status: 'done' as const, + isDuplicate: false, + confidence: 0.94, + filename: 'invoice_pinnacle_apr.pdf', + createdAt: new Date('2025-04-21T10:05:00Z'), + }, + { + vendor: 'TechVision Inc', + invNumber: 'INV-2024-020', + invDate: '2025-04-27', + dueDate: '2025-05-27', + amount: 2800, + vatPct: 0.17, + currency: 'USD', + status: 'review' as const, + isDuplicate: false, + confidence: 0.85, + filename: 'invoice_techvision_apr.pdf', + createdAt: new Date('2025-04-28T15:00:00Z'), + }, + ]; + + // Create all invoices with computed VAT and total + const invoices = await db.invoice.createMany({ + data: invoiceData.map((inv) => ({ + userId: user.id, + vendor: inv.vendor, + invNumber: inv.invNumber, + invDate: inv.invDate, + dueDate: inv.dueDate, + amount: inv.amount, + vatAmount: Math.round(inv.amount * inv.vatPct * 100) / 100, + total: Math.round(inv.amount * (1 + inv.vatPct) * 100) / 100, + currency: inv.currency, + status: inv.status, + isDuplicate: inv.isDuplicate, + confidence: inv.confidence, + filename: inv.filename, + rawJson: null, + createdAt: inv.createdAt, + })), + }); + + return NextResponse.json({ + message: `Seed complete: ${invoices.count} invoices created for demo user`, + userId: user.id, + invoiceCount: invoices.count, + breakdown: { + byVendor: { + 'Acme Corp': 3, + 'TechVision Inc': 3, + 'Global Supplies Ltd': 2, + 'CloudNine Services': 3, + 'DataFlow Systems': 2, + 'Pinnacle Solutions': 3, + 'Meridian Group': 2, + 'Nexus Technologies': 2, + }, + byStatus: { done: 14, review: 4, pending: 2 }, + duplicates: 2, + byCurrency: { USD: 15, EUR: 3, GBP: 2 }, + }, + }); + } catch (error) { + console.error('[SEED_ERROR]', error); + return NextResponse.json({ error: 'Seed failed' }, { status: 500 }); + } +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/globals.css b/omniparse-hf-space (1)/src/app/globals.css new file mode 100644 index 0000000000000000000000000000000000000000..0a7535a1276749d966eacb23c93050eb6dbd8dab --- /dev/null +++ b/omniparse-hf-space (1)/src/app/globals.css @@ -0,0 +1,2040 @@ +@import "tailwindcss"; +@import "tw-animate-css"; + +@custom-variant dark (&:is(.dark *)); + +@theme inline { + --color-background: var(--background); + --color-foreground: var(--foreground); + --font-sans: var(--font-geist-sans); + --font-mono: var(--font-geist-mono); + --color-ring: var(--ring); + --color-input: var(--input); + --color-border: var(--border); + --color-destructive: var(--destructive); + --color-accent-foreground: var(--accent-foreground); + --color-accent: var(--accent); + --color-muted-foreground: var(--muted-foreground); + --color-muted: var(--muted); + --color-secondary-foreground: var(--secondary-foreground); + --color-secondary: var(--secondary); + --color-primary-foreground: var(--primary-foreground); + --color-primary: var(--primary); + --color-popover-foreground: var(--popover-foreground); + --color-popover: var(--popover); + --color-card-foreground: var(--card-foreground); + --color-card: var(--card); + --radius-sm: calc(var(--radius) - 4px); + --radius-md: calc(var(--radius) - 2px); + --radius-lg: var(--radius); + --radius-xl: calc(var(--radius) + 4px); + --color-amber-50: #FFFBEB; + --color-amber-100: #FEF3C7; + --color-amber-200: #FDE68A; + --color-amber-300: #FCD34D; + --color-amber-400: #FBBF24; + --color-amber-500: #F59E0B; + --color-amber-600: #D97706; + --color-amber-700: #B45309; + --color-amber-800: #92400E; + --color-amber-900: #78350F; + --color-teal-400: #2DD4BF; + --color-teal-500: #14B8A6; + --color-teal-600: #0D9488; +} + +:root { + --radius: 0.625rem; + --background: #09090B; + --foreground: #FAFAFA; + --card: #111113; + --card-foreground: #FAFAFA; + --popover: #111113; + --popover-foreground: #FAFAFA; + --primary: #F59E0B; + --primary-foreground: #09090B; + --secondary: #1C1C1F; + --secondary-foreground: #FAFAFA; + --muted: #1C1C1F; + --muted-foreground: #A1A1AA; + --accent: #1C1C1F; + --accent-foreground: #FAFAFA; + --destructive: #EF4444; + --border: rgba(255, 255, 255, 0.08); + --input: rgba(255, 255, 255, 0.1); + --ring: #F59E0B; +} + +@layer base { + * { + @apply border-border outline-ring/50; + } + body { + @apply bg-background text-foreground; + font-feature-settings: "rlig" 1, "calt" 1; + } +} + +/* Custom scrollbar */ +::-webkit-scrollbar { + width: 6px; + height: 6px; +} +::-webkit-scrollbar-track { + background: transparent; +} +::-webkit-scrollbar-thumb { + background: rgba(255, 255, 255, 0.1); + border-radius: 3px; +} +::-webkit-scrollbar-thumb:hover { + background: rgba(255, 255, 255, 0.2); +} + +/* Glassmorphism card */ +.glass-card { + background: rgba(255, 255, 255, 0.03); + backdrop-filter: blur(12px); + border: 1px solid rgba(255, 255, 255, 0.06); + border-radius: 16px; + box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); +} + +.glass-card-hover { + background: rgba(255, 255, 255, 0.03); + backdrop-filter: blur(12px); + border: 1px solid rgba(255, 255, 255, 0.06); + border-radius: 16px; + transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); +} +.glass-card-hover:hover { + background: rgba(255, 255, 255, 0.06); + border-color: rgba(245, 158, 11, 0.2); + transform: translateY(-2px); + box-shadow: 0 8px 32px rgba(245, 158, 11, 0.08); +} + +/* Amber glow effect */ +.amber-glow { + box-shadow: 0 0 40px rgba(245, 158, 11, 0.15), 0 0 80px rgba(245, 158, 11, 0.05); +} + +/* Subtle grid background */ +.grid-bg { + background-image: + linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px), + linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px); + background-size: 64px 64px; +} + +/* Noise texture overlay */ +.noise-overlay::before { + content: ""; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + opacity: 0.03; + z-index: 0; + pointer-events: none; + background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E"); +} + +/* Upload drop zone */ +.drop-zone { + border: 2px dashed rgba(245, 158, 11, 0.3); + border-radius: 16px; + transition: all 0.3s ease; +} +.drop-zone.drag-over { + border-color: #F59E0B; + background: rgba(245, 158, 11, 0.05); + box-shadow: 0 0 32px rgba(245, 158, 11, 0.1); +} + +/* Chat bubble animation */ +@keyframes slideUp { + from { opacity: 0; transform: translateY(8px); } + to { opacity: 1; transform: translateY(0); } +} +.chat-bubble { + animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1); +} + +/* Pricing card highlight */ +.pricing-highlight { + border: 1px solid rgba(245, 158, 11, 0.4); + background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(20, 184, 166, 0.04) 100%); + position: relative; +} +.pricing-highlight::before { + content: ""; + position: absolute; + inset: -1px; + border-radius: 16px; + padding: 1px; + background: linear-gradient(135deg, #F59E0B, #14B8A6); + -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); + -webkit-mask-composite: xor; + mask-composite: exclude; + pointer-events: none; +} + +/* Fade in animation */ +@keyframes fadeIn { + from { opacity: 0; } + to { opacity: 1; } +} +.fade-in { + animation: fadeIn 0.5s ease; +} + +/* Status badge styles */ +.status-done { background: rgba(34, 197, 94, 0.12); color: #22C55E; } +.status-review { background: rgba(234, 179, 8, 0.12); color: #EAB308; } +.status-duplicate { background: rgba(239, 68, 68, 0.12); color: #EF4444; } + +/* Tab active indicator */ +.tab-active { + color: #F59E0B; + border-bottom: 2px solid #F59E0B; +} + +/* Focus ring for accessibility */ +*:focus-visible { + outline: 2px solid #F59E0B; + outline-offset: 2px; + border-radius: 4px; +} + +/* Hero gradient text */ +.gradient-text { + background: linear-gradient(135deg, #F59E0B 0%, #FBBF24 40%, #14B8A6 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; +} + +/* Progress bar */ +.progress-bar { + background: linear-gradient(90deg, #F59E0B, #14B8A6); + border-radius: 4px; + transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); +} + +/* Skeleton shimmer */ +@keyframes shimmer { + 0% { background-position: -200% 0; } + 100% { background-position: 200% 0; } +} +.skeleton-shimmer { + background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%); + background-size: 200% 100%; + animation: shimmer 1.5s infinite; + border-radius: 8px; +} + +/* Hero gradient orb */ +.hero-orb { + position: absolute; + width: 600px; + height: 600px; + border-radius: 50%; + background: radial-gradient(circle, rgba(245,158,11,0.12) 0%, rgba(20,184,166,0.06) 40%, transparent 70%); + filter: blur(60px); + top: -100px; + right: -150px; + pointer-events: none; + animation: orbFloat 8s ease-in-out infinite; +} +.hero-orb-2 { + position: absolute; + width: 400px; + height: 400px; + border-radius: 50%; + background: radial-gradient(circle, rgba(20,184,166,0.1) 0%, rgba(245,158,11,0.05) 40%, transparent 70%); + filter: blur(50px); + bottom: -80px; + left: -100px; + pointer-events: none; + animation: orbFloat 10s ease-in-out infinite reverse; +} +@keyframes orbFloat { + 0%, 100% { transform: translate(0, 0) scale(1); } + 33% { transform: translate(30px, -20px) scale(1.05); } + 66% { transform: translate(-20px, 15px) scale(0.95); } +} + +/* Stats counter animation */ +@keyframes countUp { + from { opacity: 0; transform: translateY(10px); } + to { opacity: 1; transform: translateY(0); } +} +.stat-item { + animation: countUp 0.6s ease-out both; +} +.stat-item:nth-child(2) { animation-delay: 0.1s; } +.stat-item:nth-child(3) { animation-delay: 0.2s; } + +/* Feature card icon colors */ +.feature-amber .feature-icon { background: rgba(245,158,11,0.1); color: #F59E0B; } +.feature-teal .feature-icon { background: rgba(20,184,166,0.1); color: #14B8A6; } +.feature-red .feature-icon { background: rgba(239,68,68,0.1); color: #EF4444; } +.feature-green .feature-icon { background: rgba(34,197,94,0.1); color: #22C55E; } +.feature-sky .feature-icon { background: rgba(56,189,248,0.1); color: #38BDF8; } +.feature-rose .feature-icon { background: rgba(244,114,182,0.1); color: #F472B6; } + +/* Dashboard stat card */ +.stat-card { + background: rgba(255,255,255,0.03); + border: 1px solid rgba(255,255,255,0.06); + border-radius: 12px; + padding: 16px 20px; + transition: all 0.3s ease; +} +.stat-card:hover { + background: rgba(255,255,255,0.05); + border-color: rgba(255,255,255,0.1); + transform: translateY(-1px); +} + +/* Invoice row hover */ +.invoice-row { + cursor: pointer; + transition: background 0.15s ease; +} +.invoice-row:hover { + background: rgba(255,255,255,0.03) !important; +} + +/* Section reveal animation */ +@keyframes sectionReveal { + from { opacity: 0; transform: translateY(24px); } + to { opacity: 1; transform: translateY(0); } +} +.section-reveal { + animation: sectionReveal 0.7s ease-out both; +} + +/* Footer link hover */ +.footer-link { + color: #A1A1AA; + transition: color 0.2s ease; + cursor: pointer; +} +.footer-link:hover { + color: #F59E0B; +} + +/* Typing dots animation */ +@keyframes typingDot { + 0%, 60%, 100% { opacity: 0.3; } + 30% { opacity: 1; } +} +.typing-dot { + animation: typingDot 1.4s ease-in-out infinite; +} +.typing-dot:nth-child(2) { animation-delay: 0.2s; } +.typing-dot:nth-child(3) { animation-delay: 0.4s; } + +/* ======================================== + Enhanced Button Styles + ======================================== */ + +/* Primary button with gradient */ +.btn-primary { + background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%); + color: #09090B; + font-weight: 600; + padding: 10px 24px; + border-radius: 10px; + transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); + position: relative; + overflow: hidden; +} +.btn-primary:hover { + transform: translateY(-1px); + box-shadow: 0 4px 20px rgba(245, 158, 11, 0.35); +} +.btn-primary:active { + transform: translateY(0); +} +.btn-primary:disabled { + opacity: 0.5; + cursor: not-allowed; + transform: none; + box-shadow: none; +} + +/* Secondary/ghost button */ +.btn-ghost { + background: transparent; + color: #FAFAFA; + font-weight: 500; + padding: 10px 24px; + border-radius: 10px; + border: 1px solid rgba(255, 255, 255, 0.1); + transition: all 0.25s ease; +} +.btn-ghost:hover { + background: rgba(255, 255, 255, 0.05); + border-color: rgba(255, 255, 255, 0.2); +} + +/* ======================================== + Form Input Enhancements + ======================================== */ + +/* Custom form inputs */ +.input-field { + background: rgba(255, 255, 255, 0.04); + border: 1px solid rgba(255, 255, 255, 0.08); + border-radius: 10px; + padding: 12px 16px; + color: #FAFAFA; + font-size: 14px; + transition: all 0.2s ease; + width: 100%; +} +.input-field:focus { + outline: none; + border-color: #F59E0B; + box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1); + background: rgba(255, 255, 255, 0.06); +} +.input-field::placeholder { + color: #52525B; +} + +/* Input with floating label */ +.input-group { + position: relative; +} +.input-label { + display: block; + font-size: 13px; + font-weight: 500; + color: #A1A1AA; + margin-bottom: 6px; +} + +/* ======================================== + Enhanced Card Styles + ======================================== */ + +/* Card with colored top border accent */ +.card-accent-amber { border-top: 2px solid rgba(245, 158, 11, 0.6); } +.card-accent-teal { border-top: 2px solid rgba(20, 184, 166, 0.6); } +.card-accent-red { border-top: 2px solid rgba(239, 68, 68, 0.6); } +.card-accent-green { border-top: 2px solid rgba(34, 197, 94, 0.6); } + +/* Hover lift effect */ +.hover-lift { + transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease; +} +.hover-lift:hover { + transform: translateY(-4px); + box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); +} + +/* ======================================== + Badge/Tag Styles + ======================================== */ + +/* Plan badge */ +.badge-amber { + background: rgba(245, 158, 11, 0.12); + color: #F59E0B; + padding: 2px 10px; + border-radius: 100px; + font-size: 12px; + font-weight: 600; + letter-spacing: 0.02em; +} +.badge-teal { + background: rgba(20, 184, 166, 0.12); + color: #14B8A6; + padding: 2px 10px; + border-radius: 100px; + font-size: 12px; + font-weight: 600; + letter-spacing: 0.02em; +} +.badge-muted { + background: rgba(255, 255, 255, 0.06); + color: #A1A1AA; + padding: 2px 10px; + border-radius: 100px; + font-size: 12px; + font-weight: 500; +} + +/* ======================================== + Tab Navigation Enhancement + ======================================== */ + +/* Dashboard tab styles */ +.dash-tab { + padding: 10px 16px; + font-size: 14px; + font-weight: 500; + color: #71717A; + border-bottom: 2px solid transparent; + transition: all 0.2s ease; + cursor: pointer; + white-space: nowrap; +} +.dash-tab:hover { + color: #FAFAFA; + background: rgba(255, 255, 255, 0.03); +} +.dash-tab.active { + color: #F59E0B; + border-bottom-color: #F59E0B; +} + +/* ======================================== + Tooltip Enhancement + ======================================== */ + +/* Custom tooltip */ +.tooltip-wrapper { + position: relative; +} +.tooltip-wrapper .tooltip-text { + visibility: hidden; + opacity: 0; + position: absolute; + bottom: calc(100% + 8px); + left: 50%; + transform: translateX(-50%) translateY(4px); + background: #27272A; + color: #FAFAFA; + padding: 6px 12px; + border-radius: 8px; + font-size: 12px; + white-space: nowrap; + z-index: 50; + border: 1px solid rgba(255, 255, 255, 0.08); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); + transition: all 0.2s ease; + pointer-events: none; +} +.tooltip-wrapper:hover .tooltip-text { + visibility: visible; + opacity: 1; + transform: translateX(-50%) translateY(0); +} + +/* ======================================== + Animation Enhancements + ======================================== */ + +/* Pulse glow for CTA elements */ +@keyframes pulseGlow { + 0%, 100% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.2); } + 50% { box-shadow: 0 0 40px rgba(245, 158, 11, 0.4); } +} +.pulse-glow { + animation: pulseGlow 3s ease-in-out infinite; +} + +/* Slide in from right */ +@keyframes slideInRight { + from { opacity: 0; transform: translateX(20px); } + to { opacity: 1; transform: translateX(0); } +} +.slide-in-right { + animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1); +} + +/* Scale in */ +@keyframes scaleIn { + from { opacity: 0; transform: scale(0.95); } + to { opacity: 1; transform: scale(1); } +} +.scale-in { + animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1); +} + +/* Stagger children */ +.stagger-children > *:nth-child(1) { animation-delay: 0ms; } +.stagger-children > *:nth-child(2) { animation-delay: 80ms; } +.stagger-children > *:nth-child(3) { animation-delay: 160ms; } +.stagger-children > *:nth-child(4) { animation-delay: 240ms; } +.stagger-children > *:nth-child(5) { animation-delay: 320ms; } +.stagger-children > *:nth-child(6) { animation-delay: 400ms; } +.stagger-children > * { + opacity: 0; + animation: fadeIn 0.5s ease forwards; +} + +/* ======================================== + Table Enhancements + ======================================== */ + +/* Modern data table */ +.data-table { + width: 100%; + border-collapse: separate; + border-spacing: 0; +} +.data-table thead th { + padding: 12px 16px; + text-align: left; + font-size: 12px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.05em; + color: #71717A; + border-bottom: 1px solid rgba(255, 255, 255, 0.06); + position: sticky; + top: 0; + background: #111113; + z-index: 1; +} +.data-table tbody td { + padding: 12px 16px; + font-size: 14px; + border-bottom: 1px solid rgba(255, 255, 255, 0.04); + color: #D4D4D8; +} +.data-table tbody tr:last-child td { + border-bottom: none; +} + +/* ======================================== + Code Block Style (for API docs) + ======================================== */ + +.code-block { + background: #0C0C0E; + border: 1px solid rgba(255, 255, 255, 0.06); + border-radius: 10px; + padding: 16px 20px; + font-family: 'Geist Mono', monospace; + font-size: 13px; + line-height: 1.6; + color: #A1A1AA; + overflow-x: auto; +} +.code-block .code-keyword { color: #F59E0B; } +.code-block .code-string { color: #14B8A6; } +.code-block .code-comment { color: #52525B; } + +/* ======================================== + Scroll-to-top button + ======================================== */ + +.scroll-top-btn { + position: fixed; + bottom: 24px; + right: 24px; + width: 44px; + height: 44px; + border-radius: 12px; + background: rgba(245, 158, 11, 0.15); + border: 1px solid rgba(245, 158, 11, 0.3); + color: #F59E0B; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + opacity: 0; + transform: translateY(8px); + transition: all 0.3s ease; + z-index: 40; +} +.scroll-top-btn.visible { + opacity: 1; + transform: translateY(0); +} +.scroll-top-btn:hover { + background: rgba(245, 158, 11, 0.25); + transform: translateY(-2px); +} + +/* ======================================== + Empty State + ======================================== */ + +.empty-state { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 48px 24px; + color: #52525B; +} +.empty-state svg { + width: 48px; + height: 48px; + margin-bottom: 16px; + opacity: 0.4; +} + +/* ======================================== + Navbar blur + ======================================== */ + +.nav-blur { + backdrop-filter: blur(16px) saturate(180%); + background: rgba(9, 9, 11, 0.8); + border-bottom: 1px solid rgba(255, 255, 255, 0.06); +} + +/* ======================================== + Detail panel slide-over + ======================================== */ + +.detail-panel { + animation: slideInRight 0.3s ease; + border-left: 1px solid rgba(255, 255, 255, 0.06); +} + +/* ======================================== + Notification badge + ======================================== */ + +.notification-badge { + position: absolute; + top: -2px; + right: -2px; + width: 8px; + height: 8px; + background: #EF4444; + border-radius: 50%; + border: 2px solid #09090B; +} + +/* ======================================== + Animated Drop Zone + ======================================== */ + +@keyframes dashRotate { + to { stroke-dashoffset: -20; } +} +.drop-zone-animated { + border: 2px dashed rgba(245, 158, 11, 0.3); + border-radius: 16px; + transition: all 0.3s ease; + background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg stroke='%23F59E0B' stroke-opacity='0.04' stroke-width='1'%3E%3Cpath d='M0 20h40M20 0v40'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); +} +.drop-zone-animated:hover { + border-color: rgba(245, 158, 11, 0.5); + background: rgba(245, 158, 11, 0.03); +} + +/* ======================================== + Notification Dropdown + ======================================== */ + +.notification-dropdown { + position: absolute; + top: calc(100% + 8px); + right: 0; + width: 320px; + background: #18181B; + border: 1px solid rgba(255,255,255,0.08); + border-radius: 12px; + box-shadow: 0 16px 48px rgba(0,0,0,0.5); + z-index: 100; + overflow: hidden; +} +.notification-item { + padding: 12px 16px; + border-bottom: 1px solid rgba(255,255,255,0.04); + transition: background 0.15s ease; +} +.notification-item:hover { + background: rgba(255,255,255,0.03); +} +.notification-item:last-child { + border-bottom: none; +} + +/* ======================================== + Modal / Dialog Overlay + ======================================== */ + +.modal-overlay { + position: fixed; + inset: 0; + background: rgba(0,0,0,0.6); + backdrop-filter: blur(4px); + z-index: 100; + display: flex; + align-items: center; + justify-content: center; + animation: fadeIn 0.2s ease; +} +.modal-content { + background: #18181B; + border: 1px solid rgba(255,255,255,0.08); + border-radius: 16px; + padding: 24px; + max-width: 480px; + width: 90%; + animation: scaleIn 0.2s ease; +} + +/* ======================================== + Enhanced Chat Message Styles + ======================================== */ + +.chat-message-user { + background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%); + color: #09090B; + border-radius: 20px 20px 6px 20px; + padding: 12px 16px; + max-width: 80%; +} +.chat-message-assistant { + background: rgba(255,255,255,0.06); + color: #FAFAFA; + border-radius: 20px 20px 20px 6px; + padding: 12px 16px; + max-width: 80%; + border: 1px solid rgba(255,255,255,0.06); +} +.chat-timestamp { + font-size: 11px; + color: rgba(255,255,255,0.3); + margin-top: 4px; +} + +/* ======================================== + Button Ripple / Pulse Effect + ======================================== */ + +.btn-primary::after { + content: ''; + position: absolute; + inset: 0; + border-radius: inherit; + opacity: 0; + transition: opacity 0.3s ease; + background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 70%); +} +.btn-primary:active::after { + opacity: 1; + transition: opacity 0s; +} + +/* ======================================== + Keyboard Shortcut Badge + ======================================== */ + +.kbd { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 2px 6px; + font-size: 11px; + font-family: 'Geist Mono', monospace; + color: #A1A1AA; + background: rgba(255,255,255,0.06); + border: 1px solid rgba(255,255,255,0.1); + border-radius: 6px; + box-shadow: 0 1px 0 rgba(255,255,255,0.05); + line-height: 1.4; +} + +/* ======================================== + Checkbox Styling (Batch Operations) + ======================================== */ + +.invoice-checkbox { + appearance: none; + width: 16px; + height: 16px; + border: 1.5px solid rgba(255,255,255,0.2); + border-radius: 4px; + background: transparent; + cursor: pointer; + transition: all 0.15s ease; + position: relative; +} +.invoice-checkbox:checked { + background: #F59E0B; + border-color: #F59E0B; +} +.invoice-checkbox:checked::after { + content: ''; + position: absolute; + left: 4px; + top: 1px; + width: 5px; + height: 9px; + border: solid #09090B; + border-width: 0 2px 2px 0; + transform: rotate(45deg); +} +.invoice-checkbox:hover { + border-color: rgba(245,158,11,0.5); +} + +/* ======================================== + Dashboard Footer + ======================================== */ + +.dash-footer { + border-top: 1px solid rgba(255,255,255,0.06); + background: rgba(255,255,255,0.01); + margin-top: auto; +} + +/* ======================================== + Focus Glow (Subtle Glow on Focus) + ======================================== */ + +.focus-glow:focus-visible { + box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); + border-color: rgba(245, 158, 11, 0.4); +} + +/* ======================================== + Animated Counter (Number Pop) + ======================================== */ + +@keyframes numberPop { + 0% { transform: scale(0.8); opacity: 0; } + 60% { transform: scale(1.05); } + 100% { transform: scale(1); opacity: 1; } +} +.number-pop { + animation: numberPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; +} + +/* ======================================== + Select Dropdown Styling + ======================================== */ + +.select-field { + background: rgba(255, 255, 255, 0.04); + border: 1px solid rgba(255, 255, 255, 0.08); + border-radius: 10px; + padding: 10px 16px; + color: #FAFAFA; + font-size: 14px; + transition: all 0.2s ease; + width: 100%; + appearance: none; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A1A1AA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); + background-repeat: no-repeat; + background-position: right 12px center; + padding-right: 36px; +} +.select-field:focus { + outline: none; + border-color: #F59E0B; + box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1); +} + +/* ======================================== + Chat Suggestion Chip Hover Glow + ======================================== */ + +.chat-suggestion:hover { + box-shadow: 0 0 12px rgba(245, 158, 11, 0.1); + border-color: rgba(245, 158, 11, 0.2); +} + +/* ======================================== + Safe Area Padding for iOS + ======================================== */ + +.pb-safe { + padding-bottom: max(16px, env(safe-area-inset-bottom)); +} + +/* ======================================== + View Transition & Micro-interactions + ======================================== */ + +/* Page/View transition */ +@keyframes viewEnter { + from { + opacity: 0; + transform: translateY(12px) scale(0.99); + } + to { + opacity: 1; + transform: translateY(0) scale(1); + } +} +.view-enter { + animation: viewEnter 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; +} + +/* Staggered card entrance */ +@keyframes cardEnter { + from { + opacity: 0; + transform: translateY(16px); + } + to { + opacity: 1; + transform: translateY(0); + } +} +.card-enter { + opacity: 0; + animation: cardEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; +} +.card-enter:nth-child(1) { animation-delay: 0ms; } +.card-enter:nth-child(2) { animation-delay: 60ms; } +.card-enter:nth-child(3) { animation-delay: 120ms; } +.card-enter:nth-child(4) { animation-delay: 180ms; } +.card-enter:nth-child(5) { animation-delay: 240ms; } +.card-enter:nth-child(6) { animation-delay: 300ms; } + +/* Animated Stat Counter (for landing page stats) */ +@keyframes countSlideUp { + from { opacity: 0; transform: translateY(20px); } + to { opacity: 1; transform: translateY(0); } +} +.stat-animate { + opacity: 0; + animation: countSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; +} +.stat-animate:nth-child(1) { animation-delay: 0.1s; } +.stat-animate:nth-child(2) { animation-delay: 0.2s; } +.stat-animate:nth-child(3) { animation-delay: 0.3s; } + +/* Enhanced Feature Cards with Gradient Border on Hover */ +.feature-card-gradient { + position: relative; + background: rgba(255,255,255,0.03); + backdrop-filter: blur(12px); + border: 1px solid rgba(255,255,255,0.06); + border-radius: 16px; + overflow: hidden; + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); +} +.feature-card-gradient::before { + content: ''; + position: absolute; + inset: 0; + border-radius: 16px; + padding: 1px; + background: linear-gradient(135deg, transparent 40%, rgba(245,158,11,0.3) 100%); + -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); + -webkit-mask-composite: xor; + mask-composite: exclude; + opacity: 0; + transition: opacity 0.4s ease; + pointer-events: none; +} +.feature-card-gradient:hover::before { + opacity: 1; +} +.feature-card-gradient:hover { + transform: translateY(-6px); + box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 40px rgba(245,158,11,0.05); +} + +/* Pricing Card "Most Popular" ribbon */ +.pricing-ribbon { + position: absolute; + top: -1px; + right: 24px; + background: linear-gradient(135deg, #F59E0B, #D97706); + color: #09090B; + font-size: 11px; + font-weight: 700; + padding: 4px 12px 6px; + border-radius: 0 0 8px 8px; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +/* Testimonial Card Enhancements */ +.testimonial-card { + position: relative; + background: rgba(255,255,255,0.03); + backdrop-filter: blur(12px); + border: 1px solid rgba(255,255,255,0.06); + border-radius: 16px; + padding: 24px; + transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); +} +.testimonial-card:hover { + transform: translateY(-4px) scale(1.01); + border-color: rgba(245,158,11,0.15); + box-shadow: 0 16px 48px rgba(0,0,0,0.2); +} +.testimonial-card::after { + content: ''; + position: absolute; + bottom: 0; + left: 24px; + right: 24px; + height: 2px; + background: linear-gradient(90deg, transparent, rgba(245,158,11,0.3), transparent); + opacity: 0; + transition: opacity 0.4s ease; +} +.testimonial-card:hover::after { + opacity: 1; +} + +/* Hero Particle/Dot Grid Enhancement */ +.hero-grid-enhanced { + background-image: + radial-gradient(circle at 1px 1px, rgba(245,158,11,0.08) 1px, transparent 0); + background-size: 40px 40px; +} + +/* Glow divider between sections */ +.section-glow-divider { + height: 1px; + background: linear-gradient(90deg, transparent, rgba(245,158,11,0.2) 50%, transparent); + border: none; +} + +/* Tab content area subtle background */ +.tab-content-area { + background: linear-gradient(180deg, rgba(255,255,255,0.01) 0%, transparent 100%); + border-radius: 12px; + padding: 24px; +} + +/* Activity timeline line animation */ +@keyframes timelineGrow { + from { transform: scaleY(0); } + to { transform: scaleY(1); } +} +.timeline-line-animated { + transform-origin: top; + animation: timelineGrow 0.8s cubic-bezier(0.16, 1, 0.3, 1) both; + animation-delay: 0.3s; +} + +/* Enhanced input focus with glow ring */ +.input-field-glow:focus { + outline: none; + border-color: rgba(245, 158, 11, 0.5); + box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08), 0 0 20px rgba(245, 158, 11, 0.06); + background: rgba(255, 255, 255, 0.06); +} + +/* Subtle hover underline for footer links */ +.footer-link-underline { + position: relative; + color: #A1A1AA; + transition: color 0.2s ease; + cursor: pointer; +} +.footer-link-underline::after { + content: ''; + position: absolute; + bottom: -2px; + left: 0; + width: 0; + height: 1px; + background: #F59E0B; + transition: width 0.3s ease; +} +.footer-link-underline:hover { + color: #F59E0B; +} +.footer-link-underline:hover::after { + width: 100%; +} + +/* ── Premium CSS Enhancements ── */ + +/* CTA button shine sweep effect */ +.btn-shine { + position: relative; + overflow: hidden; +} +.btn-shine::before { + content: ''; + position: absolute; + top: 0; + left: -100%; + width: 100%; + height: 100%; + background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent); + transition: left 0.5s ease; +} +.btn-shine:hover::before { + left: 100%; +} + +/* Floating badge animation on hero */ +@keyframes float { + 0%, 100% { transform: translateY(0px); } + 50% { transform: translateY(-8px); } +} +.float-animation { + animation: float 3s ease-in-out infinite; +} +.float-animation-delayed { + animation: float 3s ease-in-out 1.5s infinite; +} + +/* Logo pulse glow */ +@keyframes logoGlow { + 0%, 100% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.2); } + 50% { box-shadow: 0 0 24px rgba(245, 158, 11, 0.4); } +} +.logo-glow { + animation: logoGlow 3s ease-in-out infinite; +} + +/* Enhanced glassmorphism for stat cards */ +.stat-card-glass { + background: rgba(255, 255, 255, 0.03); + backdrop-filter: blur(12px); + border: 1px solid rgba(255, 255, 255, 0.06); + border-radius: 12px; + padding: 16px 20px; + transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); + position: relative; + overflow: hidden; +} +.stat-card-glass::before { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + height: 2px; + border-radius: 12px 12px 0 0; +} +.stat-card-glass.card-accent-amber::before { + background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.6), transparent); +} +.stat-card-glass.card-accent-teal::before { + background: linear-gradient(90deg, transparent, rgba(20, 184, 166, 0.6), transparent); +} +.stat-card-glass.card-accent-red::before { + background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.6), transparent); +} +.stat-card-glass.card-accent-green::before { + background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.6), transparent); +} +.stat-card-glass:hover { + transform: translateY(-3px); + box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2); + border-color: rgba(255, 255, 255, 0.1); +} + +/* Enhanced table row hover with left accent bar */ +.invoice-row-enhanced { + cursor: pointer; + transition: all 0.2s ease; + position: relative; +} +.invoice-row-enhanced:hover { + background: rgba(255, 255, 255, 0.03) !important; +} +.invoice-row-enhanced:hover td:first-child { + box-shadow: inset 3px 0 0 -1px rgba(245, 158, 11, 0.5); +} + +/* Custom recharts tooltip */ +.recharts-tooltip-custom { + background: rgba(17, 17, 19, 0.95) !important; + border: 1px solid rgba(255, 255, 255, 0.08) !important; + border-radius: 10px !important; + padding: 10px 14px !important; + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important; + backdrop-filter: blur(8px) !important; +} +.recharts-tooltip-custom .recharts-tooltip-label { + color: #A1A1AA !important; + font-size: 11px !important; + font-weight: 500 !important; + text-transform: uppercase !important; + letter-spacing: 0.05em !important; +} +.recharts-tooltip-custom .recharts-tooltip-value { + color: #FAFAFA !important; + font-size: 13px !important; + font-weight: 600 !important; +} + +/* Smooth mobile nav slide down */ +@keyframes slideDown { + from { opacity: 0; transform: translateY(-8px); max-height: 0; } + to { opacity: 1; transform: translateY(0); max-height: 400px; } +} +.mobile-nav-slide { + animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; + overflow: hidden; +} + +/* How-it-works step connector line */ +.step-connector { + position: relative; +} +.step-connector::after { + content: ''; + position: absolute; + top: 28px; + left: calc(50% + 32px); + width: calc(100% - 64px); + height: 2px; + background: linear-gradient(90deg, rgba(245, 158, 11, 0.3), rgba(20, 184, 166, 0.3)); +} +.step-connector:last-child::after { + display: none; +} + +/* Upload success animation */ +@keyframes successPop { + 0% { transform: scale(0.8); opacity: 0; } + 50% { transform: scale(1.05); } + 100% { transform: scale(1); opacity: 1; } +} +.success-pop { + animation: successPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; +} + +/* Subtle hover effect for FAQ details */ +details.glass-card summary { + transition: background 0.2s ease; +} +details.glass-card summary:hover { + background: rgba(255, 255, 255, 0.02); +} +details.glass-card[open] summary { + border-bottom: 1px solid rgba(255, 255, 255, 0.04); +} + +/* ======================================== + Light Theme Overrides + ======================================== */ + +/* Base light theme */ +.light { + --background: #FAFAFA; + --foreground: #18181B; + --card: #FFFFFF; + --card-foreground: #18181B; + --popover: #FFFFFF; + --popover-foreground: #18181B; + --primary: #D97706; + --primary-foreground: #FFFFFF; + --secondary: #F4F4F5; + --secondary-foreground: #18181B; + --muted: #F4F4F5; + --muted-foreground: #71717A; + --accent: #F4F4F5; + --accent-foreground: #18181B; + --destructive: #EF4444; + --border: rgba(0, 0, 0, 0.08); + --input: rgba(0, 0, 0, 0.08); + --ring: #D97706; + color-scheme: light; +} + +.light body { + background: #FAFAFA; + color: #18181B; +} + +/* Light glass cards */ +.light .glass-card, +.light .glass-card-hover { + background: rgba(255, 255, 255, 0.8); + border-color: rgba(0, 0, 0, 0.06); + backdrop-filter: blur(12px); +} + +.light .glass-card-hover:hover { + background: rgba(255, 255, 255, 0.95); + border-color: rgba(217, 119, 6, 0.2); + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06); +} + +/* Light navbar */ +.light .nav-blur { + background: rgba(250, 250, 250, 0.85); + border-bottom-color: rgba(0, 0, 0, 0.06); +} + +/* Light input fields */ +.light .input-field, +.light .input-field-glow { + background: #FFFFFF; + border-color: rgba(0, 0, 0, 0.1); + color: #18181B; +} +.light .input-field:focus, +.light .input-field-glow:focus { + border-color: #D97706; + box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1), 0 0 20px rgba(217, 119, 6, 0.04); + background: #FFFFFF; +} +.light .input-field::placeholder, +.light .input-field-glow::placeholder { + color: #A1A1AA; +} + +/* Light buttons */ +.light .btn-ghost { + color: #18181B; + border-color: rgba(0, 0, 0, 0.1); +} +.light .btn-ghost:hover { + background: rgba(0, 0, 0, 0.04); + border-color: rgba(0, 0, 0, 0.15); +} +.light .btn-primary { + background: linear-gradient(135deg, #D97706 0%, #B45309 100%); + color: #FFFFFF; +} + +/* Light data table */ +.light .data-table thead th { + color: #71717A; + border-bottom-color: rgba(0, 0, 0, 0.06); + background: #FAFAFA; +} +.light .data-table tbody td { + color: #52525B; + border-bottom-color: rgba(0, 0, 0, 0.04); +} + +/* Light stat card */ +.light .stat-card { + background: #FFFFFF; + border-color: rgba(0, 0, 0, 0.06); +} +.light .stat-card:hover { + background: #FAFAFA; + border-color: rgba(0, 0, 0, 0.1); +} + +/* Light drop zone */ +.light .drop-zone, +.light .drop-zone-animated { + border-color: rgba(217, 119, 6, 0.3); + background: rgba(217, 119, 6, 0.02); +} +.light .drop-zone:hover, +.light .drop-zone.drag-over { + border-color: #D97706; + background: rgba(217, 119, 6, 0.04); +} + +/* Light invoice row */ +.light .invoice-row:hover { + background: rgba(0, 0, 0, 0.02) !important; +} + +/* Light code block */ +.light .code-block { + background: #F4F4F5; + border-color: rgba(0, 0, 0, 0.06); + color: #52525B; +} + +/* Light modal */ +.light .modal-overlay { + background: rgba(0, 0, 0, 0.4); +} +.light .modal-content { + background: #FFFFFF; + border-color: rgba(0, 0, 0, 0.08); +} + +/* Light notification dropdown */ +.light .notification-dropdown { + background: #FFFFFF; + border-color: rgba(0, 0, 0, 0.08); + box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12); +} +.light .notification-item:hover { + background: rgba(0, 0, 0, 0.02); +} + +/* Light tooltips */ +.light .tooltip-wrapper .tooltip-text { + background: #27272A; + color: #FAFAFA; +} + +/* Light kbd */ +.light .kbd { + color: #71717A; + background: #F4F4F5; + border-color: rgba(0, 0, 0, 0.1); + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05); +} + +/* Light footer */ +.light .dash-footer { + border-top-color: rgba(0, 0, 0, 0.06); + background: rgba(0, 0, 0, 0.01); +} + +/* Light scroll-to-top */ +.light .scroll-top-btn { + background: rgba(217, 119, 6, 0.1); + border-color: rgba(217, 119, 6, 0.3); + color: #D97706; +} +.light .scroll-top-btn:hover { + background: rgba(217, 119, 6, 0.2); +} + +/* Light skeleton shimmer */ +.light .skeleton-shimmer { + background: linear-gradient(90deg, rgba(0,0,0,0.03) 25%, rgba(0,0,0,0.07) 50%, rgba(0,0,0,0.03) 75%); + background-size: 200% 100%; + animation: shimmer 1.5s infinite; + border-radius: 8px; +} + +/* Light grid background */ +.light .grid-bg { + background-image: + linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px), + linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px); +} + +/* Light hero orbs */ +.light .hero-orb { + background: radial-gradient(circle, rgba(217,119,6,0.08) 0%, rgba(13,148,136,0.04) 40%, transparent 70%); +} +.light .hero-orb-2 { + background: radial-gradient(circle, rgba(13,148,136,0.06) 0%, rgba(217,119,6,0.03) 40%, transparent 70%); +} + +/* Light hero dot grid */ +.light .hero-grid-enhanced { + background-image: + radial-gradient(circle at 1px 1px, rgba(217,119,6,0.06) 1px, transparent 0); +} + +/* Light section glow divider */ +.light .section-glow-divider { + background: linear-gradient(90deg, transparent, rgba(217,119,6,0.15) 50%, transparent); +} + +/* Light feature card gradient */ +.light .feature-card-gradient { + background: rgba(255,255,255,0.8); + border-color: rgba(0,0,0,0.06); +} +.light .feature-card-gradient::before { + background: linear-gradient(135deg, transparent 40%, rgba(217,119,6,0.2) 100%); +} +.light .feature-card-gradient:hover { + box-shadow: 0 20px 60px rgba(0,0,0,0.08), 0 0 40px rgba(217,119,6,0.03); +} + +/* Light testimonial card */ +.light .testimonial-card { + background: rgba(255,255,255,0.8); + border-color: rgba(0,0,0,0.06); +} +.light .testimonial-card:hover { + border-color: rgba(217,119,6,0.15); + box-shadow: 0 16px 48px rgba(0,0,0,0.08); +} +.light .testimonial-card::after { + background: linear-gradient(90deg, transparent, rgba(217,119,6,0.2), transparent); +} + +/* Light pricing highlight */ +.light .pricing-highlight { + border-color: rgba(217,119,6,0.3); + background: linear-gradient(135deg, rgba(217,119,6,0.05) 0%, rgba(13,148,136,0.02) 100%); +} + +/* Light tab content area */ +.light .tab-content-area { + background: linear-gradient(180deg, rgba(0,0,0,0.01) 0%, transparent 100%); +} + +/* Light noise overlay (very subtle) */ +.light .noise-overlay::before { + opacity: 0.015; +} + +/* Light select field */ +.light .select-field { + background: #FFFFFF; + border-color: rgba(0, 0, 0, 0.1); + color: #18181B; +} +.light .select-field:focus { + border-color: #D97706; + box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1); +} + +/* Light badge styles */ +.light .badge-amber { + background: rgba(217, 119, 6, 0.1); + color: #B45309; +} +.light .badge-teal { + background: rgba(13, 184, 166, 0.1); + color: #0D9488; +} + +/* Light status badges */ +.light .status-done { background: rgba(34, 197, 94, 0.1); color: #16A34A; } +.light .status-review { background: rgba(234, 179, 8, 0.1); color: #CA8A04; } +.light .status-duplicate { background: rgba(239, 68, 68, 0.1); color: #DC2626; } + +/* Light chat bubbles */ +.light .chat-message-user { + background: linear-gradient(135deg, #D97706 0%, #B45309 100%); + color: #FFFFFF; +} +.light .chat-message-assistant { + background: rgba(0, 0, 0, 0.04); + color: #18181B; + border-color: rgba(0, 0, 0, 0.06); +} +.light .chat-timestamp { + color: rgba(0, 0, 0, 0.3); +} + +/* Light checkbox */ +.light .invoice-checkbox { + border-color: rgba(0, 0, 0, 0.2); +} +.light .invoice-checkbox:checked { + background: #D97706; + border-color: #D97706; +} +.light .invoice-checkbox:hover { + border-color: rgba(217, 119, 6, 0.5); +} + +/* Light amber glow */ +.light .amber-glow { + box-shadow: 0 0 40px rgba(217, 119, 6, 0.1), 0 0 80px rgba(217, 119, 6, 0.03); +} + +/* Light focus visible */ +.light *:focus-visible { + outline-color: #D97706; +} + +/* Light gradient text */ +.light .gradient-text { + background: linear-gradient(135deg, #D97706 0%, #B45309 40%, #0D9488 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; +} + +/* Light scrollbar */ +.light ::-webkit-scrollbar-thumb { + background: rgba(0, 0, 0, 0.12); +} +.light ::-webkit-scrollbar-thumb:hover { + background: rgba(0, 0, 0, 0.2); +} + +/* ── Table Sort Indicators ── */ +.sort-header { + cursor: pointer; + user-select: none; + transition: color 0.15s ease; +} +.sort-header:hover { + color: var(--foreground) !important; +} +.sort-indicator { + display: inline-flex; + align-items: center; + justify-content: center; + width: 16px; + height: 16px; + font-size: 10px; + color: #F59E0B; + margin-left: 4px; + animation: sortPop 0.2s ease; +} +@keyframes sortPop { + 0% { transform: scale(0.5); opacity: 0; } + 100% { transform: scale(1); opacity: 1; } +} +.sort-header-inactive { + display: inline-flex; + align-items: center; + justify-content: center; + width: 16px; + height: 16px; + margin-left: 4px; + opacity: 0; + transition: opacity 0.15s ease; +} +.sort-header:hover .sort-header-inactive { + opacity: 0.3; +} + +/* ── Command Palette ── */ +.command-palette-backdrop { + position: fixed; + inset: 0; + z-index: 60; + background: rgba(0, 0, 0, 0.6); + backdrop-filter: blur(8px); + display: flex; + align-items: flex-start; + justify-content: center; + padding-top: 15vh; + animation: commandFadeIn 0.15s ease; +} +@keyframes commandFadeIn { + from { opacity: 0; } + to { opacity: 1; } +} +.command-palette { + width: 100%; + max-width: 560px; + margin: 0 1rem; + background: rgba(24, 24, 27, 0.95); + backdrop-filter: blur(20px); + border: 1px solid rgba(255, 255, 255, 0.08); + border-radius: 16px; + box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03); + overflow: hidden; + animation: commandSlideIn 0.2s ease; +} +@keyframes commandSlideIn { + from { opacity: 0; transform: translateY(-10px) scale(0.98); } + to { opacity: 1; transform: translateY(0) scale(1); } +} +.command-palette-input { + display: flex; + align-items: center; + gap: 12px; + padding: 16px; + border-bottom: 1px solid rgba(255, 255, 255, 0.06); +} +.command-palette-input input { + flex: 1; + background: transparent; + border: none; + outline: none; + color: var(--foreground); + font-size: 14px; +} +.command-palette-input input::placeholder { + color: var(--muted-foreground); +} +.command-palette-results { + max-height: 288px; + overflow-y: auto; + padding: 8px; +} +.command-palette-item { + display: flex; + align-items: center; + gap: 12px; + width: 100%; + text-align: left; + padding: 10px 12px; + border-radius: 10px; + font-size: 14px; + color: var(--muted-foreground); + background: transparent; + border: none; + cursor: pointer; + transition: all 0.12s ease; +} +.command-palette-item:hover { + color: var(--foreground); + background: rgba(255, 255, 255, 0.04); +} +.command-palette-item:active { + background: rgba(255, 255, 255, 0.06); +} +.command-palette-section-title { + padding: 8px 12px 4px; + font-size: 11px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.05em; + color: var(--muted-foreground); +} +.command-palette-result-sub { + font-size: 12px; + color: var(--muted-foreground); + margin-top: 2px; +} + +/* ── Duplicate Alert Panel ── */ +.duplicate-alert { + position: relative; + overflow: hidden; + border-color: rgba(245, 158, 11, 0.2) !important; + background: linear-gradient(135deg, rgba(245, 158, 11, 0.03), rgba(245, 158, 11, 0.01)) !important; +} +.duplicate-alert::before { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + height: 2px; + background: linear-gradient(90deg, transparent, #F59E0B, transparent); +} + +/* ── Welcome Panel ── */ +.welcome-panel { + position: relative; + overflow: hidden; +} +.welcome-panel::before { + content: ''; + position: absolute; + top: -40px; + right: -40px; + width: 120px; + height: 120px; + background: radial-gradient(circle, rgba(245, 158, 11, 0.08), transparent 70%); + border-radius: 50%; + pointer-events: none; +} +.welcome-panel::after { + content: ''; + position: absolute; + bottom: -30px; + left: -30px; + width: 100px; + height: 100px; + background: radial-gradient(circle, rgba(20, 184, 166, 0.06), transparent 70%); + border-radius: 50%; + pointer-events: none; +} +.welcome-stat-btn { + display: flex; + align-items: center; + gap: 8px; + padding: 12px; + border-radius: 10px; + background: rgba(255, 255, 255, 0.03); + border: 1px solid rgba(255, 255, 255, 0.04); + text-align: left; + cursor: pointer; + transition: all 0.2s ease; + color: inherit; + width: 100%; + font-family: inherit; +} +.welcome-stat-btn:hover { + background: rgba(255, 255, 255, 0.06); + border-color: rgba(255, 255, 255, 0.08); + transform: translateY(-1px); +} +.welcome-stat-btn:active { + transform: translateY(0); +} +.welcome-stat-icon { + color: var(--muted-foreground); + transition: color 0.2s ease; +} +.welcome-stat-btn:hover .welcome-stat-icon { + color: #F59E0B; +} + +/* ── Settings Toggle Switch ── */ +.toggle-switch { + position: relative; + width: 44px; + height: 24px; + border-radius: 12px; + background: #3f3f46; + border: none; + cursor: pointer; + transition: background 0.2s ease; + padding: 0; + flex-shrink: 0; +} +.toggle-switch.active { + background: #F59E0B; +} +.toggle-switch-knob { + position: absolute; + top: 2px; + left: 2px; + width: 20px; + height: 20px; + border-radius: 50%; + background: white; + transition: transform 0.2s ease; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); +} +.toggle-switch.active .toggle-switch-knob { + transform: translateX(20px); +} + +/* ── Card Depth Hover ── */ +.card-depth { + transition: transform 0.25s ease, box-shadow 0.25s ease; +} +.card-depth:hover { + transform: translateY(-2px); + box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05); +} + +/* ── Enhanced Badge System ── */ +.badge-pill { + display: inline-flex; + align-items: center; + gap: 4px; + padding: 2px 10px; + border-radius: 9999px; + font-size: 11px; + font-weight: 500; + letter-spacing: 0.01em; + transition: all 0.15s ease; +} +.badge-pill-dot { + width: 6px; + height: 6px; + border-radius: 50%; + flex-shrink: 0; +} +.badge-teal-enhanced { + background: rgba(20, 184, 166, 0.1); + color: #14B8A6; + border: 1px solid rgba(20, 184, 166, 0.15); +} +.badge-amber-enhanced { + background: rgba(245, 158, 11, 0.1); + color: #F59E0B; + border: 1px solid rgba(245, 158, 11, 0.15); +} +.badge-red-enhanced { + background: rgba(239, 68, 68, 0.1); + color: #EF4444; + border: 1px solid rgba(239, 68, 68, 0.15); +} +.badge-green-enhanced { + background: rgba(34, 197, 94, 0.1); + color: #22C55E; + border: 1px solid rgba(34, 197, 94, 0.15); +} + +/* ── Pulse Dot ── */ +.pulse-dot { + position: relative; + width: 8px; + height: 8px; + border-radius: 50%; + background: #F59E0B; +} +.pulse-dot::after { + content: ''; + position: absolute; + inset: -3px; + border-radius: 50%; + border: 2px solid #F59E0B; + animation: pulseDot 2s ease infinite; +} +@keyframes pulseDot { + 0% { transform: scale(0.8); opacity: 0.8; } + 50% { transform: scale(1.4); opacity: 0; } + 100% { transform: scale(0.8); opacity: 0; } +} + +/* ── Teal Gradient Text ── */ +.gradient-text-teal { + background: linear-gradient(135deg, #14B8A6, #5EEAD4); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; +} + +/* ── Refined Scrollbar ── */ +.scrollbar-thin::-webkit-scrollbar { + width: 6px; + height: 6px; +} +.scrollbar-thin::-webkit-scrollbar-track { + background: transparent; +} +.scrollbar-thin::-webkit-scrollbar-thumb { + background: rgba(255, 255, 255, 0.08); + border-radius: 3px; +} +.scrollbar-thin::-webkit-scrollbar-thumb:hover { + background: rgba(255, 255, 255, 0.15); +} + +/* ── Glass Card Hover Glow ── */ +.glass-card-glow { + position: relative; + transition: all 0.3s ease; +} +.glass-card-glow::after { + content: ''; + position: absolute; + inset: -1px; + border-radius: inherit; + background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(20, 184, 166, 0.1), transparent, transparent); + opacity: 0; + z-index: -1; + transition: opacity 0.3s ease; + filter: blur(8px); +} +.glass-card-glow:hover::after { + opacity: 1; +} + +/* ── Light Mode: New Class Overrides ── */ +:root.light .command-palette { + background: rgba(255, 255, 255, 0.95); + border-color: rgba(0, 0, 0, 0.08); + box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.03); +} +:root.light .command-palette-input { + border-bottom-color: rgba(0, 0, 0, 0.06); +} +:root.light .command-palette-item:hover { + background: rgba(0, 0, 0, 0.04); +} +:root.light .duplicate-alert { + background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), rgba(245, 158, 11, 0.02)) !important; +} +:root.light .welcome-panel::before { + background: radial-gradient(circle, rgba(245, 158, 11, 0.1), transparent 70%); +} +:root.light .welcome-panel::after { + background: radial-gradient(circle, rgba(20, 184, 166, 0.08), transparent 70%); +} +:root.light .welcome-stat-btn { + background: rgba(0, 0, 0, 0.02); + border-color: rgba(0, 0, 0, 0.06); +} +:root.light .welcome-stat-btn:hover { + background: rgba(0, 0, 0, 0.04); + border-color: rgba(0, 0, 0, 0.1); +} +:root.light .card-depth:hover { + box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04); +} +:root.light .toggle-switch { + background: #d4d4d8; +} +:root.light .scrollbar-thin::-webkit-scrollbar-thumb { + background: rgba(0, 0, 0, 0.1); +} +:root.light .scrollbar-thin::-webkit-scrollbar-thumb:hover { + background: rgba(0, 0, 0, 0.2); +} +:root.light .sort-header-inactive { + opacity: 0; +} +:root.light .sort-header:hover .sort-header-inactive { + opacity: 0.2; +} +:root.light .glass-card-glow::after { + background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(20, 184, 166, 0.15), transparent, transparent); +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/layout.tsx b/omniparse-hf-space (1)/src/app/layout.tsx new file mode 100644 index 0000000000000000000000000000000000000000..21ca916f8fdc1ab4d6289e837cb048e8e81395f2 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/layout.tsx @@ -0,0 +1,59 @@ +import type { Metadata } from "next"; +import { Geist, Geist_Mono } from "next/font/google"; +import "./globals.css"; +import { Toaster } from "sonner"; +import { ThemeProvider } from 'next-themes'; + +const geistSans = Geist({ + variable: "--font-geist-sans", + subsets: ["latin"], +}); + +const geistMono = Geist_Mono({ + variable: "--font-geist-mono", + subsets: ["latin"], +}); + +export const metadata: Metadata = { + title: "OmniParse AI — Invoice Processing in Seconds", + description: + "AI-powered invoice processing. Upload PDFs or images and extract vendor, dates, amounts, and line items as structured data. Export to CSV, JSON, or connect via API.", + keywords: [ + "invoice processing", + "OCR", + "AI extraction", + "automated accounting", + "document processing", + ], + icons: { + icon: "data:image/svg+xml,", + }, +}; + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return ( + + + + {children} + + + + + ); +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/app/page.tsx b/omniparse-hf-space (1)/src/app/page.tsx new file mode 100644 index 0000000000000000000000000000000000000000..6848b868cdeeca19b38c9372c85eaa6ef4aa7e97 --- /dev/null +++ b/omniparse-hf-space (1)/src/app/page.tsx @@ -0,0 +1,3466 @@ +'use client'; + +import { useState, useEffect, useCallback, useRef, useMemo } from 'react'; +import { useAppStore } from '@/stores/app-store'; +import type { InvoiceRow, View, ChatMessage } from '@/stores/app-store'; +import { + Upload, + FileText, + BarChart3, + Bot, + Download, + CreditCard, + Key, + User, + LogOut, + Menu, + X, + ChevronDown, + ChevronUp, + Search, + Trash2, + Send, + Copy, + Eye, + EyeOff, + AlertCircle, + CheckCircle, + Loader2, + ArrowRight, + Sparkles, + Shield, + Zap, + Globe, + Layers, + RefreshCw, + FileDown, + FileJson, + Quote, + ChevronRight, + ScanLine, + Database, + Lock, + Mail, + UserPlus, + Inbox, + MessageSquare, + CircleDollarSign, + CopyCheck, + Terminal, + ArrowLeft, + Crown, + Building2, + Check, + MousePointerClick, + TrendingUp, + Bell, + Clock, + Pencil, + LogIn, + Sun, + Moon, + ArrowUpDown, + Command, + Settings, +} from 'lucide-react'; +import type { LucideIcon } from 'lucide-react'; +import { toast } from 'sonner'; +import { + AreaChart, Area, BarChart, Bar, PieChart, Pie, Cell, + XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid, +} from 'recharts'; +import { PLAN_LIMITS, PLAN_LABELS, PLAN_PRICES } from '@/lib/auth'; +import { useTheme } from 'next-themes'; + +// ─── Helpers ──────────────────────────────────────────────────────────────────── + +const currencyFmt = new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', +}); + +function formatCurrency(amount: number | null, currency?: string): string { + if (amount === null || amount === undefined) return '--'; + try { + return new Intl.NumberFormat('en-US', { + style: 'currency', + currency: currency || 'USD', + }).format(amount); + } catch { + return currency ? `${currency} ${amount.toFixed(2)}` : `$${amount.toFixed(2)}`; + } +} + +function getPasswordStrength(pw: string): { label: string; color: string; width: string } { + if (!pw) return { label: '', color: 'bg-zinc-700', width: 'w-0' }; + let score = 0; + if (pw.length >= 6) score++; + if (pw.length >= 10) score++; + if (/[A-Z]/.test(pw)) score++; + if (/[0-9]/.test(pw)) score++; + if (/[^A-Za-z0-9]/.test(pw)) score++; + if (score <= 2) return { label: 'Weak', color: 'bg-red-500', width: 'w-1/3' }; + if (score <= 3) return { label: 'Medium', color: 'bg-amber-500', width: 'w-2/3' }; + return { label: 'Strong', color: 'bg-green-500', width: 'w-full' }; +} + +const DASH_TABS = [ + { id: 'upload', label: 'Upload', icon: Upload }, + { id: 'invoices', label: 'Invoices', icon: FileText }, + { id: 'analytics', label: 'Analytics', icon: BarChart3 }, + { id: 'chat', label: 'AI Chat', icon: Bot }, + { id: 'export', label: 'Export', icon: Download }, + { id: 'upgrade', label: 'Upgrade', icon: Crown }, + { id: 'api', label: 'API Access', icon: Key }, + { id: 'profile', label: 'Profile', icon: User }, + { id: 'activity', label: 'Activity', icon: Clock }, + { id: 'settings', label: 'Settings', icon: Settings }, +] as const; + +function relativeTime(dateStr: string): string { + const now = Date.now(); + const then = new Date(dateStr).getTime(); + const diffMs = now - then; + const diffMins = Math.floor(diffMs / 60000); + if (diffMins < 1) return 'Just now'; + if (diffMins < 60) return `${diffMins}m ago`; + const diffHours = Math.floor(diffMins / 60); + if (diffHours < 24) return `${diffHours}h ago`; + const diffDays = Math.floor(diffHours / 24); + if (diffDays < 30) return `${diffDays}d ago`; + return new Date(dateStr).toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); +} + +// ─── Main Page Component ──────────────────────────────────────────────────────── + +export default function Home() { + const store = useAppStore(); + const { theme, setTheme } = useTheme(); + + // ── Local Auth State ── + const [authMode, setAuthMode] = useState<'login' | 'signup'>('login'); + const [loginEmail, setLoginEmail] = useState(''); + const [loginPassword, setLoginPassword] = useState(''); + const [signupName, setSignupName] = useState(''); + const [signupEmail, setSignupEmail] = useState(''); + const [signupPassword, setSignupPassword] = useState(''); + const [signupConfirm, setSignupConfirm] = useState(''); + const [authLoading, setAuthLoading] = useState(false); + const [authError, setAuthError] = useState(''); + + // ── Dashboard Local State ── + const [invoiceSearch, setInvoiceSearch] = useState(''); + const [invoiceFilter, setInvoiceFilter] = useState('all'); + const [expandedInvoice, setExpandedInvoice] = useState(null); + const [selectedInvoices, setSelectedInvoices] = useState>(new Set()); + const [chatInput, setChatInput] = useState(''); + const [showApiKey, setShowApiKey] = useState(false); + const [profileCurrentPw, setProfileCurrentPw] = useState(''); + const [profileNewPw, setProfileNewPw] = useState(''); + const [profileConfirmPw, setProfileConfirmPw] = useState(''); + const [profilePwLoading, setProfilePwLoading] = useState(false); + + const [showScrollTop, setShowScrollTop] = useState(false); + + // ── Landing Mobile Nav ── + const [mobileMenuOpen, setMobileMenuOpen] = useState(false); + const [dashMobileMenu, setDashMobileMenu] = useState(false); + + const [editingInvoice, setEditingInvoice] = useState(null); + const [editForm, setEditForm] = useState>({}); + const [editSaving, setEditSaving] = useState(false); + const [dateFrom, setDateFrom] = useState(''); + const [dateTo, setDateTo] = useState(''); + const [sortField, setSortField] = useState('createdAt'); + const [sortDir, setSortDir] = useState<'asc' | 'desc'>('desc'); + + // ── Activity Items (real API) ── + const [activityLogs, setActivityLogs] = useState>([]); + const [activityLoading, setActivityLoading] = useState(false); + + const fetchActivity = useCallback(async () => { + setActivityLoading(true); + try { + const res = await fetch('/api/activity'); + if (res.ok) { + const data = await res.json(); + setActivityLogs(data.activities); + } + } catch { /* silent */ } + finally { setActivityLoading(false); } + }, []); + + useEffect(() => { + if (store.view === 'dashboard' && store.activeDashTab === 'activity') { + fetchActivity(); + } + }, [store.view, store.activeDashTab, fetchActivity]); + + const [showNotifications, setShowNotifications] = useState(false); + const [showShortcuts, setShowShortcuts] = useState(false); + const [showCommandPalette, setShowCommandPalette] = useState(false); + const [commandSearch, setCommandSearch] = useState(''); + + const notifications = [ + ...(store.invoices.length > 0 ? [{ + id: '1', + title: 'Invoices processed', + description: `${store.invoices.length} invoice(s) in your account`, + time: 'Just now', + icon: FileText, + color: 'text-teal-500', + }] : []), + { + id: '2', + title: 'Welcome to OmniParse', + description: 'Upload your first invoice to get started', + time: 'Getting started', + icon: Sparkles, + color: 'text-amber-500', + }, + { + id: '3', + title: 'AI Chat available', + description: store.user?.plan === 'free' + ? 'Upgrade to Pro to unlock AI Chat' + : 'Ask questions about your invoices', + time: 'Feature', + icon: Bot, + color: 'text-amber-500', + }, + ]; + + // ── Settings State ── + const [dateFormat, setDateFormat] = useState<'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD'>('MM/DD/YYYY'); + const [defaultCurrency, setDefaultCurrency] = useState('USD'); + const [compactView, setCompactView] = useState(false); + const [settingsSaved, setSettingsSaved] = useState(false); + + const saveSettings = useCallback(() => { + setSettingsSaved(true); + toast.success('Settings saved successfully'); + setTimeout(() => setSettingsSaved(false), 2000); + }, []); + + // ── Upload State ── + const [selectedFiles, setSelectedFiles] = useState([]); + const [dragOver, setDragOver] = useState(false); + const fileInputRef = useRef(null); + + const toggleSort = useCallback((field: string) => { + if (sortField === field) { + setSortDir(d => d === 'asc' ? 'desc' : 'asc'); + } else { + setSortField(field); + setSortDir('asc'); + } + }, [sortField]); + + // ── Derived invoice data (before callbacks so they can reference it) ── + const filteredInvoices = useMemo(() => { + let result = store.invoices.filter((inv) => { + if (invoiceSearch && !inv.vendor?.toLowerCase().includes(invoiceSearch.toLowerCase())) return false; + if (invoiceFilter === 'done') return inv.status === 'done' && !inv.isDuplicate; + if (invoiceFilter === 'review') return inv.status === 'review' || inv.isDuplicate; + if (invoiceFilter === 'duplicates') return inv.isDuplicate; + if (dateFrom && inv.invDate && inv.invDate < dateFrom) return false; + if (dateTo && inv.invDate && inv.invDate > dateTo) return false; + return true; + }); + result.sort((a, b) => { + let cmp = 0; + const f = sortField; + if (f === 'vendor') cmp = (a.vendor || '').localeCompare(b.vendor || ''); + else if (f === 'invNumber') cmp = (a.invNumber || '').localeCompare(b.invNumber || ''); + else if (f === 'invDate') cmp = (a.invDate || '').localeCompare(b.invDate || ''); + else if (f === 'amount') cmp = (a.amount ?? 0) - (b.amount ?? 0); + else if (f === 'total') cmp = (a.total ?? 0) - (b.total ?? 0); + else if (f === 'confidence') cmp = (a.confidence ?? 0) - (b.confidence ?? 0); + else if (f === 'status') cmp = a.status.localeCompare(b.status); + else cmp = new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(); + return sortDir === 'asc' ? cmp : -cmp; + }); + return result; + }, [store.invoices, invoiceSearch, invoiceFilter, dateFrom, dateTo, sortField, sortDir]); + + // ── Chat scroll ref ── + const chatEndRef = useRef(null); + + // ── Scroll refs for landing ── + const featuresRef = useRef(null); + const pricingRef = useRef(null); + + // ────────────────────────────────────────────────────────────────────────────── + // API Callbacks + // ────────────────────────────────────────────────────────────────────────────── + + const fetchMe = useCallback(async () => { + const { setUser, setView, setLoading } = useAppStore.getState(); + try { + const res = await fetch('/api/auth/me'); + if (res.ok) { + const data = await res.json(); + setUser(data.user); + setView('dashboard'); + } else { + setUser(null); + setLoading(false); + } + } catch { + setUser(null); + setLoading(false); + } + }, []); + + const fetchLogin = useCallback(async () => { + setAuthError(''); + setAuthLoading(true); + try { + const res = await fetch('/api/auth/login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email: loginEmail, password: loginPassword }), + }); + const data = await res.json(); + if (!res.ok) { + setAuthError(data.error || 'Login failed'); + setAuthLoading(false); + return; + } + const { setUser, setView } = useAppStore.getState(); + setUser(data.user); + setView('dashboard'); + toast.success('Welcome back!'); + } catch { + setAuthError('Network error. Please try again.'); + } finally { + setAuthLoading(false); + } + }, [loginEmail, loginPassword]); + + const fetchSignup = useCallback(async () => { + setAuthError(''); + if (signupPassword !== signupConfirm) { + setAuthError('Passwords do not match'); + return; + } + setAuthLoading(true); + try { + const res = await fetch('/api/auth/signup', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ name: signupName, email: signupEmail, password: signupPassword }), + }); + const data = await res.json(); + if (!res.ok) { + setAuthError(data.error || 'Signup failed'); + setAuthLoading(false); + return; + } + const { setUser, setView } = useAppStore.getState(); + setUser(data.user); + setView('dashboard'); + toast.success('Account created successfully!'); + } catch { + setAuthError('Network error. Please try again.'); + } finally { + setAuthLoading(false); + } + }, [signupName, signupEmail, signupPassword, signupConfirm]); + + const fetchLogout = useCallback(() => { + fetch('/api/auth/logout', { method: 'POST' }).catch(() => {}); + toast.success('Logged out'); + window.location.href = '/'; + }, []); + + const fetchInvoices = useCallback(async (filter?: string) => { + const { setLoading, setInvoices } = useAppStore.getState(); + setLoading(true); + try { + const params = filter && filter !== 'all' ? `?filter=${filter}` : ''; + const res = await fetch(`/api/invoices${params}`); + if (res.ok) { + const data = await res.json(); + setInvoices(data.invoices); + } + } catch { + toast.error('Failed to load invoices'); + } finally { + setLoading(false); + } + }, []); + + const fetchUpload = useCallback(async () => { + if (selectedFiles.length === 0) return; + const { setUploadLoading, setUploadResults } = useAppStore.getState(); + setUploadLoading(true); + try { + const formData = new FormData(); + for (const file of selectedFiles) { + formData.append('files', file); + } + const res = await fetch('/api/invoices/upload', { + method: 'POST', + body: formData, + }); + const data = await res.json(); + if (!res.ok) { + toast.error(data.error || 'Upload failed'); + setUploadLoading(false); + return; + } + setUploadResults(data.invoices); + setSelectedFiles([]); + toast.success(`${data.invoices.length} invoice(s) processed successfully!`); + fetchInvoices(invoiceFilter); + } catch { + toast.error('Upload failed. Please try again.'); + } finally { + setUploadLoading(false); + } + }, [selectedFiles, invoiceFilter, fetchInvoices]); + + const fetchDeleteInvoice = useCallback(async (id: string) => { + if (!window.confirm('Are you sure you want to delete this invoice? This action cannot be undone.')) return; + try { + const res = await fetch('/api/invoices', { + method: 'DELETE', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ id }), + }); + if (res.ok) { + toast.success('Invoice deleted'); + setSelectedInvoices(prev => { const n = new Set(prev); n.delete(id); return n; }); + fetchInvoices(invoiceFilter); + if (expandedInvoice === id) setExpandedInvoice(null); + } else { + const data = await res.json(); + toast.error(data.error || 'Failed to delete'); + } + } catch { + toast.error('Failed to delete invoice'); + } + }, [invoiceFilter, expandedInvoice, fetchInvoices]); + + const fetchBatchDelete = useCallback(async () => { + const ids = Array.from(selectedInvoices); + if (ids.length === 0) return; + if (!window.confirm(`Delete ${ids.length} invoice(s)? This action cannot be undone.`)) return; + try { + await Promise.all(ids.map(id => + fetch('/api/invoices', { + method: 'DELETE', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ id }), + }) + )); + toast.success(`${ids.length} invoice(s) deleted`); + setSelectedInvoices(new Set()); + fetchInvoices(invoiceFilter); + } catch { + toast.error('Failed to delete some invoices'); + } + }, [selectedInvoices, invoiceFilter, fetchInvoices]); + + const toggleSelect = useCallback((id: string) => { + setSelectedInvoices(prev => { + const next = new Set(prev); + if (next.has(id)) next.delete(id); + else next.add(id); + return next; + }); + }, []); + + const toggleSelectAll = useCallback(() => { + if (selectedInvoices.size === filteredInvoices.length) { + setSelectedInvoices(new Set()); + } else { + setSelectedInvoices(new Set(filteredInvoices.map(i => i.id))); + } + }, [selectedInvoices.size, filteredInvoices]); + + const fetchChat = useCallback(async () => { + if (!chatInput.trim()) return; + const { addChatMessage, chatHistory, setChatLoading } = useAppStore.getState(); + const userMsg: ChatMessage = { role: 'user', content: chatInput.trim() }; + addChatMessage(userMsg); + const historyForApi = [...chatHistory, userMsg].map((m) => ({ role: m.role, content: m.content })); + setChatInput(''); + setChatLoading(true); + try { + const res = await fetch('/api/chat', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ message: userMsg.content, history: historyForApi.slice(0, -1) }), + }); + const data = await res.json(); + if (!res.ok) { + addChatMessage({ role: 'assistant', content: data.error || 'Something went wrong.' }); + } else { + addChatMessage({ role: 'assistant', content: data.reply }); + } + } catch { + addChatMessage({ role: 'assistant', content: 'Network error. Please try again.' }); + } finally { + setChatLoading(false); + } + }, [chatInput]); + + const exportCsv = useCallback(() => { + window.open('/api/invoices/export/csv', '_blank'); + toast.success('CSV download started'); + }, []); + + const exportJson = useCallback(() => { + const { user } = useAppStore.getState(); + if (user?.plan === 'free') { + toast.error('JSON export is available on Pro+ plans. Please upgrade.'); + return; + } + window.open('/api/invoices/export/json', '_blank'); + toast.success('JSON download started'); + }, []); + + const openEditModal = useCallback((inv: InvoiceRow) => { + setEditingInvoice(inv); + setEditForm({ + vendor: inv.vendor || '', + invNumber: inv.invNumber || '', + invDate: inv.invDate || '', + dueDate: inv.dueDate || '', + amount: String(inv.amount || ''), + vatAmount: String(inv.vatAmount || ''), + total: String(inv.total || ''), + currency: inv.currency, + status: inv.status === 'review' ? 'review' : 'done', + }); + }, []); + + const saveEdit = useCallback(async () => { + if (!editingInvoice) return; + setEditSaving(true); + try { + const res = await fetch('/api/invoices/update', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ id: editingInvoice.id, ...editForm }), + }); + if (res.ok) { + toast.success('Invoice updated'); + setEditingInvoice(null); + fetchInvoices(invoiceFilter); + } else { + const data = await res.json(); + toast.error(data.error || 'Update failed'); + } + } catch { + toast.error('Failed to update invoice'); + } finally { + setEditSaving(false); + } + }, [editingInvoice, editForm, invoiceFilter, fetchInvoices]); + + // ── Effects ── + + useEffect(() => { + fetchMe(); + }, [fetchMe]); + + useEffect(() => { + if (store.view === 'dashboard' && store.activeDashTab === 'invoices') { + fetchInvoices(invoiceFilter); + } + }, [store.view, store.activeDashTab, invoiceFilter, fetchInvoices]); + + useEffect(() => { + chatEndRef.current?.scrollIntoView({ behavior: 'smooth' }); + }, [store.chatHistory, store.chatLoading]); + + // ── Drag-and-drop handlers ── + + const handleDragOver = useCallback((e: React.DragEvent) => { + e.preventDefault(); + setDragOver(true); + }, []); + + const handleDragLeave = useCallback((e: React.DragEvent) => { + e.preventDefault(); + setDragOver(false); + }, []); + + const handleDrop = useCallback((e: React.DragEvent) => { + e.preventDefault(); + setDragOver(false); + const files = Array.from(e.dataTransfer.files).filter( + (f) => f.type === 'application/pdf' || f.type.startsWith('image/') + ); + setSelectedFiles((prev) => [...prev, ...files]); + }, []); + + const handleFileSelect = useCallback((e: React.ChangeEvent) => { + if (e.target.files) { + setSelectedFiles((prev) => [...prev, ...Array.from(e.target.files!)]); + } + }, []); + + const removeFile = useCallback((index: number) => { + setSelectedFiles((prev) => prev.filter((_, i) => i !== index)); + }, []); + + // ── Scroll helpers ── + + const scrollToFeatures = useCallback(() => { + featuresRef.current?.scrollIntoView({ behavior: 'smooth' }); + setMobileMenuOpen(false); + }, []); + + const scrollToPricing = useCallback(() => { + pricingRef.current?.scrollIntoView({ behavior: 'smooth' }); + setMobileMenuOpen(false); + }, []); + + // ── Keyboard shortcut for search (decorative hint, but functional) ── + useEffect(() => { + const handler = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === 'k') { + e.preventDefault(); + const { view } = useAppStore.getState(); + if (view === 'dashboard') { + setShowCommandPalette(true); + } + } + if ((e.ctrlKey || e.metaKey) && e.key === '/') { + e.preventDefault(); + const { view } = useAppStore.getState(); + if (view === 'dashboard') { + setShowShortcuts(true); + } + } + }; + window.addEventListener('keydown', handler); + return () => window.removeEventListener('keydown', handler); + }, []); + + useEffect(() => { + const handleScroll = () => { + setShowScrollTop(window.scrollY > 400); + }; + window.addEventListener('scroll', handleScroll, { passive: true }); + return () => window.removeEventListener('scroll', handleScroll); + }, []); + + // ── Loading screen ── + + if (store.isLoading) { + return ( +
+ +
+ ); + } + + // ────────────────────────────────────────────────────────────────────────────── + // LANDING VIEW + // ────────────────────────────────────────────────────────────────────────────── + + if (store.view === 'landing') { + return ( +
+ {/* ── Navbar ── */} +
+ + {mobileMenuOpen && ( +
+
+ + +
+ + + +
+
+
+ )} +
+ +
+ {/* ── Hero Section ── */} +
+
+
+
+
+ + Powered by advanced AI extraction +
+

+ Invoice Processing,{' '} + Reimagined +

+

+ Upload any invoice and let AI extract vendor details, amounts, dates, and line items in seconds. Export structured data to CSV, JSON, or connect via API. +

+
+ + +
+
+
+
+ + SOC 2 Compliant +
+
+
+ + {/* ── Stats Bar ── */} +
+
+
+
10K+
+
Invoices Processed
+
+
+
99.2%
+
Accuracy Rate
+
+
+
500+
+
Companies Trust Us
+
+
+
+ +
+ + {/* ── How It Works ── */} +
+
+
+

How It Works

+

Three simple steps to transform your invoices into structured data

+
+
+
+
+ 1 +
+

Upload

+

+ Drag and drop your invoice PDFs or images. We support batch uploads of multiple files at once. +

+
+
+
+ 2 +
+

Extract

+

+ Our AI automatically extracts vendor details, line items, amounts, dates, and detects duplicates. +

+
+
+
+ 3 +
+

Export

+

+ Download your data as CSV or JSON, or integrate directly with your systems using our REST API. +

+
+
+
+
+ +
+ + {/* ── Features Section ── */} +
+
+
+

Everything You Need

+

Powerful features designed to streamline your invoice processing workflow

+
+
+
+
+ +
+

Instant Extraction

+

+ Extract all invoice fields in under 3 seconds per document with near-perfect accuracy. +

+
+
+
+ +
+

Duplicate Detection

+

+ Automatically flags potential duplicate invoices based on vendor and amount matching. +

+
+
+
+ +
+

AI Chat Assistant

+

+ Ask questions about your invoices, get spending insights, and analyze vendor relationships. +

+
+
+
+ +
+

Multi-Currency

+

+ Automatically detects and processes invoices in USD, EUR, GBP, CAD, AUD, and more. +

+
+
+
+ +
+

Bulk Processing

+

+ Upload dozens of invoices at once. Our system processes them in parallel for maximum speed. +

+
+
+
+ +
+

Enterprise Security

+

+ Your data is encrypted at rest and in transit. SOC 2 compliant infrastructure. +

+
+
+
+
+ +
+ + {/* ── Testimonials ── */} +
+
+
+

Trusted by Teams Worldwide

+

See what our customers have to say

+
+
+
+ +

+ “OmniParse reduced our invoice processing time from hours to minutes. The accuracy is outstanding and the duplicate detection has saved us from overpaying vendors multiple times.” +

+
+
+ SM +
+
+
Sarah Mitchell
+
CFO, TechVentures Inc.
+
+
+
+
+ +

+ “We process over 500 invoices per month. The API integration was seamless and the structured JSON output fits perfectly into our ERP system. A game changer for our accounting team.” +

+
+
+ JK +
+
+
James Kim
+
CTO, DataFlow Systems
+
+
+
+
+ +

+ “The AI chat feature is incredible. I can ask questions like 'Which vendor had the highest spending this quarter?' and get instant answers. It's like having a financial analyst on demand.” +

+
+
+ RP +
+
+
Rachel Patel
+
VP Finance, Meridian Group
+
+
+
+
+
+
+ +
+ + {/* ── FAQ ── */} +
+
+
+

Frequently Asked Questions

+
+
+
+ + What file formats are supported? + + +
+ We support PDF files and common image formats including PNG, JPG, and JPEG. You can upload multiple files at once for batch processing. +
+
+
+ + How accurate is the extraction? + + +
+ Our AI achieves 99.2% accuracy on standard invoices. Each extraction includes a confidence score so you can review lower-confidence results. The system also flags potential duplicates automatically. +
+
+
+ + Is my data secure? + + +
+ Absolutely. All data is encrypted at rest and in transit. We use SOC 2 compliant infrastructure and your documents are never shared with third parties. You can delete your data at any time. +
+
+
+ + Can I integrate OmniParse with my existing tools? + + +
+ Yes! We provide a REST API with your unique API key. You can upload invoices, retrieve processed data, and trigger exports programmatically. Full API documentation is available in your dashboard. +
+
+
+ + What happens when I reach my plan limit? + + +
+ You will receive a notification when you are approaching your monthly limit. Once reached, you can upgrade your plan or wait for the next billing cycle. Enterprise plans have unlimited processing. +
+
+
+
+
+ +
+ + {/* ── Pricing Section ── */} +
+
+
+

Simple, Transparent Pricing

+

Choose the plan that fits your needs. Upgrade or downgrade anytime.

+
+
+ {[ + { name: 'Free', price: 0, limit: '20 invoices/mo', features: ['Basic extraction', 'CSV export', 'Email support', '1 user'] }, + { name: 'Pro', price: 129, limit: '2,000 invoices/mo', features: ['Advanced extraction', 'CSV & JSON export', 'AI Chat assistant', 'API access', 'Priority support', '5 users'], highlight: true }, + { name: 'Business', price: 29, limit: '200 invoices/mo', features: ['Standard extraction', 'CSV & JSON export', 'API access', 'Email & chat support', '3 users'] }, + { name: 'Enterprise', price: 499, limit: 'Unlimited', features: ['Custom AI models', 'All export formats', 'Dedicated AI Chat', 'Full API access', 'Dedicated support', 'Unlimited users', 'SLA guarantee'] }, + ].map((plan) => ( +
+ {plan.highlight &&
Most Popular
} +
+

{plan.name}

+
+ ${plan.price}/mo +
+
{plan.limit}
+
+
    + {plan.features.map((f) => ( +
  • + + {f} +
  • + ))} +
+ +
+ ))} +
+
+
+
+ + {/* ── Footer ── */} +
+
+
+

Product

+
    +
  • Features
  • +
  • Pricing
  • +
  • API Docs
  • +
  • Changelog
  • +
+
+
+

Company

+
    +
  • About
  • +
  • Blog
  • +
  • Careers
  • +
  • Contact
  • +
+
+
+

Resources

+
    +
  • Documentation
  • +
  • Help Center
  • +
  • Status Page
  • +
+
+
+

Legal

+
    +
  • Privacy Policy
  • +
  • Terms of Service
  • +
  • Security
  • +
+
+
+
+
+
+
+ +
+ OmniParse AI +
+

+ © {new Date().getFullYear()} OmniParse AI. All rights reserved. +

+
+
+
+ + {/* ── Scroll to Top ── */} + +
+ ); + } + + // ────────────────────────────────────────────────────────────────────────────── + // AUTH VIEW + // ────────────────────────────────────────────────────────────────────────────── + + if (store.view === 'auth') { + const pwStrength = getPasswordStrength(authMode === 'signup' ? signupPassword : ''); + return ( +
+
+ +
+
+
+ +
+

+ {authMode === 'login' ? 'Welcome back' : 'Create your account'} +

+

+ {authMode === 'login' ? 'Sign in to your OmniParse account' : 'Get started with OmniParse for free'} +

+
+ + {/* Tab Toggle */} +
+ + +
+ + {/* Error Display */} + {authError && ( +
+ + {authError} +
+ )} + + {authMode === 'login' ? ( +
{ e.preventDefault(); fetchLogin(); }} + className="space-y-4" + > +
+ +
+ + setLoginEmail(e.target.value)} + required + placeholder="you@company.com" + className="input-field input-field-glow pl-10" + /> +
+
+
+ +
+ + setLoginPassword(e.target.value)} + required + placeholder="Enter your password" + className="input-field input-field-glow pl-10" + /> +
+
+ +
+ +
+
+

+ Demo credentials: demo@omniparse.ai / demo1234 +

+
+
+ ) : ( +
{ e.preventDefault(); fetchSignup(); }} + className="space-y-4" + > +
+ +
+ + setSignupName(e.target.value)} + required + placeholder="Your full name" + className="input-field input-field-glow pl-10" + /> +
+
+
+ +
+ + setSignupEmail(e.target.value)} + required + placeholder="you@company.com" + className="input-field input-field-glow pl-10" + /> +
+
+
+ +
+ + setSignupPassword(e.target.value)} + required + minLength={6} + placeholder="At least 6 characters" + className="input-field input-field-glow pl-10" + /> +
+ {signupPassword && ( +
+
+
+
+

{pwStrength.label}

+
+ )} +
+
+ +
+ + setSignupConfirm(e.target.value)} + required + placeholder="Confirm your password" + className="input-field input-field-glow pl-10" + /> +
+
+ + + )} +
+
+
+ ); + } + + // ────────────────────────────────────────────────────────────────────────────── + // DASHBOARD VIEW + // ────────────────────────────────────────────────────────────────────────────── + + if (store.view === 'dashboard' && store.user) { + const planLimit = PLAN_LIMITS[store.user.plan] ?? PLAN_LIMITS.free; + const planLabel = PLAN_LABELS[store.user.plan] ?? store.user.plan; + const invoiceCount = store.invoices.length; + const totalAmount = store.invoices.reduce((s, i) => s + (i.total ?? 0), 0); + const dupCount = store.invoices.filter((i) => i.isDuplicate).length; + const avgConfidence = store.invoices.length > 0 + ? store.invoices.reduce((s, i) => s + (i.confidence ?? 0), 0) / store.invoices.length + : 0; + const usagePercent = planLimit === Infinity ? 0 : Math.min((invoiceCount / planLimit) * 100, 100); + + return ( +
+ {/* ── Dashboard Header ── */} +
+
+
+
+ +
+ OmniParse + + {planLabel} + +
+
+ + + + + +
+ + {showNotifications && ( + <> +
setShowNotifications(false)} /> +
+
+

Notifications

+
+
+ {notifications.map((n) => { + const NIcon = n.icon; + return ( +
+
+ +
+
+
{n.title}
+
{n.description}
+
+
+ ); + })} +
+
+ + )} +
+
+
+ {store.user.name.charAt(0).toUpperCase()} +
+ {store.user.name} +
+ + +
+
+ + {/* Mobile tab menu */} + {dashMobileMenu && ( +
+ +
+ )} +
+ + {/* ── Dashboard Tabs (desktop) ── */} +
+
+ +
+
+ + {/* ── Dashboard Content ── */} +
+
+ {/* ── Stats Overview ── */} +
+
+
+ + Total Invoices +
+
{store.invoices.length}
+
+
+
+ + Total Amount +
+
+ {formatCurrency(store.invoices.reduce((sum, inv) => sum + (inv.total ?? 0), 0))} +
+
+
+
+ + Duplicates +
+
{store.invoices.filter(i => i.isDuplicate).length}
+
+
+
+ + Avg Confidence +
+
+ {store.invoices.length > 0 + ? `${((store.invoices.reduce((sum, inv) => sum + (inv.confidence ?? 0), 0) / store.invoices.length) * 100).toFixed(1)}%` + : '--'} +
+
+
+ + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 1: UPLOAD */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'upload' && ( +
+ {/* Welcome Panel */} +
+
+
+
+ +
+
+

Welcome back, {store.user?.name?.split(' ')[0] || 'there'}!

+

Here's a quick overview of your account

+
+ + + + {store.user?.plan || 'Free'} Plan + +
+
+ + + + +
+
+
+
+

Upload Invoices

+

Drag and drop PDF or image files to extract invoice data

+
+ + {/* Usage Progress */} +
+
+ Monthly usage + + {invoiceCount} / {planLimit === Infinity ? 'Unlimited' : planLimit} + +
+
+
90 ? '!bg-red-500' : ''}`} + style={{ width: `${planLimit === Infinity ? 0 : usagePercent}%` }} + /> +
+
+ + {/* Drop Zone */} +
fileInputRef.current?.click()} + role="button" + tabIndex={0} + aria-label="Click or drag files to upload" + onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') fileInputRef.current?.click(); }} + > + + +

+ Drop your invoice files here, or click to browse +

+

+ Supports PDF, PNG, JPG, JPEG. You can upload multiple files at once. +

+
+ + {/* Selected Files List */} + {selectedFiles.length > 0 && ( +
+

{selectedFiles.length} file(s) selected

+
    + {selectedFiles.map((file, idx) => ( +
  • +
    + + {file.name} + + {(file.size / 1024).toFixed(1)} KB + +
    + +
  • + ))} +
+ +
+ )} + + {/* Upload Results */} + {store.uploadResults && store.uploadResults.length > 0 && ( +
+

+ + Results +

+
+
+ + + + + + + + + + + + {store.uploadResults.map((inv) => ( + + + + + + + + ))} + +
VendorInvoice #AmountConfidenceStatus
{inv.vendor || '--'}{inv.invNumber || '--'}{formatCurrency(inv.total, inv.currency)}{inv.confidence ? `${(inv.confidence * 100).toFixed(1)}%` : '--'} + + {inv.isDuplicate ? 'Duplicate' : 'Done'} + +
+
+
+
+ )} + + {/* Empty State */} + {!store.uploadLoading && (!store.uploadResults || store.uploadResults.length === 0) && selectedFiles.length === 0 && ( +
+ +

Upload your first invoice to get started

+
+ )} +
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 2: INVOICES */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'invoices' && ( +
+
+
+

Invoices

+

+ {filteredInvoices.length} invoice(s) found + Ctrl+K +

+
+ +
+ + {/* Search and Filter */} +
+
+ + setInvoiceSearch(e.target.value)} + placeholder="Search by vendor name..." + className="input-field input-field-glow pl-10" + /> +
+
+ {(['all', 'done', 'review', 'duplicates'] as const).map((f) => ( + + ))} +
+
+ + {/* Date Range Filter */} +
+
+ + setDateFrom(e.target.value)} + className="input-field input-field-glow" + /> +
+
+ + setDateTo(e.target.value)} + className="input-field input-field-glow" + /> +
+ {(dateFrom || dateTo) && ( +
+ +
+ )} +
+ + {/* Duplicate Alert Panel */} +{!store.isLoading && store.invoices.some(i => i.isDuplicate) && ( +
+
+
+ +
+
+

Duplicate Invoices Detected

+

+ {store.invoices.filter(i => i.isDuplicate).length} potential duplicate(s) found. Review and decide whether to keep or remove them. +

+
+ + +
+
+
+
+)} + + {/* Selection Toolbar */} + {selectedInvoices.size > 0 && ( +
+ + {selectedInvoices.size} invoice(s) selected + +
+ + +
+
+ )} + + {/* Loading Skeletons */} + {store.isLoading && ( +
+ {Array.from({ length: 5 }).map((_, i) => ( +
+ ))} +
+ )} + + {/* Invoice Table */} + {!store.isLoading && filteredInvoices.length > 0 && ( +
+
+ + + + + + + + + + + + + + + + {filteredInvoices.map((inv) => ( + setExpandedInvoice(expandedInvoice === inv.id ? null : inv.id)} + onDelete={() => fetchDeleteInvoice(inv.id)} + isSelected={selectedInvoices.has(inv.id)} + onSelect={() => toggleSelect(inv.id)} + onEdit={() => openEditModal(inv)} + /> + ))} + +
+ 0} + onChange={toggleSelectAll} + className="invoice-checkbox" + aria-label="Select all invoices" + /> + toggleSort('vendor')} + > +
+ Vendor + {sortField === 'vendor' ? ( + {sortDir === 'asc' ? '↑' : '↓'} + ) : ( + ↕ + )} +
+
toggleSort('invNumber')} + > +
+ Invoice # + {sortField === 'invNumber' ? ( + {sortDir === 'asc' ? '↑' : '↓'} + ) : ( + ↕ + )} +
+
toggleSort('invDate')} + > +
+ Date + {sortField === 'invDate' ? ( + {sortDir === 'asc' ? '↑' : '↓'} + ) : ( + ↕ + )} +
+
toggleSort('amount')} + > +
+ Amount + {sortField === 'amount' ? ( + {sortDir === 'asc' ? '↑' : '↓'} + ) : ( + ↕ + )} +
+
toggleSort('total')} + > +
+ Total + {sortField === 'total' ? ( + {sortDir === 'asc' ? '↑' : '↓'} + ) : ( + ↕ + )} +
+
toggleSort('status')} + > +
+ Status + {sortField === 'status' ? ( + {sortDir === 'asc' ? '↑' : '↓'} + ) : ( + ↕ + )} +
+
toggleSort('confidence')} + > +
+ Confidence + {sortField === 'confidence' ? ( + {sortDir === 'asc' ? '↑' : '↓'} + ) : ( + ↕ + )} +
+
Actions
+
+
+ )} + + {/* Empty State */} + {!store.isLoading && filteredInvoices.length === 0 && ( +
+ +

No invoices found

+

Upload your first invoice to get started

+
+ )} +
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 3: ANALYTICS */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'analytics' && ( + + )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 4: AI CHAT */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'chat' && ( +
+
+
+

AI Chat

+

Ask questions about your invoices

+
+ {store.chatHistory.length > 0 && ( + + )} +
+ + {/* Plan gate */} + {store.user.plan === 'free' && ( +
+ +

Upgrade to Use AI Chat

+

+ AI Chat is available on Pro and Enterprise plans. Get instant insights about your invoices, spending analysis, and more. +

+ +
+ )} + + {/* Chat Messages */} + {store.chatHistory.length === 0 && store.user.plan !== 'free' && ( +
+ +

Start a conversation

+

+ Ask about your invoices, get spending insights, or request analysis. +

+
+ {['Summarize my invoices', 'Who is my top vendor?', 'Show spending trends'].map((suggestion) => ( + + ))} +
+
+ )} + +
+ {store.chatHistory.map((msg, idx) => ( +
+
+
+ {msg.role === 'assistant' && ( +
+ +
+ )} +
+

{msg.content}

+
+
+
+
+ ))} + {store.chatLoading && ( +
+
+ + + +
+
+ )} +
+
+ + {/* Chat Input */} + {store.user.plan !== 'free' && ( +
+ setChatInput(e.target.value)} + onKeyDown={(e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); fetchChat(); } }} + placeholder="Ask about your invoices..." + disabled={store.chatLoading} + className="input-field input-field-glow rounded-xl disabled:opacity-50" + /> +
+ + Send +
+
+ )} +
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 5: EXPORT */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'export' && ( +
+
+

Export Data

+

Download your invoice data in your preferred format

+
+ +
+ {/* CSV Export */} +
+
+
+ +
+
+

CSV Export

+

Comma-separated values

+
+
+

+ Download all your invoices as a CSV file, compatible with Excel, Google Sheets, and any spreadsheet application. Includes all fields: vendor, amounts, dates, status, and confidence scores. +

+ +
+ + {/* JSON Export */} +
+
+
+ +
+
+
+

JSON Export

+ {store.user?.plan === 'free' && ( + + Pro+ + + )} +
+

Structured JSON data with raw extraction

+
+
+

+ Download structured JSON data including raw extraction results, line items, and bank details. Perfect for API integrations and programmatic processing. +

+ +
+ {/* XLSX Export */} +
+
+
+ +
+
+

Excel Export

+

XLSX spreadsheet format

+
+
+

+ Download a professionally formatted Excel spreadsheet with styled headers, currency formatting, color-coded statuses, and a summary total row. Compatible with Microsoft Excel, Google Sheets, and LibreOffice Calc. +

+ +
+
+ + {/* Empty state hint */} + {invoiceCount === 0 && ( +
+ +

No invoices to export yet. Upload some invoices first.

+
+ )} +
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 6: UPGRADE */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'upgrade' && ( +
+
+

Upgrade Your Plan

+

You are currently on the {planLabel} plan

+
+ +
+ {[ + { name: 'Free', price: 0, limit: '20 invoices/mo', features: ['Basic extraction', 'CSV export', 'Email support'] }, + { name: 'Pro', price: 129, limit: '2,000 invoices/mo', features: ['Advanced extraction', 'CSV & JSON export', 'AI Chat assistant', 'API access', 'Priority support'] }, + { name: 'Business', price: 29, limit: '200 invoices/mo', features: ['Standard extraction', 'CSV & JSON export', 'API access', 'Email & chat support'] }, + { name: 'Enterprise', price: 499, limit: 'Unlimited', features: ['Custom AI models', 'All export formats', 'Dedicated AI Chat', 'Full API access', 'Dedicated support', 'SLA guarantee'] }, + ].map((plan) => { + const isCurrent = plan.name.toLowerCase() === store.user.plan; + return ( +
+ {plan.name === 'Pro' &&
Most Popular
} +
+
+

{plan.name}

+ {isCurrent && ( + + Current + + )} +
+
+ ${plan.price}/mo +
+
{plan.limit}
+
+
    + {plan.features.map((f) => ( +
  • + + {f} +
  • + ))} +
+ +
+ ); + })} +
+
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 7: API ACCESS */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'api' && ( +
+
+

API Access

+

Use your API key to integrate OmniParse into your workflow

+
+ + {/* API Key Display */} +
+

Your API Key

+
+
+ {showApiKey + ? (store.user.apiKey || 'Not available') + : (store.user.apiKey ? store.user.apiKey.slice(0, 10) + '...' + store.user.apiKey.slice(-4) : 'Not available') + } +
+
+ + {showApiKey ? 'Hide' : 'Show'} +
+
+ + Copy +
+
+
+ + {/* cURL Example */} +
+

+ + Quick Start Example +

+
+
{`curl -X POST /api/invoices/upload \\
+  -H "Cookie: op_session=YOUR_SESSION" \\
+  -F "files=@invoice.pdf"`}
+
+
+ + {/* Endpoint Documentation */} +
+

Available Endpoints

+
+ {[ + { method: 'GET', path: '/api/auth/me', desc: 'Get current user info' }, + { method: 'POST', path: '/api/invoices/upload', desc: 'Upload and process invoice files' }, + { method: 'GET', path: '/api/invoices', desc: 'List all invoices with optional filters' }, + { method: 'DELETE', path: '/api/invoices', desc: 'Delete an invoice by ID' }, + { method: 'GET', path: '/api/invoices/export/csv', desc: 'Export all invoices as CSV' }, + { method: 'GET', path: '/api/invoices/export/json', desc: 'Export all invoices as JSON (Pro+)' }, + { method: 'POST', path: '/api/chat', desc: 'Send a message to the AI assistant (Pro+)' }, + ].map((ep) => ( +
+ + {ep.method} + +
+
{ep.path}
+
{ep.desc}
+
+
+ ))} +
+
+
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 8: PROFILE */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'profile' && ( +
+
+

Profile

+

Manage your account settings

+
+ + {/* User Info Grid */} +
+

Account Information

+
+
+
Email
+
+ + {store.user.email} +
+
+
+
Name
+
+ + {store.user.name} +
+
+
+
Plan
+
+ + {planLabel} +
+
+
+
Member Since
+
+ + {new Date(store.user.createdAt).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })} +
+
+
+
API Key
+
+ + {store.user.apiKey ? store.user.apiKey.slice(0, 20) + '...' : 'Not available'} + {store.user.apiKey && ( +
+ + Copy +
+ )} +
+
+
+
+ + {/* Change Password */} +
+

Change Password

+
{ + e.preventDefault(); + if (!profileCurrentPw || !profileNewPw || !profileConfirmPw) { + toast.error('Please fill in all password fields'); + return; + } + setProfilePwLoading(true); + try { + const res = await fetch('/api/auth/password', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + currentPassword: profileCurrentPw, + newPassword: profileNewPw, + confirmPassword: profileConfirmPw, + }), + }); + const data = await res.json(); + if (!res.ok) { + toast.error(data.error || 'Failed to update password'); + return; + } + toast.success('Password updated successfully. Please log in again.'); + setProfileCurrentPw(''); + setProfileNewPw(''); + setProfileConfirmPw(''); + setTimeout(() => { fetchLogout(); }, 1500); + } catch { + toast.error('Network error. Please try again.'); + } finally { + setProfilePwLoading(false); + } + }} + className="space-y-4" + > +
+ + setProfileCurrentPw(e.target.value)} + placeholder="Enter current password" + className="input-field input-field-glow" + /> +
+
+ + setProfileNewPw(e.target.value)} + placeholder="Enter new password" + className="input-field input-field-glow" + /> + {profileNewPw && (() => { + const strength = getPasswordStrength(profileNewPw); + return ( +
+
+
+
+

{strength.label}

+
+ ); + })()} +
+
+ + setProfileConfirmPw(e.target.value)} + placeholder="Confirm new password" + className="input-field input-field-glow" + /> +
+ + +
+ + {/* Danger Zone */} +
+

Danger Zone

+

+ Permanently delete your account and all associated data. This action cannot be undone. +

+ +
+
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 10: SETTINGS */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'settings' && ( +
+
+

Settings

+

Customize your dashboard experience

+
+ +
+ {/* Appearance */} +
+

+ + Appearance +

+
+
+
+
Theme
+
Switch between light and dark mode
+
+ +
+
+
+
Compact Table View
+
Reduce row height in invoice tables
+
+ +
+
+
+ + {/* Regional */} +
+

+ + Regional +

+
+
+ +
+ {(['MM/DD/YYYY', 'DD/MM/YYYY', 'YYYY-MM-DD'] as const).map((fmt) => ( + + ))} +
+
+
+ + +
+
+
+ + {/* Notifications & Keyboard */} +
+

+ + Notifications & Shortcuts +

+
+
+ Global Search + Ctrl+K +
+
+ Keyboard Shortcuts + Ctrl+/ +
+
+ Go to Invoices + Ctrl+K +
+
+
+ + {/* Save Button */} +
+ +
+
+
+ )} + + {/* ═══════════════════════════════════════════════════════════════════════ */} + {/* TAB 9: ACTIVITY */} + {/* ═══════════════════════════════════════════════════════════════════════ */} + {store.activeDashTab === 'activity' && ( +
+
+

Activity

+

Recent actions and events

+
+
+ {activityLoading ? ( +
+ {Array.from({ length: 3 }).map((_, i) => ( +
+
+
+
+
+
+
+ ))} +
+ ) : activityLogs.length > 0 ? ( +
+ {/* Vertical line */} +
+
+ {activityLogs.map((log) => { + const iconMap: Record = { + login: LogIn, + upload: Upload, + delete: Trash2, + export: Download, + edit: Pencil, + signup: UserPlus, + password_change: Lock, + }; + const colorMap: Record = { + login: 'text-amber-500', + upload: 'text-teal-500', + delete: 'text-red-400', + export: 'text-amber-500', + edit: 'text-blue-400', + signup: 'text-green-400', + password_change: 'text-amber-500', + }; + const ItemIcon = iconMap[log.type] || Clock; + const itemColor = colorMap[log.type] || 'text-muted-foreground'; + return ( +
+
+ +
+
+
+

{log.title}

+ {relativeTime(log.createdAt)} +
+

{log.description}

+
+
+ ); + })} +
+
+ ) : ( +
+ +

No activity yet. Actions will appear here as you use the app.

+
+ )} +
+
+ )} +
+
+ + {showCommandPalette && ( +
setShowCommandPalette(false)}> +
e.stopPropagation()}> +
+ + setCommandSearch(e.target.value)} + placeholder="Search invoices, navigate tabs..." + onKeyDown={e => { if (e.key === 'Escape') setShowCommandPalette(false); }} + /> + ESC +
+
+
Quick Actions
+ {DASH_TABS.filter(t => !commandSearch || t.label.toLowerCase().includes(commandSearch.toLowerCase())).map(tab => { + const Icon = tab.icon; + return ( + + ); + })} + {commandSearch && ( + <> +
Invoice Results
+ {store.invoices + .filter(inv => !commandSearch || inv.vendor?.toLowerCase().includes(commandSearch.toLowerCase()) || inv.invNumber?.toLowerCase().includes(commandSearch.toLowerCase())) + .slice(0, 5) + .map(inv => ( + + )) + } + {store.invoices.filter(inv => inv.vendor?.toLowerCase().includes(commandSearch.toLowerCase()) || inv.invNumber?.toLowerCase().includes(commandSearch.toLowerCase())).length === 0 && ( +
No matching invoices
+ )} + + )} +
+
+
+ )} + +
+
+
+
+ +
+ OmniParse AI +
+
+ Privacy + Terms + Support +
+
+
+ + {showShortcuts && ( +
setShowShortcuts(false)}> +
e.stopPropagation()}> +
+

Keyboard Shortcuts

+ +
+
+ {[ + { keys: ['Ctrl', 'K'], desc: 'Go to Invoices' }, + { keys: ['Ctrl', '/'], desc: 'Show shortcuts' }, + { keys: ['Enter'], desc: 'Send chat message' }, + ].map((s) => ( +
+ {s.desc} +
+ {s.keys.map((k, i) => ( + + {k} + {i < s.keys.length - 1 && +} + + ))} +
+
+ ))} +
+
+
+ )} + + {editingInvoice && ( +
setEditingInvoice(null)}> +
e.stopPropagation()}> +
+

Edit Invoice

+ +
+
+ {[ + { key: 'vendor', label: 'Vendor' }, + { key: 'invNumber', label: 'Invoice Number' }, + { key: 'invDate', label: 'Invoice Date' }, + { key: 'dueDate', label: 'Due Date' }, + { key: 'amount', label: 'Amount' }, + { key: 'vatAmount', label: 'VAT Amount' }, + { key: 'total', label: 'Total' }, + { key: 'currency', label: 'Currency' }, + ].map(({ key, label }) => ( +
+ + setEditForm(prev => ({ ...prev, [key]: e.target.value }))} + className="input-field input-field-glow" + /> +
+ ))} +
+ +
+ {['done', 'review'].map((s) => ( + + ))} +
+
+
+
+ + +
+
+
+ )} +
+ ); + } + return null; +} + +// ────────────────────────────────────────────────────────────────────────────── +// ─── Analytics Tab Component ──────────────────────────────────────────────────── + +const CHART_COLORS = { + amber: '#F59E0B', + teal: '#14B8A6', + red: '#EF4444', + green: '#22C55E', + amberLight: 'rgba(245, 158, 11, 0.15)', +}; + +function AnalyticsTab({ invoices }: { invoices: InvoiceRow[] }) { + // ── Computed analytics data ── + const monthlyData = useMemo(() => { + const map = new Map(); + invoices.forEach((inv) => { + const dateStr = inv.invDate || inv.createdAt; + if (!dateStr) return; + const monthKey = dateStr.substring(0, 7); // YYYY-MM + map.set(monthKey, (map.get(monthKey) || 0) + (inv.total ?? 0)); + }); + return Array.from(map.entries()) + .sort(([a], [b]) => a.localeCompare(b)) + .map(([month, total]) => { + const [y, m] = month.split('-'); + const label = new Date(Number(y), Number(m) - 1).toLocaleString('en-US', { + month: 'short', year: '2-digit', + }); + return { month: label, total: Math.round(total * 100) / 100 }; + }); + }, [invoices]); + + const vendorData = useMemo(() => { + const map = new Map(); + invoices.forEach((inv) => { + const vendor = inv.vendor || 'Unknown'; + map.set(vendor, (map.get(vendor) || 0) + (inv.total ?? 0)); + }); + return Array.from(map.entries()) + .sort((a, b) => b[1] - a[1]) + .slice(0, 8) + .map(([name, total]) => ({ name: name.length > 18 ? name.slice(0, 16) + '…' : name, total: Math.round(total * 100) / 100 })); + }, [invoices]); + + const statusData = useMemo(() => { + const counts = { Done: 0, Review: 0, Duplicate: 0 }; + invoices.forEach((inv) => { + if (inv.status === 'done') counts.Done++; + else if (inv.status === 'review') counts.Review++; + else if (inv.status === 'duplicate' || inv.isDuplicate) counts.Duplicate++; + }); + return [ + { name: 'Done', value: counts.Done, color: CHART_COLORS.teal }, + { name: 'Review', value: counts.Review, color: CHART_COLORS.amber }, + { name: 'Duplicate', value: counts.Duplicate, color: CHART_COLORS.red }, + ].filter((d) => d.value > 0); + }, [invoices]); + + const currencyData = useMemo(() => { + const map = new Map(); + invoices.forEach((inv) => map.set(inv.currency, (map.get(inv.currency) || 0) + 1)); + const entries = Array.from(map.entries()).sort((a, b) => b[1] - a[1]); + const maxCount = entries.length > 0 ? entries[0][1] : 1; + return entries.map(([currency, count]) => ({ currency, count, pct: Math.round((count / maxCount) * 100) })); + }, [invoices]); + + const quickStats = useMemo(() => { + const totals = invoices.map((inv) => inv.total ?? 0).filter((v) => v > 0); + const vendors = invoices.filter((inv) => inv.vendor); + const vendorCounts = new Map(); + vendors.forEach((inv) => { + const v = inv.vendor as string; + vendorCounts.set(v, (vendorCounts.get(v) || 0) + 1); + }); + let mostActive = '--'; + let maxCount = 0; + vendorCounts.forEach((count, name) => { + if (count > maxCount) { mostActive = name; maxCount = count; } + }); + return { + highest: totals.length > 0 ? Math.max(...totals) : null, + lowest: totals.length > 0 ? Math.min(...totals) : null, + mostActiveVendor: mostActive, + average: totals.length > 0 ? totals.reduce((a, b) => a + b, 0) / totals.length : null, + }; + }, [invoices]); + + const hasData = invoices.length > 0; + + return ( +
+ {/* Section Header */} +
+

Analytics

+

Visual insights into your invoice data

+
+ + {!hasData ? ( +
+ +

No invoice data yet

+

Upload invoices to see analytics here

+
+ ) : ( + <> + {/* ── Quick Stats Summary ── */} +
+
+
+ + Highest Invoice +
+
+ {quickStats.highest !== null ? formatCurrency(quickStats.highest) : '--'} +
+
+
+
+ + Lowest Invoice +
+
+ {quickStats.lowest !== null ? formatCurrency(quickStats.lowest) : '--'} +
+
+
+
+ + Most Active Vendor +
+
+ {quickStats.mostActiveVendor} +
+
+
+
+ + Average Amount +
+
+ {quickStats.average !== null ? formatCurrency(quickStats.average) : '--'} +
+
+
+ + {/* ── Charts Grid ── */} +
+ {/* a) Monthly Spending Trend */} +
+

Monthly Spending Trend

+ {monthlyData.length === 0 ? ( +
+ No date data available +
+ ) : ( + + + + + + + + + + + `$${(v / 1000).toFixed(v >= 1000 ? 1 : 0)}k`} /> + [formatCurrency(value), 'Total']} + /> + + + + )} +
+ + {/* b) Vendor Spending Breakdown */} +
+

Top Vendors by Spending

+ {vendorData.length === 0 ? ( +
+ No vendor data available +
+ ) : ( + + + + `$${(v / 1000).toFixed(v >= 1000 ? 1 : 0)}k`} /> + + [formatCurrency(value), 'Total']} + /> + + + + )} +
+
+ +
+ {/* c) Status Distribution */} +
+

Status Distribution

+ {statusData.length === 0 ? ( +
+ No status data available +
+ ) : ( +
+
+ + + + {statusData.map((entry, idx) => ( + + ))} + + [`${value} invoices`, 'Count']} + /> + + +
+
+ {statusData.map((entry) => ( +
+ +
+ {entry.name} + {entry.value} +
+
+ ))} +
+
+ )} +
+ + {/* d) Currency Distribution */} +
+

Currency Distribution

+ {currencyData.length === 0 ? ( +
+ No currency data available +
+ ) : ( +
+ {currencyData.map(({ currency, count, pct }) => ( +
+ {currency} +
+
+
+ {count} +
+ ))} +
+ )} +
+
+ + )} +
+ ); +} + +// Invoice Table Row Component (with expandable detail panel) +// ────────────────────────────────────────────────────────────────────────────── + +function InvoiceTableBody({ + invoice, + isExpanded, + onToggle, + onDelete, + isSelected, + onSelect, + onEdit, +}: { + invoice: InvoiceRow; + isExpanded: boolean; + onToggle: () => void; + onDelete: () => void; + isSelected: boolean; + onSelect: () => void; + onEdit?: () => void; +}) { + const statusBadgeClass = invoice.isDuplicate ? 'badge-amber-enhanced' : invoice.status === 'review' ? 'badge-amber-enhanced' : 'badge-teal-enhanced'; + const statusLabel = invoice.isDuplicate ? 'Duplicate' : invoice.status === 'review' ? 'Review' : 'Done'; + + return ( + <> + { if (e.key === 'Enter' || e.key === ' ') onToggle(); }} + aria-expanded={isExpanded} + > + + { e.stopPropagation(); onSelect(); }} + onClick={(e) => e.stopPropagation()} + className="invoice-checkbox" + aria-label={`Select invoice ${invoice.vendor || invoice.invNumber}`} + /> + + +
+ {isExpanded ? : } + {invoice.vendor || '--'} +
+ + {invoice.invNumber || '--'} + {invoice.invDate || '--'} + {formatCurrency(invoice.amount, invoice.currency)} + {formatCurrency(invoice.total, invoice.currency)} + + + + {statusLabel} + + + + {invoice.confidence ? `${(invoice.confidence * 100).toFixed(1)}%` : '--'} + + +
+
+ + Edit +
+
+ + Delete +
+
+ + + {isExpanded && ( + + +
+

Invoice Details

+
+
+
Filename
+
{invoice.filename || '--'}
+
+
+
Due Date
+
{invoice.dueDate || '--'}
+
+
+
VAT Amount
+
{formatCurrency(invoice.vatAmount, invoice.currency)}
+
+
+
Created
+
{new Date(invoice.createdAt).toLocaleDateString()}
+
+
+

Raw JSON

+
+
{JSON.stringify({
+                  vendor: invoice.vendor,
+                  invNumber: invoice.invNumber,
+                  invDate: invoice.invDate,
+                  dueDate: invoice.dueDate,
+                  amount: invoice.amount,
+                  vatAmount: invoice.vatAmount,
+                  total: invoice.total,
+                  currency: invoice.currency,
+                  confidence: invoice.confidence,
+                  status: invoice.status,
+                  isDuplicate: invoice.isDuplicate,
+                  filename: invoice.filename,
+                }, null, 2)}
+
+
+ + + )} + + ); +} \ No newline at end of file diff --git a/omniparse-hf-space (1)/src/components/ui/accordion.tsx b/omniparse-hf-space (1)/src/components/ui/accordion.tsx new file mode 100644 index 0000000000000000000000000000000000000000..4a8cca46b9c10394f5710a35892b36407ee70fc4 --- /dev/null +++ b/omniparse-hf-space (1)/src/components/ui/accordion.tsx @@ -0,0 +1,66 @@ +"use client" + +import * as React from "react" +import * as AccordionPrimitive from "@radix-ui/react-accordion" +import { ChevronDownIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Accordion({ + ...props +}: React.ComponentProps) { + return +} + +function AccordionItem({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AccordionTrigger({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + svg]:rotate-180", + className + )} + {...props} + > + {children} + + + + ) +} + +function AccordionContent({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + +
{children}
+
+ ) +} + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/omniparse-hf-space (1)/src/components/ui/alert-dialog.tsx b/omniparse-hf-space (1)/src/components/ui/alert-dialog.tsx new file mode 100644 index 0000000000000000000000000000000000000000..0863e40d92fe36ed1dd34d3a555f4947eff03af4 --- /dev/null +++ b/omniparse-hf-space (1)/src/components/ui/alert-dialog.tsx @@ -0,0 +1,157 @@ +"use client" + +import * as React from "react" +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" + +import { cn } from "@/lib/utils" +import { buttonVariants } from "@/components/ui/button" + +function AlertDialog({ + ...props +}: React.ComponentProps) { + return +} + +function AlertDialogTrigger({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogPortal({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogContent({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + + ) +} + +function AlertDialogHeader({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogFooter({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogAction({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogCancel({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + AlertDialog, + AlertDialogPortal, + AlertDialogOverlay, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogFooter, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogAction, + AlertDialogCancel, +} diff --git a/omniparse-hf-space (1)/src/components/ui/alert.tsx b/omniparse-hf-space (1)/src/components/ui/alert.tsx new file mode 100644 index 0000000000000000000000000000000000000000..14213546e5ac051dd33c8359f261f9f76051d66f --- /dev/null +++ b/omniparse-hf-space (1)/src/components/ui/alert.tsx @@ -0,0 +1,66 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const alertVariants = cva( + "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current", + { + variants: { + variant: { + default: "bg-card text-card-foreground", + destructive: + "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Alert({ + className, + variant, + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ) +} + +function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDescription({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +export { Alert, AlertTitle, AlertDescription } diff --git a/omniparse-hf-space (1)/src/components/ui/aspect-ratio.tsx b/omniparse-hf-space (1)/src/components/ui/aspect-ratio.tsx new file mode 100644 index 0000000000000000000000000000000000000000..3df3fd02a6a30b60b6e1474664065b0d3437bf48 --- /dev/null +++ b/omniparse-hf-space (1)/src/components/ui/aspect-ratio.tsx @@ -0,0 +1,11 @@ +"use client" + +import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio" + +function AspectRatio({ + ...props +}: React.ComponentProps) { + return +} + +export { AspectRatio } diff --git a/omniparse-hf-space (1)/src/components/ui/avatar.tsx b/omniparse-hf-space (1)/src/components/ui/avatar.tsx new file mode 100644 index 0000000000000000000000000000000000000000..71e428b4ca6154811e8f569d5fdd971ead095996 --- /dev/null +++ b/omniparse-hf-space (1)/src/components/ui/avatar.tsx @@ -0,0 +1,53 @@ +"use client" + +import * as React from "react" +import * as AvatarPrimitive from "@radix-ui/react-avatar" + +import { cn } from "@/lib/utils" + +function Avatar({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AvatarImage({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AvatarFallback({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { Avatar, AvatarImage, AvatarFallback } diff --git a/omniparse-hf-space (1)/src/components/ui/badge.tsx b/omniparse-hf-space (1)/src/components/ui/badge.tsx new file mode 100644 index 0000000000000000000000000000000000000000..02054139a9a72f2ce2c4defd14861b4129312950 --- /dev/null +++ b/omniparse-hf-space (1)/src/components/ui/badge.tsx @@ -0,0 +1,46 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const badgeVariants = cva( + "inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", + { + variants: { + variant: { + default: + "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90", + secondary: + "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", + destructive: + "border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", + outline: + "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Badge({ + className, + variant, + asChild = false, + ...props +}: React.ComponentProps<"span"> & + VariantProps & { asChild?: boolean }) { + const Comp = asChild ? Slot : "span" + + return ( + + ) +} + +export { Badge, badgeVariants } diff --git a/omniparse-hf-space (1)/src/components/ui/breadcrumb.tsx b/omniparse-hf-space (1)/src/components/ui/breadcrumb.tsx new file mode 100644 index 0000000000000000000000000000000000000000..eb88f32122082ae2dac61dd033939459215347f4 --- /dev/null +++ b/omniparse-hf-space (1)/src/components/ui/breadcrumb.tsx @@ -0,0 +1,109 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { ChevronRight, MoreHorizontal } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Breadcrumb({ ...props }: React.ComponentProps<"nav">) { + return