Dashboard-Automatizase/app/dashboard/layout.tsx
Luis Erlacher 0152a2fda0 feat: add n8n API testing script for Google OAuth2 schema and existing credentials
- Implemented a bash script to test n8n API and retrieve credential schemas.
- Added types for API responses, Google Calendar, and WhatsApp instances.
- Configured Vitest for testing with React and added setup for testing-library.
2025-10-10 14:29:02 -03:00

75 lines
2.1 KiB
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { supabase } from "@/lib/supabase";
export default function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
const router = useRouter();
const [userEmail, setUserEmail] = useState<string | null>(null);
useEffect(() => {
const getUser = async () => {
const {
data: { user },
} = await supabase.auth.getUser();
if (user) {
setUserEmail(user.email || null);
}
};
getUser();
}, []);
const handleLogout = async () => {
await supabase.auth.signOut();
router.push("/login");
};
return (
<div className="min-h-screen bg-gray-900 flex flex-col">
{/* Header */}
<header className="bg-gray-800 border-b border-gray-700">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between items-center h-16">
<div className="flex items-center">
<h1 className="text-2xl font-bold text-primary-500">
AutomatizaSE
</h1>
</div>
<div className="flex items-center space-x-4">
{userEmail && (
<span className="text-sm text-gray-400">{userEmail}</span>
)}
<button
type="button"
onClick={handleLogout}
className="px-4 py-2 text-sm font-medium text-white bg-gray-700 hover:bg-gray-600 rounded-md"
>
Sair
</button>
</div>
</div>
</div>
</header>
{/* Main Content */}
<main className="flex-1 max-w-7xl w-full mx-auto px-4 sm:px-6 lg:px-8 py-8">
{children}
</main>
{/* Footer */}
<footer className="bg-gray-800 border-t border-gray-700 mt-auto">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
<p className="text-center text-sm text-gray-400">
Copyright by AutomatizaSE
</p>
</div>
</footer>
</div>
);
}