'use client';
import { useState } from "react";
import PageLivingSpaceBuildsTableSection from "./builds/page";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";


const PageLivingSpace = () => {

    const [collectionToken, setCollectionToken] = useState<string | null>(null);
    const [buildID, setBuildID] = useState<string | null>(null);
    const [userTypeID, setUserTypeID] = useState<string | null>(null);
    const [partID, setPartID] = useState<string | null>(null);
    const [companyID, setCompanyID] = useState<string | null>(null);
    const [personID, setPersonID] = useState<string | null>(null);

    const [isUserTypeEnabled, setIsUserTypeEnabled] = useState(false);
    const [isPartsEnabled, setIsPartsEnabled] = useState(false);
    const [isCompanyEnabled, setIsCompanyEnabled] = useState(false);
    const [isPersonEnabled, setIsPersonEnabled] = useState(false);

    const tabsClassName = "border border-gray-300 rounded-sm h-10"

    return <>
        <div>{JSON.stringify({ buildID, collectionToken, userTypeID, partID, companyID, personID })}</div>
        <div className="flex flex-col m-7">
            <Tabs defaultValue="builds" className="w-full">
                <TabsList className="grid w-full grid-flow-col auto-cols-fr gap-1.5">
                    <TabsTrigger className={tabsClassName} value="builds">Builds</TabsTrigger>
                    {isUserTypeEnabled && <TabsTrigger className={tabsClassName} value="usertype">User Type</TabsTrigger>}
                    {isPartsEnabled && <TabsTrigger className={tabsClassName} value="parts">Parts</TabsTrigger>}
                    {isCompanyEnabled && <TabsTrigger className={tabsClassName} value="company">Company</TabsTrigger>}
                    {isPersonEnabled && <TabsTrigger className={tabsClassName} value="person">Person</TabsTrigger>}
                </TabsList>
                <div className="mt-6">
                    <TabsContent value="builds">
                        <PageLivingSpaceBuildsTableSection buildID={buildID} setBuildID={setBuildID} collectionToken={collectionToken} setCollectionToken={setCollectionToken} setIsUserTypeEnabled={setIsUserTypeEnabled} />
                    </TabsContent>
                    {isUserTypeEnabled && <TabsContent value="usertype">{/* Add UserType section component here */}</TabsContent>}
                    {isPartsEnabled && <TabsContent value="parts">{/* Add Parts section component here */}</TabsContent>}
                    {isCompanyEnabled && <TabsContent value="company">{/* Add Company section component here */}</TabsContent>}
                    {isPersonEnabled && <TabsContent value="person"> {/* Add Person section component here */}</TabsContent>}
                </div>
            </Tabs>
        </div>
    </>
}

export { PageLivingSpace };