import React, { useState } from "react"; import { useData } from "../contexts/DataContext"; import { useAuth } from "../contexts/AuthContext"; import { UserRole, Course } from "../types"; import { CourseForm } from "../components/CourseForm"; import { Plus, Edit, Trash2 } from "lucide-react"; import { Button } from "../components/Button"; export const CourseManagement: React.FC = () => { const { user } = useAuth(); const { institutions, courses, addCourse, updateCourse } = useData(); const [showCourseForm, setShowCourseForm] = useState(false); const [editingCourse, setEditingCourse] = useState( undefined ); // Verificar se é admin const isAdmin = user?.role === UserRole.SUPERADMIN || user?.role === UserRole.BUSINESS_OWNER; if (!isAdmin) { return (

Acesso Negado

Apenas administradores podem acessar esta página.

); } const handleAddCourse = () => { setEditingCourse(undefined); setShowCourseForm(true); }; const handleEditCourse = (course: Course) => { setEditingCourse(course); setShowCourseForm(true); }; const handleSubmitCourse = (courseData: Partial) => { if (editingCourse) { updateCourse(editingCourse.id, courseData); } else { const newCourse: Course = { id: `course-${Date.now()}`, name: courseData.name || "", institutionId: courseData.institutionId || "", year: courseData.year || new Date().getFullYear(), semester: courseData.semester, graduationType: courseData.graduationType || "", createdAt: new Date().toISOString(), createdBy: user?.id || "", isActive: courseData.isActive !== false, ...courseData, }; addCourse(newCourse); } setShowCourseForm(false); setEditingCourse(undefined); }; return (
{/* Header */}

Gestão de FOT

Gerencie todas as turmas FOT cadastradas

{/* Course Form Modal */} {showCourseForm && (
{ setShowCourseForm(false); setEditingCourse(undefined); }} onSubmit={handleSubmitCourse} initialData={editingCourse} userId={user?.id || ""} institutions={institutions} />
)} {/* Courses Table */}
{courses.length === 0 ? ( ) : ( courses.map((course) => ( )) )}
FOT Empresa Cursos Observações Instituição Ano Formatura Cidade Estado Gastos Captação Pré Venda Ações

Nenhuma turma cadastrada

Clique em "Cadastrar Turma" para adicionar a primeira turma

{(course as any).fotId || "-"}
{(course as any).empresaNome || "-"}
{(course as any).educationLevel || "-"}
{(course as any).observacoes || "-"}
{(course as any).instituicao || "-"}
{(course as any).anoFormatura || course.year || "-"}
{(course as any).cidade || "-"}
{(course as any).estado || "-"}
{(course as any).gastosCaptacao || "R$ 0,00"}
{(course as any).preVenda === "sim" ? "Sim" : "Não"}
); };