import { getUserProfile } from "@/src/lib/auth/get-user-profile";
import { redirect } from "next/navigation";

export const AdminHeaderPage = async () => {
    const user = await getUserProfile();

    if (!user) {
      redirect("/login");
    }

  return (
    <header className="h-16 border-b border-slate-200 bg-white/50 backdrop-blur-md sticky top-0 z-10 px-8 flex items-center justify-between">
        <div className="w-1/3">
        <input 
            type="text" 
            placeholder="Pesquisar artigos..." 
            className="w-full bg-slate-100 border-none rounded-full px-4 py-1.5 text-sm focus:ring-2 focus:ring-blue-500/20 outline-none"
        />
        </div>
        <div className="flex items-center gap-4">
        <div className="text-right">
            <p className="text-xs font-bold">{user?.name ?? "Loading..."}</p>
            <p className="text-[10px] text-slate-500">Editor</p>
        </div>
        <div className="w-8 h-8 bg-slate-300 rounded-full border border-white shadow-sm overflow-hidden">
            <img
            src={user?.picture ?? "https://ui-avatars.com/api/?name=User"}
            alt="User"
            />
        </div>
        </div>
    </header>
  );
};
