güncelleme
This commit is contained in:
@@ -34,7 +34,8 @@ export default function LoginPage() {
|
||||
return
|
||||
}
|
||||
|
||||
router.push("/dashboard")
|
||||
// Redirect to 2FA verification instead of dashboard
|
||||
router.push("/verify-2fa")
|
||||
router.refresh()
|
||||
} catch {
|
||||
setError("Bir hata oluştu. Lütfen tekrar deneyin.")
|
||||
|
||||
@@ -1,48 +1,30 @@
|
||||
|
||||
import { createClient } from "@/lib/supabase-server"
|
||||
import { Card, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import Image from "next/image"
|
||||
|
||||
|
||||
const products = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Ev Tipi Çelik Kasa",
|
||||
image: "/images/safe-1.jpg",
|
||||
category: "Ev",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Ofis Tipi Yanmaz Kasa",
|
||||
image: "/images/safe-2.jpg",
|
||||
category: "Ofis",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Otel Odası Kasası",
|
||||
image: "/images/safe-3.jpg",
|
||||
category: "Otel",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Silah Kasası (Tüfek)",
|
||||
image: "/images/safe-4.jpg",
|
||||
category: "Özel",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "Kuyumcu Kasası",
|
||||
image: "/images/safe-5.jpg",
|
||||
category: "Ticari",
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "Duvar İçi Gizli Kasa",
|
||||
image: "/images/safe-6.jpg",
|
||||
category: "Ev",
|
||||
},
|
||||
]
|
||||
|
||||
export default function ProductsPage() {
|
||||
// Helper to get products
|
||||
async function getProducts() {
|
||||
const supabase = createClient()
|
||||
const { data, error } = await supabase
|
||||
.from("products")
|
||||
.select("*")
|
||||
.eq("is_active", true)
|
||||
.order("created_at", { ascending: false })
|
||||
|
||||
if (error) {
|
||||
console.error("Error fetching products:", error)
|
||||
return []
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
export default async function ProductsPage() {
|
||||
const products = await getProducts()
|
||||
|
||||
return (
|
||||
<div className="container py-12 md:py-24">
|
||||
<div className="flex flex-col items-center mb-12 text-center">
|
||||
@@ -53,27 +35,44 @@ export default function ProductsPage() {
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{products.map((product) => (
|
||||
<Card key={product.id} className="overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300">
|
||||
<div className="aspect-[4/5] relative bg-slate-100 dark:bg-slate-800">
|
||||
{/* Placeholder for real images */}
|
||||
<div className="absolute inset-0 flex items-center justify-center text-slate-400">
|
||||
<span className="text-sm">Görsel: {product.name}</span>
|
||||
{products && products.length > 0 ? (
|
||||
products.map((product) => (
|
||||
<Card key={product.id} className="overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 group">
|
||||
<div className="aspect-[4/5] relative bg-slate-100 dark:bg-slate-800">
|
||||
{product.image_url ? (
|
||||
<Image
|
||||
src={product.image_url}
|
||||
alt={product.name}
|
||||
fill
|
||||
className="object-cover transition-transform duration-500 group-hover:scale-105"
|
||||
/>
|
||||
) : (
|
||||
<div className="absolute inset-0 flex items-center justify-center text-slate-400">
|
||||
<span className="text-sm">Görsel Yok</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<CardHeader className="p-4">
|
||||
<div className="flex justify-between items-start">
|
||||
<div>
|
||||
<span className="text-xs font-medium text-slate-500 uppercase tracking-wider">{product.category}</span>
|
||||
<CardTitle className="text-lg mt-1">{product.name}</CardTitle>
|
||||
<CardHeader className="p-4">
|
||||
<div className="flex justify-between items-start">
|
||||
<div className="w-full">
|
||||
<div className="flex justify-between items-center w-full">
|
||||
<span className="text-xs font-medium text-slate-500 uppercase tracking-wider">{product.category}</span>
|
||||
<span className="font-bold text-lg text-primary">₺{product.price}</span>
|
||||
</div>
|
||||
<CardTitle className="text-lg mt-1">{product.name}</CardTitle>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardFooter className="p-4 pt-0">
|
||||
<Button className="w-full">Detayları İncele</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
))}
|
||||
</CardHeader>
|
||||
<CardFooter className="p-4 pt-0">
|
||||
<Button className="w-full" variant="outline">Detayları İncele</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<div className="col-span-full text-center py-12">
|
||||
<p className="text-muted-foreground">Henüz vitrinde ürünümüz bulunmuyor.</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
130
app/(public)/verify-2fa/page.tsx
Normal file
130
app/(public)/verify-2fa/page.tsx
Normal file
@@ -0,0 +1,130 @@
|
||||
"use client"
|
||||
|
||||
import { useState, useEffect } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { AlertCircle, Loader2 } from "lucide-react"
|
||||
import { sendVerificationCode, verifyCode } from "@/lib/sms/verification-actions"
|
||||
import { createClient } from "@/lib/supabase-browser"
|
||||
|
||||
export default function Verify2FAPage() {
|
||||
const router = useRouter()
|
||||
const [code, setCode] = useState("")
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [sent, setSent] = useState(false)
|
||||
const [maskedPhone, setMaskedPhone] = useState("")
|
||||
|
||||
useEffect(() => {
|
||||
// Init: Send code automatically
|
||||
const init = async () => {
|
||||
setLoading(true)
|
||||
const result = await sendVerificationCode()
|
||||
setLoading(false)
|
||||
if (result.error) {
|
||||
setError(result.error)
|
||||
} else {
|
||||
setSent(true)
|
||||
setMaskedPhone(result.phone || "")
|
||||
}
|
||||
}
|
||||
init()
|
||||
}, [])
|
||||
|
||||
const handleVerify = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
|
||||
try {
|
||||
const result = await verifyCode(code)
|
||||
if (result.error) {
|
||||
setError(result.error)
|
||||
} else {
|
||||
router.push("/dashboard")
|
||||
router.refresh()
|
||||
}
|
||||
} catch {
|
||||
setError("Bir hata oluştu.")
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleResend = async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
const result = await sendVerificationCode()
|
||||
setLoading(false)
|
||||
if (result.error) {
|
||||
setError(result.error)
|
||||
} else {
|
||||
setSent(true)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen bg-slate-50 dark:bg-slate-950 px-4">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader className="space-y-1">
|
||||
<CardTitle className="text-2xl font-bold">SMS Doğrulama</CardTitle>
|
||||
<CardDescription>
|
||||
{sent ? `Telefonunuza (***${maskedPhone}) gönderilen 6 haneli kodu girin.` : "Doğrulama kodu gönderiliyor..."}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{error && (
|
||||
<div className="mb-4 flex items-center space-x-2 text-sm text-red-600 bg-red-50 p-3 rounded-md">
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
<span>{error}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={handleVerify} className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="code">Doğrulama Kodu</Label>
|
||||
<Input
|
||||
id="code"
|
||||
type="text"
|
||||
placeholder="123456"
|
||||
value={code}
|
||||
onChange={(e) => setCode(e.target.value)}
|
||||
maxLength={6}
|
||||
className="text-center text-lg tracking-widest"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<Button className="w-full" type="submit" disabled={loading || !sent}>
|
||||
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
Doğrula
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
<CardFooter className="flex flex-col gap-4 text-center text-sm text-muted-foreground">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleResend}
|
||||
disabled={loading}
|
||||
className="underline underline-offset-4 hover:text-primary disabled:opacity-50"
|
||||
>
|
||||
Kodu Tekrar Gönder
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={async () => {
|
||||
const supabase = createClient()
|
||||
await supabase.auth.signOut()
|
||||
router.push("/login")
|
||||
}}
|
||||
className="text-xs"
|
||||
>
|
||||
Giriş ekranına dön
|
||||
</button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user