Initial Falah Mobile rebuild — all 7 blocks complete

- Auth system (login/register/profile)
- Nur AI chat with persona system
- Souq marketplace with FLH economy
- Forum community with Shariah moderation
- Wallet & FLH top-up
- Premium/Pro tier upgrade with Polar.sh
- Halal Monitor with map & bookmarks
- Home dashboard with daily verse & streaks
- Health endpoints

Next.js 16.2.7, Prisma v5 SQLite, JWT auth, Tailwind CSS v4
This commit is contained in:
root
2026-06-15 09:28:22 +02:00
parent ab8a2053e1
commit 5483dd291e
56 changed files with 7619 additions and 100 deletions
+170 -58
View File
@@ -1,65 +1,177 @@
import Image from "next/image";
"use client";
import { useState, useEffect } from "react";
import { useAuth } from "@/lib/AuthContext";
import Link from "next/link";
import { useRouter } from "next/navigation";
import {
Bot, ShoppingBag, MessageCircle, Wallet,
Flame, Sparkles, Star, ChevronRight,
BookOpen, MapPin, Crown, Zap,
} from "lucide-react";
import { DAILY_VERSE, generateAIResponse } from "@/lib/ai";
export default function HomePage() {
const { user, token, loading } = useAuth();
const router = useRouter();
const [streak, setStreak] = useState(0);
const [verse, setVerse] = useState(DAILY_VERSE[Math.floor(Math.random() * DAILY_VERSE.length)]);
useEffect(() => {
if (!loading && !token) router.push("/login");
}, [loading, token, router]);
if (loading) return <LoadingScreen />;
if (!user) return null;
const isPremium = user.isPremium || user.isPro;
const isPro = user.isPro;
export default function Home() {
return (
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
className="dark:invert"
src="/next.svg"
alt="Next.js logo"
width={100}
height={20}
priority
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the page.tsx file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Templates
</a>{" "}
or the{" "}
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Learning
</a>{" "}
center.
</p>
<div className="min-h-dvh bg-[#0a0a0f] pb-24">
{/* Header */}
<div className="px-4 pt-6 pb-4">
<div className="flex items-center justify-between mb-1">
<div>
<h1 className="text-xl font-bold text-white">
Assalamualaikum, {user.name.split(" ")[0]}
</h1>
<p className="text-xs text-gray-500 mt-0.5">
{new Date().toLocaleDateString("en-MY", { weekday: "long", day: "numeric", month: "long", year: "numeric" })}
</p>
</div>
{/* Streak */}
{streak > 0 && (
<div className="flex items-center gap-1.5 bg-gradient-to-r from-orange-900/40 to-orange-800/20 border border-orange-700/30 rounded-xl px-3 py-2">
<Flame size={16} className="text-orange-400 flame" />
<span className="text-sm font-bold text-orange-300">{streak}</span>
<span className="text-[10px] text-orange-400/70">day</span>
</div>
)}
</div>
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
<a
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert"
src="/vercel.svg"
alt="Vercel logomark"
width={16}
height={16}
/>
Deploy Now
</a>
<a
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
{/* Premium banner */}
{!isPremium && (
<Link href="/upgrade"
className="mt-3 flex items-center justify-between glass-gold rounded-2xl px-4 py-3 active:opacity-80 transition">
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-[#D4AF37]/20 flex items-center justify-center">
<Sparkles size={16} className="text-[#D4AF37]" />
</div>
<div>
<p className="text-sm font-semibold text-[#D4AF37]">Go Premium</p>
<p className="text-[11px] text-gray-500">Unlock unlimited AI & more</p>
</div>
</div>
<ChevronRight size={16} className="text-[#D4AF37]" />
</Link>
)}
{/* Pro badge */}
{isPro && (
<div className="mt-3 flex items-center gap-2 bg-purple-900/20 border border-purple-500/30 rounded-2xl px-4 py-2.5">
<Crown size={16} className="text-purple-400" />
<span className="text-sm font-medium text-purple-300">Pro Member Unlimited Everything</span>
</div>
)}
</div>
{/* Daily Verse */}
<div className="mx-4 mb-5 bg-gradient-to-br from-emerald-900/20 to-[#111118] border border-emerald-800/30 rounded-2xl p-4">
<div className="flex items-center gap-2 mb-2">
<BookOpen size={14} className="text-emerald-400" />
<span className="text-xs font-medium text-emerald-400">Daily Verse</span>
</div>
</main>
<p className="text-lg text-center font-arabic text-emerald-100 mb-2" dir="rtl">
{verse.arabic}
</p>
<p className="text-sm text-gray-400 text-center italic">
&ldquo;{verse.translation}&rdquo;
</p>
<p className="text-[10px] text-gray-600 text-center mt-1"> {verse.reference}</p>
</div>
{/* Quick Actions */}
<div className="px-4 mb-5">
<h2 className="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3">Quick Actions</h2>
<div className="grid grid-cols-4 gap-3">
<QuickAction href="/nur" icon={Bot} label="Nur AI" color="bg-amber-900/30 text-amber-300" />
<QuickAction href="/souq" icon={ShoppingBag} label="Souq" color="bg-[#D4AF37]/15 text-[#D4AF37]" />
<QuickAction href="/halal-monitor" icon={MapPin} label="Halal" color="bg-emerald-900/30 text-emerald-300" />
<QuickAction href="/wallet" icon={Wallet} label="Wallet" color="bg-blue-900/30 text-blue-300" />
</div>
</div>
{/* Stats Row */}
<div className="mx-4 mb-5">
<div className="grid grid-cols-3 gap-3">
<StatCard label="FLH Balance" value={user.flhBalance.toLocaleString()} icon={Zap} color="text-[#D4AF37]" />
<StatCard label="AI Today" value={`${user.dailyMsgCount}/10`} icon={Bot} color="text-amber-400" />
<StatCard label="Tier" value={isPro ? "Pro" : isPremium ? "Premium" : "Free"} icon={Crown}
color={isPro ? "text-purple-400" : isPremium ? "text-[#D4AF37]" : "text-gray-500"} />
</div>
</div>
{/* Activity Feed */}
<div className="px-4">
<div className="flex items-center justify-between mb-3">
<h2 className="text-xs font-semibold text-gray-500 uppercase tracking-wider">Activity</h2>
<Link href="/forum" className="text-[11px] text-[#D4AF37]">View all</Link>
</div>
<div className="bg-[#111118] border border-gray-800/60 rounded-2xl p-5 text-center">
<MessageCircle size={24} className="mx-auto text-gray-700 mb-2" />
<p className="text-sm text-gray-500">No recent activity</p>
<p className="text-xs text-gray-700 mt-1">Start a conversation with Nur AI</p>
</div>
</div>
{/* Premium upsell at bottom for free users */}
{!isPremium && (
<div className="mx-4 mt-5 bg-gradient-to-r from-[#D4AF37]/10 to-purple-900/10 border border-[#D4AF37]/20 rounded-2xl p-4">
<div className="flex items-start gap-3">
<div className="w-10 h-10 rounded-2xl bg-[#D4AF37]/15 flex items-center justify-center shrink-0">
<Star size={20} className="text-[#D4AF37]" />
</div>
<div className="flex-1">
<h3 className="font-semibold text-white text-sm">Unlock Your Full Potential</h3>
<p className="text-xs text-gray-500 mt-1">Premium gives you unlimited AI, halal monitor, and marketplace access.</p>
<Link href="/upgrade"
className="inline-block mt-3 text-xs font-semibold text-[#D4AF37] border border-[#D4AF37]/40 rounded-full px-4 py-1.5 active:bg-[#D4AF37]/10 transition">
See Plans
</Link>
</div>
</div>
</div>
)}
</div>
);
}
function QuickAction({ href, icon: Icon, label, color }: { href: string; icon: any; label: string; color: string }) {
return (
<Link href={href} className="flex flex-col items-center gap-1.5 active:scale-95 transition">
<div className={`w-14 h-14 rounded-2xl flex items-center justify-center ${color} bg-opacity-20`}>
<Icon size={22} />
</div>
<span className="text-[10px] text-gray-500 font-medium">{label}</span>
</Link>
);
}
function StatCard({ label, value, icon: Icon, color }: { label: string; value: string; icon: any; color: string }) {
return (
<div className="bg-[#111118] border border-gray-800/60 rounded-2xl p-3 text-center">
<Icon size={14} className={`mx-auto mb-1 ${color}`} />
<p className="text-sm font-bold text-white">{value}</p>
<p className="text-[9px] text-gray-600 mt-0.5">{label}</p>
</div>
);
}
function LoadingScreen() {
return (
<div className="min-h-dvh bg-[#0a0a0f] flex items-center justify-center">
<div className="w-8 h-8 rounded-full border-2 border-[#D4AF37]/30 border-t-[#D4AF37] animate-spin" />
</div>
);
}