"use client"; import Link from "next/link"; import { useState } from "react"; import { loginUser } from "@/src/lib/auth"; import Logo from "@/src/utils/logo"; import { Button } from "@/src/Components/UI"; import { Input } from "@/src/Components/UI"; import { Alert } from "@/src/Components/UI"; export default function LoginPage() { const [identity, setIdentity] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setLoading(true); try { await loginUser(identity, password); console.log("Login successful", { identity }); window.location.href = "/dashboard"; } catch (err) { if (err instanceof Error) { const msg = err.message.toLowerCase(); if (msg.includes("fetch") || msg.includes("network") || msg.includes("failed to fetch")) { setError("Unable to connect. Please check your internet connection and try again later."); } else { setError(err.message); } } else { setError("System temporarily unavailable. Please try later."); } } finally { setLoading(false); } } return (
{/* ── Left panel ─────────────────────────────────── */} {/* ── Right panel ────────────────────────────────── */}

مرحبًا بعودتك

سجل الدخول لإدارة عمليات التسليم

setIdentity(e.target.value)} placeholder="name@company.com / 05xxxxxxxx / username" required /> setPassword(e.target.value)} placeholder="••••••••" required />
هل نسيت كلمة المرور؟
{error && (
setError(null)} />
)}

ليس لديك حساب؟{" "} إنشاء حساب

); }