2025-06-09 11:13:05 +00:00
|
|
|
"use client"
|
|
|
|
|
|
|
|
import { useEffect, useState } from "react"
|
|
|
|
import { useRouter } from "next/navigation"
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
|
|
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
|
|
|
import { LogOut } from "lucide-react"
|
|
|
|
import TranscriptionTable from "@/components/transcription-table"
|
|
|
|
import ModelPricesTable from "@/components/model-prices-table"
|
|
|
|
import CostUpdateForm from "@/components/cost-update-form"
|
2025-06-12 20:58:22 +00:00
|
|
|
import ProductManagement from "@/components/product-management"
|
2025-06-09 11:13:05 +00:00
|
|
|
|
|
|
|
export default function Dashboard() {
|
|
|
|
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
|
|
|
const [isLoading, setIsLoading] = useState(true)
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const token = localStorage.getItem("access_token")
|
|
|
|
if (!token) {
|
|
|
|
router.push("/")
|
|
|
|
} else {
|
|
|
|
setIsAuthenticated(true)
|
|
|
|
setIsLoading(false)
|
|
|
|
}
|
|
|
|
}, [router])
|
|
|
|
|
|
|
|
const handleLogout = () => {
|
|
|
|
localStorage.removeItem("access_token")
|
|
|
|
router.push("/")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isLoading) {
|
|
|
|
return (
|
|
|
|
<div className="min-h-screen flex items-center justify-center">
|
|
|
|
<div className="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900"></div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isAuthenticated) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="min-h-screen bg-gray-50">
|
|
|
|
<header className="bg-white shadow">
|
|
|
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
|
|
<div className="flex justify-between items-center py-6">
|
2025-06-13 21:14:16 +00:00
|
|
|
<h1 className="text-3xl font-bold text-gray-900">Dashboard - Custo de Produtos</h1>
|
2025-06-09 11:13:05 +00:00
|
|
|
<Button onClick={handleLogout} variant="outline">
|
|
|
|
<LogOut className="mr-2 h-4 w-4" />
|
|
|
|
Sair
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<main className="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
|
|
|
|
<Tabs defaultValue="transcription" className="space-y-6">
|
|
|
|
<TabsList className="grid w-full grid-cols-3">
|
|
|
|
<TabsTrigger value="transcription">Dados de Transcrição</TabsTrigger>
|
|
|
|
<TabsTrigger value="models">Preços dos Modelos</TabsTrigger>
|
2025-06-12 20:58:22 +00:00
|
|
|
{/* <TabsTrigger value="costs">Atualizar Custos</TabsTrigger> */}
|
|
|
|
<TabsTrigger value="products">Produtos</TabsTrigger>
|
2025-06-09 11:13:05 +00:00
|
|
|
</TabsList>
|
|
|
|
|
|
|
|
<TabsContent value="transcription">
|
|
|
|
<Card>
|
|
|
|
<CardHeader>
|
|
|
|
<CardTitle>Dados de Transcrição</CardTitle>
|
|
|
|
<CardDescription>Visualize e exporte dados de transcrição por cliente ou empresa</CardDescription>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
|
|
<TranscriptionTable />
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</TabsContent>
|
|
|
|
|
|
|
|
<TabsContent value="models">
|
|
|
|
<Card>
|
|
|
|
<CardHeader>
|
|
|
|
<CardTitle>Preços dos Modelos</CardTitle>
|
|
|
|
<CardDescription>Gerencie os preços dos modelos de IA disponíveis</CardDescription>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
|
|
<ModelPricesTable />
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</TabsContent>
|
|
|
|
|
|
|
|
<TabsContent value="costs">
|
|
|
|
<Card>
|
|
|
|
<CardHeader>
|
2025-06-12 20:58:22 +00:00
|
|
|
<CardTitle>Atualizar Custos</CardTitle>
|
|
|
|
<CardDescription>Atualize os custos de uso dos produtos</CardDescription>
|
2025-06-09 11:13:05 +00:00
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
|
|
<CostUpdateForm />
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</TabsContent>
|
2025-06-12 20:58:22 +00:00
|
|
|
|
|
|
|
<TabsContent value="products">
|
|
|
|
<Card>
|
|
|
|
<CardHeader>
|
|
|
|
<CardTitle>Gerenciar Produtos</CardTitle>
|
|
|
|
<CardDescription>Crie, edite e gerencie produtos e seus preços</CardDescription>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
|
|
<ProductManagement />
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</TabsContent>
|
2025-06-09 11:13:05 +00:00
|
|
|
</Tabs>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|