2024-03-20 14:20:45 -05:00
|
|
|
import React, { useState } from "react";
|
2024-03-20 13:00:05 -05:00
|
|
|
import MenuTab from "@/components/menutab/MenuTab";
|
|
|
|
import ResourceForm from "@/components/forms/ResourceForm";
|
2024-03-20 14:20:45 -05:00
|
|
|
import WorkshopForm from "@/components/forms/WorkshopForm";
|
|
|
|
import CourseForm from "@/components/forms/CourseForm";
|
2024-03-20 13:00:05 -05:00
|
|
|
|
|
|
|
const Create = () => {
|
2024-03-20 14:20:45 -05:00
|
|
|
const [activeIndex, setActiveIndex] = useState(0); // State to track the active tab index
|
2024-03-20 13:00:05 -05:00
|
|
|
const homeItems = [
|
|
|
|
{ label: 'Course', icon: 'pi pi-desktop' },
|
|
|
|
{ label: 'Workshop', icon: 'pi pi-cog' },
|
|
|
|
{ label: 'Resource', icon: 'pi pi-book' },
|
2024-03-20 14:20:45 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
// Function to render the correct form based on the active tab
|
|
|
|
const renderForm = () => {
|
|
|
|
switch (homeItems[activeIndex].label) {
|
|
|
|
case 'Course':
|
|
|
|
return <CourseForm />;
|
|
|
|
case 'Workshop':
|
|
|
|
return <WorkshopForm />;
|
|
|
|
case 'Resource':
|
|
|
|
return <ResourceForm />;
|
|
|
|
default:
|
|
|
|
return null; // or a default component
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-03-20 13:00:05 -05:00
|
|
|
return (
|
|
|
|
<div className="w-fit mx-auto mt-8 flex flex-col justify-center">
|
2024-03-20 14:20:45 -05:00
|
|
|
<h2 className="text-center mb-8">Create a {homeItems[activeIndex].label}</h2>
|
|
|
|
<MenuTab items={homeItems} activeIndex={activeIndex} onTabChange={setActiveIndex} />
|
|
|
|
{renderForm()}
|
2024-03-20 13:00:05 -05:00
|
|
|
</div>
|
2024-03-20 14:20:45 -05:00
|
|
|
);
|
|
|
|
};
|
2024-03-20 13:00:05 -05:00
|
|
|
|
2024-03-20 14:20:45 -05:00
|
|
|
export default Create;
|