import { User } from "@/types";
import { PropsWithChildren } from "react";
import { Layout } from "react-feather";
import SystemAnnouncement from "./SystemAnnouncement";
import PinnedProjects from "./PinnedProjects";

export default function BulletinBoard({ user }: PropsWithChildren<{ user: User }>) {
    const thisUser = user;

    const renderBulletinBoardContent = () => {
        switch (thisUser.role_id) {
            case 1:
                return null;
            case 2:
                return (
                    <div className="flex">
                        <section className="w-1/3"><SystemAnnouncement /></section>
                        <div className="divider divider-horizontal"></div>
                        <section className="w-full"><PinnedProjects user={thisUser} /></section>
                    </div>
                );
            case 3:
                return (
                    <div className="flex">
                        <section className="w-1/3"><SystemAnnouncement /></section>
                        <div className="divider divider-horizontal"></div>
                        <section className="w-full"><PinnedProjects user={thisUser} /></section>
                    </div>
                );
            default:
                return null;
        }
    }
    
    return (
        <div className="h-full w-full bg-neutral-10 shadow-md p-6 rounded-lg">
            <p className="font-bold text-xl text-primary-main flex items-center"><Layout className="stroke-primary-main mr-2" />Bulletin Board</p>
            <div className="divider"></div>
            {renderBulletinBoardContent()}
        </div>
    )
}