import React, { useState, useEffect } from "react"; import MenuTab from "@/components/menutab/MenuTab"; import DocumentForm from "@/components/forms/DocumentForm"; import VideoForm from "@/components/forms/video/VideoForm"; import CourseForm from "@/components/forms/course/CourseForm"; import CombinedResourceForm from "@/components/forms/CombinedResourceForm"; import { useIsAdmin } from "@/hooks/useIsAdmin"; import { useRouter } from "next/router"; import { ProgressSpinner } from "primereact/progressspinner"; const Create = () => { const [activeIndex, setActiveIndex] = useState(0); // State to track the active tab index const { isAdmin, isLoading } = useIsAdmin(); const router = useRouter(); const homeItems = [ { label: 'Document', icon: 'pi pi-file' }, { label: 'Video', icon: 'pi pi-video' }, { label: 'Combined', icon: 'pi pi-clone' }, { label: 'Course', icon: 'pi pi-desktop' } ]; useEffect(() => { if (isLoading) return; if (!isAdmin) { router.push('/'); } }, [isAdmin, router, isLoading]); // Function to render the correct form based on the active tab const renderForm = () => { switch (homeItems[activeIndex].label) { case 'Course': return ; case 'Video': return ; case 'Document': return ; case 'Combined': return ; default: return null; } }; if (!isAdmin) return null; if (isLoading) return
; return (

Create a {homeItems[activeIndex].label}

{renderForm()}
); }; export default Create;